source: WorldVistAEHR/trunk/r/GEN_MED_OTHER-GMV/GMVDCVAL.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: 6.3 KB
Line 
1GMVDCVAL ;HOIFO/DAD,FT-VITALS COMPONENT: VALIDATE DATA ;9/29/00 09:18
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 ; #10040 - FILE 44 references (supported)
7 ; #10060 - FILE 200 fields (supported)
8 ; #10104 - ^XLFSTR calls (supported)
9 ;
10EN1(RESULT,GMVDATA) ;
11 ; *** Validates vitals data ***
12 N GMV,GMVD0,GMVID0,GMVIFIND,GMVIHOLD,GMVILAST,GMVINUM,GMVIXFRM
13 N GMVMSG,GMVOK,GMVQARRY,GMVQD0,GMVQFIND,GMVQHOLD,GMVQNUM,GMVRD0
14 N GMVRET,GMVRFIND,GMVRHOLD,GMVRNUM,GMVSYSBP,GMVVABBR,GMVVD0
15 N GMVVFIND,GMVVHOLD,GMVVLAST,GMVVMEAS,GMVVNUM
16 D EXIT
17 F GMV=1:1 S GMVSYSBP=$P($T(BPSYSQ+GMV),";;",2) Q:GMVSYSBP="" D
18 . S GMVD0=0
19 . F S GMVD0=$O(^GMRD(120.52,"B",GMVSYSBP,GMVD0)) Q:GMVD0'>0 D
20 .. I GMVSYSBP=$P($G(^GMRD(120.52,GMVD0,0)),U) S GMVSYSBP(GMVD0)=""
21 .. Q
22 . Q
23 I $O(@GMVDATA@(""))]"" D
24 . ; *** Vital measurement data validation ***
25 . I ($O(@GMVDATA@("V",0))>0)!($O(@GMVDATA@("Q",0))>0) D VITMEA
26 . ; *** Entered in Error data validation ***
27 . I ($O(@GMVDATA@("I",0))>0)!($O(@GMVDATA@("R",0))>0) D ENTERR
28 . Q
29 E D
30 . D MSG("ERROR: No data to validate/save")
31 . Q
32 I $G(RESULT(0))="OK" D MSG("OK: Data validated")
33 ;
34EXIT ; *** Clean-up ***
35 K ^TMP($J,"GMVXREF")
36 Q
37 ;
38VITMEA ; *** Validate vital measurement data ***
39 I $$FIND1^DIC(2,"","","`"_GMVDFN)'=GMVDFN D
40 . D MSG("ERROR: Missing or invalid Patient parameter")
41 . Q
42 K GMVRET D DT^DILF("RSTX",GMVDTDUN,.GMVRET,"-NOW")
43 I $G(GMVRET,-1)<0 D
44 . D MSG("ERROR: Missing or invalid Date/Time Vitals Taken parameter")
45 . Q
46 I $$FIND1^DIC(44,"","","`"_GMVHOSPL)'=GMVHOSPL D
47 . D MSG("ERROR: Missing or invalid Hospital Location parameter")
48 . Q
49 K GMVRET D DT^DILF("RSTX",GMVDTENT,.GMVRET,"-NOW")
50 I $G(GMVRET,-1)<0 D
51 . D MSG("ERROR: Missing or invalid Date/Time Vitals Entered parameter")
52 . Q
53 I $$FIND1^DIC(200,"","","`"_GMVENTBY)'=GMVENTBY D
54 . D MSG("ERROR: Missing or invalid Entered By parameter")
55 . Q
56 I "^C^M^"'[(U_$G(GMVMSYS)_U) D
57 . D MSG("ERROR: Missing or invalid Measurement System")
58 . Q
59 S (GMVVNUM,GMVVLAST,GMVVFIND)=0
60 F S GMVVNUM=$O(@GMVDATA@("V",GMVVNUM)) Q:GMVVNUM'>0 D
61 . S GMVVLAST=GMVVNUM
62 . S GMVSYSBP=0,GMVQARRY=U
63 . S (GMV,GMVVHOLD)=$G(@GMVDATA@("V",GMVVNUM))
64 . S GMVVD0=$$VITIEN^GMVDCUTL($P(GMV,U))
65 . S (GMVVMEAS,GMVVMEAS(1))=$P(GMV,U,2)
66 . I GMVVD0'>0 D
67 .. D MSG("ERROR: Missing or invalid Vital Type (V^"_GMVVNUM_"="_GMVVHOLD_")")
68 .. Q
69 . E D
70 .. S GMVVFIND=1
71 .. S GMVVABBR=$P($G(^GMRD(120.51,+GMVVD0,0)),U,2)
72 .. S $P(@GMVDATA@("V",GMVVNUM),U,1)=GMVVD0
73 .. D BP^GMVDCVAM,PO2^GMVDCVAM
74 .. I $$OMIT^GMVDCVAM(GMVVMEAS) D
75 ... S GMVVMEAS=$$UP^XLFSTR($E(GMVVMEAS))_$$LOW^XLFSTR($E(GMVVMEAS,2,$L(GMVVMEAS)))
76 ... I $O(@GMVDATA@("Q",GMVVNUM,0))>0 D
77 .... D MSG("ERROR: Qualifiers not allowed if vital measurement is omitted (V^"_GMVVNUM_"="_GMVVHOLD_")")
78 .... Q
79 ... Q
80 .. S GMVOK=1
81 .. I '$$VALID^GMVDCCHK($P(GMVVMEAS,";"),GMVMSYS,GMVVABBR) S GMVOK=0
82 .. I GMVOK,GMVVMEAS("PO2")]"" D
83 ... S GMVIXFRM=$$GET1^DID(120.5,1.4,"","INPUT TRANSFORM")
84 ... I GMVIXFRM]"" S X=GMVVMEAS("PO2") X GMVIXFRM I '$D(X) S GMVOK=0
85 ... Q
86 .. I 'GMVOK S GMVOK=$$OMIT^GMVDCVAM($P(GMVVMEAS,";"))
87 .. I 'GMVOK D
88 ... D MSG("ERROR: Invalid Vital Measurement (V^"_GMVVNUM_"="_GMVVHOLD_")")
89 ... Q
90 .. S GMVVMEAS=$$CNV^GMVDCCNV($P(GMVVMEAS,";"),GMVMSYS,"S",GMVVABBR)
91 .. S $P(@GMVDATA@("V",GMVVNUM),U,2)=GMVVMEAS_";"_GMVVMEAS("PO2")
92 .. S (GMVQNUM,GMVQFIND)=0
93 .. F S GMVQNUM=$O(@GMVDATA@("Q",GMVVNUM,GMVQNUM)) Q:GMVQNUM'>0 D
94 ... S (GMV,GMVQHOLD)=$G(@GMVDATA@("Q",GMVVNUM,GMVQNUM))
95 ... S GMVQD0=$$QUAIEN^GMVDCUTL(GMV)
96 ... I GMVQD0>0,$O(^GMRD(120.52,"C",GMVVD0,GMVQD0,0))'>0 S GMVQD0=-2
97 ... I GMVQD0'>0 D
98 .... I GMVQD0=-2 D MSG("ERROR: Invalid Qualifier for Vital Type (Q^"_GMVVNUM_U_GMVQNUM_"="_GMVQHOLD_")")
99 .... I GMVQD0'=-2 D MSG("ERROR: Missing or invalid Vitals Qualifier (Q^"_GMVVNUM_U_GMVQNUM_"="_GMVQHOLD_")")
100 .... Q
101 ... E D
102 .... S GMVQFIND=1
103 .... S $P(@GMVDATA@("Q",GMVVNUM,GMVQNUM),U,1)=GMVQD0
104 .... S GMVQARRY=GMVQARRY_GMVQD0_U
105 .... I GMVSYSBP,$D(GMVSYSBP(GMVQD0))#2 S GMVSYSBP=0
106 .... Q
107 ... Q
108 .. I GMVSYSBP D
109 ... D MSG("ERROR: Systolic only BPs must have a Doppler or Palpated qualifier (V^"_GMVVNUM_"="_GMVVHOLD_")")
110 ... Q
111 .. I 'GMVQFIND,$O(^GMRD(120.52,"C",GMVVD0,0))>0,'$$OMIT^GMVDCVAM(GMVVMEAS) D
112 ... D MSG("WARNING: No valid Qualifiers found (Q^"_GMVVNUM_"^##=Qualifier)")
113 ... Q
114 .. D DUPCHK^GMVDCVAM
115 .. Q
116 . Q
117 I 'GMVVFIND D
118 . D MSG("ERROR: No valid Vital Types / Measurements found (V^##=VitalType^Measurement)")
119 . Q
120 I $O(@GMVDATA@("Q",GMVVLAST)) D
121 . S GMV=$S(GMVVFIND'>0:"ERROR",1:"WARNING")
122 . D MSG(GMV_": There are more Qualifiers than there are VitalTypes / Measurements")
123 . Q
124 Q
125 ;
126ENTERR ; *** Validate Entered in Error data ***
127 I $$FIND1^DIC(200,"","","`"_GMVERRBY)'=GMVERRBY D
128 . D MSG("ERROR: Missing or invalid Entered in Error By parameter")
129 . Q
130 S (GMVINUM,GMVILAST,GMVIFIND)=0
131 F S GMVINUM=$O(@GMVDATA@("I",GMVINUM)) Q:GMVINUM'>0 D
132 . S GMVILAST=GMVINUM
133 . S (GMVID0,GMVIHOLD)=$G(@GMVDATA@("I",GMVINUM))
134 . I $$FIND1^DIC(120.5,"","","`"_GMVID0)'=GMVID0 D
135 .. D MSG("ERROR: Entered in Error IENS not found (I^"_GMVINUM_"="_GMVIHOLD_")")
136 .. Q
137 . E D
138 .. I $P($G(^GMR(120.5,GMVID0,2)),U) D
139 ... D MSG("ERROR: Vitals record already marked Entered in Error (I^"_GMVINUM_"="_GMVIHOLD_")")
140 ... Q
141 .. S GMVIFIND=1
142 .. S (GMVRNUM,GMVRFIND)=0
143 .. F S GMVRNUM=$O(@GMVDATA@("R",GMVINUM,GMVRNUM)) Q:GMVRNUM'>0 D
144 ... S (GMV,GMVRHOLD)=$G(@GMVDATA@("R",GMVINUM,GMVRNUM))
145 ... S GMVRD0=$$REAIEN^GMVDCUTL(GMV)
146 ... I GMVRD0'>0 D
147 .... D MSG("ERROR: Missing or invalid Entered in Error Reason (R^"_GMVINUM_U_GMVRNUM_"="_GMVRHOLD_")")
148 .... Q
149 ... E D
150 .... S GMVRFIND=1
151 .... S @GMVDATA@("R",GMVINUM,GMVRNUM)=GMVRD0
152 .... Q
153 ... Q
154 .. I 'GMVRFIND D
155 ... D MSG("ERROR: No valid Entered in Error Reasons found (R^"_GMVINUM_"^##=EnteredInErrorReason)")
156 ... Q
157 .. Q
158 . Q
159 I 'GMVIFIND D
160 . D MSG("ERROR: No valid Entered in Error IENS found (I^##=EnteredInError)")
161 . Q
162 I $O(@GMVDATA@("R",GMVILAST)) D
163 . S GMV=$S(GMVIFIND'>0:"ERROR",1:"WARNING")
164 . D MSG(GMV_": There are more Entered in Error Reasons than there are Entered in Error IENS")
165 . Q
166 Q
167 ;
168MSG(X) ; *** Add a line to the message array ***
169 S (GMVMSG,RESULT(-1))=1+$G(RESULT(-1),0)
170 S RESULT(GMVMSG)=X
171 I $P(X,":")="ERROR" S RESULT(0)="ERROR"
172 Q
173 ;
174BPSYSQ ;;Qualifiers that must be present if only systolic BP is present
175 ;;DOPPLER
176 ;;PALPATED
177 ;;
Note: See TracBrowser for help on using the repository browser.