source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOHL7.m@ 1722

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

initial load of WorldVistAEHR

File size: 5.4 KB
Line 
1OCXOHL7 ;SLC/RJS,CLA - External Interface - PROCESS HL7 DATA ARRAY ;4/02/03 13:50
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,179**;Dec 17,1997
3 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
4 ;
5 ;
6 Q
7SILENT(OCXMSG,OUTMSG) ;
8 ;
9 N OCXSEG0,OCXRDT,OCXHL7,OCXOZZT
10 S OCXRDT=($H*86400+$P($H,",",2))
11 S:'$D(OUTMSG) OUTMSG=""
12 D CHECK(.OCXMSG,.OUTMSG)
13 Q
14 ;
15VERBOSE(OCXMSG) ;
16 ;
17 N OCXSEG0,OCXX,OUTMSG,OCXHL7,OCXOZZT
18 S OCXRDT=($H*86400+$P($H,",",2))
19 S OUTMSG=""
20 D CHECK(.OCXMSG,.OUTMSG)
21 W:$O(OUTMSG(0)) !,"Order Check Message: ",$C(7)
22 S OCXX=0 F S OCXX=$O(OUTMSG(OCXX)) Q:'OCXX W !,OUTMSG(OCXX)
23 W:$O(OUTMSG(0)) !,$C(7)
24 Q
25 ;
26CHECK(OCXMSG,OUTMSG) ;
27 ;
28 N OCXARY,OCXDFN,OCXEL,OCXODATA,OCXOLOG,OCXOSRC,OCXDSIZE
29 N OCXOTIME,OCXQUIT,OCXSEG0,OCXSEQ,OCXSUB,OCXTEST,OCXVAR
30 ;
31 I $$RTEST D Q
32 .N OMSG,OTMOUT,OCXM
33 .S OMSG="^25^^Order Checking is recompiling and momentarily disabled"
34 .S OCXM=0 F S OCXM=$O(OUTMSG(OCXM)) Q:'OCXM Q:(OUTMSG(OCXM)[OMSG)
35 .Q:OCXM
36 .S OUTMSG($O(OUTMSG(""),-1)+1)=OMSG
37 ;
38 S OCXARY=$S($L($G(OCXMSG)):OCXMSG,1:"OCXMSG") Q:'$O(@OCXARY@(0))
39 ;
40 S (OCXQUIT,OCXSUB)=0 F S OCXSUB=$O(@OCXARY@(OCXSUB)) Q:'OCXSUB I ($P($G(@OCXARY@(OCXSUB)),"|",1)="ORC") D Q
41 .S:($P($P($G(@OCXARY@(OCXSUB)),"|",2),"^",1)="ZC") OCXQUIT=1
42 ;
43 Q:OCXQUIT
44 ;
45 S OCXOLOG=$$LOG(OCXARY)
46 ;
47 S OCXODATA="",OCXTEST=$G(OCXOVRD)
48 ;
49 S OCXVAR("DUZ")=""
50 S OCXVAR("OCXMSG")=""
51 S OCXVAR("OCXARY")=""
52 S OCXOSRC="GENERIC HL7 MESSAGE ARRAY"
53 ;
54 S OCXSUB=0 F S OCXSUB=$O(@OCXARY@(OCXSUB)) Q:'OCXSUB D
55 .N OCXLINE,OCXPC,X,OCXTDAT,OCXCLIN,LASTPC
56 .S OCXDSIZE=$$ARYSIZE($NAME(@OCXARY@(OCXSUB)))
57 .;
58 .I (OCXDSIZE<5000) D Q:'$L($G(OCXLINE(0)))
59 ..M OCXLINE(0)=@OCXARY@(OCXSUB)
60 ..S OCXLINE(0,0)=OCXLINE(0) ; This will make first node consistent with continuation lines.
61 ..S OCXSEG=$P($G(OCXLINE(0)),"|",1)
62 .;
63 .I (OCXDSIZE>4999) D Q:'$L($G(^TMP($J,"OCXLDATA",0)))
64 ..K ^TMP($J,"OCXLDATA")
65 ..M ^TMP($J,"OCXLDATA",0)=@OCXARY@(OCXSUB)
66 ..S ^TMP($J,"OCXLDATA",0,0)=^TMP($J,"OCXLDATA",0) ; This will make first node consistent with continuation lines.
67 ..S OCXSEG=$P($G(^TMP($J,"OCXLDATA",0)),"|",1)
68 .;
69 .Q:'$L(OCXSEG)
70 .;
71 .I $D(OCXODATA(OCXSEG)) D ; This is another instance of this segment.
72 ..; Process current OCXODATA and reset OCXODATA for this new instance.
73 ..; Process OCXODATA
74 ..S OCXDFN=$$GETDFN(OCXARY) I $G(OCXDFN) D UPDATE^OCXOZ01(+OCXDFN,OCXOSRC,.OUTMSG)
75 ..;
76 ..; Reset OCXODATA
77 ..S OCXSEQ=+$G(OCXODATA(OCXSEG)) F Q:'OCXSEQ D S OCXSEQ=$O(OCXODATA(OCXSEQ))
78 ...S OCXSEG0=$G(OCXODATA(OCXSEQ)) Q:'$L(OCXSEG0)
79 ...K OCXODATA(OCXSEQ),OCXODATA(OCXSEG0)
80 .;
81 .S OCXODATA(OCXSUB)=OCXSEG ; Set OCXODATA 'cross reference'
82 .S OCXODATA(OCXSEG)=OCXSUB ; Set OCXODATA 'cross reference'
83 .;
84 .; Load this segment instance into OCXODATA
85 .;
86 .; OCXPC - Keeps track of which "|" piece we're on
87 .;
88 .I (OCXDSIZE<5000) D LOADATA(OCXSEG,"OCXLINE(0)")
89 .;
90 .I (OCXDSIZE>4999) D LOADATA(OCXSEG,$NAME(^TMP($J,"OCXLDATA",0)))
91 ;
92 S OCXDFN=$$GETDFN(OCXARY)
93 I $G(OCXDFN) D UPDATE^OCXOZ01(+OCXDFN,OCXOSRC,.OUTMSG) I 1 ; Process OCXODATA for the last segment
94 ;
95 D FINISH^OCXOLOG(OCXOLOG)
96 ;
97 K ^TMP($J,"OCXLDATA")
98 ;
99 Q
100 ;
101LOADATA(OCXSEG,OCXSD) ; Get '|' piece #OCXPC of OCXSD Segment Data array.
102 ;
103 N OCXTEXT,OCXPCNT,OCXD0,OCXD1
104 ;
105 Q:'$L(OCXSEG)
106 S OCXPCNT=0,OCXD0="" F S OCXD0=$O(@OCXSD@(OCXD0)) Q:'$L(OCXD0) D
107 .S OCXTEXT=$G(@OCXSD@(OCXD0))
108 .F OCXD1=1:1:$L(OCXTEXT) D
109 ..I ($E(OCXTEXT,OCXD1)="|") S OCXPCNT=OCXPCNT+1 Q
110 ..I ($L($G(OCXODATA(OCXSEG,OCXPCNT)))<241) S OCXODATA(OCXSEG,OCXPCNT)=$G(OCXODATA(OCXSEG,OCXPCNT))_$E(OCXTEXT,OCXD1)
111 ;
112 Q
113 ;
114RTEST() ; Does ^OCXOZ01 exist ?? Is it currently being compiled ??
115 N DATE,TMOUT
116 Q:'$L($T(^OCXOZ01)) 1
117 I '($P($G(^OCXD(861,1,0)),U,1)="SITE PREFERENCES") K ^OCXD(861,1) S ^OCXD(861,1,0)="SITE PREFERENCES"
118 S DATE=$P($G(^OCXD(861,1,0)),U,3)
119 I DATE,((+DATE)=(+$H)),(((+$P($H,",",2))-(+$P(DATE,",",2)))<1800) Q 1
120 Q 0
121 ;
122LOG(OCXARY) ;
123 ; Log Data Messages
124 ;
125 I $G(OCXTRACE),$$CDATA^OCXOZ01 W:$G(OCXTRACE) !," Raw Input Data: ",! D ZW(OCXARY) Q 0
126 Q:'$L($T(LOG^OCXOZ01)) 0 Q:'$$LOG^OCXOZ01 0
127 N OCXDFN,OCXNL
128 I '$O(@OCXARY@(0)) S OCXARY="OCXNL",OCXNL(1)="Null HL7 Data Array Found"
129 S OCXDFN=$$GETDFN(OCXARY)
130 Q $$NEW^OCXOLOG(OCXARY,"HL7",+$G(DUZ),+OCXDFN)
131 ;
132ARYSIZE(ARY) ; Get array size (Local or Global)
133 ;
134 N ARY1,SIZE
135 ;
136 S SIZE=0
137 ;
138 I '(ARY["^") F S ARY=$Q(@ARY) Q:'$L(ARY) S SIZE=SIZE+$L(@ARY)
139 ;
140 I (ARY["^") D
141 .S ARY=$NAME(@ARY),ARY1=ARY
142 .S:($E(ARY,$L(ARY))=")") ARY=$E(ARY,1,$L(ARY)-1)_","
143 .F S ARY1=$Q(@ARY1) Q:'$L(ARY1) Q:'(ARY1[ARY) S SIZE=SIZE+$L(@ARY1)
144 ;
145 Q SIZE
146 ;
147ZW(ARY) ; ZWrite an array (Local or Global)
148 ;
149 N ARY1
150 ;
151 I '(ARY["^") D Q
152 .F S ARY=$Q(@ARY) Q:'$L(ARY) W !,ARY," = ",@ARY
153 ;
154 I (ARY["^") D Q
155 .S ARY=$NAME(@ARY),ARY1=ARY
156 .S:($E(ARY,$L(ARY))=")") ARY=$E(ARY,1,$L(ARY)-1)_","
157 .F S ARY1=$Q(@ARY1) Q:'$L(ARY1) Q:'(ARY1[ARY) W !,ARY1," = ",@ARY1
158 ;
159 Q
160 ;
161ERROR Q
162 ;
163 ; **** Old Labels to insure backwards compatibility ****
164 ;
165 ;
166GETDFN(ARRAY) ; Returns the patient IEN from file 2.
167 ;
168 N OCXNDX,OCXARY,OCXP1,OCXP2,OCXP3
169 S OCXARY=$S($L($G(ARRAY)):ARRAY,1:"ARRAY")
170 S OCXNDX=0 F S OCXNDX=$O(@OCXARY@(OCXNDX)) Q:'OCXNDX I $P($G(@OCXARY@(OCXNDX)),"|",1)="PID" Q
171 Q:'OCXNDX 0
172 ;
173 S OCXP1=$P($G(@OCXARY@(OCXNDX)),"|",4)
174 S OCXP2=$P($G(@OCXARY@(OCXNDX)),"|",5)
175 S OCXP3=$P($G(@OCXARY@(OCXNDX)),"|",6)
176 ;
177 Q:(OCXP2["DPT(") +OCXP2
178 ;
179 I $L(OCXP3),($P($G(^DPT(+OCXP1,0)),U,1)=OCXP3) Q +OCXP1
180 ;
181 Q 0
182 ;
183 ; Old line label area.
184 ;
185PROC(OCXMSG,OUTMSG) ;
186 D SILENT(.OCXMSG,.OUTMSG)
187 Q
188 ;
189EN(OCXMSG) ;
190 D VERBOSE(.OCXMSG)
191 Q
192 ;
Note: See TracBrowser for help on using the repository browser.