source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFRTC.m@ 623

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

initial load of WorldVistAEHR

File size: 3.5 KB
Line 
1MPIFRTC ;ALB/JRP-GET ICN FROM MPI USING REAL TIME CONNECTION ;21-JAN-1997
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**1**;30 Apr 99
3 ;
4GETICN(DFN) ;Get ICN from MPI using real time connection
5 ;
6 ;Input : DFN - Pointer to entry in PATIENT file (#2)
7 ;Output : ICN = Success
8 ; -1^Reason = Failure
9 ;
10 ;Check input
11 S DFN=+$G(DFN)
12 Q:('$D(^DPT(DFN,0))) "-1^Did not pass valid DFN"
13 ;Declare variables
14 N DPTZERO,CREATED,USER,INFOARR,MSG2MPI,MSG2DHCP,TMP,ICN
15 S MSG2MPI="^TMP(""MPIFRTC"","_$J_",""MSG2MPI"")"
16 S MSG2DHCP="^TMP(""MPIFRTC"","_$J_",""MSG2DHCP"")"
17 S INFOARR="^TMP(""MPIFRTC"","_$J_",""INFOARR"")"
18 K @MSG2MPI,@MSG2DHCP,@INFOARR
19 ;Determine user that created patient and date/time patient was created
20 S DPTZERO=$G(^DPT(DFN,0))
21 S USER=+$P(DPTZERO,"^",15)
22 S:('USER) USER=+$G(DUZ)
23 S CREATED=+$P(DPTZERO,"^",16)
24 S:('CREATED) CREATED=$$NOW^XLFDT()
25 ;Set up extra info array for message builder
26 ; - Event reason code (EVN segment, seq #4)
27 S @INFOARR@("REASON",1)=94
28 ; - Operator (EVN segment, seq #5)
29 S @INFOARR@("USER")=$P($G(^VA(200,USER,0)),"^",1)
30 ;Build MSH segment for ADT-A28 HL7 message
31 D BLDMSH("A28","MPI","200M",MSG2MPI,1)
32 ;Build rest of ADT-A28 HL7 message
33 S TMP=$$BLDMSG^VAFCMSG1(DFN,"A28",CREATED,INFOARR,MSG2MPI,2)
34 ;need to remove local ICN from PID segment
35 S $P(@MSG2MPI@(3),"^",3)="",$P(@MSG2MPI@(3),"^",4)=""
36 ;Send ADT-A28 HL7 message to MPI using real time connection
37 S TMP=$$EN^HLCSAC("MPIVA DIR",MSG2MPI,MSG2DHCP)
38 Q:(TMP<0) TMP
39 ;Process ADT-A31 HL7 message returned by MPI (contains ICN assignment)
40 S ICN=$$PROCESS^MPIFA31I(MSG2DHCP)
41 ;Done - Clean up and return ICN
42EX K @MSG2MPI,@MSG2DHCP,@INFOARR
43 Q ICN
44 ;
45BLDMSH(EVNTHL7,RCVAPP,RCVFAC,ARRAY,LINE) ;Build MSH segment for ADT
46 ; HL7 message
47 ;
48 ;Input : EVNTHL7 - HL7 ADT event to build MSH segment for A28
49 ; (Defaults to A28)
50 ; RCVAPP - Text to use as RECEIVING APPLICATION (seq #5)
51 ; RCVFAC - Text to use as RECEIVING FACILITY (seq #6)
52 ; ARRAY - Array to store MSH segment in (full global reference)
53 ; (Defaults to ^TMP("MPIFRTC",$J,"MSH"))
54 ; LINE - Line number in ARRAY to store MSH segment in
55 ; Can not be zero or negative number (defaults to 1)
56 ;Output : None
57 ; ARRAY() will be in the following format
58 ; ARRAY(LINE) = MSH segment
59 ; ARRAY(LINE,1) = First continuation node
60 ; ARRAY(LINE,n) = Nth continuation node
61 ;Notes : ARRAY(LINE) will be initialized (KILLed) on input
62 ; : ARRAY(LINE) will not be defined on bad input
63 ; : SENDING APPLICATION (seq #3) and SENDING FACILITY (seq #4)
64 ; are based on the application attached to the PIMS ADT-xxx
65 ; HL7 Server Protocol
66 ;
67 ;Check input
68 S EVNTHL7=$G(EVNTHL7)
69 S:(EVNTHL7="") EVNTHL7="A28"
70 S RCVAPP=$G(RCVAPP)
71 S RCVFAC=$G(RCVFAC)
72 S ARRAY=$G(ARRAY)
73 S:(ARRAY="") ARRAY="^TMP(""MPIFRTC"","_$J_",""MSH"")"
74 S LINE=+$G(LINE)
75 S:(LINE<1) LINE=1
76 ;Declare variables
77 N HLEID,HL,TMPMSHAR
78 ;Inintialize output array
79 K @ARRAY@(LINE)
80 ;Get pointer to ADT-xxx HL7 Server Protocol
81 S HLEID=$$GETSRVR^VAFCMSG5(EVNTHL7)
82 ;Initialize HL7 variables
83 D INIT^HLFNC2(HLEID,.HL)
84 ;Build MSH segment for ADT-xxx HL7 message
85 D MSH^HLFNC2(.HL,"",.TMPMSHAR)
86 ;Manually set RECEIVING APPLICATION (seq #5)
87 S $P(TMPMSHAR,HL("FS"),5)=RCVAPP
88 ;Manually set RECEIVING FACILITY (seq #6)
89 S $P(TMPMSHAR,HL("FS"),6)=RCVFAC
90 ;Move MSH segment into output array
91 S @ARRAY@(LINE)=TMPMSHAR
92 S HL=0
93 F S HL=+$O(MSH(HL)) Q:('HL) S @ARRAY@(LINE,HL)=TMPMSHAR(HL)
94 ;Done
95 Q
Note: See TracBrowser for help on using the repository browser.