BHLJVN1 ;SSI/EJN - Manual and Nightly Routine for JVN GIS Interface [ 10/10/2002 10:43 PM ]
;;3.01;BHL IHS Interfaces with GIS;**3**;FEB 15, 2001
;
; Program to transmit GIS O01 HL7 Messages manually or
; through a nightly TaskMan batch process via the
; IHS Scheduling file (#44). HL7 Messages are transmitted
; to Cloverleaf for the Joslin Vision Network.
;
N BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN
;
MAN ; Manual transmission of O01 Messages to Cloverleaf for JVN
;
D RES
;
S (BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN)=""
;
K ^TMP("BHLJVN")
; Call standard RPMS patient lookup code
D EN^DDIOL("","","!!!!!")
S DIC="^DPT(",DIC(0)="AEMQ"
D ^AUPNLK
K DIC
;
G EXIT:Y<0
; Check if patient is dead, if so then ask for another selection
I $P($G(^DPT(DFN,.35)),U,1)'="" D
. D EN^DDIOL("This patient is no longer living, please select another patient.","","!!")
. S DIC="^DPT(",DIC(0)="AEMQ" D ^AUPNLK
K DIC
;
G EXIT:Y<0
; Set variables from buffer
S BHLJNAME=$P($G(^DPT(DFN,0)),U)
S BHLJDFN=DFN,BHLJDOB=$$FMTE^XLFDT(DOB),BHLJSSN=SSN
;
; Select Clinic for appointment
D EN^DDIOL("","","!!")
S DIC="^SC(",DIC(0)="AEMZQ",DIC("A")="Select CLINIC: ",DIC("S")="I $P(^(0),U,3)=""C""" D ^DIC
K DIC
;
G EXIT:Y<0
; Set variables from buffer
S BHLJCLIN=$P($G(Y),U,1),BHLJCNAM=$P($G(Y),U,2)
;
; Display selected patient information, ask if want to transmit to JVN
D EN^DDIOL("The following patient has been selected:","","!!")
D EN^DDIOL(" Name: "_BHLJNAME,"","!")
D EN^DDIOL(" DOB: "_BHLJDOB,"","!")
D EN^DDIOL(" SSN: "_BHLJSSN,"","!")
D EN^DDIOL(" HRN: "_$$HRN^AUPNPAT(BHLJDFN,DUZ(2)),"","!")
D EN^DDIOL(" Scheduled Date/Time: "_$$FMTE^XLFDT($$NOW^XLFDT()),"","!")
D EN^DDIOL(" Location: "_BHLJCNAM,"","!")
D EN^DDIOL("","","!!")
K DIR
S DIR(0)="YA"
S DIR("A")="Transmit information to Joslin Vision Network NOW? "
S DIR("B")="No"
D ^DIR
G EXIT:Y<0!(Y="")!(Y["^")
K DIR
;
; Set ^TMP("BHLJVN") global with variables for HL7
S ^TMP("BHLJVN",$J,1)=BHLJDFN_U_BHLJCLIN_U_$E($$NOW^XLFDT(),1,12) ;maw
;
; Call GIS to send HL7 message for patient to Cloverleaf for JVN
I Y=1 D VAR
G MAN
Q
NJOB ; Nightly Job
;
; This can be queued as a nightly job in TaskMan to loop through the
; IHS Scheduling file (#44) to create and transmit GIS O01 HL7
; messages for the next days Retinal Imaging-JVN clinic appointments.
;
;
D RES
S BHLJBDT=$$NOW^XLFDT() ;ITSC/JCM 5/22/02
S BHLJEDT=$$FMADD^XLFDT(BHLJBDT,1) ;ITSC/JCM 5/22/02
;
D LOOP
D VAR
G EXIT
Q
LOOP ; Loops through File 44
; Finds all patients with scheduled appointments for JVN
;
K ^TMP("BHLJVN")
N BHLJCIEN,BHLJSCDT,BHLJSIEN,BHLJDFN,BHLJCNT
S (BHLJSCDT,BHLJSIEN,BHLJDFN)="",(BHLJCIEN,BHLJCNT)=0
F S BHLJCIEN=$O(^SC(BHLJCIEN)) Q:'BHLJCIEN D
. I $P(^SC(BHLJCIEN,0),U)'["JVN" Q
. S BHLJSCDT=""
. F S BHLJSCDT=$O(^SC(BHLJCIEN,"S",BHLJSCDT),-1) Q:'BHLJSCDT!(BHLJSCDT<BHLJBDT) D ;ITSC/JCM 5/19/02
.. Q:(BHLJSCDT<BHLJBDT)!(BHLJSCDT>BHLJEDT)
.. S BHLJSIEN=0
.. F S BHLJSIEN=$O(^SC(BHLJCIEN,"S",BHLJSCDT,1,BHLJSIEN)) Q:'BHLJSIEN D
... S BHLJDFN=$P($G(^SC(BHLJCIEN,"S",BHLJSCDT,1,BHLJSIEN,0)),U,1)
... S BHLJCNT=BHLJCNT+1
... S ^TMP("BHLJVN",$J,BHLJCNT)=BHLJDFN_U_BHLJCIEN_U_BHLJSCDT
;
Q
VAR ; Set up variables for JVN Interface O01 Message
;
Q:'$D(^TMP("BHLJVN",$J))
;
; Variables:
; INDA = DFN
; INDA(44,1) = IEN of Clinic
; INDA(44,2) = Scheduled Date/Time of Appointment
;
S BHLJCNT=0
F S BHLJCNT=$O(^TMP("BHLJVN",$J,BHLJCNT)) Q:'BHLJCNT D
. S INDA=$P($G(^TMP("BHLJVN",$J,BHLJCNT)),U,1)
. S INDA(44,1)=$P($G(^TMP("BHLJVN",$J,BHLJCNT)),U,2)
. S INDA(44,2)=$P($G(^TMP("BHLJVN",$J,BHLJCNT)),U,3)
. D HL7
;
Q
;
HL7 ; Send O01 HL7 Messages to Cloverleaf for PACS Broker
;
S X="BHL JVN SCHEDULED APPT INFO",DIC=101 D EN^XQOR
Q
FILL(BHLJDT) ; Filler Order (ORC-3)
; This function will return the Fill Order value
; based on the INDA(44,2) variable passed from GIS
;
; BHLJDT = INDA(44,2)
; Filler Order = Date_"-"_HRN
; (Date will not include time)
;
I $G(BHLJDT)'="" D
. S BHLJDT=$E($P($$FMTHL7^XLFDT(BHLJDT),"-"),1,8)
E S BHLJDT=$E($P($$FMTHL7^XLFDT($$NOW^XLFDT()),"-"),1,8)
;S X=BHLJDT_"-"_$$LZERO^BHLPID($$HRN^AUPNPAT(INDA,DUZ(2)),6)
S X=BHLJDT_"-"_$G(BHLRN) ;cmi/maw
Q X
EXIT ;
K BHLJBDT,BHLJEDT,DIC,DIR,BHLJCNT,BHLJCIEN,BHLJSCDT,INDA,BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN,BHLJDT,BHLJBP,BHLJMSG
Q
;
RES ;-- check the interface and restart if necessary
I '$D(ZTQUEUED) W !,"Checking Interfaces..."
F BHLJBP="FORMAT CONTROLLER","OUTPUT CONTROLLER","HL IHS JVN PACS TRANSMITTER" D
. S BHLJMSG=$$CHK^BHLBCK(BHLJBP,"")
Q
;
BHLJVN1 ;SSI/EJN - Manual and Nightly Routine for JVN GIS Interface [ 10/10/2002 10:43 PM ]
+1 ;;3.01;BHL IHS Interfaces with GIS;**3**;FEB 15, 2001
+2 ;
+3 ; Program to transmit GIS O01 HL7 Messages manually or
+4 ; through a nightly TaskMan batch process via the
+5 ; IHS Scheduling file (#44). HL7 Messages are transmitted
+6 ; to Cloverleaf for the Joslin Vision Network.
+7 ;
+8 NEW BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN
+9 ;
MAN ; Manual transmission of O01 Messages to Cloverleaf for JVN
+1 ;
+2 DO RES
+3 ;
+4 SET (BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN)=""
+5 ;
+6 KILL ^TMP("BHLJVN")
+7 ; Call standard RPMS patient lookup code
+8 DO EN^DDIOL("","","!!!!!")
+9 SET DIC="^DPT("
SET DIC(0)="AEMQ"
+10 DO ^AUPNLK
+11 KILL DIC
+12 ;
+13 IF Y<0
GOTO EXIT
+14 ; Check if patient is dead, if so then ask for another selection
+15 IF $PIECE($GET(^DPT(DFN,.35)),U,1)'=""
Begin DoDot:1
+16 DO EN^DDIOL("This patient is no longer living, please select another patient.","","!!")
+17 SET DIC="^DPT("
SET DIC(0)="AEMQ"
DO ^AUPNLK
End DoDot:1
+18 KILL DIC
+19 ;
+20 IF Y<0
GOTO EXIT
+21 ; Set variables from buffer
+22 SET BHLJNAME=$PIECE($GET(^DPT(DFN,0)),U)
+23 SET BHLJDFN=DFN
SET BHLJDOB=$$FMTE^XLFDT(DOB)
SET BHLJSSN=SSN
+24 ;
+25 ; Select Clinic for appointment
+26 DO EN^DDIOL("","","!!")
+27 SET DIC="^SC("
SET DIC(0)="AEMZQ"
SET DIC("A")="Select CLINIC: "
SET DIC("S")="I $P(^(0),U,3)=""C"""
DO ^DIC
+28 KILL DIC
+29 ;
+30 IF Y<0
GOTO EXIT
+31 ; Set variables from buffer
+32 SET BHLJCLIN=$PIECE($GET(Y),U,1)
SET BHLJCNAM=$PIECE($GET(Y),U,2)
+33 ;
+34 ; Display selected patient information, ask if want to transmit to JVN
+35 DO EN^DDIOL("The following patient has been selected:","","!!")
+36 DO EN^DDIOL(" Name: "_BHLJNAME,"","!")
+37 DO EN^DDIOL(" DOB: "_BHLJDOB,"","!")
+38 DO EN^DDIOL(" SSN: "_BHLJSSN,"","!")
+39 DO EN^DDIOL(" HRN: "_$$HRN^AUPNPAT(BHLJDFN,DUZ(2)),"","!")
+40 DO EN^DDIOL(" Scheduled Date/Time: "_$$FMTE^XLFDT($$NOW^XLFDT()),"","!")
+41 DO EN^DDIOL(" Location: "_BHLJCNAM,"","!")
+42 DO EN^DDIOL("","","!!")
+43 KILL DIR
+44 SET DIR(0)="YA"
+45 SET DIR("A")="Transmit information to Joslin Vision Network NOW? "
+46 SET DIR("B")="No"
+47 DO ^DIR
+48 IF Y<0!(Y="")!(Y["^")
GOTO EXIT
+49 KILL DIR
+50 ;
+51 ; Set ^TMP("BHLJVN") global with variables for HL7
+52 ;maw
SET ^TMP("BHLJVN",$JOB,1)=BHLJDFN_U_BHLJCLIN_U_$EXTRACT($$NOW^XLFDT(),1,12)
+53 ;
+54 ; Call GIS to send HL7 message for patient to Cloverleaf for JVN
+55 IF Y=1
DO VAR
+56 GOTO MAN
+57 QUIT
NJOB ; Nightly Job
+1 ;
+2 ; This can be queued as a nightly job in TaskMan to loop through the
+3 ; IHS Scheduling file (#44) to create and transmit GIS O01 HL7
+4 ; messages for the next days Retinal Imaging-JVN clinic appointments.
+5 ;
+6 ;
+7 DO RES
+8 ;ITSC/JCM 5/22/02
SET BHLJBDT=$$NOW^XLFDT()
+9 ;ITSC/JCM 5/22/02
SET BHLJEDT=$$FMADD^XLFDT(BHLJBDT,1)
+10 ;
+11 DO LOOP
+12 DO VAR
+13 GOTO EXIT
+14 QUIT
LOOP ; Loops through File 44
+1 ; Finds all patients with scheduled appointments for JVN
+2 ;
+3 KILL ^TMP("BHLJVN")
+4 NEW BHLJCIEN,BHLJSCDT,BHLJSIEN,BHLJDFN,BHLJCNT
+5 SET (BHLJSCDT,BHLJSIEN,BHLJDFN)=""
SET (BHLJCIEN,BHLJCNT)=0
+6 FOR
SET BHLJCIEN=$ORDER(^SC(BHLJCIEN))
IF 'BHLJCIEN
QUIT
Begin DoDot:1
+7 IF $PIECE(^SC(BHLJCIEN,0),U)'["JVN"
QUIT
+8 SET BHLJSCDT=""
+9 ;ITSC/JCM 5/19/02
FOR
SET BHLJSCDT=$ORDER(^SC(BHLJCIEN,"S",BHLJSCDT),-1)
IF 'BHLJSCDT!(BHLJSCDT<BHLJBDT)
QUIT
Begin DoDot:2
+10 IF (BHLJSCDT<BHLJBDT)!(BHLJSCDT>BHLJEDT)
QUIT
+11 SET BHLJSIEN=0
+12 FOR
SET BHLJSIEN=$ORDER(^SC(BHLJCIEN,"S",BHLJSCDT,1,BHLJSIEN))
IF 'BHLJSIEN
QUIT
Begin DoDot:3
+13 SET BHLJDFN=$PIECE($GET(^SC(BHLJCIEN,"S",BHLJSCDT,1,BHLJSIEN,0)),U,1)
+14 SET BHLJCNT=BHLJCNT+1
+15 SET ^TMP("BHLJVN",$JOB,BHLJCNT)=BHLJDFN_U_BHLJCIEN_U_BHLJSCDT
End DoDot:3
End DoDot:2
End DoDot:1
+16 ;
+17 QUIT
VAR ; Set up variables for JVN Interface O01 Message
+1 ;
+2 IF '$DATA(^TMP("BHLJVN",$JOB))
QUIT
+3 ;
+4 ; Variables:
+5 ; INDA = DFN
+6 ; INDA(44,1) = IEN of Clinic
+7 ; INDA(44,2) = Scheduled Date/Time of Appointment
+8 ;
+9 SET BHLJCNT=0
+10 FOR
SET BHLJCNT=$ORDER(^TMP("BHLJVN",$JOB,BHLJCNT))
IF 'BHLJCNT
QUIT
Begin DoDot:1
+11 SET INDA=$PIECE($GET(^TMP("BHLJVN",$JOB,BHLJCNT)),U,1)
+12 SET INDA(44,1)=$PIECE($GET(^TMP("BHLJVN",$JOB,BHLJCNT)),U,2)
+13 SET INDA(44,2)=$PIECE($GET(^TMP("BHLJVN",$JOB,BHLJCNT)),U,3)
+14 DO HL7
End DoDot:1
+15 ;
+16 QUIT
+17 ;
HL7 ; Send O01 HL7 Messages to Cloverleaf for PACS Broker
+1 ;
+2 SET X="BHL JVN SCHEDULED APPT INFO"
SET DIC=101
DO EN^XQOR
+3 QUIT
FILL(BHLJDT) ; Filler Order (ORC-3)
+1 ; This function will return the Fill Order value
+2 ; based on the INDA(44,2) variable passed from GIS
+3 ;
+4 ; BHLJDT = INDA(44,2)
+5 ; Filler Order = Date_"-"_HRN
+6 ; (Date will not include time)
+7 ;
+8 IF $GET(BHLJDT)'=""
Begin DoDot:1
+9 SET BHLJDT=$EXTRACT($PIECE($$FMTHL7^XLFDT(BHLJDT),"-"),1,8)
End DoDot:1
+10 IF '$TEST
SET BHLJDT=$EXTRACT($PIECE($$FMTHL7^XLFDT($$NOW^XLFDT()),"-"),1,8)
+11 ;S X=BHLJDT_"-"_$$LZERO^BHLPID($$HRN^AUPNPAT(INDA,DUZ(2)),6)
+12 ;cmi/maw
SET X=BHLJDT_"-"_$GET(BHLRN)
+13 QUIT X
EXIT ;
+1 KILL BHLJBDT,BHLJEDT,DIC,DIR,BHLJCNT,BHLJCIEN,BHLJSCDT,INDA,BHLJDFN,BHLJNAME,BHLJDOB,BHLJSSN,BHLJCNAM,BHLJCLIN,BHLJDT,BHLJBP,BHLJMSG
+2 QUIT
+3 ;
RES ;-- check the interface and restart if necessary
+1 IF '$DATA(ZTQUEUED)
WRITE !,"Checking Interfaces..."
+2 FOR BHLJBP="FORMAT CONTROLLER","OUTPUT CONTROLLER","HL IHS JVN PACS TRANSMITTER"
Begin DoDot:1
+3 SET BHLJMSG=$$CHK^BHLBCK(BHLJBP,"")
End DoDot:1
+4 QUIT
+5 ;