RGFIBM ;ALB/CJM-SEND FACILITY INTEGRATION MESSAGE ;08/27/99
;;1.0;CLINICAL INFO RESOURCE NETWORK;**5,9**;30 Apr 99
;
SEND(DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
;Description: Sends the facility integration message for this patient
;using routing logic based on the subscription list.
;
;Input:
; DFN - ien of patient
; LEGACY - station number of the legacy site
; PRIMARY - station number of the primary site
;Output:
; Function Value - 1 on success, 0 on failure
; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
; ERROR - error message (pass by reference,optional)
;
N HL,HLA,HLERR,HLL,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX,RGI,ERRFOUND
K RESULTS,ERROR
;
;
I $G(DFN),$G(PRIMARY),$G(LEGACY) D
.;just checking!
E S ERROR="MISSING PARAMETER" Q 0
;
I '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR) Q 0
;
D ROUTE^RGFIRM(DFN,LEGACY,PRIMARY,.HLL)
;
D GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
;
S ERRFOUND=0
I +$P($G(RESULTS),"^",2) S ERROR=$P(RESULTS,"^",3),ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR_" MSGID: "_+RESULTS D EXC^RGFIU(6,ERROR,DFN) S ERRFOUND=1
S RGI=0
I $D(RESULTS) F S RGI=$O(RESULTS(RGI)) Q:'RGI D
.I +$P($G(RESULTS(RGI)),"^",2) S ERROR=$P(RESULTS(RGI),"^",3),ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR_" MSGID: "_+RESULTS(RGI) D EXC^RGFIU(6,ERROR,DFN) S ERRFOUND=1
Q:ERRFOUND 0
Q 1
;
BUILD(LOC,DFN,LEGACY,PRIMARY,ERROR) ;
;Description: Builds the facility integration message.
;
;Input:
; LOC - global location to place the message, referenced by @indirection
; DFN - ien of patient
; LEGACY - station number of the legacy site
; PRIMARY - station number of the primary site
;Output:
; Function Value - 1 on success, 0 on failure
; ERROR - error message (pass by reference,optional)
; HL7 variables defined by INIT^HLFNC2
;
N ICNPLUS
K ERROR
;
;
I $G(DFN),$G(PRIMARY),$G(LEGACY) D
.;just checking!
E S ERROR="MISSING PARAMETER NEEDED TO BUILD FACILITY INTEGRATION MESSAGE" D EXC^RGFIU(6,ERROR,DFN) Q 0
;
;don't send message if there is no ICN to identify it
S ICNPLUS=$$GETICN^MPIF001(DFN)
I (+ICNPLUS)'>0 S ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT LACKS ICN" D EXC^RGFIU(6,ERROR,DFN) Q 0
;
;don't send if local ICN
I $$IFLOCAL^MPIF001(DFN) S ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT ICN IS LOCAL" D EXC^RGFIU(6,ERROR,DFN) Q 0
;
D INIT^HLFNC2("RG FACILITY INTEGRATION SERVER",.HL)
I $G(HL) S ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_HL D EXC^RGFIU(6,ERROR,DFN) Q 0
;
S @LOC@(1)=$$EVN^VAFHLEVN("A08",51)
S @LOC@(2)=$$EN^VAFCPID(DFN,"2,3,5,19")
S @LOC@(3)="PV1"
S $P(@LOC@(3),HL("FS"),3)="O"
S @LOC@(4)="NTE"
S $P(@LOC@(4),HL("FS"),3)="P"
S $P(@LOC@(4),HL("FS"),4)=LEGACY_$E(HL("ECH"),1)_PRIMARY
Q 1
;
SITESEND(TO,DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
;Description: Sends the facility integration message for this patient
;to a single site.
;
;Input:
; TO - station # of destination
; DFN - ien of patient
; LEGACY - station number (without suffix) of the legacy site
; PRIMARY - station number (without suffix) of the primary site
;Output:
; Function Value - 1 on success, 0 on failure
; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
; ERROR - error message (pass by reference,optional)
;
N HL,HLA,HLERR,HLL,SITEIEN,LINK,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX
K RESULTS,ERROR
;
;
I $G(DFN),$G(PRIMARY),$G(LEGACY),$G(TO) D
.;just checking!
E S ERROR="MISSING PARAMETER" Q 0
;
S SITEIEN=$$LKUP^XUAF4(TO)
I 'SITEIEN S ERROR="SITE NOT FOUND IN INSTITUTION FILE" Q 0
;
;set HLL array to route message to a single site
S LINK=$$GETLINK^RGFIU(SITEIEN)
I '$L(LINK) D
.D EXC^RGFIU(224,"Facility Integration Message not sent to station # "_TO,DFN)
E D
.S HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_LINK
;
;create the message
I '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR) Q 0
;
D GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
;
I +$P($G(RESULTS),"^",2) S ERROR=$P(RESULTS,"^",3),ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR D EXC^RGFIU(6,ERROR,DFN) Q 0
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGFIBM 4582 printed Nov 22, 2024@16:52 Page 2
RGFIBM ;ALB/CJM-SEND FACILITY INTEGRATION MESSAGE ;08/27/99
+1 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**5,9**;30 Apr 99
+2 ;
SEND(DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
+1 ;Description: Sends the facility integration message for this patient
+2 ;using routing logic based on the subscription list.
+3 ;
+4 ;Input:
+5 ; DFN - ien of patient
+6 ; LEGACY - station number of the legacy site
+7 ; PRIMARY - station number of the primary site
+8 ;Output:
+9 ; Function Value - 1 on success, 0 on failure
+10 ; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
+11 ; ERROR - error message (pass by reference,optional)
+12 ;
+13 NEW HL,HLA,HLERR,HLL,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX,RGI,ERRFOUND
+14 KILL RESULTS,ERROR
+15 ;
+16 ;
+17 IF $GET(DFN)
IF $GET(PRIMARY)
IF $GET(LEGACY)
Begin DoDot:1
+18 ;just checking!
End DoDot:1
+19 IF '$TEST
SET ERROR="MISSING PARAMETER"
QUIT 0
+20 ;
+21 IF '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR)
QUIT 0
+22 ;
+23 DO ROUTE^RGFIRM(DFN,LEGACY,PRIMARY,.HLL)
+24 ;
+25 DO GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
+26 ;
+27 SET ERRFOUND=0
+28 IF +$PIECE($GET(RESULTS),"^",2)
SET ERROR=$PIECE(RESULTS,"^",3)
SET ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR_" MSGID: "_+RESULTS
DO EXC^RGFIU(6,ERROR,DFN)
SET ERRFOUND=1
+29 SET RGI=0
+30 IF $DATA(RESULTS)
FOR
SET RGI=$ORDER(RESULTS(RGI))
if 'RGI
QUIT
Begin DoDot:1
+31 IF +$PIECE($GET(RESULTS(RGI)),"^",2)
SET ERROR=$PIECE(RESULTS(RGI),"^",3)
SET ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR_" MSGID: "_+RESULTS(RGI)
DO EXC^RGFIU(6,ERROR,DFN)
SET ERRFOUND=1
End DoDot:1
+32 if ERRFOUND
QUIT 0
+33 QUIT 1
+34 ;
BUILD(LOC,DFN,LEGACY,PRIMARY,ERROR) ;
+1 ;Description: Builds the facility integration message.
+2 ;
+3 ;Input:
+4 ; LOC - global location to place the message, referenced by @indirection
+5 ; DFN - ien of patient
+6 ; LEGACY - station number of the legacy site
+7 ; PRIMARY - station number of the primary site
+8 ;Output:
+9 ; Function Value - 1 on success, 0 on failure
+10 ; ERROR - error message (pass by reference,optional)
+11 ; HL7 variables defined by INIT^HLFNC2
+12 ;
+13 NEW ICNPLUS
+14 KILL ERROR
+15 ;
+16 ;
+17 IF $GET(DFN)
IF $GET(PRIMARY)
IF $GET(LEGACY)
Begin DoDot:1
+18 ;just checking!
End DoDot:1
+19 IF '$TEST
SET ERROR="MISSING PARAMETER NEEDED TO BUILD FACILITY INTEGRATION MESSAGE"
DO EXC^RGFIU(6,ERROR,DFN)
QUIT 0
+20 ;
+21 ;don't send message if there is no ICN to identify it
+22 SET ICNPLUS=$$GETICN^MPIF001(DFN)
+23 IF (+ICNPLUS)'>0
SET ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT LACKS ICN"
DO EXC^RGFIU(6,ERROR,DFN)
QUIT 0
+24 ;
+25 ;don't send if local ICN
+26 IF $$IFLOCAL^MPIF001(DFN)
SET ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT ICN IS LOCAL"
DO EXC^RGFIU(6,ERROR,DFN)
QUIT 0
+27 ;
+28 DO INIT^HLFNC2("RG FACILITY INTEGRATION SERVER",.HL)
+29 IF $GET(HL)
SET ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_HL
DO EXC^RGFIU(6,ERROR,DFN)
QUIT 0
+30 ;
+31 SET @LOC@(1)=$$EVN^VAFHLEVN("A08",51)
+32 SET @LOC@(2)=$$EN^VAFCPID(DFN,"2,3,5,19")
+33 SET @LOC@(3)="PV1"
+34 SET $PIECE(@LOC@(3),HL("FS"),3)="O"
+35 SET @LOC@(4)="NTE"
+36 SET $PIECE(@LOC@(4),HL("FS"),3)="P"
+37 SET $PIECE(@LOC@(4),HL("FS"),4)=LEGACY_$EXTRACT(HL("ECH"),1)_PRIMARY
+38 QUIT 1
+39 ;
SITESEND(TO,DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
+1 ;Description: Sends the facility integration message for this patient
+2 ;to a single site.
+3 ;
+4 ;Input:
+5 ; TO - station # of destination
+6 ; DFN - ien of patient
+7 ; LEGACY - station number (without suffix) of the legacy site
+8 ; PRIMARY - station number (without suffix) of the primary site
+9 ;Output:
+10 ; Function Value - 1 on success, 0 on failure
+11 ; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
+12 ; ERROR - error message (pass by reference,optional)
+13 ;
+14 NEW HL,HLA,HLERR,HLL,SITEIEN,LINK,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX
+15 KILL RESULTS,ERROR
+16 ;
+17 ;
+18 IF $GET(DFN)
IF $GET(PRIMARY)
IF $GET(LEGACY)
IF $GET(TO)
Begin DoDot:1
+19 ;just checking!
End DoDot:1
+20 IF '$TEST
SET ERROR="MISSING PARAMETER"
QUIT 0
+21 ;
+22 SET SITEIEN=$$LKUP^XUAF4(TO)
+23 IF 'SITEIEN
SET ERROR="SITE NOT FOUND IN INSTITUTION FILE"
QUIT 0
+24 ;
+25 ;set HLL array to route message to a single site
+26 SET LINK=$$GETLINK^RGFIU(SITEIEN)
+27 IF '$LENGTH(LINK)
Begin DoDot:1
+28 DO EXC^RGFIU(224,"Facility Integration Message not sent to station # "_TO,DFN)
End DoDot:1
+29 IF '$TEST
Begin DoDot:1
+30 SET HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_LINK
End DoDot:1
+31 ;
+32 ;create the message
+33 IF '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR)
QUIT 0
+34 ;
+35 DO GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
+36 ;
+37 IF +$PIECE($GET(RESULTS),"^",2)
SET ERROR=$PIECE(RESULTS,"^",3)
SET ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_ERROR
DO EXC^RGFIU(6,ERROR,DFN)
QUIT 0
+38 QUIT 1