YSCLHLMA ;DSS/PO;19 May 2020 14:13:48;28 Nov 2019 18:02:34
;;5.01;MENTAL HEALTH;**149**;Dec 30, 1994;Build 72
;
Q
;
; Reference to ^XLFDT supported by DBIA #10103
;
SAVEDATA(DFN,PSGORD,PSORXIEN) ; Get and save the data needed to Build and send registration and clinical/dispense messages
; input: DFN patient file IEN
; PSGORD pharmacy patient file UnitDose ien e.g. 167 or 167U
; PSORXIEN prescription ien of prescription file
Q ; obsolete, used for HL7 trigger events, save for future use
D GET^YSCLHLGT(.YSCLARR,DFN,PSGORD,PSORXIEN)
M ^XTMP("YSCLHL7",$$NOW^XLFDT,DFN_U_+$G(PSGORD)_U_+$G(PSORXIEN),"DATA")=YSCLARR
D XTMPZRO^YSCLHLOP
Q
;
XMITALL(REXMIT,FROMDT,TODT) ; re-transmit or transmit HL7 messages,
; input: inputs are optional
; REXMIT re-transmit flag if 1, it will retransmit the message for given date range
; whether or not the HL7 messages transmit
; FROMDT start date to start re-transmission
; TODT end date for re-transmission
; if no input paramters, only HL7 messages that are not transferred will be transferred, up to yesterday
;
N I,NODE,XMITRES,YSCLARR,YSDT
S REXMIT=+$G(REXMIT)
S YSDT=$S(+$G(FROMDT)>0:FROMDT,1:$$FMADD^XLFDT(DT,-7)) ; start from seven days ago in case of holiday or weekend
S TODT=$S(+$G(TODT)>0:TODT,1:DT)
;
F S YSDT=$O(^XTMP("YSCLHL7",YSDT)) Q:(YSDT="")!(YSDT>=TODT) D
. S NODE=""
. F S NODE=$O(^XTMP("YSCLHL7",YSDT,NODE)) Q:NODE="" D
.. Q:'REXMIT&($G(^XTMP("YSCLHL7",YSDT,NODE,"STATUS","ALL"))>0) ; do not transmit, if all are already transmited
.. K YSCLARR,XMITRES
.. M YSCLARR=^XTMP("YSCLHL7",YSDT,NODE,"DATA")
.. M XMITRES=^XTMP("YSCLHL7",YSDT,NODE,"STATUS")
.. I REXMIT F I=1:1 Q:'$D(XMITRES(I)) S XMITRES(I)=0 ; force re-transmission of messages for one patient
.. D XMI1PT(.YSCLARR,.XMITRES) ; transmit the HL7 message for one patient.
.. M ^XTMP("YSCLHL7",YSDT,NODE,"STATUS")=XMITRES ; save the transmission status of messages
Q
;
XMI1PT(YSCLARR,XMITRES,YSILENT) ; Transmit the HL7 message(s) from YSCLARR for one Patient.
; input: YSCLARR ; data to build the HL7 message(s) from
; input/Output: XMITRES ; call by reference - transmission Status.
; YSILENT optional, if 1 no message is written
N NODE,I
S:'$G(XMITRES(1)) XMITRES(1)=$$ADTA28^YSCLHLAD(.YSCLARR,$G(YSILENT))_U_"ADT"_U_DT
;
I YSCLARR("*PSORXIEN") D ; patient with a Clozapine presciption order
. S:'$G(XMITRES(2)) XMITRES(2)=$$RDEO11^YSCLHLRD(.YSCLARR,$G(YSILENT))_U_"RDE"_U_DT
;
I YSCLARR("*PSGORD") D ; patient with a unit dose med order
. S I=0
. F S I=$O(YSCLARR("*RPT",I)) Q:'I D
.. S NODE="" F S NODE=$O(YSCLARR("*RPT",I,NODE)) Q:NODE="" S YSCLARR(NODE)=YSCLARR("*RPT",I,NODE)
.. S:'$G(XMITRES(I+1)) XMITRES(I+1)=$$RDEO11^YSCLHLRD(.YSCLARR)_U_"RDE"_U_DT
;if all messages are sent set XMITRES("ALL") to 1 otherwise 0
S XMITRES("ALL")=1 F I=1:1 Q:'$D(XMITRES(I)) S XMITRES("ALL")=+$G(XMITRES("ALL"))&+XMITRES(I)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYSCLHLMA 3094 printed Nov 22, 2024@17:23:44 Page 2
YSCLHLMA ;DSS/PO;19 May 2020 14:13:48;28 Nov 2019 18:02:34
+1 ;;5.01;MENTAL HEALTH;**149**;Dec 30, 1994;Build 72
+2 ;
+3 QUIT
+4 ;
+5 ; Reference to ^XLFDT supported by DBIA #10103
+6 ;
SAVEDATA(DFN,PSGORD,PSORXIEN) ; Get and save the data needed to Build and send registration and clinical/dispense messages
+1 ; input: DFN patient file IEN
+2 ; PSGORD pharmacy patient file UnitDose ien e.g. 167 or 167U
+3 ; PSORXIEN prescription ien of prescription file
+4 ; obsolete, used for HL7 trigger events, save for future use
QUIT
+5 DO GET^YSCLHLGT(.YSCLARR,DFN,PSGORD,PSORXIEN)
+6 MERGE ^XTMP("YSCLHL7",$$NOW^XLFDT,DFN_U_+$GET(PSGORD)_U_+$GET(PSORXIEN),"DATA")=YSCLARR
+7 DO XTMPZRO^YSCLHLOP
+8 QUIT
+9 ;
XMITALL(REXMIT,FROMDT,TODT) ; re-transmit or transmit HL7 messages,
+1 ; input: inputs are optional
+2 ; REXMIT re-transmit flag if 1, it will retransmit the message for given date range
+3 ; whether or not the HL7 messages transmit
+4 ; FROMDT start date to start re-transmission
+5 ; TODT end date for re-transmission
+6 ; if no input paramters, only HL7 messages that are not transferred will be transferred, up to yesterday
+7 ;
+8 NEW I,NODE,XMITRES,YSCLARR,YSDT
+9 SET REXMIT=+$GET(REXMIT)
+10 ; start from seven days ago in case of holiday or weekend
SET YSDT=$SELECT(+$GET(FROMDT)>0:FROMDT,1:$$FMADD^XLFDT(DT,-7))
+11 SET TODT=$SELECT(+$GET(TODT)>0:TODT,1:DT)
+12 ;
+13 FOR
SET YSDT=$ORDER(^XTMP("YSCLHL7",YSDT))
if (YSDT="")!(YSDT>=TODT)
QUIT
Begin DoDot:1
+14 SET NODE=""
+15 FOR
SET NODE=$ORDER(^XTMP("YSCLHL7",YSDT,NODE))
if NODE=""
QUIT
Begin DoDot:2
+16 ; do not transmit, if all are already transmited
if 'REXMIT&($GET(^XTMP("YSCLHL7",YSDT,NODE,"STATUS","ALL"))>0)
QUIT
+17 KILL YSCLARR,XMITRES
+18 MERGE YSCLARR=^XTMP("YSCLHL7",YSDT,NODE,"DATA")
+19 MERGE XMITRES=^XTMP("YSCLHL7",YSDT,NODE,"STATUS")
+20 ; force re-transmission of messages for one patient
IF REXMIT
FOR I=1:1
if '$DATA(XMITRES(I))
QUIT
SET XMITRES(I)=0
+21 ; transmit the HL7 message for one patient.
DO XMI1PT(.YSCLARR,.XMITRES)
+22 ; save the transmission status of messages
MERGE ^XTMP("YSCLHL7",YSDT,NODE,"STATUS")=XMITRES
End DoDot:2
End DoDot:1
+23 QUIT
+24 ;
XMI1PT(YSCLARR,XMITRES,YSILENT) ; Transmit the HL7 message(s) from YSCLARR for one Patient.
+1 ; input: YSCLARR ; data to build the HL7 message(s) from
+2 ; input/Output: XMITRES ; call by reference - transmission Status.
+3 ; YSILENT optional, if 1 no message is written
+4 NEW NODE,I
+5 if '$GET(XMITRES(1))
SET XMITRES(1)=$$ADTA28^YSCLHLAD(.YSCLARR,$GET(YSILENT))_U_"ADT"_U_DT
+6 ;
+7 ; patient with a Clozapine presciption order
IF YSCLARR("*PSORXIEN")
Begin DoDot:1
+8 if '$GET(XMITRES(2))
SET XMITRES(2)=$$RDEO11^YSCLHLRD(.YSCLARR,$GET(YSILENT))_U_"RDE"_U_DT
End DoDot:1
+9 ;
+10 ; patient with a unit dose med order
IF YSCLARR("*PSGORD")
Begin DoDot:1
+11 SET I=0
+12 FOR
SET I=$ORDER(YSCLARR("*RPT",I))
if 'I
QUIT
Begin DoDot:2
+13 SET NODE=""
FOR
SET NODE=$ORDER(YSCLARR("*RPT",I,NODE))
if NODE=""
QUIT
SET YSCLARR(NODE)=YSCLARR("*RPT",I,NODE)
+14 if '$GET(XMITRES(I+1))
SET XMITRES(I+1)=$$RDEO11^YSCLHLRD(.YSCLARR)_U_"RDE"_U_DT
End DoDot:2
End DoDot:1
+15 ;if all messages are sent set XMITRES("ALL") to 1 otherwise 0
+16 SET XMITRES("ALL")=1
FOR I=1:1
if '$DATA(XMITRES(I))
QUIT
SET XMITRES("ALL")=+$GET(XMITRES("ALL"))&+XMITRES(I)
+17 QUIT
+18 ;