Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AGMPPURG

AGMPPURG.m

Go to the documentation of this file.
AGMPPURG ; IHS/SD/TPF - MPI HLO MESSAGE PURGE
 ;;7.2;IHS PATIENT REGISTRATION;**1,6**;JAN 07, 2011;Build 23
 Q
 ;
 ;NOT FINISHED
INTERACT ;EP - USER INTERACTIVE PURGE
 N ONLYSUC,ONLYFAIL,ONLYADT,ONLYACK,ONLYA28,ONLYA08
 N ONLYMFN,ONLYMFK
 Q
 ;
PURGE  ;EP PURGE MPI HL7 MESSAGES OLDER THAN 7DAYS
 ;
 N MPIIEN,MPIIEN2,MPIDATE,MPIDT1,MPIDAYS,MPITYPE,QUIT
 N GRDTOTAL,EVENTTOT,DIRECTOT,MSGTYPTO,ACKCODET,STATUSTO
 S (GRDTOTAL,EVENTTOT,DIRECTOT,MSGTYPTO,STATUSTO)=0
 S (MPIIEN,MPIIEN2,QUIT)=0
 S MPIDAYS=$$GET1^DIQ(9009061,DUZ(2)_",",2202)  ;DAYS TO KEEP MPI HLO MESSAGES
 S:MPIDAYS="" MPIDAYS=7
 S X="T-"_MPIDAYS D ^%DT S PURGDT=Y
 ;B "S+"
 ;S PURGDT=3100804
 F  S MPIIEN=$O(^HLB(MPIIEN)) Q:'MPIIEN!(QUIT)  D
 .S LINK=$P($G(^HLB(MPIIEN,0)),U,5)
 .Q:LINK'="MPI"
 .S MPIDIREC=$P($G(^HLB(MPIIEN,0)),U,4)   ;DIRECTION INCOMING DO NOT HAVE A COMPLETION STATUS
 .S COMSTAT=$P($G(^HLB(MPIIEN,0)),U,20)  ;COMPLETION STATUS
 .S SCHEDPUR=$P($G(^HLB(MPIIEN,0)),U,9)  ;SCHEDULED PURGE
 .S MSGBOD=$P($G(^HLB(MPIIEN,0)),U,2)  ;MESSAGE BODY
 .S MSGTYPE=$P($G(^HLA(MSGBOD,0)),U,3)  ;MESSAGE TYPE
 .S EVENT=$P($G(^HLA(MSGBOD,0)),U,4)  ;EVENT
 .I COMSTAT'="SU" Q
 .S TRANDATE=$P($G(^HLB(MPIIEN,0)),U,16)  ;TRANSMISSION DATE/TIME
 .S MSGID=$P($G(^HLB(MPIIEN,0)),U)   ;MESSAGE ID
 .S ACKCODE=$P($G(^HLA(MSGID,1,1,0)),U,2)
 .;B "S+"
 .I $G(TRANDATE)>(PURGDT) S QUIT=1 Q
 .S GRDTOTAL=GRDTOTAL+1
 .S:EVENT'="" EVENTTOT(EVENT)=$G(EVENTTOT(EVENT))+1
 .S:MPIDIREC'="" DIRECTOT(MPIDIREC)=$G(DIRECTOT(MPIDIREC))+1
 .S:MSGTYPE'="" MSGTYPTO(MSGTYPE)=$G(MSGTYPTO(MSGTYPE))+1
 .S:ACKCODE'="" ACKCODET(ACKCODE)=$G(ACKCODET(ACKCODE))+1
 .S COMSTAT=$S(COMSTAT'="":COMSTAT,1:"UNDEF")
 .S STATUSTO=$G(STATUSTO(COMSTAT))+1
 .I '$D(ZTQUEUED) D
 ..W !!,"TRANDATE: ",TRANDATE
 ..W !,"PURGE: ",MPIIEN
 ..W !,"MPIDIREC: ",MPIDIREC
 ..W !,"MSG TYPE: ",MSGTYPE
 ..W !,"EVENT: ",EVENT
 ..W !,"ACKCODE: ",ACKCODE
 .;B:SCHEDPUR="" "S+"
 .S DA=MPIIEN,DIK="^HLB(" D ^DIK
 .S DA=MSGBOD,DIK="^HLA(" D ^DIK
 .D AC(MPIIEN,MSGID)  ;CLEAN UP FOR HLB
 .I MPIDIREC="I" D ADI,QUEUEI Q
 .I MPIDIREC="O" D ADO(SCHEDPUR),QUEUEO
 I '$D(ZTQUEUED) D PRINT
 Q
 ;USE TO CLEAN UP BODIES W/O HEADERS. RESET HLC
SELKILL ;EP
 ; 9/08/2017 - GCD - CR 7705 - Disabled this because it can delete data for any HLO application, not just MPI, among other issues.
 Q
 ;
 S IEN=0 F CNT=1:1 S IEN=$O(^HLA(IEN)) Q:IEN=""  D
 .Q:$D(^HLB(IEN))
 .S DA=IEN,DIK="^HLA(" D ^DIK
 .W "."
 S ^HLC("FILE777","OUT")=BEGIN
 S ^HLC("FILE778","OUT","TCP")=BEGIN
 Q
 ;
PRINT ;EP - PRINT COUNTS
 N EVENT,MPIDIREC,MSGTYPE,ACKCODE
 S EVENT=""
 F  S EVENT=$O(EVENTTOT(EVENT)) Q:EVENT=""  W !,"EVENT: ",EVENT,?25,EVENTTOT(EVENT)
 S MPIDIREC=""
 F  S MPIDIREC=$O(DIRECTOT(MPIDIREC)) Q:MPIDIREC=""  W !,"DIRECTION: ",MPIDIREC,?25,DIRECTOT(MPIDIREC)
 S MSGTYPE=""
 F  S MSGTYPE=$O(MSGTYPTO(MSGTYPE)) Q:MSGTYPE=""  W !,"MSG TYPE: ",MSGTYPE,?25,MSGTYPTO(MSGTYPE)
 S ACKCODE=""
 F  S ACKCODE=$O(ACKCODET(ACKCODE)) Q:ACKCODE=""  W !,"ACK CODE: ",ACKCODE,?25,ACKCODET(ACKCODE)
 W !,"GRAND TOT PURGED: ",GRDTOTAL
 Q
 ;
AC(MPIIEN,MSGID) ;DELETE "AC" XREF FOR IEN
 ;MPI EXAMPLE:HLB("AC","8990MPI14752 26",26)=
 ;STATION # MPI = 8990
 ;HL LOGICAL LINK = MPI
 ;MSG ID = 14752 26
 K ^HLB("AC",MSGID,MPIIEN)
 S CMP="8990MPI"_MSGID
 K ^HLB("AC",CMP,MPIIEN)
 Q
ADI ;DELETE "AD" XREF FOR "IN" IEN
 K ^HLB("AD","IN",MPIIEN)
 Q
ADO(SCHEDPUR) ;DELETE "AD" XREF FOR "OUT" IEN
 Q:$G(SCHEDPUR)=""
 ;EXAMPLE:  ^HLB("AD","OUT",3090819.1143,3)=""
 K ^HLB("AD","OUT",SCHEDPUR,MPIIEN)
 Q
QUEUEI ;DELETE "QUEUE" XREF FOR IEN
 ;EXAMPLE: ^HLB("QUEUE","IN",3100611.0903,"RPMS-MPI","ACK","A28",42)
 K ^HLB("QUEUE","IN",TRANDATE,"RPMS-MPI",MSGTYPE,EVENT,MPIIEN)
 Q
QUEUEO ;DELETE "QUEUE" XREF FOR IEN
 ;EXAMPLE: ^HLB("QUEUE","OUT","MPI:8899","MPI RPMS",41)=
 N HLOG,PORT,MPILINK,REC
 S HLOG=$O(^HLCS(870,"B","MPI",""))  ;MPI LOGICAL LINK
 S PORT=$$GET1^DIQ(870,HLOG_",",400.08,"E")  ;TCP/IP PORT (OPTIMIZED)
 S MPILINK="MPI:"_PORT
 K ^HLB("QUEUE","OUT",MPILINK,"MPI RPMS",MPIIEN)
 Q