source: WorldVistAEHR/trunk/r/CARE_MANAGEMENT-ORRC/ORRCVIT.m@ 1696

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1ORRCVIT ;SLC/MKB - Vitals utilities ; 25 Jul 2003 9:31 AM
2 ;;1.0;CARE MANAGEMENT;;Jul 15, 2003
3 ;
4 ; ID = "VIT:"_PatientID_;_MeasurementDate everywhere below
5 ;
6LIST(ORY,DFN,SDATE,EDATE,VALS) ; -- Return MAX sets of measurements for DFN
7 ; in @ORY@(#) = Item=ID^^MeasurementDate in HL7 format, and if VALS
8 ; = Data=Vital^Value^Unit^MetricValue^Unit^BMI^SuppO2^CriticalFlag^Qualifiers
9 ; RPC = ORRC VITALS BY PATIENT
10 N ORN,GMRVSTR,CNT,IDT,VDT,TYPE,IFN,DATA,X K ^UTILITY($J,"GMRVD")
11 S SDATE=$$HL7TFM^XLFDT($G(SDATE)),EDATE=$$HL7TFM^XLFDT($G(EDATE))
12 S DFN=+$G(DFN),MAX=$S(SDATE&EDATE:100,1:5)
13 I $G(EDATE),$L(EDATE,".")<2 S EDATE=EDATE_".2359"
14 S GMRVSTR="BP;T;R;P;HT;WT;CVP;CG;PO2;PN",GMRVSTR(0)=SDATE_U_EDATE_U_MAX_"^1"
15 D EN1^GMRVUT0 S ORY=$NA(^TMP($J,"ORRCVIT")),(ORN,CNT)=0 K @ORY
16 S IDT=0 F S IDT=$O(^UTILITY($J,"GMRVD",IDT)) Q:IDT<1 D Q:CNT'<MAX
17 . S VDT=9999999-IDT,CNT=CNT+1
18 . S ORN=ORN+1,@ORY@(ORN)="Item=VIT:"_DFN_";"_VDT_U_U_VDT Q:'$G(VALS)
19 . S TYPE="" F S TYPE=$O(^UTILITY($J,"GMRVD",IDT,TYPE)) Q:TYPE="" D
20 .. S IFN=0 F S IFN=$O(^UTILITY($J,"GMRVD",IDT,TYPE,IFN)) Q:IFN<1 S X=$G(^(IFN)) D
21 ... D @TYPE ;return DATA w/relevant pieces
22 ... S ORN=ORN+1,@ORY@(ORN)="Data="_DATA
23 K ^UTILITY($J,"GMRVD")
24 Q
25 ;
26DETAIL(ORY,VITAL) ; -- Return details of VITALs
27 ; where VITAL(#) = ID
28 ; in @ORY@(#) = Item=ID^^MeasurementDate in HL7 format
29 ; = Data=Vital^Value^Unit^MetricValue^Unit^BMI^SuppO2^CriticalFlag^Qualifiers
30 ; RPC = ORRC VITALS BY ID
31 N GMRVSTR,DFN,STRT,STOP,ORN,ORI,ID,IDT,VDT,TYPE,IFN,DATA,X
32 K ^UTILITY($J,"GMRVD") D RANGE
33 S GMRVSTR="BP;T;R;P;HT;WT;CVP;CG;PO2;PN",GMRVSTR(0)=STRT_U_STOP_"^100^1"
34 D EN1^GMRVUT0 S ORY=$NA(^TMP($J,"ORRCVIT")),ORN=0 K @ORY
35 S ORI=0 F S ORI=$O(VITAL(ORI)) Q:ORI<1 S ID=$G(VITAL(ORI)) D
36 . S VDT=$P(ID,";",2),IDT=9999999-VDT
37 . S ORN=ORN+1,@ORY@(ORN)="Item="_ID_U_U_VDT
38 . S TYPE="" F S TYPE=$O(^UTILITY($J,"GMRVD",IDT,TYPE)) Q:TYPE="" D
39 .. S IFN=0 F S IFN=$O(^UTILITY($J,"GMRVD",IDT,TYPE,IFN)) Q:IFN<1 S X=$G(^(IFN)) D
40 ... D @TYPE ;return DATA w/relevant pieces
41 ... S ORN=ORN+1,@ORY@(ORN)="Data="_DATA
42 K ^UTILITY($J,"GMRVD")
43 Q
44 ;
45RANGE ; -- Get STRT,STOP,DFN from VITALs
46 N ORI,ID,VDT S (STRT,STOP)=""
47 S ORI=0 F S ORI=$O(VITAL(ORI)) Q:ORI<1 S ID=$G(VITAL(ORI)) D
48 . S DFN=+$P(ID,":",2),VDT=$P(ID,";",2)
49 . I $S('$L(STRT):1,VDT<STRT:1,1:0) S STRT=VDT
50 . I $S('$L(STOP):1,VDT>STOP:1,1:0) S STOP=VDT
51 Q
52 ;
53 ; Return formatted DATA string from X:
54 ;
55BP ; -- Blood Pressure = B/P^value^^^^^^[*]^Q1;..;Qn
56 S DATA="B/P^"_$P(X,U,8)_"^^^^^^"_$P(X,U,12)_U_$P(X,U,17)
57 Q
58T ; -- Temperature = Temp.^value^F^metric^C^^^[*]^Q1;..;Qn
59 S DATA="Temp.^"_$P(X,U,8)_"^F^"_$P(X,U,13)_"^C^^^"_$P(X,U,12)_U_$P(X,U,17)
60 Q
61R ; -- Respiration = Resp.^value^^^^^^[*]^Q1;..;Qn
62 S DATA="Resp.^"_$P(X,U,8)_"^^^^^^"_$P(X,U,12)_U_$P(X,U,17)
63 Q
64P ; -- Pulse = Pulse^value^^^^^^[*]^Q1;..;Qn
65 S DATA="Pulse^"_$P(X,U,8)_"^^^^^^"_$P(X,U,12)_U_$P(X,U,17)
66 Q
67HT ; -- Height = Ht.^value^in^metric^cm^^^[*]^Q1;..;Qn
68 S DATA="Ht.^"_$P(X,U,8)_"^in^"_$P(X,U,13)_"^cm^^^"_$P(X,U,12)_U_$P(X,U,17)
69 Q
70WT ; -- Weight = Wt.^value^lb^metric^kg^BodyMassIndex^^[*]^Q1;..;Qn
71 S DATA="Wt.^"_$P(X,U,8)_"^lb^"_$P(X,U,13)_"^kg^"_$P(X,U,14)_U_U_$P(X,U,12)_U_$P(X,U,17)
72 Q
73CVP ; -- CenVenPress = CVP^value^cmH2O^^^^^[*]^Q1;..;Qn
74 S DATA="CVP^"_$P(X,U,8)_"^cmH2O^^^^^"_$P(X,U,12)_U_$P(X,U,17)
75 Q
76CG ; -- Circm/Girth = C/G^value^in^metric^cm^^^[*]^Q1;..;Qn
77 S DATA="C/G^"_$P(X,U,8)_"^in^"_$P(X,U,13)_"^cm^^^"_$P(X,U,12)_U_$P(X,U,17)
78 Q
79PO2 ; -- PulseOx = Pulse Ox^value^^^^^l/min of supplemental O2^[*]^Q1;..;Qn
80 S DATA="Pulse Ox^"_$P(X,U,8)_"^^^^^"_$P(X,U,15)_U_$P(X,U,12)_U_$P(X,U,17)
81 Q
82PN ; -- Pain = Pain^value^^^^^^[*]^Q1;..;Qn
83 S DATA="Pain^"_$P(X,U,8)_"^^^^^^"_$P(X,U,12)_U_$P(X,U,17)
84 Q
85 ;
86IDS(ORY,DFN,SDATE,EDATE) ; --Return recent measurement IDs for DFN
87 ; in @ORY@(DFN) = #sets ^ 1 if any are critical
88 ; @ORY@(DFN,ID) = * if critical, else null
89 ; [from ORRCDPT1]
90 N GMRVSTR,MAX,CNT,ABN,IDT,VDT,X
91 S ORY=$NA(^TMP($J,"ORRCVIT")) K @ORY,^UTILITY($J,"GMRVD")
92 S DFN=+$G(DFN),MAX=$S($G(SDATE)&$G(EDATE):100,1:5)
93 I $G(EDATE),$L(EDATE,".")<2 S EDATE=EDATE_".2359" ;end of day
94 S GMRVSTR="BP;T;R;P;HT;WT;CVP;CG;PO2;PN",GMRVSTR(0)=$G(SDATE)_U_$G(EDATE)_U_MAX_"^1"
95 D EN1^GMRVUT0 S CNT=0,ABN=""
96 S IDT=0 F S IDT=$O(^UTILITY($J,"GMRVD",IDT)) Q:IDT<1 D Q:CNT'<MAX
97 . S VDT=9999999-IDT,CNT=CNT+1,X=$$ABN(IDT)
98 . S @ORY@(DFN,"VIT:"_DFN_";"_VDT)=X S:$L(X) ABN=1
99 S:CNT @ORY@(DFN)=CNT_U_ABN
100 K ^UTILITY($J,"GMRVD")
101 Q
102 ;
103ABN(IDT) ; -- Return * if any value from measurement set is critical, else null
104 N Y,TYPE,IFN S Y=""
105 S TYPE="" F S TYPE=$O(^UTILITY($J,"GMRVD",IDT,TYPE)) Q:TYPE="" D
106 . S IFN=0 F S IFN=$O(^UTILITY($J,"GMRVD",IDT,TYPE,IFN)) Q:IFN<1 S:$G(^(IFN))["*" Y="*"
107 Q Y
Note: See TracBrowser for help on using the repository browser.