source: FOIAVistA/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGFIBM.m@ 1288

Last change on this file since 1288 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.4 KB
Line 
1RGFIBM ;ALB/CJM-SEND FACILITY INTEGRATION MESSAGE ;08/27/99
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**5,9**;30 Apr 99
3 ;
4SEND(DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
5 ;Description: Sends the facility integration message for this patient
6 ;using routing logic based on the subscription list.
7 ;
8 ;Input:
9 ; DFN - ien of patient
10 ; LEGACY - station number of the legacy site
11 ; PRIMARY - station number of the primary site
12 ;Output:
13 ; Function Value - 1 on success, 0 on failure
14 ; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
15 ; ERROR - error message (pass by reference,optional)
16 ;
17 N HL,HLA,HLERR,HLL,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX,RGI,ERRFOUND
18 K RESULTS,ERROR
19 ;
20 ;
21 I $G(DFN),$G(PRIMARY),$G(LEGACY) D
22 .;just checking!
23 E S ERROR="MISSING PARAMETER" Q 0
24 ;
25 I '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR) Q 0
26 ;
27 D ROUTE^RGFIRM(DFN,LEGACY,PRIMARY,.HLL)
28 ;
29 D GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
30 ;
31 S ERRFOUND=0
32 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
33 S RGI=0
34 I $D(RESULTS) F S RGI=$O(RESULTS(RGI)) Q:'RGI D
35 .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
36 Q:ERRFOUND 0
37 Q 1
38 ;
39BUILD(LOC,DFN,LEGACY,PRIMARY,ERROR) ;
40 ;Description: Builds the facility integration message.
41 ;
42 ;Input:
43 ; LOC - global location to place the message, referenced by @indirection
44 ; DFN - ien of patient
45 ; LEGACY - station number of the legacy site
46 ; PRIMARY - station number of the primary site
47 ;Output:
48 ; Function Value - 1 on success, 0 on failure
49 ; ERROR - error message (pass by reference,optional)
50 ; HL7 variables defined by INIT^HLFNC2
51 ;
52 N ICNPLUS
53 K ERROR
54 ;
55 ;
56 I $G(DFN),$G(PRIMARY),$G(LEGACY) D
57 .;just checking!
58 E S ERROR="MISSING PARAMETER NEEDED TO BUILD FACILITY INTEGRATION MESSAGE" D EXC^RGFIU(6,ERROR,DFN) Q 0
59 ;
60 ;don't send message if there is no ICN to identify it
61 S ICNPLUS=$$GETICN^MPIF001(DFN)
62 I (+ICNPLUS)'>0 S ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT LACKS ICN" D EXC^RGFIU(6,ERROR,DFN) Q 0
63 ;
64 ;don't send if local ICN
65 I $$IFLOCAL^MPIF001(DFN) S ERROR="UNABLE TO SEND FACILITY INTEGRATION MESSAGE - PATIENT ICN IS LOCAL" D EXC^RGFIU(6,ERROR,DFN) Q 0
66 ;
67 D INIT^HLFNC2("RG FACILITY INTEGRATION SERVER",.HL)
68 I $G(HL) S ERROR="ERROR ENCOUNTERED BY HL7 WHILE SENDING FACILITY INTEGRATION MESSAGE: "_HL D EXC^RGFIU(6,ERROR,DFN) Q 0
69 ;
70 S @LOC@(1)=$$EVN^VAFHLEVN("A08",51)
71 S @LOC@(2)=$$EN^VAFCPID(DFN,"2,3,5,19")
72 S @LOC@(3)="PV1"
73 S $P(@LOC@(3),HL("FS"),3)="O"
74 S @LOC@(4)="NTE"
75 S $P(@LOC@(4),HL("FS"),3)="P"
76 S $P(@LOC@(4),HL("FS"),4)=LEGACY_$E(HL("ECH"),1)_PRIMARY
77 Q 1
78 ;
79SITESEND(TO,DFN,LEGACY,PRIMARY,RESULTS,ERROR) ;
80 ;Description: Sends the facility integration message for this patient
81 ;to a single site.
82 ;
83 ;Input:
84 ; TO - station # of destination
85 ; DFN - ien of patient
86 ; LEGACY - station number (without suffix) of the legacy site
87 ; PRIMARY - station number (without suffix) of the primary site
88 ;Output:
89 ; Function Value - 1 on success, 0 on failure
90 ; RESULTS() - results array returned by calling GENERATE^HLMA (pass by reference,optional)
91 ; ERROR - error message (pass by reference,optional)
92 ;
93 N HL,HLA,HLERR,HLL,SITEIEN,LINK,HLDT,HLCD,HLINK0,HLINKIEN,HLINKP,HLINKX,HLDOM,HLECH,HLFS,HLHDR,HLINST,HLN,HLPARAM,HLQ,HLSAN,HLTYPE,HLX
94 K RESULTS,ERROR
95 ;
96 ;
97 I $G(DFN),$G(PRIMARY),$G(LEGACY),$G(TO) D
98 .;just checking!
99 E S ERROR="MISSING PARAMETER" Q 0
100 ;
101 S SITEIEN=$$LKUP^XUAF4(TO)
102 I 'SITEIEN S ERROR="SITE NOT FOUND IN INSTITUTION FILE" Q 0
103 ;
104 ;set HLL array to route message to a single site
105 S LINK=$$GETLINK^RGFIU(SITEIEN)
106 I '$L(LINK) D
107 .D EXC^RGFIU(224,"Facility Integration Message not sent to station # "_TO,DFN)
108 E D
109 .S HLL("LINKS",1)="RG FACILITY INTEGRATION CLIENT^"_LINK
110 ;
111 ;create the message
112 I '$$BUILD("HLA(""HLS"")",DFN,LEGACY,PRIMARY,.ERROR) Q 0
113 ;
114 D GENERATE^HLMA("RG FACILITY INTEGRATION SERVER","LM",1,.RESULTS)
115 ;
116 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
117 Q 1
Note: See TracBrowser for help on using the repository browser.