VAFCMSG ;ALB/JRP-BACKGROUND JOB TO TRANSMIT ENTRIES IN PIVOT FILE ; 3/2/04 12:54pm
;;5.3;Registration;**91,149,530,578,1015**;Jun 06, 1996;Build 21
;
MAIN ;Main entry point for background job
;
;attempt to lock non existant global.
L +^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7"):1 I '$T Q
;Send messages ? 0=STOP,2=SUSPEND
N SEND
S SEND=$P($$SEND^VAFHUTL(),"^",2)
I (SEND=0)!(SEND=2) L -^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7") Q
;Send Registration messages
D BCSTA04
;Send changes to patient's demographical data (ADT-A08)
D BCSTA08
;Send changes to patient's treating facility list (MFU-M05)
D BCKTFMFU^VAFCTFMF
;unlock global
L -^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7")
;K DIC,X,Y
Q
;
BCSTA08 ;Broadcast ADT-A08 messages for all entries in ADT/HL PIVOT file
;(#391.71) that have been marked for transmission
;
;Input : None
;Output : None
;
;Declare variables
N PIVOTPTR,NODE,DFN,EDITDATE,TMP,INFOARR
S INFOARR="^TMP(""VAFCMSG"","_$J_",""EVNTINFO"")"
K @INFOARR
;Loop through pivot file based on demographic updates
S PIVOTPTR=0
F S PIVOTPTR=+$O(^VAT(391.71,"AXMIT",4,PIVOTPTR)) Q:('PIVOTPTR) D
.;Bad entry in cross reference - delete it and quit
.I ('$D(^VAT(391.71,PIVOTPTR))) K ^VAT(391.71,"AXMIT",4,PIVOTPTR) Q
.;Get event date and pointer to patient
.S NODE=$G(^VAT(391.71,PIVOTPTR,0))
.S EDITDATE=+NODE
.S DFN=+$P(NODE,"^",3)
.;PATCH 530 check global for lock status - quit if locked.
.L +^DPT(DFN):1 I '$T Q
.;Bad pointer to patient - mark entry as transmitted and quit
.I ('$D(^DPT(DFN,0)))!($G(^DPT(DFN,-9))) D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.I $P(^DPT(DFN,0),U)="" D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.I '$D(^DPT("B",$P(^DPT(DFN,0),U),DFN)) D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.;Store info into event information array
.K @INFOARR
.S @INFOARR@("PIVOT")=PIVOTPTR
.;Event reason code
.; 99 = Death 98 = Resurrection 97=Sensitivity Update
.; Death will overwrite any other reason code. It is the
.; dominant reason code.
.S @INFOARR@("REASON",1)=""
.S @INFOARR@("REASON",1)=$P($G(^VAT(391.71,PIVOTPTR,0)),"^",10)
.I (+$G(^DPT(DFN,.35))) S @INFOARR@("REASON",1)=99
.;
.; user/operator name from duz
.S DIC="^VA(200,",DIC(0)="MZO",X="`"_+$P(NODE,"^",9) D ^DIC
.S @INFOARR@("USER")=$P($G(Y),"^",2)
.;
.S @INFOARR@("EVENT-NUM")=$P(NODE,"^",2)
.S @INFOARR@("VAR-PTR")=$P(NODE,"^",5)
.;
.;Broadcast ADT-A08 message
.S TMP=$$BCSTADT^VAFCMSG0(DFN,"A08",EDITDATE,INFOARR)
.;Store result in pivot file
.S:$P(TMP,U,2)]"" TMP=$P(TMP,U,2) D FILERM^VAFCUTL(PIVOTPTR,TMP)
.;Error broadcasting message
.Q:(TMP<0)
.;Mark entry in pivot file as transmitted
.D XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
.;PATCH 530 if locked by check unlock.
.L -^DPT(DFN)
;Done - clean up and quit
K @INFOARR
Q
;
BCSTA04 ;Broadcast ADT-A04 messages for all entries in ADT/HL PIVOT file
;(#391.71) that have been marked for transmission
;
;Input : None
;Output : None
;
;Declare variables
N PIVOTPTR,NODE,DFN,EDITDATE,FIELDS,RESULT
S PIVOTPTR=0
F S PIVOTPTR=+$O(^VAT(391.71,"AXMIT",3,PIVOTPTR)) Q:('PIVOTPTR) D
.;Bad entry in cross reference - delete it and quit
.I ('$D(^VAT(391.71,PIVOTPTR))) K ^VAT(391.71,"AXMIT",3,PIVOTPTR) Q
.;Get event date and pointer to patient
.S NODE=$G(^VAT(391.71,PIVOTPTR,0))
.S FIELDS=$G(^VAT(391.71,PIVOTPTR,2))
.S USER=+$P(NODE,"^",9)
.S EDITDATE=+NODE
.S DFN=+$P(NODE,"^",3)
.;PATCH 530 check for locked record - quit if locked.
.L +^DPT(DFN):1 I '$T Q
.;Bad pointer to patient - mark entry as transmitted and quit
.I ('$D(^DPT(DFN,0)))!($G(^DPT(DFN,-9))) D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.I $P(^DPT(DFN,0),U)="" D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.I '$D(^DPT("B",$P(^DPT(DFN,0),U),DFN)) D XMITFLAG^VAFCDD01(PIVOTPTR,"",1) Q
.;Broadcast ADT-A04 message
.S RESULT=$$EN^VAFCA04(DFN,EDITDATE,USER,PIVOTPTR)
.D XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
.L -^DPT(DFN)
;Done - quit
Q
VAFCMSG ;ALB/JRP-BACKGROUND JOB TO TRANSMIT ENTRIES IN PIVOT FILE ; 3/2/04 12:54pm
+1 ;;5.3;Registration;**91,149,530,578,1015**;Jun 06, 1996;Build 21
+2 ;
MAIN ;Main entry point for background job
+1 ;
+2 ;attempt to lock non existant global.
+3 LOCK +^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7"):1
IF '$TEST
QUIT
+4 ;Send messages ? 0=STOP,2=SUSPEND
+5 NEW SEND
+6 SET SEND=$PIECE($$SEND^VAFHUTL(),"^",2)
+7 IF (SEND=0)!(SEND=2)
LOCK -^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7")
QUIT
+8 ;Send Registration messages
+9 DO BCSTA04
+10 ;Send changes to patient's demographical data (ADT-A08)
+11 DO BCSTA08
+12 ;Send changes to patient's treating facility list (MFU-M05)
+13 DO BCKTFMFU^VAFCTFMF
+14 ;unlock global
+15 LOCK -^VAT(391.71,"VAFC BATCH UPDATE ADT/HL7")
+16 ;K DIC,X,Y
+17 QUIT
+18 ;
BCSTA08 ;Broadcast ADT-A08 messages for all entries in ADT/HL PIVOT file
+1 ;(#391.71) that have been marked for transmission
+2 ;
+3 ;Input : None
+4 ;Output : None
+5 ;
+6 ;Declare variables
+7 NEW PIVOTPTR,NODE,DFN,EDITDATE,TMP,INFOARR
+8 SET INFOARR="^TMP(""VAFCMSG"","_$JOB_",""EVNTINFO"")"
+9 KILL @INFOARR
+10 ;Loop through pivot file based on demographic updates
+11 SET PIVOTPTR=0
+12 FOR
SET PIVOTPTR=+$ORDER(^VAT(391.71,"AXMIT",4,PIVOTPTR))
IF ('PIVOTPTR)
QUIT
Begin DoDot:1
+13 ;Bad entry in cross reference - delete it and quit
+14 IF ('$DATA(^VAT(391.71,PIVOTPTR)))
KILL ^VAT(391.71,"AXMIT",4,PIVOTPTR)
QUIT
+15 ;Get event date and pointer to patient
+16 SET NODE=$GET(^VAT(391.71,PIVOTPTR,0))
+17 SET EDITDATE=+NODE
+18 SET DFN=+$PIECE(NODE,"^",3)
+19 ;PATCH 530 check global for lock status - quit if locked.
+20 LOCK +^DPT(DFN):1
IF '$TEST
QUIT
+21 ;Bad pointer to patient - mark entry as transmitted and quit
+22 IF ('$DATA(^DPT(DFN,0)))!($GET(^DPT(DFN,-9)))
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+23 IF $PIECE(^DPT(DFN,0),U)=""
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+24 IF '$DATA(^DPT("B",$PIECE(^DPT(DFN,0),U),DFN))
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+25 ;Store info into event information array
+26 KILL @INFOARR
+27 SET @INFOARR@("PIVOT")=PIVOTPTR
+28 ;Event reason code
+29 ; 99 = Death 98 = Resurrection 97=Sensitivity Update
+30 ; Death will overwrite any other reason code. It is the
+31 ; dominant reason code.
+32 SET @INFOARR@("REASON",1)=""
+33 SET @INFOARR@("REASON",1)=$PIECE($GET(^VAT(391.71,PIVOTPTR,0)),"^",10)
+34 IF (+$GET(^DPT(DFN,.35)))
SET @INFOARR@("REASON",1)=99
+35 ;
+36 ; user/operator name from duz
+37 SET DIC="^VA(200,"
SET DIC(0)="MZO"
SET X="`"_+$PIECE(NODE,"^",9)
DO ^DIC
+38 SET @INFOARR@("USER")=$PIECE($GET(Y),"^",2)
+39 ;
+40 SET @INFOARR@("EVENT-NUM")=$PIECE(NODE,"^",2)
+41 SET @INFOARR@("VAR-PTR")=$PIECE(NODE,"^",5)
+42 ;
+43 ;Broadcast ADT-A08 message
+44 SET TMP=$$BCSTADT^VAFCMSG0(DFN,"A08",EDITDATE,INFOARR)
+45 ;Store result in pivot file
+46 IF $PIECE(TMP,U,2)]""
SET TMP=$PIECE(TMP,U,2)
DO FILERM^VAFCUTL(PIVOTPTR,TMP)
+47 ;Error broadcasting message
+48 IF (TMP<0)
QUIT
+49 ;Mark entry in pivot file as transmitted
+50 DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
+51 ;PATCH 530 if locked by check unlock.
+52 LOCK -^DPT(DFN)
End DoDot:1
+53 ;Done - clean up and quit
+54 KILL @INFOARR
+55 QUIT
+56 ;
BCSTA04 ;Broadcast ADT-A04 messages for all entries in ADT/HL PIVOT file
+1 ;(#391.71) that have been marked for transmission
+2 ;
+3 ;Input : None
+4 ;Output : None
+5 ;
+6 ;Declare variables
+7 NEW PIVOTPTR,NODE,DFN,EDITDATE,FIELDS,RESULT
+8 SET PIVOTPTR=0
+9 FOR
SET PIVOTPTR=+$ORDER(^VAT(391.71,"AXMIT",3,PIVOTPTR))
IF ('PIVOTPTR)
QUIT
Begin DoDot:1
+10 ;Bad entry in cross reference - delete it and quit
+11 IF ('$DATA(^VAT(391.71,PIVOTPTR)))
KILL ^VAT(391.71,"AXMIT",3,PIVOTPTR)
QUIT
+12 ;Get event date and pointer to patient
+13 SET NODE=$GET(^VAT(391.71,PIVOTPTR,0))
+14 SET FIELDS=$GET(^VAT(391.71,PIVOTPTR,2))
+15 SET USER=+$PIECE(NODE,"^",9)
+16 SET EDITDATE=+NODE
+17 SET DFN=+$PIECE(NODE,"^",3)
+18 ;PATCH 530 check for locked record - quit if locked.
+19 LOCK +^DPT(DFN):1
IF '$TEST
QUIT
+20 ;Bad pointer to patient - mark entry as transmitted and quit
+21 IF ('$DATA(^DPT(DFN,0)))!($GET(^DPT(DFN,-9)))
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+22 IF $PIECE(^DPT(DFN,0),U)=""
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+23 IF '$DATA(^DPT("B",$PIECE(^DPT(DFN,0),U),DFN))
DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
QUIT
+24 ;Broadcast ADT-A04 message
+25 SET RESULT=$$EN^VAFCA04(DFN,EDITDATE,USER,PIVOTPTR)
+26 DO XMITFLAG^VAFCDD01(PIVOTPTR,"",1)
+27 LOCK -^DPT(DFN)
End DoDot:1
+28 ;Done - quit
+29 QUIT