source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGMSTHL7.m@ 1306

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

initial load of WorldVistAEHR

File size: 3.4 KB
RevLine 
[613]1DGMSTHL7 ;ALB/SCK - Military Sexual Trauma HL7 Message builder ;8 Jan 99
2 ;;5.3;Registration;**195**;Aug 13, 1993
3 Q
4 ;
5EVENT(DFN,DGEVNT,DGRSLT) ; Entry point to initiate HL7 ADT message for a MST status event
6 ; Input
7 ; DFN - IEN of patient in the PATIENT File, #2
8 ; DGEVNT - Event type, currently only A08 supported, Optional
9 ; Default is A08
10 ; DGRSLT - Location of results from event trigger
11 ;
12 ; Output
13 ; DGRSLT= results of event action
14 ;
15 N EVNTDT,EVNTINFO
16 ;
17 S DFN=$G(DFN)
18 I 'DFN S @DGRSLT="-1^Invalid DFN" Q
19 ;
20 S DGEVNT=$G(DGEVNT)
21 S:'(DGEVNT]"") DGEVNT="A08"
22 I DGEVNT'["A08" S @DGRSLT="-1^Event type not supported" Q
23 ;
24 S DGRSLT=$G(DGRSLT)
25 Q:'(DGRSLT]"")
26 ;
27 N GLOREF
28 S GLOREF="^TMP(""HLS"","_$J_")"
29 K @GLOREF
30 ;
31 S EVNTINFO("DFN")=DFN
32 S EVNTINFO("EVENT")="A08"
33 S EVNTINFO("DATE")=$$NOW^XLFDT
34 S EVNTINFO("SERVER")="DGMST A08 SERVER"
35 ;
36 S @DGRSLT=$$BLDMSG(.EVNTINFO,GLOREF)
37 I (+@DGRSLT>0) D
38 . S @DGRSLT=$$SENDMSG(.EVNTINFO,GLOREF)
39 Q
40 ;
41BLDMSG(EVNTINFO,XMTARRY) ;
42 ; Input
43 ; EVNTINFO - Array of event information
44 ; ("DATE") - Event date
45 ; ("DFN") - IEN of patient in PATIENT File (#2)
46 ; ("EVENT") - HL7 message event
47 ; ("SERVER") - HL7 Server protocol
48 ;
49 ; XMTARRY - Location to place HL7 message array, Optional
50 ; Default is ^TMP("HLS",$J)
51 ;
52 ; Output
53 ; XMTARRY - HL7 Message
54 ;
55 N HLEID,HL,HLFS,HLECH,HLQ,LASTLINE,VAFSTR,LINESADD,HLP
56 ;
57 S XMTARRY=$G(XMTARRY)
58 S:(XMTARRY="") XMTARRY="^TMP(""HLS"","_$J_")"
59 ;
60 Q:$G(EVNTINFO("SERVER"))']"" "-1^Server protocol not defined"
61 I $G(EVNTINFO("SERVER"))]"" D
62 . D INIT^HLFNC2(EVNTINFO("SERVER"),.HL)
63 Q:($O(HL(""))="") "-1^Unable to initialize HL7 variables"
64 ;
65 ;; Build EVN segment
66 N VAFEVN,VAFSTR
67 S VAFSTR="1,2,"
68 S VAFEVN=$$EN^VAFHLEVN(EVNTINFO("EVENT"),EVNTINFO("DATE"),VAFSTR,HL("Q"),HL("FS"))
69 S $P(VAFEVN,HL("FS"),2)=EVNTINFO("EVENT")
70 S LASTLINE=1+$G(LASTLINE)
71 S @XMTARRY@(LASTLINE)=VAFEVN
72 ;
73 ;; Build PID segment
74 N VAFPID
75 S VAFSTR="1,2,3,4,5,6,7,8,10,11,12,13,14,16,17,19,"
76 S VAFPID=$$EN^VAFHLPID(EVNTINFO("DFN"),VAFSTR)
77 S LASTLINE=1+$G(LASTLINE),LINESADD=1+$G(LINESADD)+$O(VAFPID(""),-1)
78 M @XMTARRY@(LASTLINE)=VAFPID
79 ;
80 ;; Build ZEL segment, include only the MST status and status change date
81 N VAFZEL
82 S VAFSTR="1,23,24,"
83 S VAFZEL=$$EN^VAFHLZEL(EVNTINFO("DFN"),VAFSTR)
84 S LASTLINE=1+$G(LASTLINE)
85 M @XMTARRY@(LASTLINE)=VAFZEL
86 ;
87 Q LASTLINE_U_LINESADD
88 ;
89SENDMSG(EVNTINFO,XMTARRY) ; Send ADT HL7 message
90 ; Input
91 ; EVNTINFO
92 ; XMTARRY
93 ;
94 ; Output
95 ;
96 ;
97 N ARRY4HL7,KILLARRY,HL,HLRESLT
98 S XMTARRY=$G(XMTARRY)
99 S:'(XMTARRY]"") XMTARRY="^TMP(""HLS"","_$J_")"
100 Q:($O(@XMTARRY@(""))="") "-1^Can not send empty message"
101 ;
102 K HL
103 S ARRY4HL7="^TMP(""HLS"","_$J_")"
104 ;
105 ;; If server not specified, then quit with error
106 Q:$G(EVNTINFO("SERVER"))']"" "-1^Server protocol not defined"
107 ;
108 ;; Initialize HL7 variables
109 I $G(EVNTINFO("SERVER"))]"" D
110 . D INIT^HLFNC2(EVNTINFO("SERVER"),.HL)
111 Q:($O(HL(""))="") "-1^Unable to initialize HL7 variables"
112 ;
113 ;; Check if XMTARRY is ^TMP("HLS",$J)
114 S KILLARRY=0
115 I (XMTARRY'=ARRY4HL7) D
116 . ;; make sure '$J' wasn't used
117 . Q:(XMTARRY="TMP(""HLS"",$J")
118 . K @ARRY4HL7
119 . M @ARRY4HL7=@XMTARRY
120 . S KILLARRY=1
121 ;
122 ;; Broadcast message
123 D GENERATE^HLMA(EVNTINFO("SERVER"),"GM",1,.HLRESLT,"",.HLP)
124 S:('HLRESLT) HLRESLT=$P(HLRESLT,"^",2,3)
125 ;
126 ;; Delete ^TMP("HLS",$J) if XMTARRY was different
127 K:(KILLARRY) @ARRY4HL7
128 ;
129 Q $G(HLRESLT)
Note: See TracBrowser for help on using the repository browser.