source: WorldVistAEHR/trunk/r/GEN_MED_OTHER-GMV/GMVRPCM.m@ 1271

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1GMVRPCM ; HOIFO/DP - RPC for Vitals Manager ;07/25/05 9:10am
2 ;;5.0;GEN. MED. REC. - VITALS;**1,8,13,3**;Oct 31, 2002
3 ; Integration Agreements:
4 ; #10040 [Supported] File 44 references
5 ; #10076 [Supported] XUSEC Calls
6 ; #2263 [Supported] XPAR Calls
7 ; #2541 [Supported] XUPARAM Calls
8 ; #2692 [Controlled] ORQPTQ1
9 ; #3227 [Private] NURAPI Calls
10 ; #4084 [Private] File 44 AC x-ref
11 ; #4360 [Private] GMV MANAGER RPC
12ADDQUAL ; [P] Add qualifier to vital/category
13 S GMVVIT=+$P(DATA,";",1),GMVCAT=+$P(DATA,";",2),GMVQUAL=+$P(DATA,";",3)
14 I $O(^GMRD(120.52,GMVQUAL,1,"B",GMVVIT,0)) D Q
15 .S @RESULTS@(0)="1^Qualifier already assigned."
16 S GMVFDA(120.521,"+1,"_GMVQUAL_",",.01)=GMVVIT
17 S GMVFDA(120.521,"+1,"_GMVQUAL_",",.02)=GMVCAT
18 D UPDATE^DIE("","GMVFDA","GMVIEN","GMVERR")
19 I $G(GMVIEN(1)) S @RESULTS@(0)=+GMVIEN(1)_"^Qualifier Assigned"
20 E S @RESULTS@(0)="-1^Unable to assign qualifier"
21 Q
22DELQUAL ; [P] Delete qualifier from vital/category
23 S GMVVIT=+$P(DATA,";",1),GMVCAT=+$P(DATA,";",2),GMVQUAL=+$P(DATA,";",3)
24 S X=$O(^GMRD(120.52,GMVQUAL,1,"B",GMVVIT,0))
25 S GMVFDA(120.521,X_","_GMVQUAL_",",.01)="@"
26 D FILE^DIE("","GMVFDA","GMVERR")
27 I $D(GMVERR) S @RESULTS@(0)="-1^Unable to remove qualifier."
28 E S @RESULTS@(0)="1^Qualifier removed."
29 Q
30DELTEMP ; [P] Delete Template
31 S GMVENT=$P(DATA,U,1),GMVNAME=$P(DATA,U,2)
32 I $$GET^XPAR(GMVENT,"GMV TEMPLATE DEFAULT")=GMVNAME D
33 .D DEL^XPAR(GMVENT,"GMV TEMPLATE DEFAULT",1)
34 D DEL^XPAR(GMVENT,"GMV TEMPLATE",GMVNAME,.GMVERR)
35 I '$G(GMVERR) S @RESULTS@(0)="1^Template Removed."
36 E S @RESULTS@(0)="-1^"_GMVERR
37 Q
38GETCATS ; [P] Return Listing of categories
39 N GMVQI
40 F GMVCAT=0:0 S GMVCAT=$O(^GMRD(120.52,"AA",DATA,GMVCAT)) Q:'GMVCAT D
41 .Q:$$ACTIVE^GMVUID(120.53,"",GMVCAT_",","")
42 .S GMVQUAL="",X="" F S X=$O(^GMRD(120.52,"AA",DATA,GMVCAT,X)) Q:X="" D
43 ..S GMVQI=$O(^GMRD(120.52,"AA",DATA,GMVCAT,X,0))
44 ..Q:$$ACTIVE^GMVUID(120.52,"",GMVQI_",","")
45 ..S GMVQUAL=GMVQUAL_$S(GMVQUAL]"":", ",1:"")_X
46 .S Y=$O(@RESULTS@(""),-1)+1
47 .S @RESULTS@(Y)=GMVCAT_U_$P(^GMRD(120.53,GMVCAT,0),U)_U_GMVQUAL
48 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)_U_$P(^GMRD(120.51,DATA,0),U)
49 Q
50GETDATA ; [P] Generic fileman data call
51 ; Variable DATA = File#^IENS^Field#
52 S @RESULTS@(0)=$$GET1^DIQ($P(DATA,U,1),$P(DATA,U,2),$P(DATA,U,3))
53 Q
54GETDEF ; [P] Get Default Template
55 I $G(DATA)]"" D Q
56 .S X=$$GET^XPAR($P(DATA,U),"GMV TEMPLATE DEFAULT")
57 .I X="" S @RESULTS@(0)="-1^No Default Template"
58 .E S @RESULTS@(0)=X
59 D ENVAL^XPAR(.GMV,"GMV TEMPLATE DEFAULT")
60 S X="" F S X=$O(GMV(X)) Q:X="" D
61 .S Y=$O(@RESULTS@(""),-1)+1
62 .S @RESULTS@(Y)=X_U_GMV(X,1)
63 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
64 Q
65GETHILO ; [P] Returns an abnormal value
66 S @RESULTS@(0)=+$$GET1^DIQ(120.57,"1,",DATA)
67 Q
68GETLIST ; [P] Return listing of file
69 K GMVRET,^TMP("DILIST",$J)
70 S GMVSCRN=""
71 I +DATA=44 S DATA2=$P(DATA,U,2),DATA=+DATA
72 I DATA=120.51 D ; Set screen for vitals list
73 .S GMVSCRN="I $$VITALIEN^GMVUTL8()[("",""_+Y_"","")"
74 I DATA=42 D ; Screen for ward location
75 .S GMVSCRN="I '$$INACT42^GMVUT2(+Y)"
76 I DATA=44 D Q ; Clinics
77 .N CNT S X=DATA2,CNT=0
78 .F S X=$O(^SC("AC","C",X)) Q:'X!(CNT>100) D
79 ..Q:+$G(^SC(X,"OOS"))
80 ..S Y=$G(^SC(X,"I"))
81 ..I Y Q:DT>+Y&($P(Y,U,2)=""!(DT<$P(Y,U,2)))
82 ..S @RESULTS@($O(@RESULTS@(""),-1)+1)=DATA_";"_X_U_$P(^SC(X,0),U),CNT=CNT+1
83 .S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
84 I DATA=100.21 D Q ; CPRS Teams
85 .D TEAMS^ORQPTQ1(.GMVRET)
86 .F X=0:0 S X=$O(GMVRET(X)) Q:'X S @RESULTS@(X)=DATA_";"_GMVRET(X)
87 .S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
88 I DATA=211.4 D Q ; NURS Locations
89 .D ACTLOCS^NURAPI(.GMVRET)
90 .F X=0:0 S X=$O(GMVRET(X)) Q:'X S @RESULTS@(X)=DATA_";"_GMVRET(X)
91 .S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
92 I DATA=120.52 S GMVSCRN="I '$$ACTIVE^GMVUID(120.52,.01,+Y_"","","""")"
93 D LIST^DIC(DATA,"","@;.01","P","","","","",GMVSCRN)
94 F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X D
95 .S @RESULTS@(X)=DATA_";"_^TMP("DILIST",$J,X,0)
96 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)_U_$$GET1^DID(DATA,"","","NAME")
97 K ^TMP("DILIST",$J)
98 Q
99GETQUAL ; [P] Return qualifiers list
100 ; DATA=VitalIEN;CatIEN
101 ; Uses X-ref of ^GMRD(120.52,"AA",VitalIEN,CategoryIEN,QName,QIEN)
102 S GMVIT=+$P(DATA,";",1),GMVCAT=+$P(DATA,";",2)
103 I '$D(^GMRD(120.53,GMVCAT,0)) S @RESULTS@(0)="-1^No such category" Q
104 I $$ACTIVE^GMVUID(120.53,"",GMVCAT_",","") S @RESULTS@(0)="-1^Inactive category" Q
105 I '$D(^GMRD(120.51,GMVIT,0)) S @RESULTS@(0)="-1^No such vital" Q
106 I $$ACTIVE^GMVUID(120.51,"",GMVIT_",","") S @RESULTS@(0)="-1^Inactive vital type" Q
107 S GMVNAM=""
108 F S GMVNAM=$O(^GMRD(120.52,"AA",GMVIT,GMVCAT,GMVNAM)) Q:GMVNAM="" D
109 .S GMVIEN=$O(^GMRD(120.52,"AA",GMVIT,GMVCAT,GMVNAM,0)) ; Assume only one of this name
110 .Q:$$ACTIVE^GMVUID(120.52,"",GMVIEN_",","")
111 .S Y=$O(@RESULTS@(""),-1)+1
112 .S @RESULTS@(Y)=GMVIEN_U_GMVNAM
113 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)_U_$P(^GMRD(120.53,GMVCAT,0),U)
114 Q
115GETTEMP ; [P] Get Template List
116 I $G(DATA)]"" D
117 .S GMVENT=$$ENTITY($P(DATA,U,1)),GMVNAME=$P(DATA,U,2)
118 .I GMVNAME="" D
119 ..D GETLST^XPAR(.GMVTMP,GMVENT,"GMV TEMPLATE")
120 ..F X=0:0 S X=$O(GMVTMP(X)) Q:'X D
121 ...S GMV(GMVENT,$P(GMVTMP(X),U,1))=$P(GMVTMP(X),U,2,10)
122 .I GMVNAME]"" S GMV(GMVENT,GMVNAME)=$$GET^XPAR(GMVENT,"GMV TEMPLATE",GMVNAME)
123 I $G(DATA)="" D ENVAL^XPAR(.GMV,"GMV TEMPLATE")
124 S GMVENT="",GMVNAME=""
125 F S GMVENT=$O(GMV(GMVENT)) Q:GMVENT="" D
126 .S GMVROOT=$P(GMVENT,";",2),GMVTYPE=$$TYPE(GMVROOT),GMVIEN=+GMVENT
127 .Q:GMVTYPE=0 ;unknown template type
128 .Q:GMVROOT="VA(200,"&('$$GET^XPAR("SYS","GMV ALLOW USER TEMPLATES"))
129 .I GMVROOT="VA(200,"&(GMVIEN'=DUZ) Q:'$D(^XUSEC("GMV MANAGER",DUZ))
130 .F S GMVNAME=$O(GMV(GMVENT,GMVNAME)) Q:GMVNAME="" D
131 ..S GMVOWNER=$P($G(@(U_GMVROOT_(+GMVIEN)_",0)"),"Unk"),U)
132 ..S Y=$O(@RESULTS@(""),-1)+1
133 ..S @RESULTS@(Y)=GMVTYPE_U_GMVENT_U_GMVOWNER_U_GMVNAME_U_GMV(GMVENT,GMVNAME)
134 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
135 Q
136LOOKUP ; [P] Does a lookup on a file
137 N GMVSCRN
138 S GMVSCRN=$S(+DATA=44:"I "_"""^C^W^"""_"[$P(^(0),U,3)",1:"")
139 I $P(DATA,"^",3)="" S GMVFLD="@;.01"
140 E S GMVFLD="@;"_$P(DATA,"^",3)
141 S GMVFLD=$P(GMVFLD,";",1,5) ; Limit lookup to 4 display fields
142 D FIND^DIC(+DATA,"",GMVFLD,"P",$P(DATA,"^",2),61,,GMVSCRN)
143 I ^TMP("DILIST",$J,0)<1 D Q
144 .S @RESULTS@(0)="-1^No entries found matching '"_$P(DATA,U,2)_"'."
145 I ^TMP("DILIST",$J,0)>60 D Q
146 .S @RESULTS@(0)="-1^Too many matches found, please be more specific."
147 F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X D
148 .S @RESULTS@(X)=+DATA_";"_^TMP("DILIST",$J,X,0)
149 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
150 Q
151NEWQUAL ; [P] Create New Qualifier
152 S @RESULTS@(0)="-1^Use the New Term Rapid Turnaround (NTRT) process to add qualifiers"
153 Q
154NEWTEMP ; [P] New Template
155 S GMVENT=$P(DATA,"^",1),GMVNAME=$P(DATA,"^",2),GMVDESC=$P(DATA,"^",3)
156 S GMVENT=$$ENTITY(GMVENT)
157 S GMVTYPE=$$TYPE($P(GMVENT,";",2))
158 S GMVOWN=$P($G(@(U_$P(GMVENT,";",2)_+GMVENT_",0)"),"Unk"),U)
159 S:GMVDESC="" GMVDESC="No Description"
160 D ADD^XPAR(GMVENT,"GMV TEMPLATE",GMVNAME,GMVDESC,.GMVERR)
161 I 'GMVERR S @RESULTS@(0)=GMVTYPE_U_GMVENT_U_GMVOWN_U_GMVNAME
162 E S @RESULTS@(0)="-1^"_GMVERR
163 Q
164RENTEMP ; [P] Rename a Template
165 S GMVENT=$P(DATA,U,1),GMVOLD=$P(DATA,U,2),GMVNEW=$P(DATA,U,3)
166 D REP^XPAR(GMVENT,"GMV TEMPLATE",GMVOLD,GMVNEW,.GMVERR)
167 I 'GMVERR S @RESULTS@(0)="1^Renamed"
168 E S @RESULTS@(0)="-1^"_GMVERR Q
169 ; Reset default template if this was a default template
170 D:$$GET^XPAR(GMVENT,"GMV TEMPLATE DEFAULT")=GMVOLD
171 .D EN^XPAR(GMVENT,"GMV TEMPLATE DEFAULT",1,GMVNEW)
172 Q
173RPC(RESULTS,OPTION,DATA) ; [Procedure] Main RPC call tag
174 ; RPC: [GMV MANAGER]
175 ;
176 ; Input parameters
177 ; 1. RESULTS [Reference/Required] RPC Return array
178 ; 2. OPTION [Literal/Required] RPC Option to execute
179 ; 3. DATA [Literal/Required] Other data as required for call
180 ;
181 N GMV,GMVCAT,GMVDESC,GMVENT,GMVERR,GMVFDA,GMVFLD,GMVIEN,GMVIT,GMVNAM,GMVNAME,GMVNEW,GMVOLD,GMVOWN,GMVOWNER,GMVQUAL,GMVROOT,GMVTYPE,GMVVAL,GMVVIT,GMVSCRN
182 S RESULTS=$NA(^TMP("GMVMGR",$J)) K @RESULTS
183 D:$T(@OPTION)]"" @OPTION
184 S:'$D(@RESULTS) @RESULTS@(0)="-1^No results returned"
185 D CLEAN^DILF
186 Q
187SETDATA ; [P] Save New Qualifier Name/Abbv
188 S @RESULTS@(0)="-1^Use the New Term Rapid Turnaround (NTRT) process to add qualifiers"
189 Q
190SETDEF ; [P] Set Default Template
191 D EN^XPAR($P(DATA,U),"GMV TEMPLATE DEFAULT",1,$P(DATA,U,2),.GMVERR)
192 I '$G(GMVERR) S @RESULTS@(0)="1^Set As Default."
193 E S @RESULTS@(0)="-1^"_GMVERR
194 Q
195SETHILO ; [P] Set abnormal value
196 L +(^GMRD(120.57,0)):5
197 E S @RESULTS@(0)="-1^Site File In Use." Q
198 S GMVFLD=$P(DATA,"^",1),GMVVAL=$P(DATA,"^",2)
199 S GMVFDA(120.57,"1,",GMVFLD)=GMVVAL
200 D FILE^DIE("","GMVFDA","GMVERR")
201 L -(^GMRD(120.57,0))
202 S @RESULTS@(0)="1^Update Complete."
203 Q
204SETTEMP ; [P] Set Template data
205 D EN^XPAR($P(DATA,U),"GMV TEMPLATE",$P(DATA,U,2),$P(DATA,U,3),.GMVERR)
206 I '$G(GMVERR) S @RESULTS@(0)="1^Template Saved."
207 E S @RESULTS@(0)="-1^"_GMVERR
208 Q
209VALID ; [P] Verify data validity against fileman
210 D VAL^DIE($P(DATA,U,1),$P(DATA,U,2),$P(DATA,U,3),"H",$P(DATA,U,4),.GMVRET)
211 I GMVRET'="^" S @RESULTS@(0)="1^Valid Data"
212 E S @RESULTS@(0)="-1^"_^TMP("DIERR",$J,1,"TEXT",1)
213 Q
214ENTITY(X) ; [Function] Convert USR, SYS, and DIV entities
215 ; Input parameters
216 ; 1. X [Literal/Required] XPAR generic entity to transform to variable pointer format
217 ;
218 Q:X="USR" DUZ_";VA(200,"
219 Q:X="SYS" $$FIND1^DIC(4.2,"","QX",$$KSP^XUPARAM("WHERE"))_";DIC(4.2,"
220 Q:X="DIV" DUZ(2)_";DIC(4,"
221 Q X
222 ;
223TYPE(X) ; [F] Returns the type of template
224 ; Input parameters
225 ; 1. X [Literal/Required] Variable pointer to evaluate
226 ;
227 Q:X="DIC(4.2," 1 ;Domain
228 Q:X="DIC(4," 2 ; Institution
229 Q:X="SC(" 3 ; Hospital Location
230 Q:X="VA(200," 4 ; New Person
231 Q 0 ; Unknown
232 ;
233VT ;VitalTypeIENS
234 N X,Y,Z
235 S Y=0,@RESULTS@(0)="-1"
236 F X="T","P","R","BP","HT","WT","PN","PO2","CVP","CG" D
237 .S Z=$O(^GMRD(120.51,"C",X,0))
238 .Q:'Z
239 .S Y=Y+1,@RESULTS@(Y)=Z
240 Q
Note: See TracBrowser for help on using the repository browser.