AGMPHLBU ; IHS/SD/TPF - HLO MPI A08 BACKGROUND UPDATE TASK ;
;;7.2;IHS PATIENT REGISTRATION;**1,6**;JAN 07, 2011;Build 23
;
;RTN RUNS IN BACKGROUND AND TRAVERSES THE ADT/HL PIVOT FILE
;ANY RECORDS WITH FIELD 'REQUIRES TRANSMISSION' SET TO 'YES'
A08UPDT ;EP - SEND A08 MESSAGES TO MPI
D UPDATE^AGMPCHK ;Added 9/8 by SWH, this routine will update the AGMPCHK list. It was added here to avoid adding a new TASK in taskman
L +^AGMPHLBU:5 Q:'$T ;DO NOT START IF ALREADY RUNNING
N PIVOT,TYPE,DFN,HLMSG,TEMPDUZ2
S TEMPDUZ2=DUZ(2)
S TYPE=4 ;THIS IS NOT AN HL7 EVENT
;FOR LOOP TO DO OTHER TYPES IN FUTURE?
;4 = ONLY DO REGISTRATION UPDATES
S PIVOT=""
F S PIVOT=$O(^VAT(391.71,"AXMIT",4,PIVOT)) Q:'PIVOT D
.S DFN=$P($G(^VAT(391.71,PIVOT,0)),U,3) ;PATIENT
.I $$DEMOPAT^AGMPHLU(DFN) Q ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
.S DUZ(2)=$P($G(^VAT(391.71,PIVOT,9999999)),U)
.I DUZ(2)=""!(DUZ(2)=0) D Q ;QUIT AND TRY AGAIN
..;D NOTIF^AGMPIHLO(DFN,"PIVOT="_PIVOT_" DUZ2="_$P($G(^VAT(391.71,PIVOT,9999999)),U))
..;THIS IS SOME TYPE OF TIMING ISSUE. MARK WILLIAMS IS INVESTIGATING
..;VAFCDD01 DOES NOT POPULATE DUZ2 IN ADT/HL7 PIVOT FILE
.S HLMSG=$S(TYPE=4:"A08("_DFN_")",1:"OTHER") ;DO MSG BASED ON TYPE OF EVENT
.D @HLMSG
S DUZ(2)=TEMPDUZ2 ;RESTORE TASK TO ORIGINAL DUZ(2)
L -^AGMPHLBU ;CLEAR RUNNING FLAG
Q
;
A08(DFN) ;EP - CREATE A08 MESSAGE
I $$DEMOPAT^AGMPHLU($G(DFN)) Q ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
N SUCCESS
D CREATMSG^AGMPIHLO(DFN,"A08",,.SUCCESS) ;THIS COULD BE ADDED TO THE AG UPDATE PATIENT PROTOCOL AS THE ENTRY ACTION
I 'SUCCESS D NOTIF^AGMPIHLO(DFN,"Unable to create A08 to update patient on MPI from AGMPHHBU") Q
I SUCCESS[("NOT DEFINED IN PID^AGMPIHL1") Q ;TIMING ISSUE TRY AGAIN
I SUCCESS D SETXMIT(PIVOT)
;KICK OFF PROTOCOL
S X="AG UPDATE A PATIENT",DIC=101,INDA=DFN
D EN^XQOR
Q
;
OTHER ;EP - STUB FOR OTHER TYPES - FUTURE USE
Q
;
SETXMIT(PIVOT) ;EP - RESET TRANSMIT FLAG
K DIE,DIR,DIC,DA,DR
S DIE="^VAT(391.71,"
S DA=PIVOT
S DR=".06///1;.08///0" ;SET AS TRANSMITED AND NO TRANSMISSION REQUIRED
D ^DIE
Q
AGMPHLBU ; IHS/SD/TPF - HLO MPI A08 BACKGROUND UPDATE TASK ;
+1 ;;7.2;IHS PATIENT REGISTRATION;**1,6**;JAN 07, 2011;Build 23
+2 ;
+3 ;RTN RUNS IN BACKGROUND AND TRAVERSES THE ADT/HL PIVOT FILE
+4 ;ANY RECORDS WITH FIELD 'REQUIRES TRANSMISSION' SET TO 'YES'
A08UPDT ;EP - SEND A08 MESSAGES TO MPI
+1 ;Added 9/8 by SWH, this routine will update the AGMPCHK list. It was added here to avoid adding a new TASK in taskman
DO UPDATE^AGMPCHK
+2 ;DO NOT START IF ALREADY RUNNING
LOCK +^AGMPHLBU:5
IF '$TEST
QUIT
+3 NEW PIVOT,TYPE,DFN,HLMSG,TEMPDUZ2
+4 SET TEMPDUZ2=DUZ(2)
+5 ;THIS IS NOT AN HL7 EVENT
SET TYPE=4
+6 ;FOR LOOP TO DO OTHER TYPES IN FUTURE?
+7 ;4 = ONLY DO REGISTRATION UPDATES
+8 SET PIVOT=""
+9 FOR
SET PIVOT=$ORDER(^VAT(391.71,"AXMIT",4,PIVOT))
IF 'PIVOT
QUIT
Begin DoDot:1
+10 ;PATIENT
SET DFN=$PIECE($GET(^VAT(391.71,PIVOT,0)),U,3)
+11 ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
IF $$DEMOPAT^AGMPHLU(DFN)
QUIT
+12 SET DUZ(2)=$PIECE($GET(^VAT(391.71,PIVOT,9999999)),U)
+13 ;QUIT AND TRY AGAIN
IF DUZ(2)=""!(DUZ(2)=0)
Begin DoDot:2
+14 ;D NOTIF^AGMPIHLO(DFN,"PIVOT="_PIVOT_" DUZ2="_$P($G(^VAT(391.71,PIVOT,9999999)),U))
+15 ;THIS IS SOME TYPE OF TIMING ISSUE. MARK WILLIAMS IS INVESTIGATING
+16 ;VAFCDD01 DOES NOT POPULATE DUZ2 IN ADT/HL7 PIVOT FILE
End DoDot:2
QUIT
+17 ;DO MSG BASED ON TYPE OF EVENT
SET HLMSG=$SELECT(TYPE=4:"A08("_DFN_")",1:"OTHER")
+18 DO @HLMSG
End DoDot:1
+19 ;RESTORE TASK TO ORIGINAL DUZ(2)
SET DUZ(2)=TEMPDUZ2
+20 ;CLEAR RUNNING FLAG
LOCK -^AGMPHLBU
+21 QUIT
+22 ;
A08(DFN) ;EP - CREATE A08 MESSAGE
+1 ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
IF $$DEMOPAT^AGMPHLU($GET(DFN))
QUIT
+2 NEW SUCCESS
+3 ;THIS COULD BE ADDED TO THE AG UPDATE PATIENT PROTOCOL AS THE ENTRY ACTION
DO CREATMSG^AGMPIHLO(DFN,"A08",,.SUCCESS)
+4 IF 'SUCCESS
DO NOTIF^AGMPIHLO(DFN,"Unable to create A08 to update patient on MPI from AGMPHHBU")
QUIT
+5 ;TIMING ISSUE TRY AGAIN
IF SUCCESS[("NOT DEFINED IN PID^AGMPIHL1")
QUIT
+6 IF SUCCESS
DO SETXMIT(PIVOT)
+7 ;KICK OFF PROTOCOL
+8 SET X="AG UPDATE A PATIENT"
SET DIC=101
SET INDA=DFN
+9 DO EN^XQOR
+10 QUIT
+11 ;
OTHER ;EP - STUB FOR OTHER TYPES - FUTURE USE
+1 QUIT
+2 ;
SETXMIT(PIVOT) ;EP - RESET TRANSMIT FLAG
+1 KILL DIE,DIR,DIC,DA,DR
+2 SET DIE="^VAT(391.71,"
+3 SET DA=PIVOT
+4 ;SET AS TRANSMITED AND NO TRANSMISSION REQUIRED
SET DR=".06///1;.08///0"
+5 DO ^DIE
+6 QUIT