YSCLHLOP ; HEC/hrubovcak clozapine HL7 option support ;19 May 2020 14:13:48
;;5.01;MENTAL HEALTH;**149**;Dec 30, 1994;Build 72
;
; Reference to ^PS(55 supported by IA #787
; Reference to ^PSDRUG supported by IA #221
; Reference to ^PSRX supported by IA #780
; Reference to ^PSO52API supported by IA #4820
; Reference to ^DIE supported by IA #2053
; Reference to ^DICRW supported by IA #1005
; Reference to ^%ZTLOAD supported by IA #10063
; Reference to ^DIQ supported by DBIA #2056
; Reference to ^XLFDT supported by DBIA #10103
; Reference to ^VASITE supported by DBIA #10112
;
Q
;
RETRANS ; entry point from TaskMan to retransmit HL7 messages
;
Q:'$G(ZTSK) ; must be queued
N YSHL7
S YSHL7("allowDups")=1
;
; fall through to transmit the messages
DLYHL7 ; Clozapine HL7 Message Transmission [YSCL HL7 CLOZ TRANSMISSION] TaskMan entry point
D DT^DICRW
K ^TMP($J) ; clear any residue
N N,X,Y,YSCLABRT,YSCLZDRUG,YSDFN,YSFMERR,YSFMFDA,YSILENT,YSNOW,YSORLST,YSPSRX,YSRXIEN,YSRXLST
; only one process can run at a time
S N=$$NOW^XLFDT L +^XTMP("YSCLHL7",0):DILOCKTM E D Q
. S ^XTMP("YSCLHL7",0,"LOCK FAILED")=N_U_$S($G(ZTSK):"Task #"_ZTSK,1:"no task")_U_"Job #"_$J
; (#20.01) HL7 TRANSMISSION START [1D] ^ (#20.02) HL7 TRANSMISSION END [2D]
S YSFMFDA(603.03,"1,",20.01)=$$NOW^XLFDT,YSFMFDA(603.03,"1,",20.02)="@"
D FILE^DIE("","YSFMFDA","YSFMERR")
; update zero node at beginning
D XTMPZRO S ^XTMP("YSCLHL7",0,"RUNNING")=$G(ZTSK)_U_N K ^XTMP("YSCLHL7",0,"LOCK FAILED")
S YSCLABRT=0 ; if true transmission aborted
S X=0 F S X=$O(^PSDRUG("ACLOZ",X)) Q:'X S YSCLZDRUG(X)="" ; Clozapine IEN list
I '$O(YSCLZDRUG(0)) S YSCLABRT=1 D Q
. S YSCLABRT(1)="* No Clozapine entries found in the DRUG file (#55). *"
. D SNDMSG ;
D BLDPTLST ; list of active clozapine patients
I '$O(^TMP($J,"YSCLOZDFN",0)) S YSCLABRT=1 D Q
. S YSCLABRT(1)="* No active Clozapine patients found in file #603.01. *"
. D SNDMSG
;
S YSNOW=$$NOW^XLFDT,YSDFN=0
K ^TMP($J,"YS HL7LST") S ^TMP($J,"YS HL7LST",0)=0 ; list for MailMan report
F S YSDFN=$O(^TMP($J,"YSCLOZDFN",YSDFN)) Q:'YSDFN D
. D GETCLZRX(.YSRXLST,YSDFN) S YSRXIEN=0 F S YSRXIEN=$O(YSRXLST(YSRXIEN)) Q:'YSRXIEN D
.. N HLO,YSCLARR,YSHLRSLT,YSNWIEN
.. S HLO("Rx#")=$P(YSRXLST(YSRXIEN),U) ; prescription # may contain letters
.. I '$G(YSHL7("allowDups")) Q:$O(^YSCL(603.05,"RX",HLO("Rx#"),0)) ; already transmitted
.. D GET^YSCLHLGT(.YSCLARR,YSDFN,0,YSRXIEN) ; data for HL7 message
.. I $G(YSCLARR("MED_RX#/ORDER#"))="" S YSCLARR("MED_RX#/ORDER#")=$G(HLO("Rx#"))
.. Q:YSCLARR("MED_RX#/ORDER#")=""
.. D XMI1PT^YSCLHLMA(.YSCLARR,.YSHLRSLT,1) ; "1" is for YSILENT, no writes to device
.. Q:'$O(YSHLRSLT(0)) ; nothing sent
.. D UPDT4RX(.YSHLRSLT,YSDFN,.HLO)
; now do orders
S YSORDT=$$HTFM^XLFDT($H-90) ; default to 90 days
N YSUNSNT S YSUNSNT=0 ; true if messages not sent
; ^PS(55,"AUDS",start date/time,dfn,order#) cross-ref
F S YSORDT=$O(^PS(55,"AUDS",YSORDT)) Q:'YSORDT!(YSORDT>YSNOW) D ; skip future orders
. S YSORDT("LAST")=YSORDT
. S YSDFN=0 F S YSDFN=$O(^PS(55,"AUDS",YSORDT,YSDFN)) Q:'YSDFN D:$D(^TMP($J,"YSCLOZDFN",YSDFN))
.. N YSUDSIEN
.. S YSUDSIEN=0 F S YSUDSIEN=$O(^PS(55,"AUDS",YSORDT,YSDFN,YSUDSIEN)) Q:'YSUDSIEN D
... N YSCLARR,YSGORD,YSUNSNT
... S YSUNSNT=0
... D GETCLZOR^YSCLHLGT(.YSCLARR,YSDFN,YSUDSIEN) Q:'$D(YSCLARR("*RPT"))
... ; ajf ; check for order number
... N YSORNUM S YSORNUM=YSCLARR("MED_RX#/ORDER#")
... S YSGORD=YSUDSIEN Q:YSGORD=""
... I '$G(YSHL7("allowDups")) Q:$O(^YSCL(603.05,"ON",YSCLARR("MED_RX#/ORDER#"),0)) ; already transmitted
... D GET^YSCLHLGT(.YSCLARR,YSDFN,YSGORD,0) ; data for HL7 message
... N HLO,YSHLRSLT D XMI1PT^YSCLHLMA(.YSCLARR,.YSHLRSLT,1) ; "1" is for YSILENT, no writes to terminal
... I '$O(YSHLRSLT(0)) S YSUNSNT=YSUNSNT+1 Q ; nothing sent
... ;ajf ; SET YSGORD = YSORNUM
... S YSGORD=YSORNUM
... D UPDT4OR(.YSHLRSLT,YSDFN,YSGORD)
; all done
D SNDMSG
; (#20.02) HL7 TRANSMISSION END [2D]
K YSFMERR,YSFMFDA S YSFMFDA(603.03,"1,",20.02)=$$NOW^XLFDT
D FILE^DIE("","YSFMFDA","YSFMERR")
; transmission finished, update ^XTMP zero node, delete "RUNNING" node, release LOCK, exit
D XTMPZRO K ^XTMP("YSCLHL7",0,"RUNNING") L -^XTMP("YSCLHL7",0)
K ^TMP($J),YSORDT ; clean up
Q
;
GETCLZRX(RXRSLT,DFN) ; RXRSLT passed by ref., get clozapine prescriptions
; YSRXIEN is IEN in PRESCRIPTION file (#52)
N DRUGIEN,PRFLIEN,YSRXIEN K RXRSLT S RXRSLT=0
; ^PS(55,D0,P,D1,0)= (#.01) PRESCRIPTION PROFILE [1P:52]
S PRFLIEN=0 F S PRFLIEN=$O(^PS(55,DFN,"P",PRFLIEN)) Q:'PRFLIEN K DRUGIEN,YSRXIEN S YSRXIEN=+$G(^PS(55,DFN,"P",PRFLIEN,0)) I YSRXIEN>0,$D(^PSRX(YSRXIEN,0)) D
. S YSRXIEN(0)=$G(^PSRX(YSRXIEN,0)),DRUGIEN=+$P(YSRXIEN(0),U,6) Q:'(DRUGIEN>0) ; must have drug pointer
. Q:'$D(^PSDRUG("ACLOZ",DRUGIEN)) ; not Clozapine
. K YSFMERR Q:$$GET1^DIQ(52,YSRXIEN_",",100,"I","YSFMERR") ; (#100) STATUS [1S], '0' FOR ACTIVE
. S RXRSLT(YSRXIEN)=YSRXIEN(0),RXRSLT=RXRSLT+1
;
Q
;
;
UPDT4RX(YSHLRST,YSDFN,HLO) ; update file #603.05 for prescriptions, save MailMan text
; YSHRSLT, HLO both passed by ref.
N YSNWIEN S YSNWIEN=0 F S YSNWIEN=$O(YSHLRSLT(YSNWIEN)) Q:'YSNWIEN D
. ; save info for MailMan message
. S HLO("type")=$P(YSHLRSLT(YSNWIEN),U,2) ; type of message
. S HLO("ien")=$P(YSHLRSLT(YSNWIEN),U) Q:'HLO("ien") ; must have IEN
. D HLOCNTR
. S ^TMP($J,"YS HL7LST","Rx",HLO("ien"))=HLO("type")_U_HLO("Rx#")
. N YSFMUPDT
. S YSFMUPDT(603.51,.01)=YSNOW ; (#.01) DATE/TIME OF TRANSMISSION [1D]
. S YSFMUPDT(603.51,.02)=HLO("ien") ; (#.02) HLO IEN [2N]
. S YSFMUPDT(603.51,.03)=HLO("type") ; (#.03) MESSAGE TYPE [3F]
. S YSFMUPDT(603.51,.04)=HLO("Rx#") ; (#.04) PRESCRIPTION # [4F]
. D UPDTFL(YSDFN,.YSFMUPDT) ; update subfile
;
Q
;
UPDT4OR(YSHRLST,YSDFN,YSGORD) ; update file #603.05 for orders, save MailMan text
; YSHRSLT passed by ref.
N HLO,YSNWIEN
S YSNWIEN=0 F S YSNWIEN=$O(YSHLRSLT(YSNWIEN)) Q:'YSNWIEN D
. ; save info for MailMan message
. S HLO("type")=$P(YSHLRSLT(YSNWIEN),U,2) ; type of message
. S HLO("ien")=$P(YSHLRSLT(YSNWIEN),U) Q:'HLO("ien") ; must have IEN
. D HLOCNTR
. S ^TMP($J,"YS HL7LST","Order",HLO("ien"))=HLO("type")_U_YSGORD
. N YSFMUPDT
. S YSFMUPDT(603.52,.01)=YSNOW ; (#.01) DATE/TIME OF TRANSMISSION [1D]
. S YSFMUPDT(603.52,.02)=HLO("ien") ; (#.02) HLO IEN [2N]
. S YSFMUPDT(603.52,.03)=HLO("type") ; (#.03) MESSAGE TYPE [3F]
. S YSFMUPDT(603.52,.04)=YSGORD ; (#.04) ORDER # [4F]
. D UPDTFL(YSDFN,.YSFMUPDT) ; update subfile
Q
;
HLOCNTR ; count of HLO messages sent
N NHL7 S NHL7=$G(^TMP($J,"YS HL7LST",0))+1,^(0)=NHL7 ; message count
Q
ASK2QUE ;
N DTOUT,DUOUT
Q:$G(ZTSK) ; can't be queued
D DT^DICRW
Q:$$RUNCHK ; already running
;
K DIR S DIR(0)="YA",DIR("A")="Are you sure you want to continue? ",DIR("B")="NO"
S DIR("A",1)=" " ; skip a line
S DIR("A",2)="This will queue the HL7 messages for all active Clozapine patients."
S DIR("A",3)="If HL7 messages have already been sent for a prescription or order"
S DIR("A",4)="they will NOT be retransmitted."
D ^DIR Q:$D(DTOUT)!$D(DUOUT)
I 'Y D Q
. K DIR S DIR(0)="EA",DIR("A")="Nothing queued. Press enter: ",DIR("A",1)=" " D ^DIR
;
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
S ZTIO="",ZTRTN="DLYHL7^"_$T(+0),ZTDTH=$H,ZTDESC="Clozapine HL7 transmission"
D ^%ZTLOAD
;
K DIR S DIR(0)="EA",DIR("A")="Press enter: ",DIR("A",1)=" "
S DIR("A",2)=$S($G(ZTSK):"Queued as task #"_ZTSK,1:"NOT queued!")
D ^DIR
Q
;
RETRHL7 ; Retransmit Clozapine HL7 Messages [YSCL HL7 CLOZ RETRANSMIT]
;
D DT^DICRW N DIR,V,X,Y,DTOUT,DUOUT
; this cannot be queued
I $G(ZTSK) S ^XTMP("YSCLHL7",0,"RETRANSMIT QUEUE ATTEMPT")=ZTSK_U_$$NOW^XLFDT Q
; only one at a time
Q:$$RUNCHK
;
K DIR S DIR(0)="YA",DIR("A")="Are you sure you want to continue? ",DIR("B")="NO"
S DIR("A",1)=" " ; skip a line
S DIR("A",2)="This will retransmit HL7 messages for all active Clozapine patients."
S DIR("A",3)="If a Prescription or Order is found messages will be sent."
S DIR("A",4)="Duplicate HL7 messages could be transmitted."
D ^DIR Q:$D(DTOUT)!$D(DUOUT)
I 'Y D Q
. K DIR S DIR(0)="EA",DIR("A")="Nothing queued. Press enter: ",DIR("A",1)=" " D ^DIR
;
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
S ZTIO="",ZTRTN="RETRANS^"_$T(+0),ZTDTH=$H,ZTDESC="Clozapine HL7 retransmit"
D ^%ZTLOAD
;
K DIR S DIR(0)="EA",DIR("A")="Press enter: ",DIR("A",1)=" "
S DIR("A",2)=$S($G(ZTSK):"Queued as task #"_ZTSK,1:"NOT queued!")
D ^DIR
Q
;
BLDPTLST ; build list of Clozapine Patients
N YSIEN,X,YSDFN,YSRXPT,YSFLD
; get file 55 data
;^PS(55,D0,SAND)= (#53) CLOZAPINE REGISTRATION NUMBER [1F] ^ (#54) CLOZAPINE STATUS [2S] ^ (#55) DATE OF LAST CLOZAPINE RX [3D] ^
; ==>(#56) DEMOGRAPHICS SENT [4S] ^ (#57) RESPONSIBLE PROVIDER [5P:200] ^ (#58) REGISTRATION DATE [6D] ^
S YSIEN=0 F S YSIEN=$O(^YSCL(603.01,YSIEN)) Q:'YSIEN D
. S X=$G(^YSCL(603.01,YSIEN,0)),YSDFN=+$P(X,U,2) Q:'YSDFN ; must have patient pointer
. K YSRXPT S YSRXPT(54)=$$GET1^DIQ(55,YSDFN,54,"I")
. ; only active patients on list
. Q:'(YSRXPT(54)="A") F YSFLD=53,55:1:58 S YSRXPT(YSFLD)=$$GET1^DIQ(55,YSDFN,YSFLD,"I")
. M ^TMP($J,"YSCLOZDFN",YSDFN,"FILE55")=YSRXPT
;
Q
;
UPDTFL(YSDFN,YSFMUPDT) ; update file & sub-file
; YSFMUPDT - data for ^DIE, passed by ref.
N J,YSFMERR,YSFMIEN,YSFMROOT,YSIENS,YSUBFL
; add patient if not in file #603.05
I '$D(^YSCL(603.05,YSDFN)) D
. S YSFMROOT(603.05,"+1,",.01)=YSDFN,YSFMIEN(1)=YSDFN ; entry is DINUM pointer
. D UPDATE^DIE("","YSFMROOT","YSFMIEN","YSFMERR")
. K YSFMERR,YSFMIEN,YSFMROOT
; sub-file 603.51 or 603.52
S YSUBFL=+$O(YSFMUPDT(0)),YSIENS="+1,"_YSDFN_"," ; adding to multiple
S J=0 F S J=$O(YSFMUPDT(YSUBFL,J)) Q:'J S YSFMROOT(YSUBFL,YSIENS,J)=YSFMUPDT(YSUBFL,J)
D UPDATE^DIE("","YSFMROOT","YSFMIEN","YSFMERR")
Q
;
SNDMSG ; send MailMan message
N CNT,HLIEN,L,NHL7,X,Y,YSFROM,YSITE,YSXMBODY,YSXMSUBJ,YSXMTO,YSXMZ
K ^TMP("XMERR",$J),^TMP($J,"YSXMTXT")
S YSITE=$$SITE^VASITE,NHL7=+$G(^TMP($J,"YS HL7LST",0))
S YSXMBODY=$NA(^TMP($J,"YSXMTXT")) ; mail message text
D ADD2TXT(" HL7 transmission report "_$$FMTE^XLFDT($$NOW^XLFDT))
D ADD2TXT(" Site: "_$P(YSITE,U,2)_" ("_$P(YSITE,U,3)_")"),ADD2TXT(" ")
I $G(YSHL7("allowDups")) D
. S X=$$GET1^DIQ(200,DUZ_",",.01)
. D ADD2TXT(" NOTE: This is a requested retransmission.")
. D ADD2TXT(" Requested by: "_X_" (#"_DUZ_")")
;
I $G(YSCLABRT) D ; process aborted
. D ADD2TXT(" *** ERROR: The Clozapine HL7 transmission process aborted. ***")
. S X=0 F S X=$O(YSCLABRT(X)) Q:'X D ADD2TXT(YSCLABRT(X))
;
D ADD2TXT(" Total messages sent: "_NHL7),ADD2TXT(" ")
S CNT=0 ; counter for Mail message
D:NHL7 ; ^TMP($J,"YS HL7LST","Rx",HLIEN)=HLO("type")_U_HLO("Rx#")
. D ADD2TXT(" Message ID Type Prescription"),ADD2TXT(" ")
. S HLIEN=0 F S HLIEN=$O(^TMP($J,"YS HL7LST","Rx",HLIEN)) Q:'HLIEN D
.. S CNT=CNT+1
.. N HLO S HLO("msgId")=$$GET1^DIQ(778,HLIEN_",",.01) ; (#.01) MESSAGE ID [1F]
.. S HLO("body")=$$GET1^DIQ(778,HLIEN_",",.02,"I") ; (#.02) MESSAGE BODY [2P:777] internal format
.. ; (#.03) MESSAGE TYPE [3F] ^ (#.04) EVENT [4F]
.. S HLO("type")=$$GET1^DIQ(777,HLO("body")_",",.03)_U_$$GET1^DIQ(777,HLO("body")_",",.04)
.. S L=$J(CNT,3)_". "_HLO("msgId")_$J(" ",19-$L(HLO("msgId"))),L=L_HLO("type")_$J(" ",10-$L(HLO("type")))
.. S X=^TMP($J,"YS HL7LST","Rx",HLIEN)
.. D ADD2TXT(L_$P(X,U,2)) ; add Rx #
. ; add order info
. D ADD2TXT(" "),ADD2TXT(" Message ID Type Order Number"),ADD2TXT(" ")
. S HLIEN=0 F S HLIEN=$O(^TMP($J,"YS HL7LST","Order",HLIEN)) Q:'HLIEN D
.. S CNT=CNT+1
.. N HLO S HLO("msgId")=$$GET1^DIQ(778,HLIEN_",",.01) ; (#.01) MESSAGE ID [1F]
.. S HLO("body")=$$GET1^DIQ(778,HLIEN_",",.02,"I") ; (#.02) MESSAGE BODY [2P:777] internal format
.. ; (#.03) MESSAGE TYPE [3F] ^ (#.04) EVENT [4F]
.. S HLO("type")=$$GET1^DIQ(777,HLO("body")_",",.03)_U_$$GET1^DIQ(777,HLO("body")_",",.04)
.. S L=$J(CNT,3)_". "_HLO("msgId")_$J(" ",19-$L(HLO("msgId"))),L=L_HLO("type")_$J(" ",10-$L(HLO("type")))
.. S X=^TMP($J,"YS HL7LST","Order",HLIEN)
.. D ADD2TXT(L_$P(X,U,2)) ; add Order #
;
S YSXMTO(DUZ)="",YSXMTO("G.YSCLHL7 LOGS")="" ; recipients
D ADD2TXT(" ")
; add Mail Groups, etc. to message
S X=" " F S X=$O(YSXMTO(X)) Q:X="" D ADD2TXT(" Sent to: "_X)
D ADD2TXT($$EOR^YSCLHLPR)
S YSXMSUBJ="Clozapine HL7 report "_$P(YSITE,U,2)_" ("_$P(YSITE,U,3)_")"
D SENDMSG^XMXAPI(DUZ,YSXMSUBJ,YSXMBODY,.YSXMTO,"",.YSXMZ)
Q
;
ADD2TXT(TXLN) ; add TXLN to MailMan message text
N C S C=$G(^TMP($J,"YSXMTXT",0))+1,^(0)=C
S ^TMP($J,"YSXMTXT",C,0)=TXLN Q
;
RUNCHK(YSRSLT) ; Boolean function, zero if transmission NOT running
; there is user interaction if ZTSK not true
S YSRSLT=0
L +^XTMP("YSCLHL7",0):DILOCKTM E D ; cant't LOCK if running
. S YSRSLT=1 ; return true
. Q:$G(ZTSK) ; queued
. N DIR,V,X
. S DIR(0)="EA",DIR("A")="Press enter: "
. S DIR("A",1)="The Clozapine HL7 Message Transmission appears to be running."
. S V=$NA(^XTMP("YSCLHL7",0,"RUNNING")),X=$G(@V),DIR("A",2)=V_" node: "
. S DIR("A",2)=$S('$D(@V):" Is not defined.",1:" Task #"_$P(X,U)_" started "_$$FMTE^XLFDT($P(X,U,2)))
. D ^DIR
;
L -^XTMP("YSCLHL7",0)
Q YSRSLT
;
XTMPZRO ;set zero node in ^XTMP("YSCLHL7")
; update ^XTMP("YSCLHL7",0) with purge date and $$NOW
N C,J,N
S N=$$NOW^XLFDT,C=$$FMADD^XLFDT($$DT^XLFDT,90) ; 90 days in the future
S J=C,$P(J,U,2)=N,$P(J,U,3)="YSCL Clozapine Daily HL7 Transmission Data",^XTMP("YSCLHL7",0)=J
I $G(ZTSK) S ^XTMP("YSCLHL7",0,"TASK #")=ZTSK_U_N
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYSCLHLOP 13819 printed Nov 22, 2024@17:23:45 Page 2
YSCLHLOP ; HEC/hrubovcak clozapine HL7 option support ;19 May 2020 14:13:48
+1 ;;5.01;MENTAL HEALTH;**149**;Dec 30, 1994;Build 72
+2 ;
+3 ; Reference to ^PS(55 supported by IA #787
+4 ; Reference to ^PSDRUG supported by IA #221
+5 ; Reference to ^PSRX supported by IA #780
+6 ; Reference to ^PSO52API supported by IA #4820
+7 ; Reference to ^DIE supported by IA #2053
+8 ; Reference to ^DICRW supported by IA #1005
+9 ; Reference to ^%ZTLOAD supported by IA #10063
+10 ; Reference to ^DIQ supported by DBIA #2056
+11 ; Reference to ^XLFDT supported by DBIA #10103
+12 ; Reference to ^VASITE supported by DBIA #10112
+13 ;
+14 QUIT
+15 ;
RETRANS ; entry point from TaskMan to retransmit HL7 messages
+1 ;
+2 ; must be queued
if '$GET(ZTSK)
QUIT
+3 NEW YSHL7
+4 SET YSHL7("allowDups")=1
+5 ;
+6 ; fall through to transmit the messages
DLYHL7 ; Clozapine HL7 Message Transmission [YSCL HL7 CLOZ TRANSMISSION] TaskMan entry point
+1 DO DT^DICRW
+2 ; clear any residue
KILL ^TMP($JOB)
+3 NEW N,X,Y,YSCLABRT,YSCLZDRUG,YSDFN,YSFMERR,YSFMFDA,YSILENT,YSNOW,YSORLST,YSPSRX,YSRXIEN,YSRXLST
+4 ; only one process can run at a time
+5 SET N=$$NOW^XLFDT
LOCK +^XTMP("YSCLHL7",0):DILOCKTM
IF '$TEST
Begin DoDot:1
+6 SET ^XTMP("YSCLHL7",0,"LOCK FAILED")=N_U_$SELECT($GET(ZTSK):"Task #"_ZTSK,1:"no task")_U_"Job #"_$JOB
End DoDot:1
QUIT
+7 ; (#20.01) HL7 TRANSMISSION START [1D] ^ (#20.02) HL7 TRANSMISSION END [2D]
+8 SET YSFMFDA(603.03,"1,",20.01)=$$NOW^XLFDT
SET YSFMFDA(603.03,"1,",20.02)="@"
+9 DO FILE^DIE("","YSFMFDA","YSFMERR")
+10 ; update zero node at beginning
+11 DO XTMPZRO
SET ^XTMP("YSCLHL7",0,"RUNNING")=$GET(ZTSK)_U_N
KILL ^XTMP("YSCLHL7",0,"LOCK FAILED")
+12 ; if true transmission aborted
SET YSCLABRT=0
+13 ; Clozapine IEN list
SET X=0
FOR
SET X=$ORDER(^PSDRUG("ACLOZ",X))
if 'X
QUIT
SET YSCLZDRUG(X)=""
+14 IF '$ORDER(YSCLZDRUG(0))
SET YSCLABRT=1
Begin DoDot:1
+15 SET YSCLABRT(1)="* No Clozapine entries found in the DRUG file (#55). *"
+16 ;
DO SNDMSG
End DoDot:1
QUIT
+17 ; list of active clozapine patients
DO BLDPTLST
+18 IF '$ORDER(^TMP($JOB,"YSCLOZDFN",0))
SET YSCLABRT=1
Begin DoDot:1
+19 SET YSCLABRT(1)="* No active Clozapine patients found in file #603.01. *"
+20 DO SNDMSG
End DoDot:1
QUIT
+21 ;
+22 SET YSNOW=$$NOW^XLFDT
SET YSDFN=0
+23 ; list for MailMan report
KILL ^TMP($JOB,"YS HL7LST")
SET ^TMP($JOB,"YS HL7LST",0)=0
+24 FOR
SET YSDFN=$ORDER(^TMP($JOB,"YSCLOZDFN",YSDFN))
if 'YSDFN
QUIT
Begin DoDot:1
+25 DO GETCLZRX(.YSRXLST,YSDFN)
SET YSRXIEN=0
FOR
SET YSRXIEN=$ORDER(YSRXLST(YSRXIEN))
if 'YSRXIEN
QUIT
Begin DoDot:2
+26 NEW HLO,YSCLARR,YSHLRSLT,YSNWIEN
+27 ; prescription # may contain letters
SET HLO("Rx#")=$PIECE(YSRXLST(YSRXIEN),U)
+28 ; already transmitted
IF '$GET(YSHL7("allowDups"))
if $ORDER(^YSCL(603.05,"RX",HLO("Rx#"),0))
QUIT
+29 ; data for HL7 message
DO GET^YSCLHLGT(.YSCLARR,YSDFN,0,YSRXIEN)
+30 IF $GET(YSCLARR("MED_RX#/ORDER#"))=""
SET YSCLARR("MED_RX#/ORDER#")=$GET(HLO("Rx#"))
+31 if YSCLARR("MED_RX#/ORDER#")=""
QUIT
+32 ; "1" is for YSILENT, no writes to device
DO XMI1PT^YSCLHLMA(.YSCLARR,.YSHLRSLT,1)
+33 ; nothing sent
if '$ORDER(YSHLRSLT(0))
QUIT
+34 DO UPDT4RX(.YSHLRSLT,YSDFN,.HLO)
End DoDot:2
End DoDot:1
+35 ; now do orders
+36 ; default to 90 days
SET YSORDT=$$HTFM^XLFDT($HOROLOG-90)
+37 ; true if messages not sent
NEW YSUNSNT
SET YSUNSNT=0
+38 ; ^PS(55,"AUDS",start date/time,dfn,order#) cross-ref
+39 ; skip future orders
FOR
SET YSORDT=$ORDER(^PS(55,"AUDS",YSORDT))
if 'YSORDT!(YSORDT>YSNOW)
QUIT
Begin DoDot:1
+40 SET YSORDT("LAST")=YSORDT
+41 SET YSDFN=0
FOR
SET YSDFN=$ORDER(^PS(55,"AUDS",YSORDT,YSDFN))
if 'YSDFN
QUIT
if $DATA(^TMP($JOB,"YSCLOZDFN",YSDFN))
Begin DoDot:2
+42 NEW YSUDSIEN
+43 SET YSUDSIEN=0
FOR
SET YSUDSIEN=$ORDER(^PS(55,"AUDS",YSORDT,YSDFN,YSUDSIEN))
if 'YSUDSIEN
QUIT
Begin DoDot:3
+44 NEW YSCLARR,YSGORD,YSUNSNT
+45 SET YSUNSNT=0
+46 DO GETCLZOR^YSCLHLGT(.YSCLARR,YSDFN,YSUDSIEN)
if '$DATA(YSCLARR("*RPT"))
QUIT
+47 ; ajf ; check for order number
+48 NEW YSORNUM
SET YSORNUM=YSCLARR("MED_RX#/ORDER#")
+49 SET YSGORD=YSUDSIEN
if YSGORD=""
QUIT
+50 ; already transmitted
IF '$GET(YSHL7("allowDups"))
if $ORDER(^YSCL(603.05,"ON",YSCLARR("MED_RX#/ORDER#"),0))
QUIT
+51 ; data for HL7 message
DO GET^YSCLHLGT(.YSCLARR,YSDFN,YSGORD,0)
+52 ; "1" is for YSILENT, no writes to terminal
NEW HLO,YSHLRSLT
DO XMI1PT^YSCLHLMA(.YSCLARR,.YSHLRSLT,1)
+53 ; nothing sent
IF '$ORDER(YSHLRSLT(0))
SET YSUNSNT=YSUNSNT+1
QUIT
+54 ;ajf ; SET YSGORD = YSORNUM
+55 SET YSGORD=YSORNUM
+56 DO UPDT4OR(.YSHLRSLT,YSDFN,YSGORD)
End DoDot:3
End DoDot:2
End DoDot:1
+57 ; all done
+58 DO SNDMSG
+59 ; (#20.02) HL7 TRANSMISSION END [2D]
+60 KILL YSFMERR,YSFMFDA
SET YSFMFDA(603.03,"1,",20.02)=$$NOW^XLFDT
+61 DO FILE^DIE("","YSFMFDA","YSFMERR")
+62 ; transmission finished, update ^XTMP zero node, delete "RUNNING" node, release LOCK, exit
+63 DO XTMPZRO
KILL ^XTMP("YSCLHL7",0,"RUNNING")
LOCK -^XTMP("YSCLHL7",0)
+64 ; clean up
KILL ^TMP($JOB),YSORDT
+65 QUIT
+66 ;
GETCLZRX(RXRSLT,DFN) ; RXRSLT passed by ref., get clozapine prescriptions
+1 ; YSRXIEN is IEN in PRESCRIPTION file (#52)
+2 NEW DRUGIEN,PRFLIEN,YSRXIEN
KILL RXRSLT
SET RXRSLT=0
+3 ; ^PS(55,D0,P,D1,0)= (#.01) PRESCRIPTION PROFILE [1P:52]
+4 SET PRFLIEN=0
FOR
SET PRFLIEN=$ORDER(^PS(55,DFN,"P",PRFLIEN))
if 'PRFLIEN
QUIT
KILL DRUGIEN,YSRXIEN
SET YSRXIEN=+$GET(^PS(55,DFN,"P",PRFLIEN,0))
IF YSRXIEN>0
IF $DATA(^PSRX(YSRXIEN,0))
Begin DoDot:1
+5 ; must have drug pointer
SET YSRXIEN(0)=$GET(^PSRX(YSRXIEN,0))
SET DRUGIEN=+$PIECE(YSRXIEN(0),U,6)
if '(DRUGIEN>0)
QUIT
+6 ; not Clozapine
if '$DATA(^PSDRUG("ACLOZ",DRUGIEN))
QUIT
+7 ; (#100) STATUS [1S], '0' FOR ACTIVE
KILL YSFMERR
if $$GET1^DIQ(52,YSRXIEN_",",100,"I","YSFMERR")
QUIT
+8 SET RXRSLT(YSRXIEN)=YSRXIEN(0)
SET RXRSLT=RXRSLT+1
End DoDot:1
+9 ;
+10 QUIT
+11 ;
+12 ;
UPDT4RX(YSHLRST,YSDFN,HLO) ; update file #603.05 for prescriptions, save MailMan text
+1 ; YSHRSLT, HLO both passed by ref.
+2 NEW YSNWIEN
SET YSNWIEN=0
FOR
SET YSNWIEN=$ORDER(YSHLRSLT(YSNWIEN))
if 'YSNWIEN
QUIT
Begin DoDot:1
+3 ; save info for MailMan message
+4 ; type of message
SET HLO("type")=$PIECE(YSHLRSLT(YSNWIEN),U,2)
+5 ; must have IEN
SET HLO("ien")=$PIECE(YSHLRSLT(YSNWIEN),U)
if 'HLO("ien")
QUIT
+6 DO HLOCNTR
+7 SET ^TMP($JOB,"YS HL7LST","Rx",HLO("ien"))=HLO("type")_U_HLO("Rx#")
+8 NEW YSFMUPDT
+9 ; (#.01) DATE/TIME OF TRANSMISSION [1D]
SET YSFMUPDT(603.51,.01)=YSNOW
+10 ; (#.02) HLO IEN [2N]
SET YSFMUPDT(603.51,.02)=HLO("ien")
+11 ; (#.03) MESSAGE TYPE [3F]
SET YSFMUPDT(603.51,.03)=HLO("type")
+12 ; (#.04) PRESCRIPTION # [4F]
SET YSFMUPDT(603.51,.04)=HLO("Rx#")
+13 ; update subfile
DO UPDTFL(YSDFN,.YSFMUPDT)
End DoDot:1
+14 ;
+15 QUIT
+16 ;
UPDT4OR(YSHRLST,YSDFN,YSGORD) ; update file #603.05 for orders, save MailMan text
+1 ; YSHRSLT passed by ref.
+2 NEW HLO,YSNWIEN
+3 SET YSNWIEN=0
FOR
SET YSNWIEN=$ORDER(YSHLRSLT(YSNWIEN))
if 'YSNWIEN
QUIT
Begin DoDot:1
+4 ; save info for MailMan message
+5 ; type of message
SET HLO("type")=$PIECE(YSHLRSLT(YSNWIEN),U,2)
+6 ; must have IEN
SET HLO("ien")=$PIECE(YSHLRSLT(YSNWIEN),U)
if 'HLO("ien")
QUIT
+7 DO HLOCNTR
+8 SET ^TMP($JOB,"YS HL7LST","Order",HLO("ien"))=HLO("type")_U_YSGORD
+9 NEW YSFMUPDT
+10 ; (#.01) DATE/TIME OF TRANSMISSION [1D]
SET YSFMUPDT(603.52,.01)=YSNOW
+11 ; (#.02) HLO IEN [2N]
SET YSFMUPDT(603.52,.02)=HLO("ien")
+12 ; (#.03) MESSAGE TYPE [3F]
SET YSFMUPDT(603.52,.03)=HLO("type")
+13 ; (#.04) ORDER # [4F]
SET YSFMUPDT(603.52,.04)=YSGORD
+14 ; update subfile
DO UPDTFL(YSDFN,.YSFMUPDT)
End DoDot:1
+15 QUIT
+16 ;
HLOCNTR ; count of HLO messages sent
+1 ; message count
NEW NHL7
SET NHL7=$GET(^TMP($JOB,"YS HL7LST",0))+1
SET ^(0)=NHL7
+2 QUIT
ASK2QUE ;
+1 NEW DTOUT,DUOUT
+2 ; can't be queued
if $GET(ZTSK)
QUIT
+3 DO DT^DICRW
+4 ; already running
if $$RUNCHK
QUIT
+5 ;
+6 KILL DIR
SET DIR(0)="YA"
SET DIR("A")="Are you sure you want to continue? "
SET DIR("B")="NO"
+7 ; skip a line
SET DIR("A",1)=" "
+8 SET DIR("A",2)="This will queue the HL7 messages for all active Clozapine patients."
+9 SET DIR("A",3)="If HL7 messages have already been sent for a prescription or order"
+10 SET DIR("A",4)="they will NOT be retransmitted."
+11 DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+12 IF 'Y
Begin DoDot:1
+13 KILL DIR
SET DIR(0)="EA"
SET DIR("A")="Nothing queued. Press enter: "
SET DIR("A",1)=" "
DO ^DIR
End DoDot:1
QUIT
+14 ;
+15 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
+16 SET ZTIO=""
SET ZTRTN="DLYHL7^"_$TEXT(+0)
SET ZTDTH=$HOROLOG
SET ZTDESC="Clozapine HL7 transmission"
+17 DO ^%ZTLOAD
+18 ;
+19 KILL DIR
SET DIR(0)="EA"
SET DIR("A")="Press enter: "
SET DIR("A",1)=" "
+20 SET DIR("A",2)=$SELECT($GET(ZTSK):"Queued as task #"_ZTSK,1:"NOT queued!")
+21 DO ^DIR
+22 QUIT
+23 ;
RETRHL7 ; Retransmit Clozapine HL7 Messages [YSCL HL7 CLOZ RETRANSMIT]
+1 ;
+2 DO DT^DICRW
NEW DIR,V,X,Y,DTOUT,DUOUT
+3 ; this cannot be queued
+4 IF $GET(ZTSK)
SET ^XTMP("YSCLHL7",0,"RETRANSMIT QUEUE ATTEMPT")=ZTSK_U_$$NOW^XLFDT
QUIT
+5 ; only one at a time
+6 if $$RUNCHK
QUIT
+7 ;
+8 KILL DIR
SET DIR(0)="YA"
SET DIR("A")="Are you sure you want to continue? "
SET DIR("B")="NO"
+9 ; skip a line
SET DIR("A",1)=" "
+10 SET DIR("A",2)="This will retransmit HL7 messages for all active Clozapine patients."
+11 SET DIR("A",3)="If a Prescription or Order is found messages will be sent."
+12 SET DIR("A",4)="Duplicate HL7 messages could be transmitted."
+13 DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+14 IF 'Y
Begin DoDot:1
+15 KILL DIR
SET DIR(0)="EA"
SET DIR("A")="Nothing queued. Press enter: "
SET DIR("A",1)=" "
DO ^DIR
End DoDot:1
QUIT
+16 ;
+17 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
+18 SET ZTIO=""
SET ZTRTN="RETRANS^"_$TEXT(+0)
SET ZTDTH=$HOROLOG
SET ZTDESC="Clozapine HL7 retransmit"
+19 DO ^%ZTLOAD
+20 ;
+21 KILL DIR
SET DIR(0)="EA"
SET DIR("A")="Press enter: "
SET DIR("A",1)=" "
+22 SET DIR("A",2)=$SELECT($GET(ZTSK):"Queued as task #"_ZTSK,1:"NOT queued!")
+23 DO ^DIR
+24 QUIT
+25 ;
BLDPTLST ; build list of Clozapine Patients
+1 NEW YSIEN,X,YSDFN,YSRXPT,YSFLD
+2 ; get file 55 data
+3 ;^PS(55,D0,SAND)= (#53) CLOZAPINE REGISTRATION NUMBER [1F] ^ (#54) CLOZAPINE STATUS [2S] ^ (#55) DATE OF LAST CLOZAPINE RX [3D] ^
+4 ; ==>(#56) DEMOGRAPHICS SENT [4S] ^ (#57) RESPONSIBLE PROVIDER [5P:200] ^ (#58) REGISTRATION DATE [6D] ^
+5 SET YSIEN=0
FOR
SET YSIEN=$ORDER(^YSCL(603.01,YSIEN))
if 'YSIEN
QUIT
Begin DoDot:1
+6 ; must have patient pointer
SET X=$GET(^YSCL(603.01,YSIEN,0))
SET YSDFN=+$PIECE(X,U,2)
if 'YSDFN
QUIT
+7 KILL YSRXPT
SET YSRXPT(54)=$$GET1^DIQ(55,YSDFN,54,"I")
+8 ; only active patients on list
+9 if '(YSRXPT(54)="A")
QUIT
FOR YSFLD=53,55:1:58
SET YSRXPT(YSFLD)=$$GET1^DIQ(55,YSDFN,YSFLD,"I")
+10 MERGE ^TMP($JOB,"YSCLOZDFN",YSDFN,"FILE55")=YSRXPT
End DoDot:1
+11 ;
+12 QUIT
+13 ;
UPDTFL(YSDFN,YSFMUPDT) ; update file & sub-file
+1 ; YSFMUPDT - data for ^DIE, passed by ref.
+2 NEW J,YSFMERR,YSFMIEN,YSFMROOT,YSIENS,YSUBFL
+3 ; add patient if not in file #603.05
+4 IF '$DATA(^YSCL(603.05,YSDFN))
Begin DoDot:1
+5 ; entry is DINUM pointer
SET YSFMROOT(603.05,"+1,",.01)=YSDFN
SET YSFMIEN(1)=YSDFN
+6 DO UPDATE^DIE("","YSFMROOT","YSFMIEN","YSFMERR")
+7 KILL YSFMERR,YSFMIEN,YSFMROOT
End DoDot:1
+8 ; sub-file 603.51 or 603.52
+9 ; adding to multiple
SET YSUBFL=+$ORDER(YSFMUPDT(0))
SET YSIENS="+1,"_YSDFN_","
+10 SET J=0
FOR
SET J=$ORDER(YSFMUPDT(YSUBFL,J))
if 'J
QUIT
SET YSFMROOT(YSUBFL,YSIENS,J)=YSFMUPDT(YSUBFL,J)
+11 DO UPDATE^DIE("","YSFMROOT","YSFMIEN","YSFMERR")
+12 QUIT
+13 ;
SNDMSG ; send MailMan message
+1 NEW CNT,HLIEN,L,NHL7,X,Y,YSFROM,YSITE,YSXMBODY,YSXMSUBJ,YSXMTO,YSXMZ
+2 KILL ^TMP("XMERR",$JOB),^TMP($JOB,"YSXMTXT")
+3 SET YSITE=$$SITE^VASITE
SET NHL7=+$GET(^TMP($JOB,"YS HL7LST",0))
+4 ; mail message text
SET YSXMBODY=$NAME(^TMP($JOB,"YSXMTXT"))
+5 DO ADD2TXT(" HL7 transmission report "_$$FMTE^XLFDT($$NOW^XLFDT))
+6 DO ADD2TXT(" Site: "_$PIECE(YSITE,U,2)_" ("_$PIECE(YSITE,U,3)_")")
DO ADD2TXT(" ")
+7 IF $GET(YSHL7("allowDups"))
Begin DoDot:1
+8 SET X=$$GET1^DIQ(200,DUZ_",",.01)
+9 DO ADD2TXT(" NOTE: This is a requested retransmission.")
+10 DO ADD2TXT(" Requested by: "_X_" (#"_DUZ_")")
End DoDot:1
+11 ;
+12 ; process aborted
IF $GET(YSCLABRT)
Begin DoDot:1
+13 DO ADD2TXT(" *** ERROR: The Clozapine HL7 transmission process aborted. ***")
+14 SET X=0
FOR
SET X=$ORDER(YSCLABRT(X))
if 'X
QUIT
DO ADD2TXT(YSCLABRT(X))
End DoDot:1
+15 ;
+16 DO ADD2TXT(" Total messages sent: "_NHL7)
DO ADD2TXT(" ")
+17 ; counter for Mail message
SET CNT=0
+18 ; ^TMP($J,"YS HL7LST","Rx",HLIEN)=HLO("type")_U_HLO("Rx#")
if NHL7
Begin DoDot:1
+19 DO ADD2TXT(" Message ID Type Prescription")
DO ADD2TXT(" ")
+20 SET HLIEN=0
FOR
SET HLIEN=$ORDER(^TMP($JOB,"YS HL7LST","Rx",HLIEN))
if 'HLIEN
QUIT
Begin DoDot:2
+21 SET CNT=CNT+1
+22 ; (#.01) MESSAGE ID [1F]
NEW HLO
SET HLO("msgId")=$$GET1^DIQ(778,HLIEN_",",.01)
+23 ; (#.02) MESSAGE BODY [2P:777] internal format
SET HLO("body")=$$GET1^DIQ(778,HLIEN_",",.02,"I")
+24 ; (#.03) MESSAGE TYPE [3F] ^ (#.04) EVENT [4F]
+25 SET HLO("type")=$$GET1^DIQ(777,HLO("body")_",",.03)_U_$$GET1^DIQ(777,HLO("body")_",",.04)
+26 SET L=$JUSTIFY(CNT,3)_". "_HLO("msgId")_$JUSTIFY(" ",19-$LENGTH(HLO("msgId")))
SET L=L_HLO("type")_$JUSTIFY(" ",10-$LENGTH(HLO("type")))
+27 SET X=^TMP($JOB,"YS HL7LST","Rx",HLIEN)
+28 ; add Rx #
DO ADD2TXT(L_$PIECE(X,U,2))
End DoDot:2
+29 ; add order info
+30 DO ADD2TXT(" ")
DO ADD2TXT(" Message ID Type Order Number")
DO ADD2TXT(" ")
+31 SET HLIEN=0
FOR
SET HLIEN=$ORDER(^TMP($JOB,"YS HL7LST","Order",HLIEN))
if 'HLIEN
QUIT
Begin DoDot:2
+32 SET CNT=CNT+1
+33 ; (#.01) MESSAGE ID [1F]
NEW HLO
SET HLO("msgId")=$$GET1^DIQ(778,HLIEN_",",.01)
+34 ; (#.02) MESSAGE BODY [2P:777] internal format
SET HLO("body")=$$GET1^DIQ(778,HLIEN_",",.02,"I")
+35 ; (#.03) MESSAGE TYPE [3F] ^ (#.04) EVENT [4F]
+36 SET HLO("type")=$$GET1^DIQ(777,HLO("body")_",",.03)_U_$$GET1^DIQ(777,HLO("body")_",",.04)
+37 SET L=$JUSTIFY(CNT,3)_". "_HLO("msgId")_$JUSTIFY(" ",19-$LENGTH(HLO("msgId")))
SET L=L_HLO("type")_$JUSTIFY(" ",10-$LENGTH(HLO("type")))
+38 SET X=^TMP($JOB,"YS HL7LST","Order",HLIEN)
+39 ; add Order #
DO ADD2TXT(L_$PIECE(X,U,2))
End DoDot:2
End DoDot:1
+40 ;
+41 ; recipients
SET YSXMTO(DUZ)=""
SET YSXMTO("G.YSCLHL7 LOGS")=""
+42 DO ADD2TXT(" ")
+43 ; add Mail Groups, etc. to message
+44 SET X=" "
FOR
SET X=$ORDER(YSXMTO(X))
if X=""
QUIT
DO ADD2TXT(" Sent to: "_X)
+45 DO ADD2TXT($$EOR^YSCLHLPR)
+46 SET YSXMSUBJ="Clozapine HL7 report "_$PIECE(YSITE,U,2)_" ("_$PIECE(YSITE,U,3)_")"
+47 DO SENDMSG^XMXAPI(DUZ,YSXMSUBJ,YSXMBODY,.YSXMTO,"",.YSXMZ)
+48 QUIT
+49 ;
ADD2TXT(TXLN) ; add TXLN to MailMan message text
+1 NEW C
SET C=$GET(^TMP($JOB,"YSXMTXT",0))+1
SET ^(0)=C
+2 SET ^TMP($JOB,"YSXMTXT",C,0)=TXLN
QUIT
+3 ;
RUNCHK(YSRSLT) ; Boolean function, zero if transmission NOT running
+1 ; there is user interaction if ZTSK not true
+2 SET YSRSLT=0
+3 ; cant't LOCK if running
LOCK +^XTMP("YSCLHL7",0):DILOCKTM
IF '$TEST
Begin DoDot:1
+4 ; return true
SET YSRSLT=1
+5 ; queued
if $GET(ZTSK)
QUIT
+6 NEW DIR,V,X
+7 SET DIR(0)="EA"
SET DIR("A")="Press enter: "
+8 SET DIR("A",1)="The Clozapine HL7 Message Transmission appears to be running."
+9 SET V=$NAME(^XTMP("YSCLHL7",0,"RUNNING"))
SET X=$GET(@V)
SET DIR("A",2)=V_" node: "
+10 SET DIR("A",2)=$SELECT('$DATA(@V):" Is not defined.",1:" Task #"_$PIECE(X,U)_" started "_$$FMTE^XLFDT($PIECE(X,U,2)))
+11 DO ^DIR
End DoDot:1
+12 ;
+13 LOCK -^XTMP("YSCLHL7",0)
+14 QUIT YSRSLT
+15 ;
XTMPZRO ;set zero node in ^XTMP("YSCLHL7")
+1 ; update ^XTMP("YSCLHL7",0) with purge date and $$NOW
+2 NEW C,J,N
+3 ; 90 days in the future
SET N=$$NOW^XLFDT
SET C=$$FMADD^XLFDT($$DT^XLFDT,90)
+4 SET J=C
SET $PIECE(J,U,2)=N
SET $PIECE(J,U,3)="YSCL Clozapine Daily HL7 Transmission Data"
SET ^XTMP("YSCLHL7",0)=J
+5 IF $GET(ZTSK)
SET ^XTMP("YSCLHL7",0,"TASK #")=ZTSK_U_N
+6 QUIT
+7 ;