source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0F.m

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

initial load of FOIAVistA 6/30/08 version

File size: 8.4 KB
Line 
1OCXOZ0F ;SLC/RJS,CLA - Order Check Scan ;SEP 4,2007 at 23:12
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,221**;Dec 17,1997
3 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
4 ;
5 ; ***************************************************************
6 ; ** Warning: This routine is automatically generated by the **
7 ; ** Rule Compiler (^OCXOCMP) and ANY changes to this routine **
8 ; ** will be lost the next time the rule compiler executes. **
9 ; ***************************************************************
10 ;
11 Q
12 ;
13CHK454 ; Look through the current environment for valid Event/Elements for this patient.
14 ; Called from CHK58+22^OCXOZ05.
15 ;
16 Q:$G(OCXOERR)
17 ;
18 ; Local CHK454 Variables
19 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
20 ; OCXDF(57) ---> Data Field: MOST RECENT RENAL TEST ABNORMAL FLAG (BOOLEAN)
21 ; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
22 ; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
23 ; OCXDF(155) --> Data Field: RECENT CONTRAST MEDIA CREATININE FLAG (BOOLEAN)
24 ;
25 ; Local Extrinsic Functions
26 ; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
27 ; RECCREAT( --------> RECENT CREATININE LAB PROCEDURE
28 ;
29 S OCXDF(57)=$P($$ABREN(OCXDF(37)),"^",1) I $L(OCXDF(57)),(OCXDF(57)) S OCXDF(58)=$P($$ABREN(OCXDF(37)),"^",2),OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1) D CHK459
30 S OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1) I $L(OCXDF(154)) S OCXDF(155)=$P($$RECCREAT(OCXDF(37),OCXDF(154)),"^",1) I $L(OCXDF(155)),'(OCXDF(155)) D CHK490^OCXOZ0G
31 Q
32 ;
33CHK459 ; Look through the current environment for valid Event/Elements for this patient.
34 ; Called from CHK454+16.
35 ;
36 Q:$G(OCXOERR)
37 ;
38 ; Local Extrinsic Functions
39 ; FILE(DFN,129, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: ABNORMAL RENAL RESULTS)
40 ;
41 S OCXOERR=$$FILE(DFN,129,"58,154") Q:OCXOERR
42 Q
43 ;
44CHK466 ; Look through the current environment for valid Event/Elements for this patient.
45 ; Called from CHK196+18^OCXOZ09.
46 ;
47 Q:$G(OCXOERR)
48 ;
49 ; Local CHK466 Variables
50 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
51 ; OCXDF(58) ---> Data Field: ABNORMAL RENAL BIOCHEM RESULTS (FREE TEXT)
52 ; OCXDF(154) --> Data Field: RECENT CONTRAST MEDIA CREATININE DAYS (NUMERIC)
53 ;
54 ; Local Extrinsic Functions
55 ; ABREN( -----------> DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
56 ; FILE(DFN,130, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: CONTRAST MEDIA ORDER)
57 ;
58 S OCXDF(58)=$P($$ABREN(OCXDF(37)),"^",2),OCXDF(154)=$P($$CMCDAYS^ORKRA(OCXDF(37)),"^",1),OCXOERR=$$FILE(DFN,130,"58,154") Q:OCXOERR
59 Q
60 ;
61CHK471 ; Look through the current environment for valid Event/Elements for this patient.
62 ; Called from CHK1+34^OCXOZ02.
63 ;
64 Q:$G(OCXOERR)
65 ;
66 ; Local CHK471 Variables
67 ; OCXDF(12) ---> Data Field: LAB RESULT (FREE TEXT)
68 ; OCXDF(34) ---> Data Field: ORDER NUMBER (NUMERIC)
69 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
70 ; OCXDF(96) ---> Data Field: ORDERABLE ITEM NAME (FREE TEXT)
71 ; OCXDF(113) --> Data Field: LAB TEST ID (NUMERIC)
72 ; OCXDF(150) --> Data Field: LAB RESULT < THRESHOLD (BOOLEAN)
73 ; OCXDF(151) --> Data Field: LAB RESULT > THRESHOLD (BOOLEAN)
74 ; OCXDF(152) --> Data Field: LAB SPECIMEN ID (NUMERIC)
75 ;
76 ; Local Extrinsic Functions
77 ; LABTHRSB( --------> LAB THRESHOLD EXCEEDED BOOLEAN
78 ; ORDITEM( ---------> GET ORDERABLE ITEM FROM ORDER NUMBER
79 ;
80 S OCXDF(151)=$P($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),">"),"^",1) I $L(OCXDF(151)),(OCXDF(151)),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)) I $L(OCXDF(37)) D CHK477
81 S OCXDF(150)=$P($$LABTHRSB(OCXDF(113),OCXDF(152),OCXDF(12),"<"),"^",1) I $L(OCXDF(150)),(OCXDF(150)),$L(OCXDF(34)) S OCXDF(96)=$$ORDITEM(OCXDF(34)) I $L(OCXDF(37)) D CHK484
82 Q
83 ;
84CHK477 ; Look through the current environment for valid Event/Elements for this patient.
85 ; Called from CHK471+19.
86 ;
87 Q:$G(OCXOERR)
88 ;
89 ; Local CHK477 Variables
90 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
91 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
92 ;
93 ; Local Extrinsic Functions
94 ; FILE(DFN,131, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: GREATER THAN LAB THRESHOLD)
95 ; PATLOC( ----------> PATIENT LOCATION
96 ;
97 S OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,131,"12,37,96,113,147,152") Q:OCXOERR
98 Q
99 ;
100CHK484 ; Look through the current environment for valid Event/Elements for this patient.
101 ; Called from CHK471+20.
102 ;
103 Q:$G(OCXOERR)
104 ;
105 ; Local CHK484 Variables
106 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
107 ; OCXDF(147) --> Data Field: PATIENT LOCATION (FREE TEXT)
108 ;
109 ; Local Extrinsic Functions
110 ; FILE(DFN,132, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: LESS THAN LAB THRESHOLD)
111 ; PATLOC( ----------> PATIENT LOCATION
112 ;
113 S OCXDF(147)=$P($$PATLOC(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,132,"12,37,96,113,147,152") Q:OCXOERR
114 Q
115 ;
116ABREN(DFN) ; Compiler Function: DETERMINE IF RENAL LAB RESULTS ARE ABNORMAL HIGH OR LOW
117 ;
118 N OCXFLAG,OCXVAL,OCXLIST,OCXTEST,UNAV,OCXTLIST,OCXTERM,OCXSLIST,OCXSPEC
119 S (OCXLIST,OCXTLIST)="",UNAV="0^<Unavailable>"
120 S OCXSLIST="" Q:'$$TERMLKUP("SERUM SPECIMEN",.OCXSLIST) UNAV
121 F OCXTERM="SERUM CREATININE","SERUM UREA NITROGEN" D Q:($L(OCXLIST)>130)
122 .Q:'$$TERMLKUP(OCXTERM,.OCXTLIST)
123 .S OCXTEST=0 F S OCXTEST=$O(OCXTLIST(OCXTEST)) Q:'OCXTEST D Q:($L(OCXLIST)>130)
124 ..S OCXSPEC=0 F S OCXSPEC=$O(OCXSLIST(OCXSPEC)) Q:'OCXSPEC D Q:($L(OCXLIST)>130)
125 ...S OCXVAL=$$LOCL^ORQQLR1(DFN,OCXTEST,OCXSPEC),OCXFLAG=$P(OCXVAL,U,5)
126 ...I $L(OCXVAL),((OCXFLAG["H")!(OCXFLAG["L")) D
127 ....N OCXY S OCXY=""
128 ....S OCXY=$P(OCXVAL,U,2)_": "_$P(OCXVAL,U,3)_" "_$P(OCXVAL,U,4)
129 ....S OCXY=OCXY_" "_$S($L(OCXFLAG):"["_OCXFLAG_"]",1:"")
130 ....S OCXY=OCXY_" "_$$FMTE^XLFDT($P(OCXVAL,U,7),"2P")
131 ....S:$L(OCXLIST) OCXLIST=OCXLIST_" " S OCXLIST=OCXLIST_OCXY
132 Q:'$L(OCXLIST) UNAV Q 1_U_OCXLIST
133 ;
134 ;
135FILE(DFN,OCXELE,OCXDFL) ; This Local Extrinsic Function logs a validated event/element.
136 ;
137 N OCXTIMN,OCXTIML,OCXTIMT1,OCXTIMT2,OCXDATA,OCXPC,OCXPC,OCXVAL,OCXSUB,OCXDFI
138 S DFN=+$G(DFN),OCXELE=+$G(OCXELE)
139 ;
140 Q:'DFN 1 Q:'OCXELE 1 K OCXDATA
141 ;
142 S OCXDATA(DFN,OCXELE)=1
143 F OCXPC=1:1:$L(OCXDFL,",") S OCXDFI=$P(OCXDFL,",",OCXPC) I OCXDFI D
144 .S OCXVAL=$G(OCXDF(+OCXDFI)),OCXDATA(DFN,OCXELE,+OCXDFI)=OCXVAL
145 ;
146 M ^TMP("OCXCHK",$J,DFN)=OCXDATA(DFN)
147 ;
148 Q 0
149 ;
150LABTHRSB(OCXLAB,OCXSPEC,OCXRSLT,OCXOP) ; Compiler Function: LAB THRESHOLD EXCEEDED BOOLEAN
151 ;
152 Q:'$G(OCXLAB)!'$G(OCXSPEC)!'$G(OCXRSLT)!'$L($G(OCXOP)) 0
153 ;
154 N OCXX,OCXPENT,OCXERR,OCXLABSP,OCXPVAL,OCXEXCD
155 S OCXEXCD=0,OCXLABSP=OCXLAB_";"_OCXSPEC
156 D ENVAL^XPAR(.OCXX,"ORB LAB "_OCXOP_" THRESHOLD",OCXLABSP,.OCXERR)
157 Q:+$G(ORERR)'=0 OCXEXCD
158 Q:+$G(OCXX)=0 OCXEXCD
159 S OCXPENT="" F S OCXPENT=$O(OCXX(OCXPENT)) Q:'OCXPENT!OCXEXCD=1 D
160 .S OCXPVAL=OCXX(OCXPENT,OCXLABSP)
161 .I $L(OCXPVAL) D
162 ..I $P(OCXPENT,";",2)="VA(200,",@((+OCXRSLT)_OCXOP_OCXPVAL) D
163 ...S OCXEXCD=1
164 Q OCXEXCD
165 ;
166ORDITEM(OIEN) ; Compiler Function: GET ORDERABLE ITEM FROM ORDER NUMBER
167 Q:'$G(OIEN) ""
168 ;
169 N OITXT,X S OITXT=$$OI^ORQOR2(OIEN) Q:'OITXT "No orderable item found."
170 S X=$G(^ORD(101.43,+OITXT,0)) Q:'$L(X) "No orderable item found."
171 Q $P(X,U,1)
172 ;
173PATLOC(DFN) ; Compiler Function: PATIENT LOCATION
174 ;
175 N OCXP1,OCXP2
176 S OCXP1=$G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",2))
177 S OCXP2=$P($G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",3)),"^",1)
178 I OCXP2 D
179 .S OCXP2=$P($G(^SC(+OCXP2,0)),"^",1,2)
180 .I $L($P(OCXP2,"^",2)) S OCXP2=$P(OCXP2,"^",2)
181 .E S OCXP2=$P(OCXP2,"^",1)
182 .S:'$L(OCXP2) OCXP2="NO LOC"
183 I $L(OCXP1),$L(OCXP2) Q OCXP1_"^"_OCXP2
184 ;
185 S OCXP2=$G(^DPT(+$G(DFN),.1))
186 I $L(OCXP2) Q "I^"_OCXP2
187 Q "O^OUTPT"
188 ;
189RECCREAT(ORDFN,ORDAYS) ;extrinsic function to return most recent
190 ;SERUM CREATININE within <ORDAYS> in format:
191 ; test id^result units flag ref range collection d/t
192 N BDT,CDT,ORY,ORX,ORZ,X,ORI,ORJ,CREARSLT,LABFILE,SPECFILE
193 Q:'$L($G(ORDFN)) "0^"
194 Q:'$L($G(ORDAYS)) "0^"
195 D NOW^%DTC
196 S BDT=$$FMADD^XLFDT(%,"-"_ORDAYS,"","","")
197 K %
198 Q:'$L($G(BDT)) "0^"
199 S LABFILE=$$TERMLKUP("SERUM CREATININE",.ORY)
200 Q:$G(LABFILE)'=60 "0^"
201 Q:+$D(ORY)<1 "0^"
202 S SPECFILE=$$TERMLKUP("SERUM SPECIMEN",.ORX)
203 Q:$G(SPECFILE)'=61 "0^"
204 Q:+$D(ORX)<1 "0^"
205 S ORI=0 F S ORI=$O(ORY(ORI)) Q:'ORI I +$G(CREARSLT)<1 D
206 .S ORJ=0 F S ORJ=$O(ORX(ORJ)) Q:'ORJ I +$G(CREARSLT)<1 D
207 ..S ORZ=$$LOCL^ORQQLR1(ORDFN,ORI,ORJ)
208 ..Q:'$L($G(ORZ))
209 ..S CDT=$P(ORZ,U,7)
210 ..I CDT'<BDT S CREARSLT=1
211 Q:+$G(CREARSLT)<1 "0^"
212 Q $P(ORZ,U)_U_$P(ORZ,U,3)_" "_$P(ORZ,U,4)_" "_$P(ORZ,U,5)_" ("_$P(ORZ,U,6)_") "_$$FMTE^XLFDT(CDT,"2P")_U_$P(ORZ,U,3)
213 ;
214TERMLKUP(OCXTERM,OCXLIST) ;
215 Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
216 ;
Note: See TracBrowser for help on using the repository browser.