source: FOIAVistA/trunk/r/GEN_MED_OTHER-GMV/GMVER1.m@ 1800

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

initial load of FOIAVistA 6/30/08 version

File size: 6.4 KB
Line 
1GMVER1 ;HOIFO/RM,YH,FT-ENTERED IN ERROR FOR A PATIENT & DATE RANGE ;12/12/01 12:36
2 ;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; #10104 - ^XLFSTR calls (supported)
6 ; #10103 - ^XLFDT calls (supported)
7 ;
8EN1(RESULT,GMVDFN,GMVBEG,GMVEND) ; [RPC entry point]
9 ; Returns Entered in Error records for a date range
10 ; Input:
11 ; RESULT = Where data is returned (closed array reference) (Required)
12 ; GMVDFN = A pointer to the Patient file (#2) (Required)
13 ; GMVBEG = Beginning date for all vitals
14 ; GMVEND = Ending date for all vitals
15 ;
16 ; Output:
17 ; RESULT() = TMP global address with the nodes of report text
18 ; The TMP global nodes are:
19 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,1)=date/time of the error, Vital
20 ; type, name of user
21 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,2)=error reason
22 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,3)=revised data, if any (optional)
23 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,4)=the incorrect data
24 ;
25 S GMRVITY=0
26 K ^TMP($J,"LIST"),^TMP($J,"ERRORS")
27 F S GMRVITY=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY)) Q:GMRVITY'>0 F GMRVDT=0:0 S GMRVDT=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT)) Q:GMRVDT'>0 S GMRVDATE=9999999-GMRVDT I GMRVDATE'<GMVBEG,GMRVDATE'>GMVEND D SORT
28 S GMRDATE=0
29 F S GMRDATE=$O(^TMP($J,"LIST",GMRDATE)) Q:GMRDATE'>0 F GMRVITY=0:0 S GMRVITY=$O(^TMP($J,"LIST",GMRDATE,GMRVITY)) Q:GMRVITY'>0 F GMRVDA=0:0 S GMRVDA=$O(^TMP($J,"LIST",GMRDATE,GMRVITY,GMRVDA)) Q:GMRVDA'>0 D WRT
30Q ; KILL VARIABLES
31 K BADRATE,GOODRATE,GMRDAT,GMRDATE,GMRPR,GMRVDA,GMRVDATE,GMRVDT,GMRVERR,GMVEND,GMRVITY,GMVBEG,GMRVX,GMRP,GMRTYPE
32 K GREASON,GMRZZ,GMRVARY,GMRQUAL,GMRVPO,GMVNODE,GMVSPACE,^TMP($J,"LIST")
33 I '$D(^TMP($J,"ERRORS")) S ^TMP($J,"ERRORS",0)="No data for the time period indicated."
34 S RESULT=$NA(^TMP($J,"ERRORS"))
35 Q
36SORT ; loop through the AA x-ref and find patient entries marked as
37 ; entered in error (i.e., node 2 exists).
38 S GMRVERR=0
39 F S GMRVERR=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVERR)) Q:GMRVERR'>0 I '$D(^GMR(120.5,GMRVERR,2)) Q
40 S GMRVDA=0
41 F S GMRVDA=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVDA)) Q:GMRVDA'>0 I $D(^GMR(120.5,GMRVDA,2)) S ^TMP($J,"LIST",GMRVDATE,GMRVITY,GMRVDA)=GMRVERR
42 Q
43WRT ;
44 S GMRVERR=^TMP($J,"LIST",GMRDATE,GMRVITY,GMRVDA)
45 S GMRDAT("GOOD")=$S($D(^GMR(120.5,+GMRVERR,0)):^(0),1:"")
46 I $D(^GMR(120.5,+GMRVERR,0)) D
47 .K GMRVX
48 .S GMRVX=$P(^GMRD(120.51,GMRVITY,0),"^",2)
49 .S GMRVX(0)=$P(GMRDAT("GOOD"),"^",8)
50 .D:GMRVX(0)>0!(GMRVX(0)=0) EN1^GMVSAS0
51 .S GMRVX(1)=$S('$D(GMRVX(1)):"",'GMRVX(1):"",1:"*")
52 .S GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
53 .S GMRZZ=""
54 .I $P($G(^GMR(120.5,GMRVERR,5,0)),"^",4)>0 D
55 ..K GMRVARY
56 ..S GMRVARY=""
57 ..D CHAR^GMVCHAR(GMRVERR,.GMRVARY,GMRVITY)
58 ..S GMRZZ=$$WRITECH^GMVCHAR(GMRVERR,.GMRVARY,9)
59 ..S:GMRZZ'=""&(GMRVX'="PO2") GMRZZ=" ("_GMRZZ_")"
60 ..Q
61 . I GMRVX="P" D
62 ..I GMRZZ'="",GMRVX(0)=1 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)=""
63 ..I GMRZZ'="",GMRVX(0)=0 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)="*"
64 ..Q
65 .S GMRVPO=$P(^GMR(120.5,GMRVERR,0),"^",10)
66 .S $P(GMRDAT("GOOD"),"^",8)=GMRVX(0)_GMRVX(1)_$S(GMRVPO'="":" with supplemental O2 "_$S(GMRVPO["l/min":$P(GMRVPO," l/min")_"L/min",1:"")_$S(GMRVPO["l/min":$P(GMRVPO," l/min",2),1:GMRVPO),1:"")_$S(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
67 .Q
68 I $D(^GMR(120.5,+GMRVDA,0)) D
69 .S GMRDAT("BAD")=$S($D(^GMR(120.5,+GMRVDA,0)):^(0),1:"")
70 .K GMRVX,GMRVX(0),GMRVX(1)
71 .S GMRVX=$P(^GMRD(120.51,GMRVITY,0),"^",2)
72 .S GMRVX(0)=$P(GMRDAT("BAD"),"^",8)
73 .D:GMRVX(0)>0 EN1^GMVSAS0
74 .S GMRVX(1)=$S('$D(GMRVX(1)):"",'GMRVX(1):"",1:"*")
75 .S GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
76 .S GMRZZ=""
77 .I $P($G(^GMR(120.5,GMRVDA,5,0)),"^",4)>0 D
78 ..K GMRVARY
79 ..S GMRVARY=""
80 ..D CHAR^GMVCHAR(GMRVDA,.GMRVARY,GMRVITY)
81 ..S GMRZZ=$$WRITECH^GMVCHAR(GMRVDA,.GMRVARY,9)
82 ..S:GMRZZ'=""&(GMRVX'="PO2") GMRZZ=" ("_GMRZZ_")"
83 ..Q
84 .I GMRVX="P" D
85 ..I GMRZZ'="",GMRVX(0)=1 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)=""
86 ..I GMRZZ'="",GMRVX(0)=0 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)="*"
87 ..Q
88 .S GMRVPO=$P(^GMR(120.5,GMRVDA,0),"^",10)
89 .S $P(GMRDAT("BAD"),"^",8)=GMRVX(0)_GMRVX(1)_$S(GMRVPO'="":" with supplemental O2 "_$S(GMRVPO["l/min":$P(GMRVPO," l/min")_"L/min",1:"")_$S(GMRVPO["l/min":$P(GMRVPO," l/min",2),1:GMRVPO),1:"")_$S(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
90 .S GREASON="" D ERREASON
91 S GMRPR("VSDT")=$$FMTE^XLFDT(GMRDATE)
92 S GMRPR("ENUS")=$E($$PERSON^GMVUTL1(+$P(GMRDAT("BAD"),U,6)),1,21)
93 S GMRPR("TYPE")=$S(GMRVITY="":"",$D(^GMRD(120.51,GMRVITY,0)):$P(^(0),"^"),1:"")
94 S GMVNODE=""
95 S GMVSPACE=$$REPEAT^XLFSTR(" ",79) ;line of spaces
96 S GMVNODE=GMRPR("VSDT")
97 S GMVNODE=GMVNODE_$$FILLER^GMVUTL1(21,$L(GMVNODE),GMVSPACE)_GMRPR("TYPE")
98 S GMVNODE=GMVNODE_$$FILLER^GMVUTL1(58,$L(GMVNODE),GMVSPACE)_GMRPR("ENUS")
99 S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,1)=GMVNODE
100 S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,2)=" Reason: "_GREASON
101 S GMVNODE=""
102 I $G(GMRVERR)>0 S GMVNODE=" (Revised) "_$P(GMRDAT("GOOD"),"^",8) D
103 .I GMRVX="PN" D
104 ..S GOODRATE=$P(GMRDAT("GOOD"),U,8)
105 ..S GMVNODE=GMVNODE_$S(GOODRATE=0:" No pain",GOODRATE=10:" Worst imaginable pain",GOODRATE=99:" Unable to respond",1:"")
106 ..Q
107 .Q
108 I $L(GMVNODE)>0 D
109 .S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,3)=GMVNODE
110 .Q
111 S GMVNODE=""
112 I GMRVDA>0 S GMVNODE=" (Bad data) "_$P(GMRDAT("BAD"),"^",8) D
113 .I GMRVX="PN" D
114 ..S BADRATE=$P(GMRDAT("BAD"),U,8)
115 ..S GMVNODE=GMVNODE_$S(BADRATE=0:" No pain",BADRATE=10:" Worst imaginable pain",BADRATE=99:" Unable to respond",1:"")
116 ..Q
117 .Q
118 I $L(GMVNODE)>0 D
119 .S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,4)=GMVNODE
120 .Q
121 Q
122ERREASON ;ERROR REASON
123 Q:'$D(^GMR(120.5,+GMRVDA,2.1))
124 S GER=0
125 F S GER=$O(^GMR(120.5,+GMRVDA,2.1,GER)) Q:GER'>0 S GER(1)=+$G(^GMR(120.5,+GMRVDA,2.1,GER,0)) D
126 .S GER(2)=$S(GER(1)=1:"incorrect date/time",GER(1)=2:"incorrect reading",GER(1)=3:"incorrect patient",GER(1)=4:"invalid record",1:"")
127 .I GER(2)'="" S GREASON=GREASON_$S(GREASON'="":", ",1:"")_GER(2)
128 .Q
129 K GER
130 Q
131WRTDAT(TYPE,DATA) ;
132 I '((TYPE="BP")!(TYPE="P")!(TYPE="R")),DATA>0 D @($$UP^XLFSTR(TYPE))
133 Q DATA
134T S DATA=DATA_" F ("_$J(+DATA-32*5/9,0,1)_" C)" Q
135WT S DATA=DATA_" lb ("_$J(DATA/2.2,0,2)_" kg)" Q
136HT S DATA=$S(DATA\12:DATA\12_" ft ",1:"")_$S(DATA#12:DATA#12_" in",1:"")_" ("_$J(DATA*2.54,0,2)_" cm)" Q
137CG S DATA=DATA_" in ("_$J(+DATA/.3937,0,2)_" cm)" Q
138CVP S DATA=DATA_" cmH2O ("_$J(DATA/1.36,0,1)_" mmHg)" Q
139PO2 S DATA=DATA_"%" Q
140PN I DATA=0 S DATA=DATA_" No pain " Q
141 I DATA=99 S DATA=DATA_" Unable to respond " Q
142 I DATA=10 S DATA=DATA_" Worst imaginable pain " Q
143 Q
Note: See TracBrowser for help on using the repository browser.