VistA-WorldVistAEHR/r/ORDER_ENTRY_RESULTS_REPORTI.../OCXOCMP1.m

128 lines
7.2 KiB
Mathematica

OCXOCMP1 ;SLC/RJS,CLA - ORDER CHECK CODE COMPILER (Compile Data Field Navigation Code) ;12/22/98 13: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) OCXWARN
S OCXDF=0 F S OCXDF=$O(^TMP("OCXCMP",$J,"DATA FIELD",OCXDF)) Q:'OCXDF D Q:OCXWARN
.N OCXGETC,OCXGETN,OCXCOD2,OCXERR,OCXNAM,OCXPARM
.N OCXPATH,OCXCON,OCXFCODE,OCXDPTR,OCXREC,OCXATT
.K OCXREC(4) M OCXREC(4)=^OCXS(860.4,OCXDF)
.S OCXNAM=$P($G(OCXREC(4,0)),U,1) Q:'$L(OCXNAM)
.S OCXCON=0 F S OCXCON=$O(OCXREC(4,"LINK",OCXCON)) Q:'OCXCON D Q:$G(OCXWARN)
..K OCXREC(6) M OCXREC(6)=^OCXS(860.6,OCXCON)
..S OCXCONN=$P($G(OCXREC(6,0)),U,1) I '$L(OCXCONN) D WARN^OCXOCMPV("Data context IEN #"_(+OCXCON)_" not defined in Data Context file...",4,OCXDF,$P($T(+1)," ",1)) Q
..S OCXCONA=$P($G(OCXREC(6,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
..S OCXPATH=$G(OCXREC(4,"LINK",OCXCON,"DATAPATH")) I '$L(OCXPATH) D WARN^OCXOCMPV("Data Link-Path not defined",4,OCXDF,$P($T(+1)," ",1)) Q
..S OCXLNK=$O(^OCXS(863.3,"B",OCXPATH,0)) I 'OCXLNK D WARN^OCXOCMPV("Data Link-Path '"_OCXPATH_"' not defined in Meta-Dictionary Link file...",4,OCXDF,$P($T(+1)," ",1)) Q
..S OCXATT=$P($G(^OCXS(863.3,OCXLNK,0)),U,5) I 'OCXATT D WARN^OCXOCMPV("Data Link-Attribute '"_OCXPATH_"' ("_OCXLNK_") not defined in Meta-Dictionary Attribute file...",4,OCXDF,$P($T(+1)," ",1)) Q
..I '$G(OCXAUTO) W:($X>60) ! W "."
..S $P(OCXREC(4,0),U,3)=""
..F OCXPARM="OCXO EXTERNAL FUNCTION CALL","OCXO VARIABLE NAME","OCXO VT-BAR PIECE NUMBER","OCXO UP-ARROW PIECE NUMBER","OCXO SEMI-COLON PIECE NUMBER","OCXO HL7 SEGMENT ID","OCXO FILE POINTER" D
...Q:'$O(^OCXS(863.8,"B",OCXPARM,0))
...S OCXPARM(OCXPARM)=$$GETPARM(33,OCXPATH,OCXPARM) I '$L(OCXPARM(OCXPARM)) K OCXPARM(OCXPARM) Q
..S OCXDTYP=$$GETPARM(34,OCXATT,"DATA TYPE")
..I '$L(OCXDTYP) D WARN^OCXOCMPV("Data Link-Attribute '"_OCXPATH_"' Data Type not defined in Meta-Dictionary Attribute file...",4,OCXDF,$P($T(+1)," ",1)) Q
..S:'OCXDTYP OCXDTYP=$O(^OCXS(864.1,"B",OCXDTYP,0)) S OCXDTYPN=$P($G(^OCXS(864.1,+OCXDTYP,0)),U,1)
..I '$L(OCXDTYPN) D WARN^OCXOCMPV("Data Link-Attribute '"_OCXPATH_"' Data Type '"_OCXDTYP_"' not defined in Meta-Dictionary Data Type file...",4,OCXDF,$P($T(+1)," ",1)) Q
..;
..S OCXFCODE(OCXCON,"AN")=OCXNAM
..S OCXFCODE(OCXCON,"AV")="OCXDF("_(+OCXDF)_")"
..S OCXFCODE(OCXCON,"CN")=OCXCONN
..S OCXFCODE(OCXCON,"CA")=OCXCONA
..S OCXFCODE(OCXCON,"DTYP","DATA TYPE INDEX")=OCXDTYP
..S OCXFCODE(OCXCON,"DTYP","DATA TYPE NAME")=OCXDTYPN
..S OCXFCODE(OCXCON,"DA MODE")=+$P($G(OCXREC(6,0)),U,3)
..;
..S $P(^OCXS(860.4,OCXDF,0),U,3)=OCXDTYP
..Q:$G(OCXERR)
..;
..I $L($G(OCXPARM("OCXO EXTERNAL FUNCTION CALL"))) D
...I '$L($G(OCXPARM("OCXO VARIABLE NAME"))) D
....I ($E(OCXPARM("OCXO EXTERNAL FUNCTION CALL"),1)="(") S OCXGETC=OCXPARM("OCXO EXTERNAL FUNCTION CALL")
....E S OCXGETC="$$"_OCXPARM("OCXO EXTERNAL FUNCTION CALL")
...I $L($G(OCXPARM("OCXO VARIABLE NAME"))) D
....I (OCXTLOG),((OCXPARM("OCXO EXTERNAL FUNCTION CALL")?.8AN1"^"1.8AN1"(".E)!(OCXPARM("OCXO EXTERNAL FUNCTION CALL")?1.8AN1"(".E)) D I 1
.....N OCXX
.....S OCXX="S OCXOERR=$$TIMELOG(""O"","""_$P(OCXPARM("OCXO EXTERNAL FUNCTION CALL")_"(","(",1)_""")"
.....S OCXX=OCXX_" D "_OCXPARM("OCXO EXTERNAL FUNCTION CALL")
.....S OCXX=OCXX_" S OCXOERR=$$TIMELOG(""I"","""_$P(OCXPARM("OCXO EXTERNAL FUNCTION CALL")_"(","(",1)_""")"
.....D FILECODE(OCXCON,OCXX,"SDS")
....E D FILECODE(OCXCON,"D "_OCXPARM("OCXO EXTERNAL FUNCTION CALL"),"D")
....S OCXGETC=$G(OCXPARM("OCXO VARIABLE NAME"))
..;
..I '$L($G(OCXPARM("OCXO EXTERNAL FUNCTION CALL"))) D
...I '$L($G(OCXPARM("OCXO VARIABLE NAME"))) D
....D WARN^OCXOCMPV("Not enough information in the MetaDictionary link file to generate navigation code.",4,OCXDF,$P($T(+1)," ",1)) S OCXERR=1 Q
...I $L($G(OCXPARM("OCXO VARIABLE NAME"))) S OCXGETC="$G("_$G(OCXPARM("OCXO VARIABLE NAME"))_")"
..;
..Q:OCXWARN
..;
..S:$L($G(OCXPARM("OCXO VT-BAR PIECE NUMBER"))) OCXGETC="$P("_OCXGETC_",""|"","_(OCXPARM("OCXO VT-BAR PIECE NUMBER")+1)_")"
..S:$G(OCXPARM("OCXO UP-ARROW PIECE NUMBER")) OCXGETC="$P("_OCXGETC_",""^"","_OCXPARM("OCXO UP-ARROW PIECE NUMBER")_")"
..S:$G(OCXPARM("OCXO SEMI-COLON PIECE NUMBER")) OCXGETC="$P("_OCXGETC_","";"","_OCXPARM("OCXO SEMI-COLON PIECE NUMBER")_")"
..;
..I ($L($G(OCXPARM("OCXO FILE POINTER")))) D
...N OCXX S OCXX=OCXPARM("OCXO FILE POINTER")
...I (OCXX=(+OCXX)) S OCXGETC="$$POINTER("_(+OCXX)_","_OCXGETC_")"
...E S OCXGETC="$$POINTER("""_(OCXX)_""","_OCXGETC_")"
..S:(OCXDTYPN="DATE/TIME") OCXGETC="$$DT2INT("_OCXGETC_")"
..Q:'$L(OCXGETC)
..S OCXFCODE(OCXCON,"G")=OCXGETC
..D FILECODE(OCXCON,"S OCXDF("_(+OCXDF)_")="_OCXGETC)
..I $G(OCXTRACE) D
...N OCXTXT
...I $D(OCXPARM("OCXO VARIABLE NAME")) D
....S OCXTXT="W:$D("_OCXPARM("OCXO VARIABLE NAME")_") !,||LNTAG||,?30,""Data Field: "_$E(OCXNAM,1,25)_" : "",?30,"" ("
....I $D(OCXCONA) S OCXTXT=OCXTXT_" "_OCXCONA
....I $D(OCXPARM("OCXO VARIABLE NAME")) S OCXTXT=OCXTXT_" "_$$DBLQT(OCXPARM("OCXO VARIABLE NAME"))
....I $D(OCXPARM("OCXO HL7 SEGMENT ID")) S OCXTXT=OCXTXT_" "_OCXPARM("OCXO HL7 SEGMENT ID")
....I $D(OCXPARM("OCXO VT-BAR PIECE NUMBER")) S OCXTXT=OCXTXT_" "_OCXPARM("OCXO VT-BAR PIECE NUMBER")
....I $D(OCXPARM("OCXO UP-ARROW PIECE NUMBER")) S OCXTXT=OCXTXT_" piece "_OCXPARM("OCXO UP-ARROW PIECE NUMBER")
....I (OCXDTYPN="DATE/TIME") S OCXTXT=OCXTXT_" ) "",$$INT2DT("_OCXGETC_",1)"
....E I (OCXDTYPN="BOOLEAN") S OCXTXT=OCXTXT_" ) "",$S(+"_OCXGETC_":""TRUE"",1:""FALSE"")"
....E S OCXTXT=OCXTXT_" ) "","_OCXGETC
....I $L($G(OCXPARM("OCXO HL7 SEGMENT ID"))) D
.....S ^TMP("OCXCMP",$J,"DATA FIELD TRACE","HL7",$G(OCXPARM("OCXO HL7 SEGMENT ID")," "),+$G(OCXPARM("OCXO VT-BAR PIECE NUMBER")),+$G(OCXPARM("OCXO UP-ARROW PIECE NUMBER")),OCXDF)=OCXTXT
....E S ^TMP("OCXCMP",$J,"DATA FIELD TRACE",OCXCON,0,0,+$G(OCXPARM("OCXO UP-ARROW PIECE NUMBER")),OCXDF)=OCXTXT
...;
...D FILECODE(OCXCON,"W:$G(OCXTRACE) !,||LNTAG||,?30,""Data Field: "_OCXNAM_" = """""",OCXDF("_(+OCXDF)_"),""""""""")
..I 0 D FILECODE(OCXCON,"S OCXOERR=$$LOGDF("_(+OCXDF)_","_(+OCXCON)_",OCXDF("_(+OCXDF)_"))")
.;
.;
.M ^TMP("OCXCMP",$J,"DATA FIELD",OCXDF)=OCXFCODE
;
D BLDDF^OCXOCMPH
;
Q OCXWARN
;
DBLQT(X) ;
N A,C F A=35:1:126,0 I A S C=$C(A) Q:'(X[C)
Q:'A X S C=$C(C) S X=$TR(X,"""",C) F Q:'(X[C) S X=$P(X,C,1)_""""""_$P(X,C,2,999)
Q X
;
FILECODE(OCXCON,CODE,OPLIST) ;
;
N OCXNDX S OCXNDX=$O(OCXFCODE(OCXCON,9999),-1)+1,OCXFCODE(OCXCON,OCXNDX)=CODE
S:$L($G(OPLIST)) OCXFCODE(OCXCON,OCXNDX,"OPLIST")=OPLIST
Q
;
UDEFPARM(PARM) ;
Q:$D(OCXPARM(PARM)) 0
D WARN^OCXOCMPV(" '"_PARM_"' parameter missing, in MetaDictionary link file.",4,OCXDF,$P($T(+1)," ",1)) Q 1
;
GETPARM(FILE,INST,PARM) ;
Q:'$L(FILE) "" Q:'$L(INST) "" Q:'$L(PARM) ""
N OCXP,OCXP1,OCXI,OCXGL
S OCXGL="^OCXS" S:(FILE=1) OCXGL="^OCXD" S:(FILE=7) OCXGL="^OCXD" S:(FILE=10) OCXGL="^OCXD" S FILE=FILE/10+860
Q:'$D(@OCXGL@(+FILE,0)) ""
I (PARM=+PARM),$D(^OCXS(863.8,PARM,0)) S OCXP=PARM
E S OCXP=$O(^OCXS(863.8,"B",PARM,0))
Q:'OCXP ""
I (INST=+INST),$D(@OCXGL@(FILE,INST,0)) S OCXI=INST
E S OCXI=$O(@OCXGL@(FILE,"B",INST,0))
Q:'OCXI "" S OCXP1=$O(@OCXGL@(FILE,OCXI,"PAR","B",OCXP,0)) Q:'OCXP1 ""
Q $G(@OCXGL@(FILE,OCXI,"PAR",OCXP1,"VAL"))
;