source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLTF0.m@ 1006

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

initial load of WorldVistAEHR

File size: 7.8 KB
Line 
1HLTF0 ;AISC/SAW,JRP - File Data in Message Text File ;05/05/2000 09:01
2 ;;1.6;HEALTH LEVEL SEVEN;**12,19,64,91,109**;Oct 13, 1995
3 ;
4STATUS(MTIEN,STATUS,ERR,ERRTEXT,COMDT,NOEVENT) ;Update Status of Entry in Message Text File and log an event for errors
5 ;
6 ;This is a subroutine call with parameter passing. No output
7 ;parameters are returned
8 ;
9 ;$D(HLTCP) will determine if you are updating file 773, instead
10 ; of file 772.
11 ;Required Input Parameters
12 ; MTIEN = IEN of entry in file 772 or 773, to be updated
13 ; STATUS = IEN of new status (pointer to Message Status file)
14 ;Optional Parameters
15 ; ERR = IEN of error message (pointer to Error Message file)
16 ; ERRTEXT = An error message of up to 200 characters
17 ; COMDT = 0/1 ; 1=update DATE/TIME PROCESSED, field 100
18 ; NOEVENT = 1 if an event should NOT be logged. Presumably this signals that the application already logged the event
19 ;
20 ;Check for required parameters
21 I '$G(MTIEN)!('$G(STATUS)) Q
22 ;File new status info
23 N HLJ,HLOCK,X
24 ;if TCP update status in file 773, else status in file 772
25 I $D(HLTCP) S X="HLJ(773,",HLOCK="^HLMA("
26 E S X="HLJ(772,",HLOCK="^HL(772,"
27 S X=X_""""_MTIEN_","")",HLOCK=HLOCK_MTIEN_")"
28 ;20=status, 21=date process
29 S @X@(20)=STATUS,@X@(21)=$S(STATUS=1:"@",1:$$NOW^XLFDT)
30 ;22=error msg
31 S:$G(ERRTEXT)]"" @X@(22)=$E(ERRTEXT,1,200)
32 ;23=error type
33 S:$G(ERR) @X@(23)=+ERR
34 ;100=date/time processed
35 S:$G(COMDT) @X@(100)=$$NOW^XLFDT
36 ;**109** F L +@HLOCK:1 Q:$T H 1
37 D FILE^HLDIE("","HLJ","","STATUS","HLTF0") ;HL*1.6*109
38 ;**109** L -@HLOCK
39 ;
40 ;if the status is error, and the event is not being surpressed by the
41 ;application, log a new event
42 I '$G(NOEVENT),$G(STATUS)=4 D
43 .N CODE,HL7MSGID,ERROR,PARENT,EVENT
44 .S CODE=$G(ERR)
45 .S (HL7MSGID,PARENT)=""
46 .I $G(MTIEN) D
47 ..N NODE
48 ..I $G(HLTCP) D
49 ...S NODE=$G(^HLMA(MTIEN,0))
50 ...S HL7MSGID=$P(NODE,"^",2)
51 ...S PARENT=$P(NODE,"^",6)
52 ..E D
53 ...S NODE=$G(^HL(772,MTIEN,0))
54 ...S HL7MSGID=$P(NODE,"^",6)
55 ...S PARENT=$P(NODE,"^",8)
56 .;
57 .S EVENT=$$EVENT^HLEME(CODE,"HEALTH LEVEL SEVEN",HL7MSGID,,,.ERROR)
58 .;I 'EVENT,'$D(ZTQUEUED) W !,"Failed to create an Event in STATUS^HLTF0: ",$G(ERROR)_" "_$G(ERROR(1))_" "_$G(ERROR(2))
59 .;
60 .I EVENT D
61 ..I $L($G(ERRTEXT)),$$ADDNOTE^HLEME(EVENT,"Application Error Text: "_ERRTEXT)
62 ..;If this message was not the initial message in a transaction protocol, then provide some information about the initial message
63 ..I PARENT,PARENT'=$G(MTIEN) D
64 ...N PLINK,PMSGID,PMSGTYPE,PNODE,PEVENT,PNOTES
65 ...I $D(HLTCP) D
66 ....S PNODE=$G(^HLMA(PARENT,0))
67 ....S PLINK=$P(PNODE,"^",7)
68 ....S PMSGID=$P(PNODE,"^",2)
69 ....S PMSGTYPE=$P(PNODE,"^",13)
70 ....S PEVENT=$P(PNODE,"^",14)
71 ...E D
72 ....S PNODE=$G(^HL(772,PARENT,0))
73 ....S PLINK=$P(PNODE,"^",11)
74 ....S PMSGID=$P(PNODE,"^",6)
75 ....S PMSGTYPE=""
76 ....S PEVENT=""
77 ...S PNOTES(1)="Initial Message in this transaction protocol:"
78 ...S PNOTES(2)=" Initial Message ID: "_PMSGID
79 ...S PNOTES(3)=" Logical Link of Initial Message: "
80 ...S:PLINK PNOTES(3)=PNOTES(3)_$P($G(^HLCS(870,PLINK,0)),"^")
81 ...S:PMSGTYPE PNOTES(4)=" Inital Message Type: "_$P($G(^HL(771.2,PMSGTYPE,0)),"^")
82 ...S:PEVENT PNOTES(5)=" Inital Message Event: "_$P($G(^HL(779.001,PEVENT,0)),"^")
83 ...I $$ADDNOTE^HLEME(EVENT,.PNOTES) ;then notes successfully added
84 Q
85 ;
86STATS(MTIEN,HLCHAR,HLEVN) ;Enter Statistics for an Entry in Message
87 ;Text File
88 ;
89 ;This is a subroutine call with parameter passing. No output
90 ;parameters are returned
91 ;
92 ;Required Input Parameters
93 ; MTIEN = The IEN from the Message Text file of the entry to be
94 ; updated
95 ; HLCHAR = The number of characters in the message
96 ; HLEVN = The number of HL7 events in the message
97 ;
98 ;Check for required parameters
99 I '$G(MTIEN)!('$D(HLCHAR))!('$D(HLEVN)) Q
100 I '$D(^HL(772,MTIEN,0)) Q
101 ;File statistical info
102 ;**109** F L +^HL(772,MTIEN):1 H:'$T 1 I $T D Q
103 D
104 . S ^HL(772,MTIEN,"S")=HLCHAR_"^"_$G(HLEVN)
105 ;**109** . L -^HL(772,MTIEN)
106 Q
107STUFF(HLMT) ;Update Fields on Zero Node of the Message Text File for
108 ;Version 1.5 Interface Only
109 ;
110 ;This is a subroutine call with parameter passing. No output
111 ;parameters are returned
112 ;
113 ;Required Input Parameter
114 ; HLMT = Message type, O for outgoing or I for incoming
115 ;
116 ;Check for required parameter
117 Q:HLMT']""
118 ;File zero node data
119 N DA,DIC,DIE,DR
120 S (DIC,DIE)="^HL(772,",DA=HLDA
121 S DR="4////"_HLMT_$S('$G(HLDAP):"",1:";2////"_HLDAP)_$S('$G(HLXMZ):"",1:";5////"_HLXMZ)_$S('$G(HLDAI):"",1:";7////"_HLDAI)_";Q"_$S('$P($G(HLNDAP0),U,12):"",1:";3////"_$P($G(HLNDAP0),U,12))
122 F L +^HL(772,DA):1 H:'$T 1 I $T D Q
123 . D ^DIE
124 . L -^HL(772,DA)
125 Q
126UPDATE(MTIEN,MTIENP,HLMT,EID,CLIENT,SERVER,PRIORITY,REPLYTO,LOGLINK,HLP) ;
127 ;Update Fields of the Message Text File #772 or Message Administration
128 ; File #773 for Bi-directional TCP
129 ;
130 ;$D(HLTCP) will determine if you are updating file 773, instead
131 ; of file 772.
132 ;
133 ;This is a subroutine call with parameter passing. No output
134 ;parameters are returned
135 ;
136 ;Required Input Parameters
137 ; MTIEN = The IEN from file 772 or 773 of the entry to be
138 ; updated
139 ; MTIENP = The IEN from the Message Text file of the parent entry
140 ; to which this entry (MTIEN) should be linked. TCP will
141 ; ignore this parameter.
142 ; HLMT = The type of message, I for Incoming or O for Outgoing
143 ;NOTE: Either Client or Server must be passed. Both parameters may
144 ; be passed
145 ; CLIENT = The IEN of the client (subscriber) application from
146 ; the Application Parameter file
147 ; SERVER = The IEN of the server (event driver) application from
148 ; the Application Parameter file
149 ;Optional parameters
150 ; EID = The IEN from the Protocol file of the event related to this
151 ; Message Text file entry
152 ;PRIORITY = I for immediate or D for deferred
153 ; REPLYTO = The IEN from the Message Text file of the message being
154 ; acknowledged. (Only used for acknowledgement messages.)
155 ; LOGLINK = The IEN of the logical link from the Logical Link file
156 ; HLP("SECURITY") = A 1 to 40 character string
157 ; HLP("CONTPTR") = Continuation pointer, a 1 to 180 character string
158 ; HLP("MSGTYPE") = M for Single Message or B for Batch of Messages
159 ; HLP("EVENT") = ien of event type
160 ; HLP("MTYPE") = ien of message type
161 ; HLP("HLTCPI") = ien of initial message
162 ; HLP("ACKTIME") = acknowledge timeout override for this message
163 ; HLP("NAMESPACE") = Passed in by application namespace - HL*1.6*91
164 ;
165 ;Check for required parameters
166 I '$G(MTIEN)!($G(HLMT)']"") Q
167 ;File new status info
168 N HLJ,HLOCK,X,Y
169 ;if TCP update status in file 773, else status in file 772
170 S Y=$D(HLTCP)
171 I Y S X="HLJ(773,",HLOCK="^HLMA("
172 E S X="HLJ(772,",HLOCK="^HL(772,"
173 ;transmission type
174 S X=X_""""_MTIEN_","")",HLOCK=HLOCK_MTIEN_")",@X@($S(Y:3,1:4))=HLMT
175 ;sending or server application
176 S:$G(SERVER) @X@($S(Y:13,1:2))=SERVER
177 ;receiving or client application
178 S:$G(CLIENT) @X@($S(Y:14,1:3))=CLIENT
179 ;acknowledgement to
180 S:$G(REPLYTO) @X@($S(Y:12,1:7))=REPLYTO
181 ;parent message
182 S:$G(MTIENP) @X@(8)=MTIENP
183 ;priority
184 S:$G(PRIORITY)]"" @X@($S(Y:4,1:9))=PRIORITY
185 ;related event protocol
186 S:$G(EID) @X@($S(Y:8,1:10))=EID
187 ;logical link
188 S:$G(LOGLINK) @X@($S(Y:7,1:11))=LOGLINK
189 ;security
190 S:$G(HLP("SECURITY"))]"" @X@($S(Y:9,1:12))=HLP("SECURITY")
191 ;namespace - HL*1.6*91
192 I HLOCK["HL(772" S:$G(HLP("NAMESPACE"))?1U1.3UN @X@(16)=HLP("NAMESPACE") ;HL*1.6*91
193 ;message type
194 S:$G(HLP("MSGTYPE"))]"" @X@($S(Y:5,1:14))=HLP("MSGTYPE")
195 ;continuation pointer
196 S:$G(HLP("CONTPTR"))]"" @X@($S(Y:11,1:13))=HLP("CONTPTR")
197 ;ack timeout override
198 S:$G(HLP("ACKTIME")) @X@(26)=HLP("ACKTIME")
199 ;only for file 773
200 I Y D
201 . ;initial message
202 . S:$G(HLP("HLTCPI")) @X@(6)=HLP("HLTCPI")
203 . ;message type
204 . S:$G(HLP("MTYPE")) @X@(15)=HLP("MTYPE")
205 . ;event type
206 . S:$G(HLP("EVENT")) @X@(16)=HLP("EVENT")
207 ;**109** F L +@HLOCK:1 Q:$T H 1
208 D FILE^HLDIE("","HLJ","","UPDATE","HLTF0") ; HL*1.6*109
209 ;**109** L -@HLOCK
210 Q
Note: See TracBrowser for help on using the repository browser.