source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORRP027.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 8.6 KB
Line 
1RORRP027 ;HCIOFO/SG - RPC: RORICR CDC SAVE ; 10/16/06 1:58pm
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 ;--------------------------------------------------------------------
5 ; Registry: [VA HIV]
6 ;--------------------------------------------------------------------
7 Q
8 ;
9 ;***** AIDS INDICATOR DISEASE (VIII)
10AID(IENS) ;
11 N CODE,RC,TMP
12 S CODE=+$P(RORDATA(RORPTR),U,2)
13 Q:CODE'>0 "2^AID"_U_CODE
14 ;--- Initial diagnosis
15 S RORAILST(CODE)=$P(RORDATA(RORPTR),U,3)
16 ;--- Initial date
17 S TMP=$$DATE1^RORRP026($P(RORDATA(RORPTR),U,4))
18 Q:TMP<0 "4^AID"_U_CODE
19 S $P(RORAILST(CODE),U,2)=TMP
20 Q 0
21 ;
22 ;***** STORES THE AIDS INDICATOR DICEASES INTO THE FDA
23AIDSTORE() ;
24 N CODE,DATE,DTMIN,II,NODE,RC,TMP
25 S NODE=$$ROOT^DILFD(799.41,","_IENS,1)
26 S RC=0,DTMIN=""
27 ;--- Mark the old records for removal
28 S CODE=0
29 F S CODE=$O(@NODE@(CODE)) Q:CODE'>0 D:'$D(RORAILST(CODE))
30 . S RORFDAFI(799.41,CODE_","_IENS,.01)="@"
31 ;--- Prepare the records to be added/updated
32 S II=+$O(RORIEN(""),-1)
33 S CODE=0
34 F S CODE=$O(RORAILST(CODE)) Q:CODE'>0 D
35 . S DATE=$P(RORAILST(CODE),U,2)
36 . I DATE>0 S:(DATE<DTMIN)!(DTMIN'>0) DTMIN=DATE
37 . ;--- Update the record
38 . I $D(@NODE@(CODE)) D Q
39 . . S TMP=CODE_","_IENS
40 . . S RORFDAFI(799.41,TMP,.02)=$P(RORAILST(CODE),U,1)
41 . . S RORFDAFI(799.41,TMP,.03)=DATE
42 . ;--- Add the record
43 . S II=II+1,RORIEN(II)=CODE,TMP="?+"_II_","_IENS
44 . S RORFDAUP(799.41,TMP,.01)=CODE
45 . S RORFDAUP(799.41,TMP,.02)=$P(RORAILST(CODE),U,1)
46 . S RORFDAUP(799.41,TMP,.03)=DATE
47 ;--- Populate the CLINICAL AIDS fields (if they are empty)
48 K TMP S TMP(1)=+IENS
49 D AIDSOI^RORDD01(.TMP,DTMIN)
50 ;---
51 Q RC
52 ;
53 ;***** CANCELS THE EDITING
54 ; RPC: [RORICR CDC CANCEL]
55 ;
56 ; .RESULTS Reference to a local variable where the results
57 ; are returned to.
58 ;
59 ; REGIEN Registry IEN
60 ;
61 ; PATIEN IEN of the registry patient (DFN)
62 ;
63 ; Return Values:
64 ;
65 ; A negative value of the first "^"-piece of the RESULTS(0)
66 ; indicates an error (see the RPCSTK^RORERR procedure for more
67 ; details).
68 ;
69 ; Otherwise, zero is returned in the RESULTS(0).
70 ;
71CANCEL(RESULTS,REGIEN,PATIEN) ;
72 N IENS,RC,RORERRDL
73 D CLEAR^RORERR("CANCEL^RORRP027",1) K RESULTS
74 ;--- Check the parameters
75 S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
76 . ;--- Registry IEN
77 . I $G(REGIEN)'>0 D Q
78 . . S RC=$$ERROR^RORERR(-88,,,,"REGIEN",$G(REGIEN))
79 . S REGIEN=+REGIEN
80 . ;--- Patient IEN
81 . I $G(PATIEN)'>0 D Q
82 . . S RC=$$ERROR^RORERR(-88,,,,"PATIEN",$G(PATIEN))
83 . S PATIEN=+PATIEN
84 ;
85 ;--- Get the IENS of the registry record
86 S IENS=$$PRRIEN^RORUTL01(PATIEN,REGIEN)_","
87 ;
88 ;--- Unlock the records
89 I IENS>0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
90 . S RC=$$UNLOCK^RORLOCK(799.4,IENS)
91 S RESULTS(0)=0
92 Q
93 ;
94 ;***** DEMOGRAPHIC INFORMATION (III)
95CDM(IENS) ;
96 N BUF,RC,TMP
97 S BUF=RORDATA(RORPTR)
98 S RC=$$CDCFDA^RORRP026(IENS,"CDM^RORRP026",BUF,.RORFDAFI)
99 Q:RC RC
100 ;--- Default values
101 F TMP=9.04,9.08,9.09 S RORFDAFI(799.4,IENS,TMP)=""
102 ;--- Age at diagnosis
103 S TMP=+$P(BUF,U,3)
104 I TMP Q:$P(BUF,U,4)'?.2N "4^CDM" D
105 . S:TMP=1 RORFDAFI(799.4,IENS,9.03)=$P(BUF,U,4)
106 . S:TMP=2 RORFDAFI(799.4,IENS,9.04)=$P(BUF,U,4)
107 ;--- Country of birth
108 S TMP=+$P(BUF,U,7)
109 S:TMP=7 RORFDAFI(799.4,IENS,9.08)=$P(BUF,U,8)
110 S:TMP=8 RORFDAFI(799.4,IENS,9.09)=$P(BUF,U,8)
111 Q 0
112 ;
113 ;***** COMMENTS (X)
114CMT(IENS) ;
115 N CNT,NE,PTR,RC,SEG,TMP K RORCMT
116 ;--- Load the comments
117 S PTR=RORPTR,(CNT,NE,RC)=0
118 F D Q:RC!(SEG'="CMT") S PTR=$O(RORDATA(PTR)) Q:PTR=""
119 . S SEG=$P(RORDATA(PTR),U) Q:SEG'="CMT"
120 . S RORPTR=PTR Q:CNT'<3
121 . S TMP=$P(RORDATA(RORPTR),U,3)
122 . S CNT=CNT+1,RORCMT(CNT)=TMP
123 . S:TMP'="" NE=NE+1
124 ;--- Store the reference into the FDA
125 S RORFDAFI(799.4,IENS,25)=$S(NE>0:"RORCMT",1:"@")
126 Q RC
127 ;
128 ;***** CLINICAL STATUS (VIII)
129CS(IENS) ;
130 N RC,TMP
131 S RC=$$CDCFDA^RORRP026(IENS,"CS^RORRP026",RORDATA(RORPTR),.RORFDAFI)
132 Q RC
133 ;
134 ;***** PROCESSES THE ERROR(S) AND UNLOCKS THE RECORDS
135ERROR(RESULTS,RC) ;
136 D RPCSTK^RORERR(.RESULTS,RC)
137 D UNLOCK^RORLOCK(.RORLOCK)
138 Q
139 ;
140 ;***** FACILITY OF DIAGNOSIS (IV)
141FD(IENS) ;
142 N RC,TMP
143 S RC=$$CDCFDA^RORRP026(IENS,"FD^RORRP026",RORDATA(RORPTR),.RORFDAFI)
144 Q RC
145 ;
146 ;***** FORM HEADERS
147HDR(IENS) ;
148 N RC,TMP
149 S RC=$$CDCFDA^RORRP026(IENS,"HDR^RORRP026",RORDATA(RORPTR),.RORFDAFI)
150 ;--- Person who completed the form
151 S RORFDAFI(799.4,IENS,9.05)=DUZ
152 Q RC
153 ;
154 ;***** LABORATORY DATA (VI)
155LD1(IENS) ;
156 N BUF,FLD,DATE,RC,TMP
157 S BUF=RORDATA(RORPTR)
158 S RC=$$CDCFDA^RORRP026(IENS,"LD1^RORRP026",BUF,.RORFDAFI)
159 Q:RC RC
160 ;--- Positive HIV detection test
161 S FLD=$$PHIVFLD^RORRP026($P(BUF,U,12))
162 I FLD S RC=0 D Q:RC RC
163 . S DATE=$$DATE1^RORRP026($P(BUF,U,13))
164 . I DATE<0 S RC="13^LD1" Q
165 . S RORFDAFI(799.4,IENS,FLD)=DATE
166 Q 0
167 ;
168LD2(IENS) ;
169 N RC,TMP
170 S RC=$$CDCFDA^RORRP026(IENS,"LD2^RORRP026",RORDATA(RORPTR),.RORFDAFI)
171 Q RC
172 ;
173 ;***** PATIENT HISTORY (V)
174PH(IENS) ;
175 N RC,TMP
176 S RC=$$CDCFDA^RORRP026(IENS,"PH^RORRP026",RORDATA(RORPTR),.RORFDAFI)
177 Q RC
178 ;
179 ;***** UPDATES THE CDC DATA
180 ; RPC: [RORICR CDC SAVE]
181 ;
182 ; .RESULTS Reference to a local variable where the results
183 ; are returned to.
184 ;
185 ; REGIEN Registry IEN
186 ;
187 ; PATIEN IEN of the registry patient (DFN)
188 ;
189 ; [FLAGS] Flags that control the execution (can be combined):
190 ; H Update the patient history. If this flag is
191 ; not provided, the PH data segment is ignored.
192 ;
193 ; .RORDATA Reference to a local array that contains the CDC
194 ; data in the same format as the output of the RORICR
195 ; CDC LOAD remote procedure (see the LOADCDC^RORRP025
196 ; and description of the RPC for more details).
197 ;
198 ; NOTE #1: The CS data segment must be always included before the
199 ; AID segments. Otherwise, the latter will be ignored.
200 ;
201 ; NOTE #2: Any AIDS indicator disease, which has empty 3rd piece
202 ; in the corresponding AID segment (or no segment at all),
203 ; will be removed from the patient record.
204 ;
205 ; NOTE #3: There should be at least one empty comment (i.e. the
206 ; "CMT^1" segment) among the data if you want to clear
207 ; the CDC comments. Otherwise, they will not be updated.
208 ;
209 ; Return Values:
210 ;
211 ; A negative value of the first "^"-piece of the RESULTS(0)
212 ; indicates an error (see the RPCSTK^RORERR procedure for more
213 ; details).
214 ;
215 ; Positive value of the first "^"-piece of the RESULTS(0) indicates
216 ; an error in the CDC data. The value is the number of the erroneous
217 ; piece of the data segment whose name is returned in the second
218 ; piece of the RESULTS(0). For example, the "11^CDM" means that the
219 ; 11th piece of the CDM data segment (ONSET OF ILLNESS/AIDS- STATE)
220 ; contains an invalid value.
221 ;
222 ; Otherwise, zero is returned in the RESULTS(0).
223 ;
224SAVECDC(RESULTS,REGIEN,PATIEN,FLAGS,RORDATA) ;
225 N RORAILST ; List of AIDS indicator diseases
226 N RORCMT ; Buffer for the CDC comments (WP field)
227 N RORFDAFI ; FDA for FILE^DIE
228 N RORFDAUP ; FDA for UPDATE^DIE
229 N RORIEN ; List of IEN's to be assigned
230 ;
231 N I,IEN,IENS,RC,RORERRDL,RORMSG,RORPTR,SEG,SEGLST
232 D CLEAR^RORERR("SAVECDC^RORRP027",1)
233 K RESULTS S (RESULTS(0),RORPTR)=0
234 ;--- Check the parameters
235 S RC=0 D I RC<0 D ERROR(.RESULTS,RC) Q
236 . ;--- Registry IEN
237 . I $G(REGIEN)'>0 D Q
238 . . S RC=$$ERROR^RORERR(-88,,,,"REGIEN",$G(REGIEN))
239 . S REGIEN=+REGIEN
240 . ;--- Patient IEN
241 . I $G(PATIEN)'>0 D Q
242 . . S RC=$$ERROR^RORERR(-88,,,,"PATIEN",$G(PATIEN))
243 . S PATIEN=+PATIEN
244 . ;--- Flags
245 . S FLAGS=$$UP^XLFSTR($G(FLAGS))
246 ;
247 ;--- Get IEN of the registry record
248 S IEN=$$PRRIEN^RORUTL01(PATIEN,REGIEN) Q:IEN'>0
249 S IENS=IEN_","
250 S RORLOCK(799.4,IENS)=""
251 ;
252 ;--- Prepare the data
253 S SEGLST=",HDR,CDM,FD,LD1,LD2,CS,AID,TS1,TS2,CMT,"
254 S:FLAGS["H" SEGLST=SEGLST_"PH,"
255 S (RC,RORPTR)=0
256 F S RORPTR=$O(RORDATA(RORPTR)) Q:RORPTR'>0 D Q:RC
257 . S SEG=$TR($P(RORDATA(RORPTR),U)," ")
258 . X:SEGLST[(","_SEG_",") "S RC=$$"_SEG_"(IENS)"
259 I RC<0 D ERROR(.RESULTS,RC) Q
260 I RC>0 S RESULTS(0)=RC Q
261 ;
262 ;--- Process the list of AIDS indicator diseases
263 S RC=$$AIDSTORE()
264 I RC<0 D ERROR(.RESULTS,RC) Q
265 ;
266 ;--- Update the record(s)
267 I $D(RORFDAFI)>1 D I RC<0 D ERROR(.RESULTS,RC) Q
268 . D FILE^DIE(,"RORFDAFI","RORMSG")
269 . S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,PATIEN,799.4,IENS)
270 ;--- Add the record(s)
271 I $D(RORFDAUP)>1 D I RC<0 D ERROR(.RESULTS,RC) Q
272 . D UPDATE^DIE(,"RORFDAUP","RORIEN","RORMSG")
273 . S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,PATIEN,799.4,IENS)
274 ;
275 ;--- Unlock the records
276 S RC=$$UNLOCK^RORLOCK(.RORLOCK)
277 I RC<0 D ERROR(.RESULTS,RC) Q
278 S RESULTS(0)=0
279 Q
280 ;
281 ;***** TREATMENT/SERVICES REFERRALS (IX)
282TS1(IENS) ;
283 N RC,TMP
284 S RC=$$CDCFDA^RORRP026(IENS,"TS1^RORRP026",RORDATA(RORPTR),.RORFDAFI)
285 Q RC
286 ;
287TS2(IENS) ;
288 N RC,TMP
289 S RC=$$CDCFDA^RORRP026(IENS,"TS2^RORRP026",RORDATA(RORPTR),.RORFDAFI)
290 Q RC
Note: See TracBrowser for help on using the repository browser.