source: WorldVistAEHR/trunk/r/GEN_MED_OTHER-GMV/GMVPXRM.m@ 1111

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

initial load of WorldVistAEHR

File size: 6.5 KB
Line 
1GMVPXRM ;HIOFO/FT-API to return FILE 120.5 data ;10/14/04 11:46
2 ;;5.0;GEN. MED. REC. - VITALS;**6**;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; #4113 - ^PXRMSXRM routine (controlled)
6 ; #4114 - ^PXRMINDX global (controlled)
7 ; #10103 - ^XLFDT calls (supported)
8 ; #10141 - ^XPDUTL calls (supported)
9 ;
10 ; Entry point(s) available for use by other packages:
11 ; EN is documented in IA #3647
12 ; VITALS is documented in IA #3647
13 ;
14EN(GMVDATA,GMVIEN,GMVIB) ; Returns data for a single FILE 120.5 entry.
15 ; Input:
16 ; GMVDATA = Array name passed by reference (required)
17 ; GMVIEN = IEN for FILE 120.5 entry (required)
18 ; GMVIB = "I" for Internal value only
19 ; "B" for Internal and External values (default = B)
20 ;
21 ; If GMVIB = "I", then
22 ; Output = GMVDATA(n)=internal value
23 ;
24 ; If GMVIB = "B", then
25 ; Output: GMVDATA(n)=internal value^external value
26 ;
27 ; where:
28 ; GMVDATA(1)=.01 (DATE/TIME VITALS TAKEN)
29 ; GMVDATA(2)=.02 (PATIENT)
30 ; GMVDATA(3)=.03 (VITAL TYPE)
31 ; GMVDATA(4)=.04 (DATE/TIME VITALS ENTERED)
32 ; GMVDATA(5)=.05 (HOSPITAL LOCATION)
33 ; GMVDATA(6)=.06 (ENTERED BY)
34 ; GMVDATA(7)=1.2 (RATE)
35 ; GMVDATA(8)=1.4 (SUPPLEMENTAL O2)
36 ; GMVDATA(9)=2 (ENTERED IN ERROR)
37 ; GMVDATA(10)=3 (ERROR ENTERED BY)
38 ; GMVDATA(11,n)=4 (REASON ENTERED IN ERROR) <--multiple
39 ; GMVDATA(12,n)=5 (QUALIFIER) <--multiple
40 ;
41 ; If the lookup failed then: GMVDATA(1)=-1^error text
42 ;
43 N GMVCNT,GMVIEN1
44 I $G(GMVIB)'="I",$G(GMVIB)'="B" S GMVIB="B"
45 I $G(GMVIEN)="" S GMVDATA(1)="-1^Record Number is Null" Q
46 I '$D(^GMR(120.5,+GMVIEN,0)) D Q
47 .S GMVDATA(1)="-1^The entry does not exist"
48 .Q
49 ;
50 N TEMP
51 S TEMP=^GMR(120.5,GMVIEN,0)
52 S GMVDATA(1)=$P(TEMP,U,1)
53 S GMVDATA(2)=$P(TEMP,U,2)
54 S GMVDATA(3)=$P(TEMP,U,3)
55 S GMVDATA(4)=$P(TEMP,U,4)
56 S GMVDATA(5)=$P(TEMP,U,5)
57 S GMVDATA(6)=$P(TEMP,U,6)
58 S GMVDATA(7)=$P(TEMP,U,8)
59 S GMVDATA(8)=$P(TEMP,U,10)
60 S TEMP=$G(^GMR(120.5,GMVIEN,2))
61 S GMVDATA(9)=$P(TEMP,U,1)
62 S GMVDATA(10)=$P(TEMP,U,2)
63 ;entered-in-error reasons
64 S (GMVCNT,GMVIEN1)=0
65 F S GMVIEN1=$O(^GMR(120.5,GMVIEN,2.1,GMVIEN1)) Q:'GMVIEN1 D
66 .S GMVCNT=GMVCNT+1
67 .S TP=+$P($G(^GMR(120.5,GMVIEN,2.1,GMVIEN1,0)),U,1)
68 .S GMVDATA(11,GMVCNT)=TP
69 .Q
70 ;loop through qualifier multiple
71 N EM,TP
72 I GMVCNT=0 S GMVDATA(11,1)=""
73 S (GMVCNT,GMVIEN1)=0
74 F S GMVIEN1=$O(^GMR(120.5,GMVIEN,5,GMVIEN1)) Q:'GMVIEN1 D
75 .S GMVCNT=GMVCNT+1
76 .S TP=+$P($G(^GMR(120.5,GMVIEN,5,GMVIEN1,0)),U,1)
77 .S GMVDATA(12,GMVCNT)=TP
78 .Q
79 I GMVCNT=0 S GMVDATA(12,1)=""
80 ;
81 Q:GMVIB="I"
82 ;
83 S GMVDATA(1)=$P(GMVDATA(1),U,1)_U_$$EXTERNAL^DILFD(120.5,.01,"",$P(GMVDATA(1),U,1),.EM)
84 S GMVDATA(2)=$P(GMVDATA(2),U,1)_U_$$EXTERNAL^DILFD(120.5,.02,"",$P(GMVDATA(2),U,1),.EM)
85 S GMVDATA(3)=$P(GMVDATA(3),U,1)_U_$$EXTERNAL^DILFD(120.5,.03,"",$P(GMVDATA(3),U,1),.EM)
86 S GMVDATA(4)=$P(GMVDATA(4),U,1)_U_$$EXTERNAL^DILFD(120.5,.04,"",$P(GMVDATA(4),U,1),.EM)
87 S GMVDATA(5)=$P(GMVDATA(5),U,1)_U_$$EXTERNAL^DILFD(120.5,.05,"",$P(GMVDATA(5),U,1),.EM)
88 S GMVDATA(6)=$P(GMVDATA(6),U,1)_U_$$EXTERNAL^DILFD(120.5,.06,"",$P(GMVDATA(6),U,1),.EM)
89 S GMVDATA(7)=$P(GMVDATA(7),U,1)_U_$P(GMVDATA(7),U,1) ;same
90 S GMVDATA(8)=$P(GMVDATA(8),U,1)_U_$P(GMVDATA(8),U,1) ;same
91 S GMVDATA(9)=$P(GMVDATA(9),U,1)_U_$$EXTERNAL^DILFD(120.5,2,"",$P(GMVDATA(9),U,1),.EM)
92 S GMVDATA(10)=$P(GMVDATA(10),U,1)_U_$$EXTERNAL^DILFD(120.5,3,"",$P(GMVDATA(10),U,1),.EM)
93 ;
94 ;loop through entered-in-error reason multiple
95 S (GMVCNT,GMVIEN1)=0
96 F S GMVIEN1=$O(GMVDATA(11,GMVIEN1)) Q:'GMVIEN1 D
97 .S TP=+$P(GMVDATA(11,GMVIEN1),U,1)
98 .Q:'TP
99 .S GMVDATA(11,GMVIEN1)=TP_U_$$EXTERNAL^DILFD(120.506,.01,"",TP,.EM)
100 .S GMVCNT=1
101 .Q
102 I GMVCNT=0 S GMVDATA(11,1)="^"
103 ;loop through qualifier multiple
104 S (GMVCNT,GMVIEN1)=0
105 F S GMVIEN1=$O(GMVDATA(12,GMVIEN1)) Q:'GMVIEN1 D
106 .S TP=+$P(GMVDATA(12,GMVIEN1),U,1)
107 .Q:'TP
108 .S GMVDATA(12,GMVIEN1)=TP_U_$P($G(^GMRD(120.52,+TP,0)),U,1)
109 .S GMVCNT=1
110 .Q
111 I GMVCNT=0 S GMVDATA(12,1)="^"
112 Q
113 ;
114VITALS ; This entry point is for use by the Clinical Reminders package
115 ; to re-index the ACR cross-reference nodes for FILE 120.5.
116 ;
117 ; a) This entry point kills the ACR cross-reference nodes for FILE 120.5
118 ; i.e., ^PXRMINDX(120.5).
119 ; b) Re-builds the ACR cross-reference nodes.
120 ; c) Calls the Clinical Reminders package to generate a mail message
121 ; summarizing the rebuilding of the ACR cross-reference.
122 ;
123 N DAS,DATE,DFN,END,ENTRIES,ETEXT,GLOBAL,IND,NE,NE1,NE2,NERROR
124 N START,TEMP,TENP,TEXT,VT
125 S GLOBAL=$$GET1^DID(120.5,"","","GLOBAL NAME")
126 ; Don't leave any old cross-reference nodes around.
127 K ^PXRMINDX(120.5)
128 S ENTRIES=$P(^GMR(120.5,0),U,4)
129 S TENP=ENTRIES/10
130 S TENP=+$P(TENP,".",1)
131 D BMES^XPDUTL("Building index for VITALS DATA.")
132 S TEXT="There are "_ENTRIES_" entries to process."
133 D MES^XPDUTL(TEXT)
134 S START=$H
135 S (DAS,IND,NE,NE1,NE2,NERROR)=0
136 F S DAS=+$O(^GMR(120.5,DAS)) Q:DAS=0 D
137 . S IND=IND+1
138 . I IND#TENP=0 D
139 .. S TEXT="Processing entry "_IND
140 .. D MES^XPDUTL(TEXT)
141 . I IND#10000=0 W "."
142 . S TEMP=^GMR(120.5,DAS,0)
143 . S DATE=$P(TEMP,U,1)
144 . I DATE="" D Q
145 .. S ETEXT=DAS_" no date",NE1=NE1+1
146 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
147 . S DFN=$P(TEMP,U,2)
148 . I DFN="" D Q
149 .. S ETEXT=DAS_" no patient",NE1=NE1+1
150 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR) Q
151 . S VT=$P(TEMP,U,3)
152 . I VT="" D Q
153 .. S ETEXT=DAS_" no vital type",NE1=NE1+1
154 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
155 .;If this entry is marked as entered-in-error do not index it.
156 . I $P($G(^GMR(120.5,DAS,2)),U,1) S NE2=NE2+1 Q
157 . S ^PXRMINDX(120.5,"IP",VT,DFN,DATE,DAS)=""
158 . S ^PXRMINDX(120.5,"PI",DFN,VT,DATE,DAS)=""
159 . S NE=NE+1
160 S END=$H
161 S TEXT=" VITAL MEASUREMENTS entries indexed: "_NE
162 D BMES^XPDUTL(TEXT)
163 S TEXT=" Bad entries not indexed: "_NE1
164 D MES^XPDUTL(TEXT)
165 S TEXT="Entered-in-Error entries not indexed: "_NE2
166 D MES^XPDUTL(TEXT)
167 S TEXT=" "
168 D MES^XPDUTL(TEXT)
169 D DETIME^PXRMSXRM(START,END)
170 ; If there were errors send a message.
171 I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL)
172 ;Send a MailMan message with the results.
173 D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
174 S ^PXRMINDX(120.5,"GLOBAL NAME")=$$GET1^DID(120.5,"","","GLOBAL NAME")
175 S ^PXRMINDX(120.5,"BUILT BY")=DUZ
176 S ^PXRMINDX(120.5,"DATE BUILT")=$$NOW^XLFDT
177 Q
178 ;
179SVITAL(X,DA) ; Set ACR index entry
180 ; X(1)=DATE/TIME, X(2)=DFN, X(3)=VITAL TYPE, X(4)=ENTERED IN ERROR
181 ; Do not index entries that are marked as entered-in-error.
182 I $G(X(4)) Q
183 S ^PXRMINDX(120.5,"IP",X(3),X(2),X(1),DA)=""
184 S ^PXRMINDX(120.5,"PI",X(2),X(3),X(1),DA)=""
185 Q
186 ;
187KVITAL(X,DA) ; Delete ACR index entry
188 K ^PXRMINDX(120.5,"IP",X(3),X(2),X(1),DA)
189 K ^PXRMINDX(120.5,"PI",X(2),X(3),X(1),DA)
190 Q
Note: See TracBrowser for help on using the repository browser.