190 lines
9.0 KiB
Mathematica
190 lines
9.0 KiB
Mathematica
|
OCXOCMPM ;SLC/RJS,CLA - ORDER CHECK CODE COMPILER (Compile Rule Element MetaCode) ;10/29/98 12:37
|
||
|
;;3.0;ORDER ENTRY/RESULTS REPORTING;**32**;Dec 17,1997
|
||
|
;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
|
||
|
;
|
||
|
EN() ;
|
||
|
;
|
||
|
Q:$G(OCXWARN) 1
|
||
|
S OCXDLK=$O(^OCXS(860.6,"B","DATABASE LOOKUP",0))
|
||
|
S OCXEL=0 F S OCXEL=$O(^TMP("OCXCMP",$J,"ELEMENT",OCXEL)) Q:'OCXEL D Q:OCXWARN
|
||
|
.N OCXD1,OCXREC,OCXDFC,OCXCNT,OCXFCODE,OCXDFL,OCXSCAN
|
||
|
.S (OCXFCODE,OCXDFL)=""
|
||
|
.;
|
||
|
.I '$G(OCXAUTO) W:($X>60) ! W "."
|
||
|
.;
|
||
|
.M OCXREC=^OCXS(860.3,OCXEL) Q:'$D(OCXREC(0))
|
||
|
.S OCXNAM=$P(OCXREC(0),U,1) Q:'$L(OCXNAM)
|
||
|
.S OCXCON=$P(OCXREC(0),U,2) I '(OCXCON) D WARN^OCXOCMPV("Context not defined for Element...",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
.I '(OCXCON) D WARN^OCXOCMPV("Context not defined for Element...",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
.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
|
||
|
.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
|
||
|
.;
|
||
|
.I (OCXTRACE) D FILECODE("W:$G(OCXTRACE) !,||LNTAG||,?27,""Metacode Function MCE"_OCXEL_"() Execution trace. ""","Y")
|
||
|
.D FILECODE("N OCXRES","Y")
|
||
|
.D FILECODE("Q:'(|PATIENT IEN|) 0 I $D(^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_")) Q $G(^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_"))","Y")
|
||
|
.;
|
||
|
.I '(OCXCON=OCXDLK) D FILECODE("Q 0","Y")
|
||
|
.;
|
||
|
.I (OCXCON=OCXDLK) D
|
||
|
..;
|
||
|
..D FILECODE("S OCXRES("_(+OCXEL)_")=0","S")
|
||
|
..;
|
||
|
..; SORT PRIMARY DATA FIELDS
|
||
|
..;
|
||
|
..S OCXD1=0 F S OCXD1=$O(OCXREC("COND",OCXD1)) Q:'OCXD1 D
|
||
|
...N OCXDF,OCXSUB
|
||
|
...F OCXSUB=1,2,3 D
|
||
|
....N OCXFREC S OCXDF=+$G(OCXREC("COND",OCXD1,"DFLD"_OCXSUB)) Q:'OCXDF
|
||
|
....M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF)
|
||
|
....I '$D(OCXFREC(OCXCON)) S OCXFREC=OCXFREC-99999
|
||
|
....I OCXDF,OCXFREC S OCXDFC(OCXFREC,OCXD1)=OCXDF,OCXDFL(OCXDF)=""
|
||
|
..;
|
||
|
..;
|
||
|
..; GET PRIMARY DATA FIELD'S 'GET CODE'
|
||
|
..;
|
||
|
..S OCXCNT="" F S OCXCNT=$O(OCXDFC(OCXCNT),-1) Q:'OCXCNT D
|
||
|
...S OCXD1=0 F S OCXD1=$O(OCXDFC(OCXCNT,OCXD1)) Q:'OCXD1 D Q:OCXWARN
|
||
|
....N OCXDF,OCXD2,OCXFREC
|
||
|
....S OCXDF=+$G(OCXDFC(OCXCNT,OCXD1)) Q:'OCXDF
|
||
|
....I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
|
||
|
....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
|
||
|
....S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 D FILECODE($G(OCXFREC(OCXD2)))
|
||
|
....;
|
||
|
....; GET EXPRESSION CONDITIONAL EVALUATION CODE
|
||
|
....;
|
||
|
....I $D(OCXFREC) D
|
||
|
.....N OCXCOD1,OCXCOD2,OCXCVAL,OCXFLDG,OCXFLDN,OCXFLDP,OCXFLDS,OCXDFLD
|
||
|
.....N OCXNAM,OCXOPER,OCXOPC,OCXD2,OCXD3,OCXP,OCXP1,OCXP2,OCXP3
|
||
|
.....;
|
||
|
.....S OCXOPER=$G(OCXREC("COND",OCXD1,"OPER"))
|
||
|
.....I '(OCXOPER) D WARN^OCXOCMPV("Operator/Function not defined...",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
.....S OCXOPN=$P($G(^OCXS(863.9,OCXOPER,0)),U,1),OCXOPDT=$P($G(^OCXS(863.9,OCXOPER,0)),U,2)
|
||
|
.....I '(OCXOPDT) D WARN^OCXOCMPV("Data Type not defined for '"_OCXOPN_"' Operator",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
.....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
|
||
|
.....;
|
||
|
.....S OCXOPC=$$GETPARM^OCXOCMPE(39,OCXOPER,"OCXO GENERATE CODE FUNCTION")
|
||
|
.....I '$L(OCXOPC) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' parameter not defined",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
.....S:'(OCXOPC=+OCXOPC) OCXOPC=$$GETIEN("^OCXS(863.7)",OCXOPC)
|
||
|
.....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
|
||
|
.....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
|
||
|
.....S OCXD2=0 F S OCXD2=$O(^OCXS(863.7,+OCXOPC,"PAR",OCXD2)) Q:'OCXD2 D
|
||
|
......N OCXPOS,OCXVNAM
|
||
|
......S OCXPOS=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,"IN")) Q:'OCXPOS Q:$D(OCXP(OCXPOS))
|
||
|
......S OCXVNAM=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,0)) Q:'OCXVNAM
|
||
|
......S OCXVNAM=$P($G(^OCXS(863.8,+OCXVNAM,0)),U,2) Q:'$L(OCXVNAM)
|
||
|
......S OCXP(+OCXPOS)=OCXVNAM,OCXP(OCXVNAM)=""
|
||
|
......;
|
||
|
.....D GETC^OCXOCMPE(OCXEL,OCXD1,.OCXP)
|
||
|
..D FILECODE("E Q 0","Y")
|
||
|
..;
|
||
|
..; GATHER OUTPUT DATA FOR THIS ELEMENT-EVENT
|
||
|
..;
|
||
|
..S OCXDF=0 F S OCXDF=$O(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF)) Q:'OCXDF D
|
||
|
...N OCXCON,OCXFREC S OCXCON=$P($G(^OCXS(860.3,OCXEL,0)),U,2)
|
||
|
...I $D(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXDLK)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXDLK)
|
||
|
...E D
|
||
|
....I '$G(OCXAUTO) D
|
||
|
.....W !
|
||
|
.....W !,"Database Lookup Method not defined for:"
|
||
|
.....W !," '"_$P($G(^OCXS(860.3,+OCXEL,0)),U,1)_"'"
|
||
|
.....W !," ( "_(+OCXDF)_" ) "_$P($G(^OCXS(860.4,+OCXDF,0)),U,1)
|
||
|
....M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",OCXDF,OCXCON)
|
||
|
...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
|
||
|
...S OCXDFL(OCXDF)=+$G(^TMP("OCXCMP",$J,"ELEMENT",OCXEL,"DATA",OCXDF))
|
||
|
...S OCXD2=0 F S OCXD2=$O(OCXFREC(OCXD2)) Q:'OCXD2 I $L($G(OCXFREC(OCXD2))) D
|
||
|
....D FILECODE(OCXFREC(OCXD2),$G(OCXFREC(OCXD2,"OPLIST")))
|
||
|
..;
|
||
|
..; FILE ELEMENT-EVENT IN ACTIVE PATIENT DATA FILE
|
||
|
..;
|
||
|
..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:"")
|
||
|
..;
|
||
|
..D FILECODE("S OCXRES("_(+OCXEL)_")=11","S")
|
||
|
..D FILECODE("M ^TMP(""OCXCHK"",$J,|PATIENT IEN|,"_(+OCXEL)_")=OCXRES("_(+OCXEL)_")","M")
|
||
|
..D FILECODE("Q +OCXRES("_(+OCXEL)_")","Y")
|
||
|
.;
|
||
|
.; RESOLVE EXTRINSIC FUNCTON RUNTIME PARAMETERS
|
||
|
.;
|
||
|
.F D Q:'OCXSCAN Q:OCXWARN
|
||
|
..S (OCXSCAN,OCXD2)=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 I $L(OCXFCODE(OCXD2)),(OCXFCODE(OCXD2)["|") D
|
||
|
...N OCXPIEC,DFNAM,DFNUM,DFCODE
|
||
|
...S DFCODE=OCXFCODE(OCXD2)
|
||
|
...F OCXPIEC=2:2:$L(DFCODE,"|") S DFNAM=$P($P(DFCODE,"|",OCXPIEC),"|",1) I $L(DFNAM),'(DFNAM["""") S DFNAM(DFNAM)=""
|
||
|
...S DFNAM="" F S DFNAM=$O(DFNAM(DFNAM)) Q:'$L(DFNAM) D
|
||
|
....N DFBNAM,DFNUM,OCXFREC,OCXD3
|
||
|
....S DFBNAM="|"_DFNAM_"|",OCXSCAN=1
|
||
|
....S DFNUM=+$O(^OCXS(860.4,"B",DFNAM,0))
|
||
|
....I 'DFNUM S DFNUM=+$O(^OCXS(860.4,"C",DFNAM,0))
|
||
|
....I 'DFNUM D WARN^OCXOCMPV("Data field argument '"_DFNAM_"' not defined in Data Field file...",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
....I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXCON)
|
||
|
....E I $D(^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)) M OCXFREC=^TMP("OCXCMP",$J,"DATA FIELD",DFNUM,OCXDLK)
|
||
|
....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
|
||
|
....I '$D(OCXFREC) D WARN^OCXOCMPV("Data field '"_DFNAM_"' get code not defined for '"_OCXCONN_" context...",3,OCXEL,$P($T(+1)," ",1)) Q
|
||
|
....S OCXFREC($O(OCXFREC(99999),-1)+1)="I $L(OCXDF("_(+DFNUM)_"))"
|
||
|
....S OCXD3=0 F S OCXD3=$O(OCXFREC(OCXD3)) Q:'OCXD3 D FILECODE($G(OCXFREC(OCXD3)),$G(OCXFREC(OCXD3,"OPLIST")),OCXD2)
|
||
|
....F Q:'(DFCODE[DFBNAM) S DFCODE=$P(DFCODE,DFBNAM,1)_"OCXDF("_(+DFNUM)_")"_$P(DFCODE,DFBNAM,2,999)
|
||
|
...S OCXFCODE(OCXD2)=DFCODE
|
||
|
..;
|
||
|
..; PURGE REDUNDANT CODE
|
||
|
..;
|
||
|
..S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
||
|
...I (OCXFCODE(OCXD2)="||NOOP||") K OCXFCODE(OCXD2) Q
|
||
|
...I '$D(OCXFCODE(OCXD2,"OPLIST")) D
|
||
|
....I '(OCXFCODE(OCXD2)["OCXTRACE") S OCXFCODE(OCXD2,"OPLIST")=$E(OCXFCODE(OCXD2),1)
|
||
|
....E S OCXFCODE(OCXD2,"OPLIST")="Y"
|
||
|
...S OCXD3=OCXD2 F S OCXD3=$O(OCXFCODE(OCXD3)) Q:'OCXD3 D
|
||
|
....Q:(OCXFCODE(OCXD2)["OCXBOOLV")
|
||
|
....I (OCXFCODE(OCXD2)=OCXFCODE(OCXD3)) K OCXFCODE(OCXD3)
|
||
|
..D REINDEX(.OCXFCODE,0)
|
||
|
.;
|
||
|
.; SAVE CODE IN ^TMP GLOBAL
|
||
|
.;
|
||
|
.D MC^OCXOCMPN(.OCXFCODE,OCXEL)
|
||
|
.;
|
||
|
.D REINDEX(.OCXFCODE,2)
|
||
|
.S OCXCOD0="MCE"_OCXEL
|
||
|
.S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
||
|
..K OCXFCODE(OCXD2,"OPLIST")
|
||
|
..S OCXFCODE(OCXD2)=" "_OCXFCODE(OCXD2)
|
||
|
.S OCXFCODE(1)=OCXCOD0_"() ; Verify Event/Element: "_$P($G(^OCXS(860.3,+OCXEL,0)),U,1)
|
||
|
.S OCXFCODE(2)=" ;"
|
||
|
.S OCXFCODE($O(OCXFCODE(" "),-1)+1)=" ;"
|
||
|
.S OCXD2=0 F S OCXD2=$O(OCXFCODE(OCXD2)) Q:'OCXD2 D
|
||
|
..N TEMP
|
||
|
..S TEMP=OCXFCODE(OCXD2)
|
||
|
..K OCXFCODE(OCXD2)
|
||
|
..S OCXFCODE(OCXD2,0)=TEMP
|
||
|
.M ^TMP("OCXCMP",$J,"INCLUDE",OCXCOD0)=OCXFCODE
|
||
|
;
|
||
|
Q OCXWARN
|
||
|
;
|
||
|
GETIEN(FILE,KEY) ;
|
||
|
;
|
||
|
N IEN1,IEN2,LEN,SHORT
|
||
|
F LEN=$L(KEY):-1:0 I LEN Q:$D(@FILE@("B",$E(KEY,1,LEN)))
|
||
|
Q:'LEN 0 S SHORT=$E(KEY,1,LEN)
|
||
|
S IEN1=0 F S IEN1=$O(@FILE@("B",SHORT,IEN1)) Q:'IEN1 Q:($P($G(@FILE@(IEN1,0)),U,1)=KEY)
|
||
|
S IEN2=IEN1 F S IEN2=$O(@FILE@("B",SHORT,IEN2)) Q:'IEN2 Q:($P($G(@FILE@(IEN2,0)),U,1)=KEY)
|
||
|
;
|
||
|
I IEN1,IEN2 Q -1
|
||
|
Q IEN1
|
||
|
;
|
||
|
REINDEX(ARRAY,NDX2) ;
|
||
|
;
|
||
|
N TEMP,NDX1 M TEMP=ARRAY K ARRAY
|
||
|
S NDX1="" F S NDX1=$O(TEMP(NDX1)) Q:'$L(NDX1) D
|
||
|
.I $L(TEMP(NDX1)) S NDX2=NDX2+1 M ARRAY(NDX2)=TEMP(NDX1)
|
||
|
Q
|
||
|
;
|
||
|
FILECODE(CODE,OPLIST,INDEX) ;
|
||
|
;
|
||
|
N OCXNDX
|
||
|
I $G(INDEX) D
|
||
|
.N PREV,HALF
|
||
|
.S PREV=$O(OCXFCODE(INDEX),-1),HALF=INDEX-PREV/2
|
||
|
.S OCXNDX=INDEX-HALF
|
||
|
E S OCXNDX=$O(OCXFCODE(""),-1)+1
|
||
|
S OCXFCODE(OCXNDX)=CODE
|
||
|
S:$L($G(OPLIST)) OCXFCODE(OCXNDX,"OPLIST")=OPLIST
|
||
|
Q
|
||
|
;
|