source: WorldVistAEHR/trunk/r/GEN_MED_OTHER-GMV/GMVDCEXT.m@ 1474

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

initial load of WorldVistAEHR

File size: 6.7 KB
Line 
1GMVDCEXT ;HOIFO/DAD,FT-VITALS COMPONENT: EXTRACT PATIENT DATA ;9/29/00 09:16
2 ;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; #10035 - FILE 2 references (supported)
6 ; #10104 - ^XLFSTR calls (supported)
7 ;
8EN1(RESULT,GMVDFN,GMVFMT,GMVABR,GMVALL,GMVBEG,GMVEND,GMVMSYS,GMVEER) ;
9 ; Return patient vitals
10 ;
11 ; Input:
12 ; RESULT = Where data is returned (closed array reference) (Required)
13 ; GMVDFN = A pointer to the Patient file (#2) (Required)
14 ; GMVFMT = Format of returned data (Optional)
15 ; 1 - IENs (default), 2 - Abbreviations, 3 - Full Names
16 ; GMVABR = Abbreviations of vital types to return (Optional)
17 ; "^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^" (Default GMVALL = 0)
18 ; "~ALL~" to return all vital types (Default GMVALL = 1)
19 ; GMVALL = Controls what data is returned (Optional)
20 ; 0 - Most recent (default), 1 - All in date range
21 ; GMVBEG = Beginning date for all vitals (Not used for GMVALL = 0)
22 ; GMVEND = Ending date for all vitals (Not used for GMVALL = 0)
23 ; GMVMSYS = Measurement system (Optional)
24 ; M = Metric, C - US Customary (Default)
25 ; GMVEER = Include entered in error records (Optional)
26 ; (0 - No (Default), 1 - Yes)
27 ;
28 ; Output:
29 ; RESULT() = VitalMeasurementIEN ^ DateTimeTaken ^ PatientDFN ^
30 ; VitalType ^ DateTimeEntered ^ HospitalLocation ^
31 ; EnteredBy ^ Measurement ^ EnteredInError ^
32 ; EnteredInErrorBy ^
33 ; Qualifier1 ; Qualifier2 ; ... ^
34 ; EnteredInErrorReason1 ; EnteredInErrorReason2 ; ... ^
35 ;
36 N GMV,GMVABBR,GMVALUE,GMVCAT,GMVCD0,GMVCD1,GMVD0,GMVD1,GMVDATA
37 N GMVDATA2,GMVER,GMVFOUND,GMVIDATE,GMVOK,GMVPOR,GMVPULSE,GMVQD0
38 N GMVQD1,GMVQUA,GMVQL
39 N GMVRATE
40 K @RESULT
41 S @RESULT@(0)="OK"
42 S GMVALL=$S("^0^1^"[(U_$G(GMVALL)_U):GMVALL,1:0)
43 S GMVFMT=$S("^1^2^3^"[(U_$G(GMVFMT)_U):GMVFMT,1:1)
44 S GMVEER=$S(GMVALL=0:0,"^0^1^"[(U_$G(GMVEER)_U):GMVEER,1:0)
45 I $$FIND1^DIC(2,"","","`"_GMVDFN)'=GMVDFN D
46 . S @RESULT@(0)="ERROR"
47 . S @RESULT@(1)="ERROR: Missing or invalid Patient parameter"
48 . Q
49 S GMVMSYS=$$MEASYS^GMVDCUTL($G(GMVMSYS))
50 K GMVRET
51 D DT^DILF("ST",$G(GMVEND),.GMVRET,"-NOW")
52 S GMVEND=$G(GMVRET)
53 K GMVRET
54 D DT^DILF("ST",$G(GMVBEG),.GMVRET,-GMVEND)
55 S GMVBEG=$G(GMVRET)
56 I GMVALL&((GMVBEG'>0)!(GMVEND'>0)) D
57 . S @RESULT@(0)="ERROR"
58 . S @RESULT@(2)="ERROR: Missing or invalid Date Range parameters"
59 . Q
60 I $G(@RESULT@(0))="ERROR" Q
61 S GMVABBR=$S($G(GMVABR)]"":GMVABR,GMVALL=1:"~ALL~",1:"^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^")
62 I GMVABBR="~ALL~" D
63 . S GMVD0=0,GMVABBR=U
64 . F S GMVD0=$O(^GMRD(120.51,GMVD0)) Q:GMVD0'>0 D
65 .. S GMVABBR(0)=$P($G(^GMRD(120.51,GMVD0,0)),U,2)
66 .. I GMVABBR(0)]"" S GMVABBR=GMVABBR_GMVABBR(0)_U
67 .. Q
68 . Q
69 S GMVABBR=$S($E(GMVABBR)'=U:U,1:"")_GMVABBR_$S($E(GMVABBR,$L(GMVABBR))'=U:U,1:"")
70 F GMV=2:1:$L(GMVABBR,U)-1 S GMVABBR(0)=$P(GMVABBR,U,GMV) D
71 . I $S(GMVABBR(0)="":1,$O(^GMRD(120.51,"C",GMVABBR(0),0))>0:1,1:0) Q
72 . I GMVABBR(0)'=+GMVABBR(0) S GMVABBR(0)=+$O(^GMRD(120.51,"B",GMVABBR(0),0))
73 . S GMVABBR(0)=$P($G(^GMRD(120.51,GMVABBR(0),0)),U,2)
74 . S $P(GMVABBR,U,GMV)=GMVABBR(0)
75 . Q
76 F GMV=1:1 S GMVPULSE=$P($T(PULSE+GMV),";;",2) Q:GMVPULSE="" D
77 . S GMVD0=0
78 . F S GMVD0=$O(^GMRD(120.52,"B",GMVPULSE,GMVD0)) Q:GMVD0'>0 D
79 .. I $P($G(^GMRD(120.52,GMVD0,0)),U)=GMVPULSE S GMVPULSE(GMVD0)=""
80 .. Q
81 . Q
82 S GMVD0=0
83 F S GMVD0=$O(^GMRD(120.51,GMVD0)) Q:GMVD0'>0 D
84 . S GMVABBR(0)=$G(^GMRD(120.51,GMVD0,0))
85 . I GMVABBR[(U_$P(GMVABBR(0),U,2)_U) S GMVABBR($P(GMVABBR(0),U,2))=GMVD0_U_$P(GMVABBR(0),U,2)_U_$P(GMVABBR(0),U)
86 . Q
87 S GMVABBR=""
88 F S GMVABBR=$O(GMVABBR(GMVABBR)) Q:GMVABBR="" I GMVABBR(GMVABBR)>0 D
89 . S GMVFOUND=0
90 . S GMVIDATE=$S(GMVALL:9999999-GMVEND,1:0)
91 . F S GMVIDATE=$O(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE)) Q:GMVIDATE'>0!$S(GMVALL:9999999-GMVIDATE<GMVBEG,1:0)!GMVFOUND D SETDATAR
92 . Q
93 Q
94 ;
95SETDATAR ;
96 S GMVD0=0
97 F S GMVD0=$O(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE,GMVD0)) Q:GMVD0'>0!GMVFOUND I $P($G(^GMR(120.5,GMVD0,0)),U,8)]"" D SETNODE
98 Q
99 ;
100SETNODE ;
101 S GMVDATA=$G(^GMR(120.5,GMVD0,0))
102 S GMVDATA2=$G(^GMR(120.5,GMVD0,2))
103 S GMVRATE=$P(GMVDATA,U,8)
104 I GMVALL=0,"^REFUSED^PASS^UNAVAILABLE^"[(U_$$UP^XLFSTR(GMVRATE)_U) Q
105 I GMVEER=0,(($P(GMVDATA2,U)>0)!($P(GMVDATA2,U,2)>0)) Q
106 I GMVABBR="PO2",$P(GMVDATA,U,10)]"" D
107 . ; *** Decode Supplemental O2 field (#1.4) ***
108 . N GMVFRATE,GMVPCENT,GMVSUPO2
109 . S GMVSUPO2=$$LOW^XLFSTR($TR($P(GMVDATA,U,10)," "))
110 . S GMVFRATE=$S(GMVSUPO2["l/min":$P(GMVSUPO2,"l/min"),1:"")
111 . S GMVFRATE=$TR(GMVFRATE,$TR(GMVFRATE,".0123456789"))
112 . S GMVPCENT=$S(GMVSUPO2["%":$P(GMVSUPO2,"%"),1:"")
113 . S GMVPCENT=$S(GMVPCENT["l/min":$P(GMVPCENT,"l/min",2),GMVPCENT=+GMVPCENT:GMVPCENT,1:"")
114 . S GMVPCENT=$TR(GMVPCENT,$TR(GMVPCENT,".0123456789"))
115 . S GMVRATE=GMVRATE_";"_GMVFRATE_";"_GMVPCENT
116 . Q
117 I 'GMVALL,GMVABBR="P" D I 'GMVOK Q
118 . ; *** Include selected pulse types (latest vitals only) ***
119 . S (GMVPULSE,GMVOK)=0
120 . F S GMVPULSE=$O(GMVPULSE(GMVPULSE)) Q:GMVPULSE'>0 D Q:GMVOK
121 .. I $O(^GMR(120.5,GMVD0,5,"B",GMVPULSE,0)) S GMVOK=1
122 .. Q
123 . Q
124 I 'GMVALL S GMVFOUND=1
125 S GMVALUE=$$CNV^GMVDCCNV(GMVRATE,GMVMSYS,"G",$P(GMVABBR(GMVABBR),U,2))
126 S @RESULT@(GMVD0)=GMVD0_U_$P(GMVDATA,U)_U_$P(GMVDATA,U,2)_U_$P(GMVABBR(GMVABBR),U,GMVFMT)_U_$P(GMVDATA,U,4)_U_$P(GMVDATA,U,5)_U_$P(GMVDATA,U,6)_U_GMVALUE_U_$P(GMVDATA2,U)_U_$P(GMVDATA2,U,2)_U
127 S GMVD1=0 K GMVQL
128 F S GMVD1=$O(^GMR(120.5,GMVD0,5,GMVD1)) Q:GMVD1'>0 D
129 . S GMVQD0=+$P($G(^GMR(120.5,GMVD0,5,GMVD1,0)),U)
130 . S GMVQD1=+$O(^GMRD(120.52,GMVQD0,1,"B",GMVABBR(GMVABBR),0))
131 . S GMVCD0=+$P($G(^GMRD(120.52,GMVQD0,1,GMVQD1,0)),U,2)
132 . S GMVCAT=$P($G(^GMRD(120.53,GMVCD0,0)),U)
133 . S GMVCAT=$S(GMVCAT]"":GMVCAT,1:" ")
134 . S GMVQUA=$G(^GMRD(120.52,GMVQD0,0))
135 . S GMVQUA(1)=GMVQD0,GMVQUA(2)=$P(GMVQUA,U,2),GMVQUA(3)=$P(GMVQUA,U)
136 . S GMVCD1=+$O(^GMRD(120.53,"AA",+GMVABBR(GMVABBR),GMVCAT,GMVCD0,0))
137 . S GMVPOR=1+$P($G(^GMRD(120.53,GMVCD0,1,GMVCD1,0)),U,5)
138 . I $G(GMVQUA(GMVFMT))]"" D
139 .. S GMVQL(GMVPOR,GMVCAT)=$G(GMVQL(GMVPOR,GMVCAT))_GMVQUA(GMVFMT)_";"
140 .. Q
141 . Q
142 S GMVPOR=0
143 F S GMVPOR=$O(GMVQL(GMVPOR)) Q:GMVPOR'>0 D
144 . S GMVCAT=""
145 . F S GMVCAT=$O(GMVQL(GMVPOR,GMVCAT)) Q:GMVCAT="" D
146 .. S @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVQL(GMVPOR,GMVCAT)
147 .. Q
148 . Q
149 S @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
150 S GMVD1=0
151 S GMVER(0)=";"_$$GET1^DID(120.506,.01,"","POINTER")
152 F S GMVD1=$O(^GMR(120.5,GMVD0,2.1,GMVD1)) Q:GMVD1'>0 D
153 . S GMVER=$P($G(^GMR(120.5,GMVD0,2.1,GMVD1,0)),U)
154 . I GMVER(0)[(";"_GMVER_":") D
155 .. I GMVFMT<3 S @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVER_";"
156 .. E S @RESULT@(GMVD0)=@RESULT@(GMVD0)_$P($P(GMVER(0),";"_GMVER_":",2),";")_";"
157 .. Q
158 . Q
159 S @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
160 Q
161 ;
162FIXUP(X) ;
163 Q $S($E(X,$L(X))=";":$E(X,1,$L(X)-1),1:X)_U
164 ;
165PULSE ;;Pulse types to include in the latest vitals extract
166 ;;APICAL
167 ;;BRACHIAL
168 ;;RADIAL
169 ;;
Note: See TracBrowser for help on using the repository browser.