[613] | 1 | OCXOCMPM ;SLC/RJS,CLA - ORDER CHECK CODE COMPILER (Compile Rule Element MetaCode) ;10/29/98 12:37
|
---|
| 2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32**;Dec 17,1997
|
---|
| 3 | ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
|
---|
| 4 | ;
|
---|
| 5 | EN() ;
|
---|
| 6 | ;
|
---|
| 7 | Q:$G(OCXWARN) 1
|
---|
| 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 OCXD1,OCXREC,OCXDFC,OCXCNT,OCXFCODE,OCXDFL,OCXSCAN
|
---|
| 11 | .S (OCXFCODE,OCXDFL)=""
|
---|
| 12 | .;
|
---|
| 13 | .I '$G(OCXAUTO) W:($X>60) ! W "."
|
---|
| 14 | .;
|
---|
| 15 | .M OCXREC=^OCXS(860.3,OCXEL) Q:'$D(OCXREC(0))
|
---|
| 16 | .S OCXNAM=$P(OCXREC(0),U,1) Q:'$L(OCXNAM)
|
---|
| 17 | .S OCXCON=$P(OCXREC(0),U,2) I '(OCXCON) D WARN^OCXOCMPV("Context not defined for Element...",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 18 | .I '(OCXCON) D WARN^OCXOCMPV("Context not defined for Element...",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 19 | .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
|
---|
| 20 | .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
|
---|
| 21 | .;
|
---|
| 22 | .I (OCXTRACE) D FILECODE("W:$G(OCXTRACE) !,||LNTAG||,?27,""Metacode Function MCE"_OCXEL_"() Execution trace. ""","Y")
|
---|
| 23 | .D FILECODE("N OCXRES","Y")
|
---|
| 24 | .D FILECODE("Q:'(|PATIENT IEN|) 0 I $D(^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_")) Q $G(^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_"))","Y")
|
---|
| 25 | .;
|
---|
| 26 | .I '(OCXCON=OCXDLK) D FILECODE("Q 0","Y")
|
---|
| 27 | .;
|
---|
| 28 | .I (OCXCON=OCXDLK) D
|
---|
| 29 | ..;
|
---|
| 30 | ..D FILECODE("S OCXRES("_(+OCXEL)_")=0","S")
|
---|
| 31 | ..;
|
---|
| 32 | ..; SORT PRIMARY DATA FIELDS
|
---|
| 33 | ..;
|
---|
| 34 | ..S OCXD1=0 F S OCXD1=$O(OCXREC("COND",OCXD1)) Q:'OCXD1 D
|
---|
| 35 | ...N OCXDF,OCXSUB
|
---|
| 36 | ...F OCXSUB=1,2,3 D
|
---|
| 37 | ....N OCXFREC S OCXDF=+$G(OCXREC("COND",OCXD1,"DFLD"_OCXSUB)) Q:'OCXDF
|
---|
| 38 | ....M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF)
|
---|
| 39 | ....I '$D(OCXFREC(OCXCON)) S OCXFREC=OCXFREC-99999
|
---|
| 40 | ....I OCXDF,OCXFREC S OCXDFC(OCXFREC,OCXD1)=OCXDF,OCXDFL(OCXDF)=""
|
---|
| 41 | ..;
|
---|
| 42 | ..;
|
---|
| 43 | ..; GET PRIMARY DATA FIELD'S 'GET CODE'
|
---|
| 44 | ..;
|
---|
| 45 | ..S OCXCNT="" F S OCXCNT=$O(OCXDFC(OCXCNT),-1) Q:'OCXCNT D
|
---|
| 46 | ...S OCXD1=0 F S OCXD1=$O(OCXDFC(OCXCNT,OCXD1)) Q:'OCXD1 D Q:OCXWARN
|
---|
| 47 | ....N OCXDF,OCXD2,OCXFREC
|
---|
| 48 | ....S OCXDF=+$G(OCXDFC(OCXCNT,OCXD1)) Q:'OCXDF
|
---|
| 49 | ....I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
|
---|
| 50 | ....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
|
---|
| 51 | ....S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 D FILECODE($G(OCXFREC(OCXD2)))
|
---|
| 52 | ....;
|
---|
| 53 | ....; GET EXPRESSION CONDITIONAL EVALUATION CODE
|
---|
| 54 | ....;
|
---|
| 55 | ....I $D(OCXFREC) D
|
---|
| 56 | .....N OCXCOD1,OCXCOD2,OCXCVAL,OCXFLDG,OCXFLDN,OCXFLDP,OCXFLDS,OCXDFLD
|
---|
| 57 | .....N OCXNAM,OCXOPER,OCXOPC,OCXD2,OCXD3,OCXP,OCXP1,OCXP2,OCXP3
|
---|
| 58 | .....;
|
---|
| 59 | .....S OCXOPER=$G(OCXREC("COND",OCXD1,"OPER"))
|
---|
| 60 | .....I '(OCXOPER) D WARN^OCXOCMPV("Operator/Function not defined...",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 61 | .....S OCXOPN=$P($G(^OCXS(863.9,OCXOPER,0)),U,1),OCXOPDT=$P($G(^OCXS(863.9,OCXOPER,0)),U,2)
|
---|
| 62 | .....I '(OCXOPDT) D WARN^OCXOCMPV("Data Type not defined for '"_OCXOPN_"' Operator",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 63 | .....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
|
---|
| 64 | .....;
|
---|
| 65 | .....S OCXOPC=$$GETPARM^OCXOCMPE(39,OCXOPER,"OCXO GENERATE CODE FUNCTION")
|
---|
| 66 | .....I '$L(OCXOPC) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' parameter not defined",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 67 | .....S:'(OCXOPC=+OCXOPC) OCXOPC=$$GETIEN("^OCXS(863.7)",OCXOPC)
|
---|
| 68 | .....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
|
---|
| 69 | .....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
|
---|
| 70 | .....S OCXD2=0 F S OCXD2=$O(^OCXS(863.7,+OCXOPC,"PAR",OCXD2)) Q:'OCXD2 D
|
---|
| 71 | ......N OCXPOS,OCXVNAM
|
---|
| 72 | ......S OCXPOS=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,"IN")) Q:'OCXPOS Q:$D(OCXP(OCXPOS))
|
---|
| 73 | ......S OCXVNAM=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,0)) Q:'OCXVNAM
|
---|
| 74 | ......S OCXVNAM=$P($G(^OCXS(863.8,+OCXVNAM,0)),U,2) Q:'$L(OCXVNAM)
|
---|
| 75 | ......S OCXP(+OCXPOS)=OCXVNAM,OCXP(OCXVNAM)=""
|
---|
| 76 | ......;
|
---|
| 77 | .....D GETC^OCXOCMPE(OCXEL,OCXD1,.OCXP)
|
---|
| 78 | ..D FILECODE("E Q 0","Y")
|
---|
| 79 | ..;
|
---|
| 80 | ..; GATHER OUTPUT DATA FOR THIS ELEMENT-EVENT
|
---|
| 81 | ..;
|
---|
| 82 | ..S OCXDF=0 F S OCXDF=$O(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF)) Q:'OCXDF D
|
---|
| 83 | ...N OCXCON,OCXFREC S OCXCON=$P($G(^OCXS(860.3,OCXEL,0)),U,2)
|
---|
| 84 | ...I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXDLK)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXDLK)
|
---|
| 85 | ...E D
|
---|
| 86 | ....I '$G(OCXAUTO) D
|
---|
| 87 | .....W !
|
---|
| 88 | .....W !,"Database Lookup Method not defined for:"
|
---|
| 89 | .....W !," '"_$P($G(^OCXS(860.3,+OCXEL,0)),U,1)_"'"
|
---|
| 90 | .....W !," ( "_(+OCXDF)_" ) "_$P($G(^OCXS(860.4,+OCXDF,0)),U,1)
|
---|
| 91 | ....M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
|
---|
| 92 | ...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
|
---|
| 93 | ...S OCXDFL(OCXDF)=+$G(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF))
|
---|
| 94 | ...S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 I $L($G(OCXFREC(OCXD2))) D
|
---|
| 95 | ....D FILECODE(OCXFREC(OCXD2),$G(OCXFREC(OCXD2,"OPLIST")))
|
---|
| 96 | ..;
|
---|
| 97 | ..; FILE ELEMENT-EVENT IN ACTIVE PATIENT DATA FILE
|
---|
| 98 | ..;
|
---|
| 99 | ..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:"")
|
---|
| 100 | ..;
|
---|
| 101 | ..D FILECODE("S OCXRES("_(+OCXEL)_")=11","S")
|
---|
| 102 | ..D FILECODE("M ^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_")=OCXRES("_(+OCXEL)_")","M")
|
---|
| 103 | ..D FILECODE("Q +OCXRES("_(+OCXEL)_")","Y")
|
---|
| 104 | .;
|
---|
| 105 | .; RESOLVE EXTRINSIC FUNCTON RUNTIME PARAMETERS
|
---|
| 106 | .;
|
---|
| 107 | .F D Q:'OCXSCAN Q:OCXWARN
|
---|
| 108 | ..S (OCXSCAN,OCXD2)=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 I $L(OCXFCODE(OCXD2)),(OCXFCODE(OCXD2)["|") D
|
---|
| 109 | ...N OCXPIEC,DFNAM,DFNUM,DFCODE
|
---|
| 110 | ...S DFCODE=OCXFCODE(OCXD2)
|
---|
| 111 | ...F OCXPIEC=2:2:$L(DFCODE,"|") S DFNAM=$P($P(DFCODE,"|",OCXPIEC),"|",1) I $L(DFNAM),'(DFNAM["""") S DFNAM(DFNAM)=""
|
---|
| 112 | ...S DFNAM="" F S DFNAM=$O(DFNAM(DFNAM)) Q:'$L(DFNAM) D
|
---|
| 113 | ....N DFBNAM,DFNUM,OCXFREC,OCXD3
|
---|
| 114 | ....S DFBNAM="|"_DFNAM_"|",OCXSCAN=1
|
---|
| 115 | ....S DFNUM=+$O(^OCXS(860.4,"B",DFNAM,0))
|
---|
| 116 | ....I 'DFNUM S DFNUM=+$O(^OCXS(860.4,"C",DFNAM,0))
|
---|
| 117 | ....I 'DFNUM D WARN^OCXOCMPV("Data field argument '"_DFNAM_"' not defined in Data Field file...",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 118 | ....I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)
|
---|
| 119 | ....E I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)
|
---|
| 120 | ....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
|
---|
| 121 | ....I '$D(OCXFREC) D WARN^OCXOCMPV("Data field '"_DFNAM_"' get code not defined for '"_OCXCONN_" context...",3,OCXEL,$P($T(+1)," ",1)) Q
|
---|
| 122 | ....S OCXFREC($O(OCXFREC(99999),-1)+1)="I $L(OCXDF("_(+DFNUM)_"))"
|
---|
| 123 | ....S OCXD3=0 F S OCXD3=$O(OCXFREC(OCXD3)) Q:'OCXD3 D FILECODE($G(OCXFREC(OCXD3)),$G(OCXFREC(OCXD3,"OPLIST")),OCXD2)
|
---|
| 124 | ....F Q:'(DFCODE[DFBNAM) S DFCODE=$P(DFCODE,DFBNAM,1)_"OCXDF("_(+DFNUM)_")"_$P(DFCODE,DFBNAM,2,999)
|
---|
| 125 | ...S OCXFCODE(OCXD2)=DFCODE
|
---|
| 126 | ..;
|
---|
| 127 | ..; PURGE REDUNDANT CODE
|
---|
| 128 | ..;
|
---|
| 129 | ..S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
---|
| 130 | ...I (OCXFCODE(OCXD2)="||NOOP||") K OCXFCODE(OCXD2) Q
|
---|
| 131 | ...I '$D(OCXFCODE(OCXD2,"OPLIST")) D
|
---|
| 132 | ....I '(OCXFCODE(OCXD2)["OCXTRACE") S OCXFCODE(OCXD2,"OPLIST")=$E(OCXFCODE(OCXD2),1)
|
---|
| 133 | ....E S OCXFCODE(OCXD2,"OPLIST")="Y"
|
---|
| 134 | ...S OCXD3=OCXD2 F S OCXD3=$O(OCXFCODE(OCXD3)) Q:'OCXD3 D
|
---|
| 135 | ....Q:(OCXFCODE(OCXD2)["OCXBOOLV")
|
---|
| 136 | ....I (OCXFCODE(OCXD2)=OCXFCODE(OCXD3)) K OCXFCODE(OCXD3)
|
---|
| 137 | ..D REINDEX(.OCXFCODE,0)
|
---|
| 138 | .;
|
---|
| 139 | .; SAVE CODE IN ^TMP GLOBAL
|
---|
| 140 | .;
|
---|
| 141 | .D MC^OCXOCMPN(.OCXFCODE,OCXEL)
|
---|
| 142 | .;
|
---|
| 143 | .D REINDEX(.OCXFCODE,2)
|
---|
| 144 | .S OCXCOD0="MCE"_OCXEL
|
---|
| 145 | .S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
---|
| 146 | ..K OCXFCODE(OCXD2,"OPLIST")
|
---|
| 147 | ..S OCXFCODE(OCXD2)=" "_OCXFCODE(OCXD2)
|
---|
| 148 | .S OCXFCODE(1)=OCXCOD0_"() ; Verify Event/Element: "_$P($G(^OCXS(860.3,+OCXEL,0)),U,1)
|
---|
| 149 | .S OCXFCODE(2)=" ;"
|
---|
| 150 | .S OCXFCODE($O(OCXFCODE(" "),-1)+1)=" ;"
|
---|
| 151 | .S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
---|
| 152 | ..N TEMP
|
---|
| 153 | ..S TEMP=OCXFCODE(OCXD2)
|
---|
| 154 | ..K OCXFCODE(OCXD2)
|
---|
| 155 | ..S OCXFCODE(OCXD2,0)=TEMP
|
---|
| 156 | .M ^TMP("OCXCMP",$J,"INCLUDE",OCXCOD0)=OCXFCODE
|
---|
| 157 | ;
|
---|
| 158 | Q OCXWARN
|
---|
| 159 | ;
|
---|
| 160 | GETIEN(FILE,KEY) ;
|
---|
| 161 | ;
|
---|
| 162 | N IEN1,IEN2,LEN,SHORT
|
---|
| 163 | F LEN=$L(KEY):-1:0 I LEN Q:$D(@FILE@("B",$E(KEY,1,LEN)))
|
---|
| 164 | Q:'LEN 0 S SHORT=$E(KEY,1,LEN)
|
---|
| 165 | S IEN1=0 F S IEN1=$O(@FILE@("B",SHORT,IEN1)) Q:'IEN1 Q:($P($G(@FILE@(IEN1,0)),U,1)=KEY)
|
---|
| 166 | S IEN2=IEN1 F S IEN2=$O(@FILE@("B",SHORT,IEN2)) Q:'IEN2 Q:($P($G(@FILE@(IEN2,0)),U,1)=KEY)
|
---|
| 167 | ;
|
---|
| 168 | I IEN1,IEN2 Q -1
|
---|
| 169 | Q IEN1
|
---|
| 170 | ;
|
---|
| 171 | REINDEX(ARRAY,NDX2) ;
|
---|
| 172 | ;
|
---|
| 173 | N TEMP,NDX1 M TEMP=ARRAY K ARRAY
|
---|
| 174 | S NDX1="" F S NDX1=$O(TEMP(NDX1)) Q:'$L(NDX1) D
|
---|
| 175 | .I $L(TEMP(NDX1)) S NDX2=NDX2+1 M ARRAY(NDX2)=TEMP(NDX1)
|
---|
| 176 | Q
|
---|
| 177 | ;
|
---|
| 178 | FILECODE(CODE,OPLIST,INDEX) ;
|
---|
| 179 | ;
|
---|
| 180 | N OCXNDX
|
---|
| 181 | I $G(INDEX) D
|
---|
| 182 | .N PREV,HALF
|
---|
| 183 | .S PREV=$O(OCXFCODE(INDEX),-1),HALF=INDEX-PREV/2
|
---|
| 184 | .S OCXNDX=INDEX-HALF
|
---|
| 185 | E S OCXNDX=$O(OCXFCODE(""),-1)+1
|
---|
| 186 | S OCXFCODE(OCXNDX)=CODE
|
---|
| 187 | S:$L($G(OPLIST)) OCXFCODE(OCXNDX,"OPLIST")=OPLIST
|
---|
| 188 | Q
|
---|
| 189 | ;
|
---|