source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOCMP2.m@ 1806

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

initial load of FOIAVistA 6/30/08 version

File size: 9.2 KB
Line 
1OCXOCMP2 ;SLC/RJS,CLA - ORDER CHECK CODE COMPILER (Compile Rule Element Evaluation Code) ;3/20/01 16:12
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,105**;Dec 17,1997
3 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
4 ;
5EN() ;
6 ;
7 Q:$G(OCXWARN) OCXWARN
8 S OCXDLK=$O(^OCXS(860.6,"B","DATABASE LOOKUP",0))
9 S OCXEL=0 F S OCXEL=$O(^TMP("OCXCMP",$J,"ELEMENT",OCXEL)) Q:'OCXEL D Q:OCXWARN
10 .N OCXD0,OCXD1,OCXREC,OCXDFC,OCXCF,OCXCNT1,OCXCNT2,OCXFCODE,OCXDFL,OCXSCAN,OCXSORT
11 .S (OCXFCODE,OCXDFL)=""
12 .K OCXREC M OCXREC=^OCXS(860.3,OCXEL) Q:'$D(OCXREC(0))
13 .S OCXNAM=$P(OCXREC(0),U,1) Q:'$L(OCXNAM)
14 .S OCXCON=$P(OCXREC(0),U,2) I '(OCXCON) D WARN^OCXOCMPV("Context not defined for Element...",3,OCXEL,$P($T(+1)," ",1)) Q
15 .Q:(OCXCON=OCXDLK)
16 .S OCXCONN=$P($G(^OCXS(860.6,+OCXCON,0)),U,1) I '$L(OCXCONN) D WARN^OCXOCMPV("Data context a '"_OCXCON_"' not defined in Data Context file...",4,OCXDF,$P($T(+1)," ",1)) Q
17 .S OCXCONA=$P($G(^OCXS(860.6,+OCXCON,0)),U,2) I '$L(OCXCONA) D WARN^OCXOCMPV("Data context abbreviation for '"_OCXCONN_"' not defined in Data Context file...",4,OCXDF,$P($T(+1)," ",1)) Q
18 .;
19 .I (OCXCONN="TIMED ORDER CHECK") D I 1
20 ..D FILECODE("I ($G(OCXOSRC)="""_OCXCONN_"""),($D(OCXOSRC(""ELEMENT"","_OCXEL_")))","Y")
21 .E D FILECODE("I ($G(OCXOSRC)="""_OCXCONN_""")","Y")
22 .;
23 .I '$G(OCXAUTO) W:($X>60) ! W "."
24 .K OCXSORT
25 .S OCXD1=0 F S OCXD1=$O(OCXREC("COND",OCXD1)) Q:'OCXD1 D Q:OCXWARN
26 ..N OCXSUB
27 ..F OCXSUB=1,2,3 D Q:OCXWARN
28 ...N OCXDF,OCXFREC,OCXCNT
29 ...S OCXDF=+$G(OCXREC("COND",OCXD1,"DFLD"_OCXSUB)) Q:'OCXDF
30 ...K OCXFREC M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF)
31 ...S OCXCNT=+$G(OCXFREC)
32 ...I '$D(OCXFREC(OCXCON)) S OCXCNT=OCXCNT+99999 I '$D(OCXFREC(OCXDLK)) D Q
33 ....D WARN^OCXOCMPV("Cannot resolve Navigation code for Data Field "_OCXCONN_" context...",4,OCXDF,$P($T(+1)," ",1)) Q
34 ...S OCXSORT(OCXD1)=$G(OCXSORT(OCXD1))+OCXCNT
35 ...S OCXSORT(OCXD1,OCXCNT,OCXDF)=""
36 .;
37 .S OCXD1=0 F S OCXD1=$O(OCXSORT(OCXD1)) Q:'OCXD1 S OCXSORT("A",OCXSORT(OCXD1),OCXD1)=""
38 .;
39 .Q:OCXWARN
40 .;
41 .; GET PRIMARY DATA FIELD'S 'GET CODE'
42 .;
43 .S OCXCNT1=0 F S OCXCNT1=$O(OCXSORT("A",OCXCNT1)) Q:'OCXCNT1 D
44 ..S OCXD1=0 F S OCXD1=$O(OCXSORT("A",OCXCNT1,OCXD1)) Q:'OCXD1 D Q:OCXWARN
45 ...N OCXDF,OCXD2,OCXFREC K OCXFREC
46 ...S OCXCNT2=0 F S OCXCNT2=$O(OCXSORT(OCXD1,OCXCNT2)) Q:'OCXCNT2 D Q:OCXWARN
47 ....S OCXDF=0 F S OCXDF=$O(OCXSORT(OCXD1,OCXCNT2,OCXDF)) Q:'OCXDF D Q:OCXWARN
48 .....I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
49 .....E S OCXD2=0 F S OCXD2=$O(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXD2)) Q:'OCXD2 I $G(^(OCXD2,"DA MODE")) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXD2) Q
50 .....S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 D FILECODE($G(OCXFREC(OCXD2)))
51 ...;
52 ...; GET EXPRESSION CONDITIONAL EVALUATION CODE
53 ...;
54 ...Q:'$D(OCXFREC)
55 ...N OCXCOD1,OCXCOD2,OCXCVAL,OCXFLDG,OCXFLDN,OCXFLDP,OCXFLDS,OCXDFLD
56 ...N OCXNAM,OCXOPER,OCXOPC,OCXD2,OCXD3,OCXP,OCXP1,OCXP2,OCXP3
57 ...S OCXOPER=$G(OCXREC("COND",OCXD1,"OPER"))
58 ...I '(OCXOPER) D WARN^OCXOCMPV("Operator/Function not defined...",3,OCXEL,$P($T(+1)," ",1)) Q
59 ...S OCXOPN=$P($G(^OCXS(863.9,OCXOPER,0)),U,1),OCXOPDT=$P($G(^OCXS(863.9,OCXOPER,0)),U,2)
60 ...I '(OCXOPDT) D WARN^OCXOCMPV("Data Type not defined for '"_OCXOPN_"' Operator",3,OCXEL,$P($T(+1)," ",1)) Q
61 ...I '$L($G(^OCXS(864.1,+OCXOPDT,0))) D WARN^OCXOCMPV("Data Type '"_OCXOPDT_"' not defined for '"_OCXOPN_"' Operator",3,OCXEL,$P($T(+1)," ",1)) Q
62 ...S OCXOPC=$$GETPARM^OCXOCMPE(39,OCXOPER,"OCXO GENERATE CODE FUNCTION")
63 ...I '$L(OCXOPC) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' parameter not defined",3,OCXEL,$P($T(+1)," ",1)) Q
64 ...S:'(OCXOPC=+OCXOPC) OCXOPC=$$GETIEN("^OCXS(863.7)",OCXOPC)
65 ...I '$D(^OCXS(863.7,+OCXOPC,0)) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' Public Function not defined",3,OCXEL,$P($T(+1)," ",1)) Q
66 ...S OCXP=$G(^OCXS(863.7,+OCXOPC,"EX")) I '$L(OCXP) D WARN^OCXOCMPV("Operator ("_(+OCXOPC)_") '"_$P($G(^OCXS(863.9,+OCXOPC,0)),U,1)_"' executable not defined",3,OCXEL,$P($T(+1)," ",1)) Q
67 ...S OCXD2=0 F S OCXD2=$O(^OCXS(863.7,+OCXOPC,"PAR",OCXD2)) Q:'OCXD2 D
68 ....N OCXPOS,OCXVNAM
69 ....S OCXPOS=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,"IN")) Q:'OCXPOS Q:$D(OCXP(OCXPOS))
70 ....S OCXVNAM=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,0)) Q:'OCXVNAM
71 ....S OCXVNAM=$P($G(^OCXS(863.8,+OCXVNAM,0)),U,2) Q:'$L(OCXVNAM)
72 ....S OCXP(+OCXPOS)=OCXVNAM,OCXP(OCXVNAM)=""
73 ....;
74 ...D GETC^OCXOCMPE(OCXEL,OCXD1,.OCXP)
75 .;
76 .; GATHER OUTPUT DATA FOR THIS ELEMENT-EVENT
77 .;
78 .S OCXDF=0 F S OCXDF=$O(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF)) Q:'OCXDF D
79 ..N OCXCON,OCXFREC S OCXCON=$P($G(^OCXS(860.3,OCXEL,0)),U,2)
80 ..I 'OCXCON D WARN^OCXOCMPV("CMP2 Data context not defined for '"_$P($G(^OCXS(860.3,+OCXEL,0)),U,1)_"' ( "_(+OCXDF)_" )",2,OCXEL,$P($T(+1)," ",1)) Q
81 ..I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
82 ..E M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXDLK)
83 ..I '$L($G(OCXFREC("G"))) D WARN^OCXOCMPV("CMP2 Get data code not defined for '"_$P($G(^OCXS(860.4,+OCXDF,0)),U,1)_"' ( "_(+OCXDF)_" )",2,OCXEL,$P($T(+1)," ",1)) Q
84 ..S OCXDFL(OCXDF)=+$G(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF))
85 ..S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 I $L($G(OCXFREC(OCXD2))) D
86 ...D FILECODE(OCXFREC(OCXD2),$G(OCXFREC(OCXD2,"OPLIST")))
87 ..;
88 .;
89 .; FILE ELEMENT-EVENT IN ACTIVE PATIENT DATA FILE
90 .;
91 .S OCXDFL="",OCXDF=0 F S OCXDF=$O(OCXDFL(OCXDF)) Q:'OCXDF S:$L(OCXDFL) OCXDFL=OCXDFL_"," S OCXDFL=OCXDFL_OCXDF_$S(OCXDFL(OCXDF):"X",1:"")
92 .;
93 .I OCXTLOG D
94 ..N OCXX,OPCODE
95 ..S OCXX="S OCXOERR=$$TIMELOG(""O"",""FILE"")"
96 ..S OCXX=OCXX_",OCXOERR=$$FILE(DFN,"_OCXEL_","""_OCXDFL_""")"
97 ..S OCXX=OCXX_",OCXOERR=$$TIMELOG(""I"",""FILE"")"
98 ..D FILECODE(OCXX,"SHS")
99 .I 'OCXTLOG D FILECODE("S OCXOERR=$$FILE(DFN,"_OCXEL_","""_OCXDFL_""") Q:OCXOERR ","SQ")
100 .;
101 .; RESOLVE EXTRINSIC FUNCTON RUNTIME PARAMETERS
102 .;
103 .S OCXSCAN=0 F D Q:'OCXSCAN Q:OCXWARN
104 ..S OCXSCAN=0 S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 I $L(OCXFCODE(OCXD2)),(OCXFCODE(OCXD2)["|") D
105 ...N OCXPIEC,DFNAM,DFNUM,DFCODE
106 ...S DFCODE=OCXFCODE(OCXD2)
107 ...F OCXPIEC=2:2:$L(DFCODE,"|") S DFNAM=$P($P(DFCODE,"|",OCXPIEC),"|",1) I $L(DFNAM),'(DFNAM["""") S DFNAM(DFNAM)=""
108 ...S DFNAM="" F S DFNAM=$O(DFNAM(DFNAM)) Q:'$L(DFNAM) D
109 ....N DFBNAM,DFNUM,OCXFREC,OCXD3
110 ....S DFBNAM="|"_DFNAM_"|",OCXSCAN=1
111 ....S DFNUM=+$O(^OCXS(860.4,"B",DFNAM,0))
112 ....I 'DFNUM S DFNUM=+$O(^OCXS(860.4,"C",DFNAM,0))
113 ....I 'DFNUM D WARN^OCXOCMPV("Data field argument '"_DFNAM_"' not defined in Data Field file...",3,OCXEL,$P($T(+1)," ",1)) Q
114 ....I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)
115 ....E I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)
116 ....E S OCXD3=0 F S OCXD3=$O(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXD3)) Q:'OCXD3 I $G(^(OCXD3,"DA MODE")) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXD3) Q
117 ....I '$D(OCXFREC) D WARN^OCXOCMPV("Data field '"_DFNAM_"' get code not defined for '"_OCXCONN_" context...",3,OCXEL,$P($T(+1)," ",1)) Q
118 ....S OCXFREC($O(OCXFREC(99999),-1)+1)="I $L(OCXDF("_(+DFNUM)_"))"
119 ....S OCXD3=0 F S OCXD3=$O(OCXFREC(OCXD3)) Q:'OCXD3 D FILECODE($G(OCXFREC(OCXD3)),$G(OCXFREC(OCXD3,"OPLIST")),OCXD2)
120 ....F Q:'(DFCODE[DFBNAM) S DFCODE=$P(DFCODE,DFBNAM,1)_"OCXDF("_(+DFNUM)_")"_$P(DFCODE,DFBNAM,2,999)
121 ...S OCXFCODE(OCXD2)=DFCODE
122 ..;
123 ..; PURGE REDUNDANT CODE
124 ..;
125 ..D PURGE(.OCXFCODE)
126 .;
127 .I (OCXTLOG) S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 I (OCXFCODE(OCXD2)["$$"),'(OCXFCODE(OCXD2)["$$TIMELOG") D
128 ..N OCXX,OPCODE
129 ..S OPCODE=$E(OCXFCODE(OCXD2),1)
130 ..S OCXX="S OCXOERR=$$TIMELOG(""O"","""_$P($P(OCXFCODE(OCXD2),"$$",2)_"(","(",1)_""")"
131 ..S OCXX=OCXX_" "_OCXFCODE(OCXD2)
132 ..S OCXX=OCXX_" S OCXOERR=$$TIMELOG(""I"","""_$P($P(OCXFCODE(OCXD2),"$$",2)_"(","(",1)_""")"
133 ..S OCXFCODE(OCXD2)=OCXX
134 ..S OCXFCODE(OCXD2,"OPLIST")="SH"_OPCODE_"S"
135 .;
136 .;
137 .; PURGE AND REINDEX CODE
138 .;
139 .D PURGE(.OCXFCODE)
140 .;
141 .; SAVE CODE IN ^TMP GLOBAL
142 .;
143 .S OCXCOD0=$O(^TMP("OCXCMP",$J,"A CODE",99999),-1)+1
144 .;
145 .M ^TMP("OCXCMP",$J,"A CODE",OCXCOD0)=OCXFCODE
146 .S ^TMP("OCXCMP",$J,"A CODE",OCXCOD0)=OCXEL
147 .S ^TMP("OCXCMP",$J,"A CODE","B",OCXEL,OCXCOD0)=""
148 ;
149 Q OCXWARN
150 ;
151PURGE(CODE) ;
152 ;
153 N D0,D1
154 ;
155 S D0=0 F S D0=$O(CODE(D0)) Q:'D0 D
156 .I (CODE(D0)="||NOOP||") K CODE(D0) Q
157 .S:'$D(CODE(D0,"OPLIST")) CODE(D0,"OPLIST")=$E(CODE(D0),1)
158 .S D1=D0 F S D1=$O(CODE(D1)) Q:'D1 D
159 ..Q:(CODE(D0)["OCXBOOLV")
160 ..I (CODE(D0)=CODE(D1)) K CODE(D1)
161 D REINDEX(.CODE)
162 Q
163 ;
164GETIEN(FILE,KEY) ;
165 ;
166 N IEN1,IEN2,LEN,SHORT
167 F LEN=$L(KEY):-1:0 I LEN Q:$D(@FILE@("B",$E(KEY,1,LEN)))
168 Q:'LEN 0 S SHORT=$E(KEY,1,LEN)
169 S IEN1=0 F S IEN1=$O(@FILE@("B",SHORT,IEN1)) Q:'IEN1 Q:($P($G(@FILE@(IEN1,0)),U,1)=KEY)
170 S IEN2=IEN1 F S IEN2=$O(@FILE@("B",SHORT,IEN2)) Q:'IEN2 Q:($P($G(@FILE@(IEN2,0)),U,1)=KEY)
171 I IEN1,IEN2 Q -1
172 Q IEN1
173 ;
174REINDEX(ARRAY) ;
175 ;
176 N TEMP,NDX1,NDX2 M TEMP=ARRAY K ARRAY
177 S (NDX1,NDX2)="" F S NDX1=$O(TEMP(NDX1)) Q:'$L(NDX1) I $L(TEMP(NDX1)) S NDX2=NDX2+1 M ARRAY(NDX2)=TEMP(NDX1)
178 Q
179 ;
180FILECODE(CODE,OPLIST,INDEX) ;
181 ;
182 N OCXNDX
183 I $G(INDEX) D
184 .N PREV,HALF
185 .S PREV=$O(OCXFCODE(INDEX),-1),HALF=INDEX-PREV/2
186 .S OCXNDX=INDEX-HALF
187 E S OCXNDX=$O(OCXFCODE(""),-1)+1
188 S OCXFCODE(OCXNDX)=CODE
189 S:$L($G(OPLIST)) OCXFCODE(OCXNDX,"OPLIST")=OPLIST
190 Q
191 ;
Note: See TracBrowser for help on using the repository browser.