source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORQQVI.m@ 1361

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

initial load of WorldVistAEHR

File size: 6.4 KB
RevLine 
[613]1ORQQVI ; slc/STAFF - Functions which return patient vital and I/O data ;10/26/06 11:44
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,198,215,250,260**;Dec 17, 1997;Build 26
3VITALS(ORY,DFN,ORSDT,OREDT) ; return patient's vital measurements taken between start date/time and end date/time
4 ;ORY: return variable, results are returned in the format:
5 ; vital measurement ien^vital type^date/time taken^rate
6 ;DFN: patient identifier from Patient File [#2]
7 ;ORSDT: start date/time in Fileman format
8 ;OREDT: end date/time in Fileman format
9 K ^UTILITY($J,"GMRVD")
10 S GMRVSTR="BP;HT;WT;T;R;P;PN" ;dee 2/12/99 added PN
11 S GMRVSTR(0)=ORSDT_"^"_OREDT_"^"_"^"
12 D EN1^GMRVUT0
13 N ORT,ORD,ORI,I
14 S ORT="",ORD=0,ORI=0,I=0
15 F S ORT=$O(^UTILITY($J,"GMRVD",ORT)) Q:ORT="" D
16 .F S ORD=$O(^UTILITY($J,"GMRVD",ORT,ORD)) Q:ORD<1 D
17 ..F S ORI=$O(^UTILITY($J,"GMRVD",ORT,ORD,ORI)) Q:ORI<1 D
18 ...S I=I+1
19 ...S ORY(I)=ORI_"^"_ORT_"^"_$P(^UTILITY($J,"GMRVD",ORT,ORD,ORI),"^",8)_"^"_$P(^(ORI),"^")
20 I I=0 S ORY(1)="^No vitals found."
21 K GMRVSTR
22 Q
23 ;
24XFASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
25 ;ORY: return variable, results are returned in the format:
26 ; vital measurement ien^vital type^rate^date/time taken
27 ;DFN: patient identifier from Patient File [#2]
28 ; F1 & F2 are ignored
29 ;
30 N CNT
31 S CNT=0
32 D VITAL("TEMPERATURE","T",DFN,.ORY,.CNT)
33 D VITAL("PULSE","P",DFN,.ORY,.CNT)
34 D VITAL("RESPIRATION","R",DFN,.ORY,.CNT)
35 D VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT)
36 D VITAL("HEIGHT","HT",DFN,.ORY,.CNT)
37 D VITAL("WEIGHT","WT",DFN,.ORY,.CNT)
38 D VITAL("PAIN","PN",DFN,ORY,.CNT) ;dee 2/11/99
39 Q
40 ;
41XVITAL(VITAL,ABBREV,DFN,ORY,CNT) ; get vital measurement
42 N DATA,IDT,IEN,OK,VTYPE
43 S VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
44 I 'VTYPE Q
45 S OK=0,IDT=0 F S IDT=$O(^GMR(120.5,"AA",DFN,VTYPE,IDT)) Q:IDT<1 D Q:OK
46 .S IEN=0 F S IEN=$O(^GMR(120.5,"AA",DFN,VTYPE,IDT,IEN)) Q:IEN<1 D Q:OK
47 ..I $P($G(^GMR(120.5,IEN,2)),U) Q ; do not retrieve if entered in error
48 ..S DATA=$G(^GMR(120.5,IEN,0))
49 ..I 'DATA Q
50 ..S CNT=CNT+1,OK=1
51 ..S ORY(CNT)=IEN_U_ABBREV_U_$P(DATA,U,8)_U_$P(DATA,U)
52 Q
53 ;
54NOTEVIT(ORY,DFN,NOTEIEN) ;
55 N VSTR,NOTEDATE
56 D NOTEVSTR^ORWPCE(.VSTR,NOTEIEN)
57 Q:$P(VSTR,";",2)=""
58 D FASTVIT(.ORY,DFN,$P(VSTR,";",2))
59 Q
60 ;
61FASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
62 ; in date range
63 ;ORY: return variable, results are returned in the format:
64 ; vital measurement ien^vital type^rate^date/time taken
65 ;DFN: patient identifier from Patient File [#2]
66 ; F1: starting date/time range
67 ; F2: ending date/time range
68 ;
69 N CNT,DT1,DT2
70 S CNT=0
71 I $G(F1)>0 D
72 . I $G(F2)="",F1["." S DT1=$P(F1,".",1)_"."_$E($P(F1,".",2),1,4)
73 . E S DT1=F1
74 E S DT1=1
75 S DT2=$S($G(F2)>0:F2,DT1>1:DT1,1:9999998)
76 ;
77 D VITAL("TEMPERATURE","T",DFN,.ORY,.CNT,DT1,DT2)
78 D VITAL("PULSE","P",DFN,.ORY,.CNT,DT1,DT2)
79 D VITAL("RESPIRATION","R",DFN,.ORY,.CNT,DT1,DT2)
80 D VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT,DT1,DT2)
81 D VITAL("HEIGHT","HT",DFN,.ORY,.CNT,DT1,DT2)
82 D VITAL("WEIGHT","WT",DFN,.ORY,.CNT,DT1,DT2)
83 D VITAL("PAIN","PN",DFN,.ORY,.CNT,DT1,DT2) ;dee 2/11/99
84 D VITAL("PULSE OXIMETRY","PO2",DFN,.ORY,.CNT,DT1,DT2)
85 D VITAL("CENTRAL VENOUS PRESSURE","CVP",DFN,.ORY,.CNT,DT1,DT2)
86 D VITAL("CIRCUMFERENCE/GIRTH","CG",DFN,.ORY,.CNT,DT1,DT2)
87 D VITAL("BODY MASS INDEX","BMI",DFN,.ORY,.CNT,DT1,DT2)
88 Q
89 ;
90VITAL(VITAL,ABBREV,DFN,ORY,CNT,F1,F2) ;
91 ;get most recent vital measurement in date range
92 I ABBREV="BMI" D BMILAST^ORWGAPIX(DFN,.ORY,.CNT) Q
93 N DATA,IDT,ENDIDT,IEN,OK,VTYPE,MVAL,VALUE
94 S VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
95 I 'VTYPE Q
96 S OK=0
97 S IDT=9999999-(F2+$S(F2#1:.0000001,1:.7))
98 S ENDIDT=9999999-(F1-.0000001)
99 F S IDT=$O(^GMR(120.5,"AA",DFN,VTYPE,IDT)) Q:IDT>ENDIDT!'IDT D Q:OK
100 .S IEN=0 F S IEN=$O(^GMR(120.5,"AA",DFN,VTYPE,IDT,IEN)) Q:IEN<1 D Q:OK
101 ..I $P($G(^GMR(120.5,IEN,2)),U) Q ; do not retrieve if entered in error
102 ..S DATA=$G(^GMR(120.5,IEN,0))
103 ..I 'DATA Q
104 ..S CNT=CNT+1,OK=1,VALUE=$P(DATA,U,8)
105 ..; changed to display 'POX' rather than 'PO2' per CQ 10592
106 ..S ORY(CNT)=IEN_U_$S(ABBREV="PO2":"POX",1:ABBREV)_U_VALUE_U_$P(DATA,U)
107 ..I $P(ORY(CNT),"^",2)="T" D ; Temperature.
108 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" F",1:"")
109 ...S MVAL=+VALUE
110 ...Q:'MVAL
111 ...S MVAL=MVAL-32
112 ...S MVAL=$J((MVAL*(5/9)),3,1)
113 ...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" C)"
114 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
115 ..I $P(ORY(CNT),"^",2)="P" D ; Pulse.
116 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE
117 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
118 ..I $P(ORY(CNT),"^",2)="R" D ; Respiration.
119 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE
120 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
121 ..I $P(ORY(CNT),"^",2)="BP" D ; Blood Pressure.
122 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE
123 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
124 ..I $P(ORY(CNT),"^",2)="HT" D ; Height.
125 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" in",1:"")
126 ...S MVAL=+VALUE
127 ...Q:'MVAL
128 ...S MVAL=$J((MVAL*2.54),3,1)
129 ...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" cm)"
130 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
131 ..I $P(ORY(CNT),"^",2)="WT" D ; Weight.
132 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" lb",1:"")
133 ...S MVAL=+VALUE
134 ...Q:'MVAL
135 ...; changed 2.2 to 2.20462262 per CQ 10637
136 ...S MVAL=$J((MVAL/2.20462262),3,1)
137 ...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" kg)"
138 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8($P(ORY(CNT),U,1))
139 ..I $P(ORY(CNT),"^",2)="PN" D ; Pain
140 ...S ORY(CNT)=ORY(CNT)_"^"_VALUE
141 ...S $P(ORY(CNT),U,7)="" ;pain doesn't have qualifiers
142 ..; looks for 'POX' rather than 'PO2' due to change for CQ 10592 above
143 ..I $P(ORY(CNT),"^",2)="POX" D ; Pulse Oximetry.
144 ...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
145 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8(+$P(ORY(CNT),U,1))
146 ...S $P(ORY(CNT),U,8)=$$SUPO2^GMVUTL8(+$P(ORY(CNT),U,1))
147 ..I $P(ORY(CNT),"^",2)="CVP" D ; Central Venous Pressure.
148 ...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
149 ...S MVAL=$P(ORY(CNT),"^",3)
150 ...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)="" Q
151 ...S MVAL=$J((MVAL/1.36),3,1)
152 ...S ORY(CNT)=ORY(CNT)_" cmH20^("_MVAL_" mmHg)"
153 ...S $P(ORY(CNT),U,7)="" ;cvp doesn't have qualifiers
154 ..I $P(ORY(CNT),"^",2)="CG" D ; Circumference Girth.
155 ...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
156 ...S MVAL=$P(ORY(CNT),"^",3)
157 ...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8(+$P(ORY(CNT),U,1)) Q
158 ...S MVAL=$J((MVAL*2.54),3,1)
159 ...S ORY(CNT)=ORY(CNT)_" in^("_MVAL_" cm)"
160 ...S $P(ORY(CNT),U,7)=$$QUALIFRS^GMVUTL8(+$P(ORY(CNT),U,1))
161 Q
Note: See TracBrowser for help on using the repository browser.