1 | OCXOZ0F ;SLC/RJS,CLA - Order Check Scan ;NOV 8,2009 at 18:44
|
---|
2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32,221,243**;Dec 17,1997;Build 242
|
---|
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 | ;
|
---|
13 | CHK446 ; 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 CHK446 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 CHK451
|
---|
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 CHK482^OCXOZ0G
|
---|
31 | Q
|
---|
32 | ;
|
---|
33 | CHK451 ; Look through the current environment for valid Event/Elements for this patient.
|
---|
34 | ; Called from CHK446+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 | ;
|
---|
44 | CHK458 ; 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 CHK458 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 | ;
|
---|
61 | CHK463 ; 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 CHK463 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 CHK469
|
---|
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 CHK476
|
---|
82 | Q
|
---|
83 | ;
|
---|
84 | CHK469 ; Look through the current environment for valid Event/Elements for this patient.
|
---|
85 | ; Called from CHK463+19.
|
---|
86 | ;
|
---|
87 | Q:$G(OCXOERR)
|
---|
88 | ;
|
---|
89 | ; Local CHK469 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 | ;
|
---|
100 | CHK476 ; Look through the current environment for valid Event/Elements for this patient.
|
---|
101 | ; Called from CHK463+20.
|
---|
102 | ;
|
---|
103 | Q:$G(OCXOERR)
|
---|
104 | ;
|
---|
105 | ; Local CHK476 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 | ;
|
---|
116 | ABREN(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 | ;
|
---|
135 | FILE(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 | ;
|
---|
150 | LABTHRSB(OCXLAB,OCXSPEC,OCXRSLT,OCXOP) ; Compiler Function: LAB THRESHOLD EXCEEDED BOOLEAN
|
---|
151 | ;
|
---|
152 | S OCXRSLT=$TR($G(OCXRSLT),"<>=","")
|
---|
153 | Q:'$G(OCXLAB)!'$G(OCXSPEC)!'$G(OCXRSLT)!'$L($G(OCXOP)) 0
|
---|
154 | ;
|
---|
155 | N OCXX,OCXPENT,OCXERR,OCXLABSP,OCXPVAL,OCXEXCD
|
---|
156 | S OCXEXCD=0,OCXLABSP=OCXLAB_";"_OCXSPEC
|
---|
157 | D ENVAL^XPAR(.OCXX,"ORB LAB "_OCXOP_" THRESHOLD",OCXLABSP,.OCXERR)
|
---|
158 | Q:+$G(ORERR)'=0 OCXEXCD
|
---|
159 | Q:+$G(OCXX)=0 OCXEXCD
|
---|
160 | S OCXPENT="" F S OCXPENT=$O(OCXX(OCXPENT)) Q:'OCXPENT!OCXEXCD=1 D
|
---|
161 | .S OCXPVAL=OCXX(OCXPENT,OCXLABSP)
|
---|
162 | .I $L(OCXPVAL) D
|
---|
163 | ..I $P(OCXPENT,";",2)="VA(200,",@((+OCXRSLT)_OCXOP_OCXPVAL) D
|
---|
164 | ...S OCXEXCD=1
|
---|
165 | Q OCXEXCD
|
---|
166 | ;
|
---|
167 | ORDITEM(OIEN) ; Compiler Function: GET ORDERABLE ITEM FROM ORDER NUMBER
|
---|
168 | Q:'$G(OIEN) ""
|
---|
169 | ;
|
---|
170 | N OITXT,X S OITXT=$$OI^ORQOR2(OIEN) Q:'OITXT "No orderable item found."
|
---|
171 | S X=$G(^ORD(101.43,+OITXT,0)) Q:'$L(X) "No orderable item found."
|
---|
172 | Q $P(X,U,1)
|
---|
173 | ;
|
---|
174 | PATLOC(DFN) ; Compiler Function: PATIENT LOCATION
|
---|
175 | ;
|
---|
176 | N OCXP1,OCXP2
|
---|
177 | S OCXP1=$G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",2))
|
---|
178 | S OCXP2=$P($G(^TMP("OCXSWAP",$J,"OCXODATA","PV1",3)),"^",1)
|
---|
179 | I OCXP2 D
|
---|
180 | .S OCXP2=$P($G(^SC(+OCXP2,0)),"^",1,2)
|
---|
181 | .I $L($P(OCXP2,"^",2)) S OCXP2=$P(OCXP2,"^",2)
|
---|
182 | .E S OCXP2=$P(OCXP2,"^",1)
|
---|
183 | .S:'$L(OCXP2) OCXP2="NO LOC"
|
---|
184 | I $L(OCXP1),$L(OCXP2) Q OCXP1_"^"_OCXP2
|
---|
185 | ;
|
---|
186 | S OCXP2=$G(^DPT(+$G(DFN),.1))
|
---|
187 | I $L(OCXP2) Q "I^"_OCXP2
|
---|
188 | Q "O^OUTPT"
|
---|
189 | ;
|
---|
190 | RECCREAT(ORDFN,ORDAYS) ;extrinsic function to return most recent
|
---|
191 | ;SERUM CREATININE within <ORDAYS> in format:
|
---|
192 | ; test id^result units flag ref range collection d/t
|
---|
193 | N BDT,CDT,ORY,ORX,ORZ,X,ORI,ORJ,CREARSLT,LABFILE,SPECFILE
|
---|
194 | Q:'$L($G(ORDFN)) "0^"
|
---|
195 | Q:'$L($G(ORDAYS)) "0^"
|
---|
196 | D NOW^%DTC
|
---|
197 | S BDT=$$FMADD^XLFDT(%,"-"_ORDAYS,"","","")
|
---|
198 | K %
|
---|
199 | Q:'$L($G(BDT)) "0^"
|
---|
200 | S LABFILE=$$TERMLKUP("SERUM CREATININE",.ORY)
|
---|
201 | Q:$G(LABFILE)'=60 "0^"
|
---|
202 | Q:+$D(ORY)<1 "0^"
|
---|
203 | S SPECFILE=$$TERMLKUP("SERUM SPECIMEN",.ORX)
|
---|
204 | Q:$G(SPECFILE)'=61 "0^"
|
---|
205 | Q:+$D(ORX)<1 "0^"
|
---|
206 | S ORI=0 F S ORI=$O(ORY(ORI)) Q:'ORI I +$G(CREARSLT)<1 D
|
---|
207 | .S ORJ=0 F S ORJ=$O(ORX(ORJ)) Q:'ORJ I +$G(CREARSLT)<1 D
|
---|
208 | ..S ORZ=$$LOCL^ORQQLR1(ORDFN,ORI,ORJ)
|
---|
209 | ..Q:'$L($G(ORZ))
|
---|
210 | ..S CDT=$P(ORZ,U,7)
|
---|
211 | ..I CDT'<BDT S CREARSLT=1
|
---|
212 | Q:+$G(CREARSLT)<1 "0^"
|
---|
213 | 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)
|
---|
214 | ;
|
---|
215 | TERMLKUP(OCXTERM,OCXLIST) ;
|
---|
216 | Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
|
---|
217 | ;
|
---|