source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OCXOZ0A.m@ 1211

Last change on this file since 1211 was 623, checked in by George Lilly, 15 years ago

revised back to 6/30/08 version

File size: 7.9 KB
RevLine 
[623]1OCXOZ0A ;SLC/RJS,CLA - Order Check Scan ;DEC 27,2007 at 06:00
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 ;
13CHK217 ; Look through the current environment for valid Event/Elements for this patient.
14 ; Called from CHK201+16^OCXOZ09.
15 ;
16 Q:$G(OCXOERR)
17 ;
18 ; Local CHK217 Variables
19 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
20 ; OCXDF(67) ---> Data Field: CONTRAST MEDIA CODE (FREE TEXT)
21 ; OCXDF(70) ---> Data Field: RECENT BARIUM STUDY TEXT (FREE TEXT)
22 ; OCXDF(121) --> Data Field: RECENT BARIUM STUDY ORDER STATUS (FREE TEXT)
23 ;
24 ; Local Extrinsic Functions
25 ; FILE(DFN,67, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: RECENT BARIUM STUDY ORDERED)
26 ; RECBAR( ----------> RECENT BARIUM STUDY
27 ; RECBARST( --------> RECENT BARIUM ORDER STATUS
28 ;
29 I $L(OCXDF(67)),(OCXDF(67)["B") S OCXDF(70)=$P($$RECBAR(OCXDF(37),48),"^",3),OCXDF(121)=$P($$RECBARST(OCXDF(37),48),"^",2),OCXOERR=$$FILE(DFN,67,"70,121") Q:OCXOERR
30 Q
31 ;
32CHK227 ; Look through the current environment for valid Event/Elements for this patient.
33 ; Called from CHK163+14^OCXOZ07.
34 ;
35 Q:$G(OCXOERR)
36 ;
37 ; Local CHK227 Variables
38 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
39 ; OCXDF(43) ---> Data Field: OI NATIONAL ID (FREE TEXT)
40 ; OCXDF(74) ---> Data Field: VA DRUG CLASS (FREE TEXT)
41 ;
42 ; Local Extrinsic Functions
43 ;
44 S OCXDF(74)=$P($$ENVAC^PSJORUT2(OCXDF(43)),"^",2) I $L(OCXDF(74)),(OCXDF(74)="AMINOGLYCOSIDES") S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) D CHK232
45 Q
46 ;
47CHK232 ; Look through the current environment for valid Event/Elements for this patient.
48 ; Called from CHK227+12.
49 ;
50 Q:$G(OCXOERR)
51 ;
52 ; Local CHK232 Variables
53 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
54 ; OCXDF(64) ---> Data Field: FORMATTED RENAL LAB RESULTS (FREE TEXT)
55 ; OCXDF(76) ---> Data Field: CREATININE CLEARANCE (ESTIM) VALUE (NUMERIC)
56 ;
57 ; Local Extrinsic Functions
58 ; CRCL( ------------> CREATININE CLEARANCE (ESTIMATED/CALCULATED)
59 ; FILE(DFN,71, -----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: AMINOGLYCOSIDE ORDER SESSION)
60 ; FLAB( ------------> FORMATTED LAB RESULTS
61 ;
62 S OCXDF(64)=$$FLAB(OCXDF(37),"SERUM CREATININE^SERUM UREA NITROGEN","SERUM SPECIMEN"),OCXDF(76)=$P($$CRCL(OCXDF(37)),"^",2),OCXOERR=$$FILE(DFN,71,"64,76") Q:OCXOERR
63 Q
64 ;
65CHK236 ; Look through the current environment for valid Event/Elements for this patient.
66 ; Called from CHK199+10^OCXOZ09.
67 ;
68 Q:$G(OCXOERR)
69 ;
70 ; Local CHK236 Variables
71 ; OCXDF(37) ---> Data Field: PATIENT IEN (NUMERIC)
72 ; OCXDF(67) ---> Data Field: CONTRAST MEDIA CODE (FREE TEXT)
73 ; OCXDF(73) ---> Data Field: ORDERABLE ITEM IEN (NUMERIC)
74 ; OCXDF(78) ---> Data Field: PATIENT TOO BIG FOR SCANNER FLAG (BOOLEAN)
75 ;
76 ; Local Extrinsic Functions
77 ; CLIST( -----------> STRING CONTAINS ONE OF A LIST OF VALUES
78 ; CTMRI( -----------> CT MRI PHYSICAL LIMITS
79 ; FILE(DFN,106, ----> FILE DATA IN PATIENT ACTIVE DATA FILE (Event/Element: RADIOLOGY PROCEDURE CONTAINS NON-BARIUM CONTRAST MEDIA)
80 ;
81 S OCXDF(37)=$G(DFN) I $L(OCXDF(37)) S OCXDF(78)=$P($$CTMRI(OCXDF(37),OCXDF(73)),"^",1) I $L(OCXDF(78)),(OCXDF(78)) D CHK241^OCXOZ0B
82 S OCXDF(67)=$$CM^ORQQRA(OCXDF(73)) I $L(OCXDF(67)),$$CLIST(OCXDF(67),"M,I,N") S OCXOERR=$$FILE(DFN,106,"") Q:OCXOERR
83 Q
84 ;
85CLIST(DATA,LIST) ; DOES THE DATA FIELD CONTAIN AN ELEMENT IN THE LIST
86 ;
87 N PC F PC=1:1:$L(LIST,","),0 I PC,$L($P(LIST,",",PC)),(DATA[$P(LIST,",",PC)) Q
88 Q ''PC
89 ;
90CRCL(DFN) ; Compiler Function: CREATININE CLEARANCE (ESTIMATED/CALCULATED)
91 ;
92 N HT,AGE,SEX,SCR,SCRD,CRCL,LRWKLD,RSLT,ORW,ORH,PSCR
93 N HTGT60,ABW,IBW,BWRATIO,BWDIFF,LOWBW,ADJBW
94 S RSLT="0^<Unavailable>"
95 S PSCR="^^^^^^0"
96 D VITAL^ORQQVI("WEIGHT","WT",DFN,.ORW,0,"",$$NOW^XLFDT)
97 Q:'$D(ORW) RSLT
98 S ABW=$P(ORW(1),U,3) Q:+$G(ABW)<1 RSLT
99 S ABW=ABW/2.2 ;ABW (actual body weight) in kg
100 D VITAL^ORQQVI("HEIGHT","HT",DFN,.ORH,0,"",$$NOW^XLFDT)
101 Q:'$D(ORH) RSLT
102 S HT=$P(ORH(1),U,3) Q:+$G(HT)<1 RSLT
103 S AGE=$$AGE^ORQPTQ4(DFN) Q:'AGE RSLT
104 S SEX=$P($$SEX^ORQPTQ4(DFN),U,1) Q:'$L(SEX) RSLT
105 S OCXTL="" Q:'$$TERMLKUP^ORB31(.OCXTL,"SERUM CREATININE") RSLT
106 S OCXTLS="" Q:'$$TERMLKUP^ORB31(.OCXTLS,"SERUM SPECIMEN") RSLT
107 S SCR="",OCXT=0 F S OCXT=$O(OCXTL(OCXT)) Q:'OCXT D
108 .S OCXTS=0 F S OCXTS=$O(OCXTLS(OCXTS)) Q:'OCXTS D
109 ..S SCR=$$LOCL^ORQQLR1(DFN,$P(OCXTL(OCXT),U),$P(OCXTLS(OCXTS),U))
110 ..I $P(SCR,U,7)>$P(PSCR,U,7) S PSCR=SCR
111 S SCR=PSCR,SCRV=$P(SCR,U,3) Q:+$G(SCRV)<.01 RSLT
112 S SCRD=$P(SCR,U,7) Q:'$L(SCRD) RSLT
113 ;
114 S HTGT60=$S(HT>60:(HT-60)*2.3,1:0) ;if ht > 60 inches
115 I HTGT60>0 D
116 .S IBW=$S(SEX="M":50+HTGT60,1:45.5+HTGT60) ;Ideal Body Weight
117 .S BWRATIO=(ABW/IBW) ;body weight ratio
118 .S BWDIFF=$S(ABW>IBW:ABW-IBW,1:0)
119 .S LOWBW=$S(IBW<ABW:IBW,1:ABW)
120 .I BWRATIO>1.3,(BWDIFF>0) S ADJBW=((0.3*BWDIFF)+IBW)
121 .E S ADJBW=LOWBW
122 I +$G(ADJBW)<1 D
123 .S ADJBW=ABW
124 S CRCL=(((140-AGE)*ADJBW)/(SCRV*72))
125 ;
126 S:SEX="M" RSLT=SCRD_U_$J(CRCL,1,1)
127 S:SEX="F" RSLT=SCRD_U_$J((CRCL*.85),1,1)
128 Q RSLT
129 ;
130CTMRI(DFN,OCXOI) ; Compiler Function: CT MRI PHYSICAL LIMITS
131 ;
132 N OCXDEV,OCXWTP,OCXHTP,OCXWTL,OCXHTL
133 S OCXDEV=$$TYPE^ORKRA(OCXOI)
134 Q:'((OCXDEV="MRI")!(OCXDEV="CT")) 0_U
135 S OCXWTP=$P($$WT^ORQPTQ4(DFN),U,2),OCXHTP=$P($$HT^ORQPTQ4(DFN),U,2)
136 I (OCXDEV="CT") S OCXWTL=$$GET^XPAR("ALL","ORK CT LIMIT WT",1,"Q"),OCXHTL=$$GET^XPAR("ALL","ORK CT LIMIT HT",1,"Q")
137 I (OCXDEV="CT"),(OCXWTL),(OCXWTP>OCXWTL) Q 1_U_"too heavy"_U_"CT scanner"
138 I (OCXDEV="CT"),(OCXHTL),(OCXHTP>OCXHTL) Q 1_U_"too tall"_U_"CT scanner"
139 I (OCXDEV="MRI") S OCXWTL=$$GET^XPAR("ALL","ORK MRI LIMIT WT",1,"Q"),OCXHTL=$$GET^XPAR("ALL","ORK MRI LIMIT HT",1,"Q")
140 I (OCXDEV="MRI"),(OCXWTL),(OCXWTP>OCXWTL) Q 1_U_"too heavy"_U_"MRI scanner"
141 I (OCXDEV="MRI"),(OCXHTL),(OCXHTP>OCXHTL) Q 1_U_"too tall"_U_"MRI scanner"
142 Q 0_U
143 ;
144FILE(DFN,OCXELE,OCXDFL) ; This Local Extrinsic Function logs a validated event/element.
145 ;
146 N OCXTIMN,OCXTIML,OCXTIMT1,OCXTIMT2,OCXDATA,OCXPC,OCXPC,OCXVAL,OCXSUB,OCXDFI
147 S DFN=+$G(DFN),OCXELE=+$G(OCXELE)
148 ;
149 Q:'DFN 1 Q:'OCXELE 1 K OCXDATA
150 ;
151 S OCXDATA(DFN,OCXELE)=1
152 F OCXPC=1:1:$L(OCXDFL,",") S OCXDFI=$P(OCXDFL,",",OCXPC) I OCXDFI D
153 .S OCXVAL=$G(OCXDF(+OCXDFI)),OCXDATA(DFN,OCXELE,+OCXDFI)=OCXVAL
154 ;
155 M ^TMP("OCXCHK",$J,DFN)=OCXDATA(DFN)
156 ;
157 Q 0
158 ;
159FLAB(DFN,OCXLIST,OCXSPEC) ; Compiler Function: FORMATTED LAB RESULTS
160 ;
161 Q:'$G(DFN) "<Patient Not Specified>"
162 Q:'$L($G(OCXLIST)) "<Lab Tests Not Specified>"
163 N OCXLAB,OCXOUT,OCXPC,OCXSL,SPEC S OCXOUT="",SPEC=""
164 I $L($G(OCXSPEC)) S OCXSL=$$TERMLKUP(OCXSPEC,.OCXSL)
165 F OCXPC=1:1:$L(OCXLIST,U) S OCXLAB=$P(OCXLIST,U,OCXPC) I $L(OCXLAB) D
166 .N OCXX,OCXY,X,Y,DIC,TEST,SPEC,OCXTL,OCXA,OCXR
167 .S OCXTL="" Q:'$$TERMLKUP(OCXLAB,.OCXTL)
168 .S OCXX="",TEST=0 F S TEST=$O(OCXTL(TEST)) Q:'TEST D
169 ..I $L($G(OCXSL)) D
170 ...S SPEC=0 F S SPEC=$O(OCXSL(SPEC)) Q:'SPEC D
171 ....S OCXX=$$LOCL^ORQQLR1(DFN,TEST,SPEC) I $L(OCXX) D
172 .....S OCXA($P(OCXX,U,7))=OCXX
173 ..I '$L($G(OCXSL)) S OCXX=$$LOCL^ORQQLR1(DFN,TEST,"")
174 ..Q:'$L(OCXX)
175 .I $D(OCXA) S OCXR="",OCXR=$O(OCXA(OCXR),-1),OCXX=OCXA(OCXR)
176 .I $L(OCXX) D
177 ..S OCXY=$P(OCXX,U,2)_": "_$P(OCXX,U,3)_" "_$P(OCXX,U,4)
178 ..S OCXY=OCXY_" "_$S($L($P(OCXX,U,5)):"["_$P(OCXX,U,5)_"]",1:"")
179 ..I $L($P(OCXX,U,7)) S OCXY=OCXY_" "_$$FMTE^XLFDT($P(OCXX,U,7),"2P")
180 .S:$L(OCXOUT) OCXOUT=OCXOUT_" " S OCXOUT=OCXOUT_$G(OCXY)
181 Q:'$L(OCXOUT) "<Results Not Found>" Q OCXOUT
182 ;
183RECBAR(DFN,HOURS) ; Compiler Function: RECENT BARIUM STUDY
184 ;
185 Q:'$G(DFN) 0 Q:'$G(HOURS) 0 N OUT S OUT=$$RECENTBA^ORKRA(DFN,HOURS) Q:'$L(OUT) 0 Q 1_U_OUT
186 ;
187 ;
188RECBARST(DFN,HOURS) ; Compiler Function: RECENT BARIUM ORDER STATUS
189 ;
190 Q:'$G(DFN) 0 Q:'$G(HOURS) 0
191 N ORDER S ORDER=$P($$RECENTBA^ORKRA(DFN,HOURS),U) Q:'$L(ORDER) 0
192 N STATUS S STATUS=$P($$STATUS^ORQOR2(ORDER),U,2) Q:'$L(STATUS) 0
193 Q 1_U_STATUS
194 ;
195TERMLKUP(OCXTERM,OCXLIST) ;
196 Q $$TERM^OCXOZ01(OCXTERM,.OCXLIST)
197 ;
Note: See TracBrowser for help on using the repository browser.