source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORDD01.m@ 1406

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

initial load of WorldVistAEHR

File size: 5.8 KB
Line 
1RORDD01 ;HCIOFO/SG - DATA DICTIONARY UTILITIES ; 6/14/06 2:07pm
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 Q
5 ;
6 ;***** "AIDSOI" TRIGGER OF THE "AIDS INDICATOR DISEASE" MULTIPLE
7 ;
8 ; .SDA Reference to a local array of record IENs
9 ;
10 ; DATE Date of an AIDS indicator disease
11 ;
12AIDSOI(SDA,DATE) ;
13 N IENS,TMP,RORFDA,RORMSG
14 ;--- Do not do anything if the CLINICAL AIDS field is already set
15 S IENS=+$G(SDA(1)) Q:IENS'>0 S IENS=IENS_","
16 Q:$$GET1^DIQ(799.4,IENS,.02,"I",,"RORMSG")
17 ;---
18 S DATE=$P(DATE,".")
19 I DATE>0 D
20 . S:'$E(DATE,4,5) $E(DATE,4,5)="01"
21 . S:'$E(DATE,6,7) $E(DATE,6,7)="01"
22 E S DATE=$$DT^XLFDT
23 ;---
24 S RORFDA(799.4,IENS,.02)=1
25 S RORFDA(799.4,IENS,.03)=DATE
26 D FILE^DIE(,"RORFDA","RORMSG")
27 Q
28 ;
29 ;***** "ANC" INDEX OF THE "REGISTRY NAME" MULTIPLE OF THE FILE #799.6
30 ;
31 ; .SDA Reference to a local array of record IENs
32 ;
33 ; REGNAME Registry name
34 ;
35 ; MODE 1 - Set, 0 - Kill
36 ;
37ANC7996(SDA,REGNAME,MODE) ;
38 I MODE S MODE=($D(^RORDATA(799.6,SDA(1),3,"ANC"))>1) D
39 . S ^RORDATA(799.6,SDA(1),3,"ANC",$E(REGNAME,1,30),SDA)=""
40 E D S MODE=($D(^RORDATA(799.6,SDA(1),3,"ANC"))>1)
41 . K ^RORDATA(799.6,SDA(1),3,"ANC",$E(REGNAME,1,30),SDA)
42 Q:MODE
43 ;--- Re-index the main record (the "ADNAUTO" index, in particular)
44 N DA,DIK
45 S DIK="^RORDATA(799.6,",DIK(1)=".01",DA=SDA(1)
46 D EN^DIK
47 Q
48 ;
49 ;***** DELETES THE DATA ASSOCIATED WITH THE MAIN REGISTRY RECORD
50 ;
51 ; IEN IEN of the registry record (file #798)
52 ; PTIEN Patient IEN
53 ;
54DEL798(IEN,PTIEN) ;
55 N DA,DIK,I,PTDEL
56 ;--- Delete the HIV record from the ROR HIV RECORD file (#799.4)
57 I $D(^RORDATA(799.4,IEN)) S DIK="^RORDATA(799.4,",DA=IEN D ^DIK
58 ;--- Check if the patient is added to more than one registry
59 S I="",PTDEL=1
60 F S I=$O(^RORDATA(798,"B",PTIEN,I)) Q:I="" S:I'=IEN PTDEL=0
61 ;--- Delete corresponding patient's records if they are not
62 ; referenced by other registries and the patient's record
63 ;--- in the PATIENT file (#2) is not a "merged" one.
64 I PTDEL D:$G(^DPT(PTIEN,-9))'>0
65 . ;--- Delete the record from the ROR PATIENT file
66 . S DIK="^RORDATA(798.4,",DA=PTIEN D ^DIK
67 . ;--- Delete the record from the ROR PATIENT EVENTS file
68 . S DIK="^RORDATA(798.3,",DA=PTIEN D ^DIK
69 Q
70 ;
71 ;***** RETURNS THE VALUE OF 'DATE SELECTED' COMPUTED FIELD
72 ;
73 ; IEN IEN of the registry record (file #798)
74 ;
75DTSEL(IEN) ;
76 N DTSEL
77 ;--- Earliest date of a selection rule
78 S DTSEL=$O(^RORDATA(798,IEN,1,"AD",""))\1
79 ;--- If SELECTION RULE multiple is empty, return DATE ENTERED
80 Q $S(DTSEL>0:DTSEL,1:$P($G(^RORDATA(798,IEN,0)),U,3)\1)
81 ;
82 ;***** STORE THE VALUE INTO THE FIELD
83 ;
84 ; FILE Sub(file) number
85 ; IENS IENS of the record
86 ; FIELD Field number
87 ; VALUE Internal value to be assigned
88 ;
89FILE(FILE,IENS,FIELD,VALUE) ;
90 N ROR8FDA,ROR8MSG,TMP
91 S TMP=$S($E(IENS,$L(IENS))=",":IENS,1:IENS_",")
92 S ROR8FDA(+FILE,TMP,+FIELD)=VALUE
93 D FILE^DIE(,"ROR8FDA","ROR8MSG")
94 Q
95 ;
96 ;***** STATUS OF THE HISTORICAL DATA DEFINITION
97 ;
98 ; HDEIEN IEN of the HDE definition (file #799.6)
99 ;
100 ; Return Values:
101 ; "" Unknown/Undefined
102 ; 0 Inactive
103 ; 1 Pending/Active
104 ; 2 Completed
105 ;
106HDESTAT(HDEIEN) ;
107 N BUF,STATUS,TYPE
108 S HDEIEN=+HDEIEN,BUF=$G(^RORDATA(799.6,HDEIEN,0))
109 S TYPE=+$P(BUF,U,2),STATUS=""
110 ;=== Auto
111 I TYPE=1 D Q STATUS
112 . N ADT
113 . ;--- Activation Date
114 . S ADT=+$P(BUF,U,7)
115 . I (ADT'>0)!(ADT<DT) S STATUS=0 Q
116 . ;--- Check if all registries have completion dates
117 . I $D(^RORDATA(799.6,HDEIEN,3,"ANC"))<10 S STATUS=2 Q
118 . ;--- Pending or Active
119 . S STATUS=1
120 ;=== Manual
121 I TYPE=2 D Q STATUS
122 . N TSKIEN,TSKSTAT
123 . ;--- Check if any tasks are defined
124 . I $O(^RORDATA(799.6,HDEIEN,4,0))'>0 S STATUS=0 Q
125 . ;--- Check if all tasks have been completed
126 . I $D(^RORDATA(799.6,HDEIEN,4,"ANC"))<10 S STATUS=2 Q
127 . ;--- Pending, Active, or Errors
128 . S STATUS=1
129 ;=== Unknown or Undefined
130 Q ""
131 ;
132 ;***** CHECKS IF THE LOCAL REGISTRY FIELD IS ACTIVE
133 ;
134 ; IEN IEN of the local field definition (file #799.53)
135 ;
136 ; Return Values:
137 ; 0 Inactivated
138 ; 1 Active
139 ;
140LFACTIVE(IEN) ;
141 N TMP
142 S TMP=$G(^ROR(799.53,+IEN,0)) Q:TMP="" 0
143 S TMP=$P(TMP,U,2)\1 Q:TMP'>0 1
144 Q (TMP>DT)
145 ;
146 ;***** RETURNS THE VALUE OF 'LOCATION' COMPUTED FIELD
147 ;
148 ; IEN IEN of the registry record (file #798)
149 ;
150LOCSEL(IEN) ;
151 N DTSEL,SRIEN
152 S DTSEL=$O(^RORDATA(798,IEN,1,"AD","")) Q:DTSEL'>0 ""
153 S SRIEN=$O(^RORDATA(798,IEN,1,"AD",DTSEL,""))
154 Q $S(SRIEN>0:$P($G(^RORDATA(798,IEN,1,SRIEN,0)),U,3),1:"")
155 ;
156 ;***** RE-INDEXES ONE RECORD OF THE (SUB)FILE
157 ;
158 ; FILE File number
159 ;
160 ; .DA Reference to a local array of record IENs
161 ;
162 ; [FIELD] Optional field number. If it is provided, then only
163 ; cross-references for this field are re-indexed.
164 ;
165REINDEX1(FILE,DA,FIELD) ;
166 N DIK
167 S DIK=$$ROOT^DILFD(FILE,$$IENS^DILF(.DA))
168 S:$G(FIELD)>0 DIK(1)=+FIELD
169 D EN^DIK
170 Q
171 ;
172 ;***** REACTS ON THE REGISTRY RECORD STATUS CHANGES
173 ;
174 ; MODE Execution mode (1 - Set, 2 - Kill)
175 ;
176 ; IEN Internal entry number of the registry record
177 ;
178 ; STOLD Old and new internal values of the STATUS field
179 ; STNEW
180 ;
181RST798(MODE,IEN,STOLD,STNEW) ;
182 Q:STNEW=STOLD
183 N IENS,RORFDA,RORMSG
184 S IENS=(+IEN)_","
185 ;---
186 D
187 . ;--- Deleted
188 . I STNEW=5 D Q
189 . . S RORFDA(798,IENS,6)=$$NOW^XLFDT
190 . . S:$G(DUZ)>0 RORFDA(798,IENS,6.1)=+DUZ
191 . ;--- Confirmed
192 . I STOLD=4,'STNEW D Q
193 . . S RORFDA(798,IENS,2)=$$NOW^XLFDT
194 . . S:$G(DUZ)>0 RORFDA(798,IENS,2.1)=+DUZ
195 ;---
196 D:$D(RORFDA)>1 FILE^DIE(,"RORFDA","RORMSG")
197 Q
198 ;
199 ;***** GENERATES THE INDEX VALUE OF THE REPORT ELEMENT
200 ;
201 ; MODE Sort mode (see the SORT BY field of the REPORT
202 ; ELEMENT multiple of the ROR TASK file for details)
203 ; VAL Value of the report element
204 ;
205SORTBY(MODE,VAL) ;
206 Q $S(MODE=3:+VAL,VAL="":" ",MODE=2:$E(VAL,1,29)_" ",1:$E(VAL,1,30))
Note: See TracBrowser for help on using the repository browser.