source: ccr/trunk/p/C0CACTOR.m@ 765

Last change on this file since 765 was 762, checked in by George Lilly, 14 years ago

updates for deidentification

File size: 10.6 KB
RevLine 
[601]1C0CACTOR ; CCDCCR/GPL - CCR/CCD PROCESSING FOR ACTORS ; 7/3/08
2 ;;1.0;C0C;;May 19, 2009;
3 ;Copyright 2008,2009 George Lilly, University of Minnesota.
4 ;Licensed under the terms of the GNU General Public License.
5 ;See attached copy of the License.
6 ;
7 ; This program is free software; you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation; either version 2 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License along
18 ; with this program; if not, write to the Free Software Foundation, Inc.,
19 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ;
21 ; PROCESS THE ACTORS SECTION OF THE CCR
22 ;
23 ; ===Revision History===
24 ; 0.1 Initial Writing of Skeleton--GPL
25 ; 0.2 Patient Data Extraction--SMH
26 ; 0.3 Information System Info Extraction--SMH
27 ; 0.4 Patient data rouine refactored; adjustments here--SMH
28 ;
29EXTRACT(IPXML,ALST,AXML) ; EXTRACT ACTOR FROM ALST INTO PROVIDED XML TEMPLATE
30 ; IPXML is the Input Actor Template into which we substitute values
31 ; This is straight XML. Values to be substituted are in @@VAL@@ format.
32 ; ALST is the actor list global generated by ACTLST^C0CCCR and has format:
33 ; ^TMP(7542,1,"ACTORS",0)=Count
34 ; ^TMP(7542,1,"ACTORS",n)="ActorID^ActorType^ActorIEN"
35 ; ActorType is an enum containing either "PROVIDER" "PATIENT" "SYSTEM"
36 ; AXML is the output arrary, to contain XML.
37 ;
38 N I,J,AMAP,AOID,ATYP,AIEN
39 D CP^C0CXPATH(IPXML,AXML) ; MAKE A COPY OF ACTORS XML
40 D REPLACE^C0CXPATH(AXML,"","//Actors") ; DELETE THE INSIDES
41 I DEBUG W "PROCESSING ACTORS ",!
42 F I=1:1:@ALST@(0) D ; PROCESS ALL ACTORS IN THE LIST
43 . I @ALST@(I)["@@" Q ; NOT A VALID ACTOR
44 . S AOID=$P(@ALST@(I),"^",1) ; ACTOR OBJECT ID
45 . S ATYP=$P(@ALST@(I),"^",2) ; ACTOR TYPE
46 . S AIEN=$P(@ALST@(I),"^",3) ; ACTOR RECORD NUMBER
47 . I AIEN="" D Q ; IEN CAN'T BE NULL
48 . . W "WARING NUL ACTOR: ",ATYP,!
49 . I ATYP="" Q ; NOT A VALID ACTOR
50 . ;
51 . I DEBUG W AOID_" "_ATYP_" "_AIEN,!
52 . I ATYP="PATIENT" D ; PATIENT ACTOR TYPE
53 . . D QUERY^C0CXPATH(IPXML,"//Actors/ACTOR-PATIENT","ATMP")
54 . . D PATIENT("ATMP",AIEN,AOID,"ATMP2")
55 . ;
56 . I ATYP="SYSTEM" D ; SYSTEM ACTOR TYPE
57 . . D QUERY^C0CXPATH(IPXML,"//Actors/ACTOR-SYSTEM","ATMP")
58 . . D SYSTEM("ATMP",AIEN,AOID,"ATMP2")
59 . ;
60 . I ATYP="NOK" D ; NOK ACTOR TYPE
61 . . D QUERY^C0CXPATH(IPXML,"//Actors/ACTOR-NOK","ATMP")
62 . . D NOK("ATMP",AIEN,AOID,"ATMP2")
63 . ;
64 . I ATYP="PROVIDER" D ; PROVIDER ACTOR TYPE
65 . . D QUERY^C0CXPATH(IPXML,"//Actors/ACTOR-PROVIDER","ATMP")
66 . . D PROVIDER("ATMP",AIEN,AOID,"ATMP2")
67 . ;
68 . I ATYP="ORGANIZATION" D ; PROVIDER ACTOR TYPE
69 . . D QUERY^C0CXPATH(IPXML,"//Actors/ACTOR-ORG","ATMP")
70 . . D ORG("ATMP",AIEN,AOID,"ATMP2")
71 . ;
72 . W "PROCESSING:",ATYP," ",AIEN,!
73 . ;I @ATMP2@(0)=0 Q ; NOTHING RETURNED, SKIP THIS ONE
74 . D INSINNER^C0CXPATH(AXML,"ATMP2") ; INSERT INTO ROOT
75 . K ATYP,AIEN,AOID,ATMP,ATMP2 ; BE SURE TO GET THE NEXT ONE
76 ;
77 N ACTTMP
78 D MISSING^C0CXPATH(AXML,"ACTTMP") ; SEARCH XML FOR MISSING VARS
79 I ACTTMP(0)>0 D ; IF THERE ARE MISSING VARS -
80 . ; STRINGS MARKED AS @@X@@
81 . W "ACTORS Missing list: ",!
82 . F I=1:1:ACTTMP(0) W ACTTMP(I),!
83 Q
84 ;
85PATIENT(INXML,AIEN,AOID,OUTXML) ; PROCESS A PATIENT ACTOR
86 I DEBUG W "PROCESSING ACTOR PATIENT ",AIEN,!
87 ;GPL SEPARATED EXTRACT FROM MAP FOR PROCESSING PATIENTS - TO MAKE
88 ; CODE REUSABLE FROM ERX
89 N AMAP
90 S AMAP=$NA(^TMP($J,"AMAP"))
91 K @AMAP
92 D PEXTRACT(AMAP,AIEN,AOID) ;EXTRACT THE PATIENT ACTOR
[762]93 I $P($$SITE^VASITE(),U,2)="OROVILLE HOSPITAL" S C0CDE=1
94 I $G(C0CDE)'="" D DEIDENT(AMAP,AIEN) ; DEIDENTIFY THE CCR
[601]95 D MAP(INXML,AMAP,OUTXML) ;MAP TO XML
96 K @AMAP ; CLEAN UP BEHIND US
97 Q
98 ;
[762]99DEIDENT(GPL,ZDFN) ; QUICK WAY TO DEIDENTIFY THE CCR
100 S @GPL@("ACTORADDRESSCITY")="ALTON"
101 S @GPL@("ACTORADDRESSLINE1")="1234 Somewhere Lane"
102 S @GPL@("ACTORADDRESSLINE2")=""
103 S @GPL@("ACTORADDRESSSOURCEID")="ACTORPATIENT_"_ZDFN
104 S @GPL@("ACTORADDRESSSTATE")="KANSAS"
105 S @GPL@("ACTORADDRESSTYPE")="Home"
106 S @GPL@("ACTORADDRESSZIPCODE")=67623
107 S @GPL@("ACTORCELLTEL")=""
108 S @GPL@("ACTORCELLTELTEXT")=""
109 S @GPL@("ACTORDATEOFBIRTH")="1957-12-25"
110 S @GPL@("ACTOREMAIL")=""
111 S @GPL@("ACTORFAMILYNAME")="ZZ PATIENT"_ZDFN
112 S @GPL@("ACTORGENDER")="MALE"
113 S @GPL@("ACTORGIVENNAME")="TEST"_ZDFN
114 S @GPL@("ACTORIEN")=2
115 S @GPL@("ACTORMIDDLENAME")="TWO"
116 S @GPL@("ACTOROBJECTID")="ACTORPATIENT_"_ZDFN
117 S @GPL@("ACTORRESTEL")="888-555-1212"
118 S @GPL@("ACTORRESTELTEXT")="Residential Telephone"
119 S @GPL@("ACTORSOURCEID")="ACTORSYSTEM_1"
120 S @GPL@("ACTORSSN")="769122557P"
121 S @GPL@("ACTORSSNSOURCEID")="ACTORPATIENT_"_ZDFN
122 S @GPL@("ACTORSSNTEXT")="SSN"
123 S @GPL@("ACTORSUFFIXNAME")=""
124 S @GPL@("ACTORWORKTEL")="888-121-1212"
125 S @GPL@("ACTORWORKTELTEXT")="Work Telephone"
126 Q
127 ;
[601]128PEXTRACT(AMAP,AIEN,AOID) ; EXTRACT TO RETURN ARRAY RARY PASSED BY NAME
129 N ZX
130 S @AMAP@("ACTOROBJECTID")=AOID ;ACTOR OBJECT ID
131 S @AMAP@("ACTORGIVENNAME")=$$GIVEN^C0CDPT(AIEN)
132 S @AMAP@("ACTORMIDDLENAME")=$$MIDDLE^C0CDPT(AIEN)
133 S @AMAP@("ACTORFAMILYNAME")=$$FAMILY^C0CDPT(AIEN)
134 S @AMAP@("ACTORDATEOFBIRTH")=$$DOB^C0CDPT(AIEN)
135 S @AMAP@("ACTORGENDER")=$$GENDER^C0CDPT(AIEN)
136 S @AMAP@("ACTORSSN")=""
137 S @AMAP@("ACTORSSNTEXT")=""
138 S @AMAP@("ACTORSSNSOURCEID")=""
139 S X="MSCDPTID" ; ROUTINE TO TEST FOR MRN ON OPENVISTA
140 X ^%ZOSF("TEST") ; TEST TO SEE IF THE ROUTINE EXISTS
141 I $T S MRN=$$^MSCDPTID(DFN) ;TEST FOR MRN ON OPENVISTA ;GPL
142 I $G(MRN)'="" D ; IF MRN IS PRESENT
143 . S @AMAP@("ACTORSSN")=MRN
144 . S @AMAP@("ACTORSSNTEXT")="MRN"
145 . S @AMAP@("ACTORSSNSOURCEID")=AOID
146 E D ; NO MRN, USE SSN
147 . S ZX=$$SSN^C0CDPT(AIEN)
148 . I ZX'="" D ; IF THERE IS A SSN IN THE RECORD
149 . . S @AMAP@("ACTORSSN")=ZX
150 . . S @AMAP@("ACTORSSNTEXT")="SSN"
151 . . S @AMAP@("ACTORSSNSOURCEID")=AOID
152 S @AMAP@("ACTORADDRESSTYPE")=$$ADDRTYPE^C0CDPT(AIEN)
153 S @AMAP@("ACTORADDRESSLINE1")=$$ADDR1^C0CDPT(AIEN)
154 S @AMAP@("ACTORADDRESSLINE2")=$$ADDR2^C0CDPT(AIEN)
155 S @AMAP@("ACTORADDRESSCITY")=$$CITY^C0CDPT(AIEN)
156 S @AMAP@("ACTORADDRESSSTATE")=$$STATE^C0CDPT(AIEN)
157 S @AMAP@("ACTORADDRESSZIPCODE")=$$ZIP^C0CDPT(AIEN)
158 S @AMAP@("ACTORRESTEL")=""
159 S @AMAP@("ACTORRESTELTEXT")=""
160 S ZX=$$RESTEL^C0CDPT(AIEN)
161 I ZX'="" D ; IF THERE IS A RESIDENT PHONE IN THE RECORD
162 . S @AMAP@("ACTORRESTEL")=ZX
163 . S @AMAP@("ACTORRESTELTEXT")="Residential Telephone"
164 S @AMAP@("ACTORWORKTEL")=""
165 S @AMAP@("ACTORWORKTELTEXT")=""
166 S ZX=$$WORKTEL^C0CDPT(AIEN)
167 I ZX'="" D ; IF THERE IS A RESIDENT PHONE IN THE RECORD
168 . S @AMAP@("ACTORWORKTEL")=ZX
169 . S @AMAP@("ACTORWORKTELTEXT")="Work Telephone"
170 S @AMAP@("ACTORCELLTEL")=""
171 S @AMAP@("ACTORCELLTELTEXT")=""
172 S ZX=$$CELLTEL^C0CDPT(AIEN)
173 I ZX'="" D ; IF THERE IS A CELL PHONE IN THE RECORD
174 . S @AMAP@("ACTORCELLTEL")=ZX
175 . S @AMAP@("ACTORCELLTELTEXT")="Cell Phone"
176 S @AMAP@("ACTOREMAIL")=$$EMAIL^C0CDPT(AIEN)
177 S @AMAP@("ACTORADDRESSSOURCEID")=AOID
178 S @AMAP@("ACTORIEN")=AIEN
179 S @AMAP@("ACTORSUFFIXNAME")="" ; DOES VISTA STORE THE SUFFIX
180 S @AMAP@("ACTORSOURCEID")="ACTORSYSTEM_1" ; THE SYSTEM IS THE SOURCE
181 Q
182 ;
183MAP(INXML,AMAP,OUTXML) ;MAP ANY ACTOR TO XML
184 D MAP^C0CXPATH(INXML,AMAP,OUTXML) ; MAP THE VARIABLE
185 Q
186 ;
187SYSTEM(INXML,AIEN,AOID,OUTXML) ; PROCESS A SYSTEM ACTOR
188 ;
189 ; N AMAP
190 S AMAP=$NA(^TMP($J,"AMAP"))
191 K @AMAP
192 S @AMAP@("ACTOROBJECTID")=AOID ;ACTOR OBJECT ID
193 S @AMAP@("ACTORINFOSYSNAME")=$$SYSNAME^C0CSYS
194 S @AMAP@("ACTORINFOSYSVER")=$$SYSVER^C0CSYS
195 S @AMAP@("ACTORINFOSYSSOURCEID")=AOID
196 D MAP^C0CXPATH(INXML,AMAP,OUTXML) ; MAP THE VARIABLE
197 Q
198 ;
199NOK(INXML,AIEN,AOID,OUTXML) ; PROCESS A NEXT OF KIN TYPE ACTOR
200 ;
201 ; N AMAP
202 S AMAP=$NA(^TMP($J,"AMAP"))
203 K @AMAP
204 S @AMAP@("ACTOROBJECTID")=AOID ;ACTOR OBJECT ID
205 S @AMAP@("ACTORDISPLAYNAME")=""
206 S @AMAP@("ACTORRELATION")=""
207 S @AMAP@("ACTORRELATIONSOURCEID")=""
208 S @AMAP@("ACTORSOURCEID")="ACTORSYSTEM_1" ; THE SYSTEM IS THE SOURCE
209 D MAP^C0CXPATH(INXML,AMAP,OUTXML) ; MAP THE VARIABLE
210 Q
211 ;
212ORG(INXML,AIEN,AOID,OUTXML) ; PROCESS AN ORGANIZATION TYPE ACTOR
213 ;
[754]214 N AMAP,ZIEN,ZSITE
[601]215 S AMAP=$NA(^TMP($J,"AMAP"))
216 K @AMAP
217 S @AMAP@("ACTOROBJECTID")=AOID ;ACTOR OBJECT ID
[754]218 S ZSITE=$$SITE^VASITE ; SITE FORMAT IEN^NAME^DATE
219 S ZIEN=$P(ZSITE,"^",1)
220 S @AMAP@("ORGANIZATIONNAME")=$P(ZSITE,U,2)
[601]221 S @AMAP@("ACTORSOURCEID")="ACTORSYSTEM_1"
[754]222 S @AMAP@("ACTORADDRESSTYPE")="Office"
223 S @AMAP@("ACTORADDRESSLINE1")=$$GET1^DIQ(4,ZIEN_",",1.01)
224 S @AMAP@("ACTORADDRESSLINE2")=$$GET1^DIQ(4,ZIEN_",",1.02)
225 S @AMAP@("ACTORADDRESSCITY")=$$GET1^DIQ(4,ZIEN_",",1.03)
226 S @AMAP@("ACTORADDRESSSTATE")=$$GET1^DIQ(4,ZIEN_",",.02)
227 S @AMAP@("ACTORPOSTALCODE")=$$GET1^DIQ(4,ZIEN_",",1.04)
228 S @AMAP@("ACTORTELEPHONE")=""
229 S @AMAP@("ACTORTELEPHONETYPE")=""
230 S ZX=$$GET1^DIQ(4.03,"1,"_ZIEN_",",.03)
231 I ZX'="" D ; THERE IS A PHONE NUMBER AVAILABLE
232 . S @AMAP@("ACTORTELEPHONE")=ZX
233 . S @AMAP@("ACTORTELEPHONETYPE")="Office"
[601]234 D MAP^C0CXPATH(INXML,AMAP,OUTXML) ; MAP THE VARIABLE
[754]235 K @AMAP
[601]236 Q
237 ;
238PROVIDER(INXML,AIEN,AOID,OUTXML) ; PROCESS A PROVIDER TYPE ACTOR
239 ;
240 ; N AMAP
241 S AMAP=$NA(^TMP($J,"AMAP"))
242 K @AMAP
243 I '$D(^VA(200,AIEN,0)) D Q ; IF NO PROVIDER RECORD (SHOULDN'T HAPPEN)
244 . W "WARNING - MISSING PROVIDER: ",AIEN,!
245 . S @OUTXML@(0)=0 ; SIGNAL NO OUTPUT
246 S @AMAP@("ACTOROBJECTID")=AOID ;ACTOR OBJECT ID
247 S @AMAP@("ACTORGIVENNAME")=$$GIVEN^C0CVA200(AIEN)
248 S @AMAP@("ACTORMIDDLENAME")=$$MIDDLE^C0CVA200(AIEN)
249 S @AMAP@("ACTORFAMILYNAME")=$$FAMILY^C0CVA200(AIEN)
250 S @AMAP@("ACTORTITLE")=$$TITLE^C0CVA200(AIEN)
251 S @AMAP@("IDTYPE")=$P($$NPI^C0CVA200(AIEN),U,1)
252 S @AMAP@("ID")=$P($$NPI^C0CVA200(AIEN),U,2)
253 S @AMAP@("IDDESC")=$P($$NPI^C0CVA200(AIEN),U,3)
254 S @AMAP@("ACTORSPECIALITY")=$$SPEC^C0CVA200(AIEN)
255 S @AMAP@("ACTORADDRESSTYPE")=$$ADDTYPE^C0CVA200(AIEN)
256 S @AMAP@("ACTORADDRESSLINE1")=$$ADDLINE1^C0CVA200(AIEN)
257 S @AMAP@("ACTORADDRESSCITY")=$$CITY^C0CVA200(AIEN)
258 S @AMAP@("ACTORADDRESSSTATE")=$$STATE^C0CVA200(AIEN)
259 S @AMAP@("ACTORPOSTALCODE")=$$POSTCODE^C0CVA200(AIEN)
260 S @AMAP@("ACTORTELEPHONE")=""
261 S @AMAP@("ACTORTELEPHONETYPE")=""
262 S ZX=$$TEL^C0CVA200(AIEN)
263 I ZX'="" D ; THERE IS A PHONE NUMBER AVAILABLE
264 . S @AMAP@("ACTORTELEPHONE")=ZX
265 . S @AMAP@("ACTORTELEPHONETYPE")=$$TELTYPE^C0CVA200(AIEN)
266 S @AMAP@("ACTOREMAIL")=$$EMAIL^C0CVA200(AIEN)
267 S @AMAP@("ACTORADDRESSSOURCEID")="ACTORSYSTEM_1"
268 S @AMAP@("ACTORSOURCEID")="ACTORSYSTEM_1" ; THE SYSTEM IS THE SOURCE
[754]269 S @AMAP@("ACTORORGLINK")="ACTORORGANIZATION_1"
[601]270 D MAP^C0CXPATH(INXML,AMAP,OUTXML) ; MAP THE VARIABLE
271 Q
272 ;
Note: See TracBrowser for help on using the repository browser.