RGFIRM ;ALB/CJM-ROUTE FACILITY INTEGRATION MESSAGE ;08/27/99
;;1.0;CLINICAL INFO RESOURCE NETWORK;**5,9**;30 Apr 99
;
MROUTE ;
;Description: routing logic for the Facility Integration Message. This
;entry point is meant to be called by the HL7 pacakge when used in
;the message routing logic of the client protocol.
;
;Input:
; HL7 variables must be defined
;Output:
; HLL("LINKS") array containing the dynamic routing list
;Variables:
; LEGACY - station # of legacy site
; PRIMARY - station # of primary site
; ICN - patient ICN from message
; DFN - ien from the patient file
;
N LEGACY,PRIMARY,ICN,DFN
S (DFN,LEGACY,PRIMARY,ICN)=""
Q:'$$PARSE^RGFIPM1(1,.LEGACY,.PRIMARY,.ICN)
S DFN=$$DFN^RGFIU(ICN)
Q:'DFN
D ROUTE(DFN,LEGACY,PRIMARY,.HLL)
Q
;
ROUTE(DFN,LEGACY,PRIMARY,HLL) ;
;Description: routing logic for the Facility Integration Message. This
;entry point is designed to be called directly by the application.
;
;Input:
; DFN - ien from the patient file
; LEGACY - station # of legacy site
; PRIMARY - station # of primary site
;Output:
; HLL("LINKS") array containing the dynamic routing list (pass HLL by reference)
;Variables:
; SUB - ien of the subscriber list
; HERE - station # of site this routine is executing on
; HEREIEN - ien in Institution file of site this routine is executing on
; MPINODE - "MPI" node from the Patient file
; CMOR - station # of CMOR
; CMORIEN - ien in Institution file of CMOR
;
K HLL("LINKS")
;
I $G(LEGACY),$G(PRIMARY),$G(DFN) D
.;just checking
E Q
;
N SUB,HERE,HEREIEN,MPINODE,CMOR,CMORIEN
S (SUB,HERE,HEREIEN,MPINODE,CMOR,CMORIEN)=""
S HEREIEN=$$SITE^VASITE(),HERE=$P(HEREIEN,"^",3),HEREIEN=+HEREIEN
S MPINODE=$$MPINODE^RGFIU(DFN)
S CMORIEN=$P(MPINODE,"^",3)
S CMOR=$$STATNUM^RGFIU(CMORIEN)
;
;If the CMOR is not known, the message can not be routed
I 'CMORIEN D Q
.D EXC^RGFIU(221,"ERROR ENCOUNTERED WHILE PROCESSING FACITLIY INTEGRATION MESSAGE: MISSING CMOR",DFN)
;
S SUB=$P(MPINODE,"^",5)
I CMOR=HERE D
.;this is the CMOR, so send to subscribers (except legacy) and Austin MPI
.N MPILINK ;logical link of MPI
.S MPILINK=$$MPILINK^MPIFAPI()
.I $P(MPILINK,"^")=-1 D
..D EXC^RGFIU(224,"Facility Integration Message not sent to MPI, no MPI link identified in CIRN SITE PARAMETER file (#991.8)",DFN)
.E D
..S HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_MPILINK
.;
.;If this prmary site is not the CMOR, than make sure the prmary site
.;is on the subscription list
.;If this prmary site is not the CMOR, than make sure the prmary site
.;is on the subscription list
.I PRIMARY'=CMOR D
..;PRIMIEN = ien of primary site in Institution file, LINK = its logical link
..N PRIMIEN,LINK
..S PRIMIEN=$$LKUP^XUAF4(PRIMARY)
..Q:'PRIMIEN
..;set HLL array to route message to primary site
..S LINK=$$GETLINK^RGFIU(PRIMIEN)
..I '$L(LINK) D
...D EXC^RGFIU(224,"Facility Integration Message not sent to primary site, station # "_PRIMARY,DFN)
..E D
...S HLL("LINKS",2)="RG FACILITY INTEGRATION CLIENT^"_LINK
.;
.D:SUB
..;there is a subscription list, use it to route the message, with changes
..;Variables:
..; ITEM - one of the sites (by subscript # on HLL("LINKS") array) on the subscriber list
..; LINK - logical link ien of subscriber
..; HERELINK - logical link of this site
..; LEGLINK - logical link of legacy site
..;
..N ITEM,NODE,LINK,HERELINK,LEGLINK
..S HERELINK=$$GETLINK^RGFIU(HEREIEN)
..S LEGLINK=$$GETLINK^RGFIU($$LKUP^XUAF4(LEGACY))
..D GET^HLSUB(SUB,,"RG FACILITY INTEGRATION CLIENT",.HLL)
..;screen out legacy and this (here) site
..S ITEM=0 F S ITEM=$O(HLL("LINKS",ITEM)) Q:'ITEM S NODE=$G(HLL("LINKS",ITEM)),LINK=$P(NODE,"^",2) D:$L(LINK)
...I HERELINK=LINK K HLL("LINKS",ITEM) Q
...I LEGLINK=LINK K HLL("LINKS",ITEM) Q
E D
.;send message to CMOR, but only if this is the legacy site
.N CMORLINK
.Q:(LEGACY'=HERE)
.S CMORLINK=$$GETLINK^RGFIU(CMORIEN)
.I '$L(CMORLINK) D
..D EXC^RGFIU(224,"Facility Integration Message not sent to site "_CMOR,DFN)
.E D
..S HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_CMORLINK
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGFIRM 4216 printed Nov 22, 2024@16:52:04 Page 2
RGFIRM ;ALB/CJM-ROUTE FACILITY INTEGRATION MESSAGE ;08/27/99
+1 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**5,9**;30 Apr 99
+2 ;
MROUTE ;
+1 ;Description: routing logic for the Facility Integration Message. This
+2 ;entry point is meant to be called by the HL7 pacakge when used in
+3 ;the message routing logic of the client protocol.
+4 ;
+5 ;Input:
+6 ; HL7 variables must be defined
+7 ;Output:
+8 ; HLL("LINKS") array containing the dynamic routing list
+9 ;Variables:
+10 ; LEGACY - station # of legacy site
+11 ; PRIMARY - station # of primary site
+12 ; ICN - patient ICN from message
+13 ; DFN - ien from the patient file
+14 ;
+15 NEW LEGACY,PRIMARY,ICN,DFN
+16 SET (DFN,LEGACY,PRIMARY,ICN)=""
+17 if '$$PARSE^RGFIPM1(1,.LEGACY,.PRIMARY,.ICN)
QUIT
+18 SET DFN=$$DFN^RGFIU(ICN)
+19 if 'DFN
QUIT
+20 DO ROUTE(DFN,LEGACY,PRIMARY,.HLL)
+21 QUIT
+22 ;
ROUTE(DFN,LEGACY,PRIMARY,HLL) ;
+1 ;Description: routing logic for the Facility Integration Message. This
+2 ;entry point is designed to be called directly by the application.
+3 ;
+4 ;Input:
+5 ; DFN - ien from the patient file
+6 ; LEGACY - station # of legacy site
+7 ; PRIMARY - station # of primary site
+8 ;Output:
+9 ; HLL("LINKS") array containing the dynamic routing list (pass HLL by reference)
+10 ;Variables:
+11 ; SUB - ien of the subscriber list
+12 ; HERE - station # of site this routine is executing on
+13 ; HEREIEN - ien in Institution file of site this routine is executing on
+14 ; MPINODE - "MPI" node from the Patient file
+15 ; CMOR - station # of CMOR
+16 ; CMORIEN - ien in Institution file of CMOR
+17 ;
+18 KILL HLL("LINKS")
+19 ;
+20 IF $GET(LEGACY)
IF $GET(PRIMARY)
IF $GET(DFN)
Begin DoDot:1
+21 ;just checking
End DoDot:1
+22 IF '$TEST
QUIT
+23 ;
+24 NEW SUB,HERE,HEREIEN,MPINODE,CMOR,CMORIEN
+25 SET (SUB,HERE,HEREIEN,MPINODE,CMOR,CMORIEN)=""
+26 SET HEREIEN=$$SITE^VASITE()
SET HERE=$PIECE(HEREIEN,"^",3)
SET HEREIEN=+HEREIEN
+27 SET MPINODE=$$MPINODE^RGFIU(DFN)
+28 SET CMORIEN=$PIECE(MPINODE,"^",3)
+29 SET CMOR=$$STATNUM^RGFIU(CMORIEN)
+30 ;
+31 ;If the CMOR is not known, the message can not be routed
+32 IF 'CMORIEN
Begin DoDot:1
+33 DO EXC^RGFIU(221,"ERROR ENCOUNTERED WHILE PROCESSING FACITLIY INTEGRATION MESSAGE: MISSING CMOR",DFN)
End DoDot:1
QUIT
+34 ;
+35 SET SUB=$PIECE(MPINODE,"^",5)
+36 IF CMOR=HERE
Begin DoDot:1
+37 ;this is the CMOR, so send to subscribers (except legacy) and Austin MPI
+38 ;logical link of MPI
NEW MPILINK
+39 SET MPILINK=$$MPILINK^MPIFAPI()
+40 IF $PIECE(MPILINK,"^")=-1
Begin DoDot:2
+41 DO EXC^RGFIU(224,"Facility Integration Message not sent to MPI, no MPI link identified in CIRN SITE PARAMETER file (#991.8)",DFN)
End DoDot:2
+42 IF '$TEST
Begin DoDot:2
+43 SET HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_MPILINK
End DoDot:2
+44 ;
+45 ;If this prmary site is not the CMOR, than make sure the prmary site
+46 ;is on the subscription list
+47 ;If this prmary site is not the CMOR, than make sure the prmary site
+48 ;is on the subscription list
+49 IF PRIMARY'=CMOR
Begin DoDot:2
+50 ;PRIMIEN = ien of primary site in Institution file, LINK = its logical link
+51 NEW PRIMIEN,LINK
+52 SET PRIMIEN=$$LKUP^XUAF4(PRIMARY)
+53 if 'PRIMIEN
QUIT
+54 ;set HLL array to route message to primary site
+55 SET LINK=$$GETLINK^RGFIU(PRIMIEN)
+56 IF '$LENGTH(LINK)
Begin DoDot:3
+57 DO EXC^RGFIU(224,"Facility Integration Message not sent to primary site, station # "_PRIMARY,DFN)
End DoDot:3
+58 IF '$TEST
Begin DoDot:3
+59 SET HLL("LINKS",2)="RG FACILITY INTEGRATION CLIENT^"_LINK
End DoDot:3
End DoDot:2
+60 ;
+61 if SUB
Begin DoDot:2
+62 ;there is a subscription list, use it to route the message, with changes
+63 ;Variables:
+64 ; ITEM - one of the sites (by subscript # on HLL("LINKS") array) on the subscriber list
+65 ; LINK - logical link ien of subscriber
+66 ; HERELINK - logical link of this site
+67 ; LEGLINK - logical link of legacy site
+68 ;
+69 NEW ITEM,NODE,LINK,HERELINK,LEGLINK
+70 SET HERELINK=$$GETLINK^RGFIU(HEREIEN)
+71 SET LEGLINK=$$GETLINK^RGFIU($$LKUP^XUAF4(LEGACY))
+72 DO GET^HLSUB(SUB,,"RG FACILITY INTEGRATION CLIENT",.HLL)
+73 ;screen out legacy and this (here) site
+74 SET ITEM=0
FOR
SET ITEM=$ORDER(HLL("LINKS",ITEM))
if 'ITEM
QUIT
SET NODE=$GET(HLL("LINKS",ITEM))
SET LINK=$PIECE(NODE,"^",2)
if $LENGTH(LINK)
Begin DoDot:3
+75 IF HERELINK=LINK
KILL HLL("LINKS",ITEM)
QUIT
+76 IF LEGLINK=LINK
KILL HLL("LINKS",ITEM)
QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+77 IF '$TEST
Begin DoDot:1
+78 ;send message to CMOR, but only if this is the legacy site
+79 NEW CMORLINK
+80 if (LEGACY'=HERE)
QUIT
+81 SET CMORLINK=$$GETLINK^RGFIU(CMORIEN)
+82 IF '$LENGTH(CMORLINK)
Begin DoDot:2
+83 DO EXC^RGFIU(224,"Facility Integration Message not sent to site "_CMOR,DFN)
End DoDot:2
+84 IF '$TEST
Begin DoDot:2
+85 SET HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_CMORLINK
End DoDot:2
End DoDot:1
+86 QUIT