source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Common/NhincDataTransformsLib/src/gov/hhs/fha/nhinc/transform/subdisc/HL7PatientTransforms.java@ 507

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

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 17.8 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.transform.subdisc;
6
7import gov.hhs.fha.nhinc.nhinclib.NullChecker;
8import java.util.List;
9import javax.xml.bind.JAXBElement;
10import org.hl7.v3.CE;
11import org.hl7.v3.II;
12import org.hl7.v3.PNExplicit;
13import org.hl7.v3.PRPAMT201301UVOtherIDs;
14import org.hl7.v3.PRPAMT201301UVPatient;
15import org.hl7.v3.PRPAMT201301UVPerson;
16import org.hl7.v3.TSExplicit;
17import org.apache.commons.logging.Log;
18import org.apache.commons.logging.LogFactory;
19import org.hl7.v3.PRPAMT201302UVOtherIDs;
20import org.hl7.v3.PRPAMT201302UVPatient;
21import org.hl7.v3.PRPAMT201302UVPerson;
22import org.hl7.v3.PRPAMT201310UVOtherIDs;
23import org.hl7.v3.PRPAMT201310UVPatient;
24import org.hl7.v3.PRPAMT201310UVPerson;
25import org.hl7.v3.PRPAMT201305UVPerson;
26import org.hl7.v3.PRPAMT201305UVPatient;
27
28/**
29 *
30 * @author Jon Hoppesch
31 */
32public class HL7PatientTransforms {
33
34 private static Log log = LogFactory.getLog(HL7PatientTransforms.class);
35
36 public static PRPAMT201301UVPatient create201301Patient(JAXBElement<PRPAMT201301UVPerson> person, String patId) {
37 return create201301Patient(person, HL7DataTransformHelper.IIFactory(patId));
38 }
39
40 public static PRPAMT201301UVPatient create201301Patient(JAXBElement<PRPAMT201301UVPerson> person, String patId, String assigningAuthority) {
41 return create201301Patient(person, HL7DataTransformHelper.IIFactory(assigningAuthority, patId));
42 }
43
44 public static PRPAMT201301UVPatient create201301Patient(JAXBElement<PRPAMT201301UVPerson> person, II id) {
45 PRPAMT201301UVPatient patient = new PRPAMT201301UVPatient();
46
47 patient.setClassCode("PAT");
48 patient.setStatusCode(HL7DataTransformHelper.CSFactory("active"));
49
50 patient.getId().add(id);
51
52 patient.setPatientPerson(person);
53
54 patient.setProviderOrganization(null);
55
56 return patient;
57 }
58
59 public static PRPAMT201310UVPatient create201310Patient(JAXBElement<PRPAMT201310UVPerson> person, String patId) {
60 return create201310Patient(person, HL7DataTransformHelper.IIFactory(patId));
61 }
62
63 public static PRPAMT201310UVPatient create201310Patient(JAXBElement<PRPAMT201310UVPerson> person, String patId, String assigningAuthority) {
64 return create201310Patient(person, HL7DataTransformHelper.IIFactory(assigningAuthority, patId));
65 }
66
67 public static PRPAMT201310UVPatient create201310Patient(JAXBElement<PRPAMT201310UVPerson> person, II id) {
68 PRPAMT201310UVPatient patient = new PRPAMT201310UVPatient();
69
70 patient.setClassCode("PAT");
71 patient.setStatusCode(HL7DataTransformHelper.CSFactory("active"));
72
73 patient.getId().add(id);
74
75 patient.setPatientPerson(person);
76
77 patient.setProviderOrganization(null);
78
79 return patient;
80 }
81
82 public static PRPAMT201302UVPatient create201302Patient(String remotePatId, JAXBElement<PRPAMT201301UVPerson> person, II localPatId) {
83 return create201302Patient(HL7DataTransformHelper.IIFactory(remotePatId), person, localPatId);
84 }
85
86 public static PRPAMT201302UVPatient create201302Patient(String remotePatId, String remoteAssigningAuthority, JAXBElement<PRPAMT201301UVPerson> person, II localPatId) {
87 return create201302Patient(HL7DataTransformHelper.IIFactory(remoteAssigningAuthority, remotePatId), person, localPatId);
88 }
89
90 public static PRPAMT201302UVPatient create201302Patient(II remotePatId, JAXBElement<PRPAMT201301UVPerson> person, II localPatId) {
91 PRPAMT201302UVPatient patient = new PRPAMT201302UVPatient();
92
93 patient.setClassCode("PAT");
94 patient.setStatusCode(HL7DataTransformHelper.CSFactory("active"));
95
96 patient.getId().add(localPatId);
97
98 if (person.getValue() != null) {
99 PRPAMT201301UVPerson inputPerson = person.getValue();
100 JAXBElement<PRPAMT201302UVPerson> patientPerson = create201302PatientPerson(inputPerson.getName().get(0), inputPerson.getAdministrativeGenderCode(), inputPerson.getBirthTime(), inputPerson.getAsOtherIDs(), remotePatId);
101 patient.setPatientPerson(patientPerson);
102 }
103
104 patient.setProviderOrganization(null);
105
106 return patient;
107 }
108
109 public static PRPAMT201302UVPatient create201302Patient(JAXBElement<PRPAMT201310UVPerson> person, String remotePatId, II localPatId) {
110 return create201302Patient(person, HL7DataTransformHelper.IIFactory(remotePatId), localPatId);
111 }
112
113 public static PRPAMT201302UVPatient create201302Patient(JAXBElement<PRPAMT201310UVPerson> person, String remotePatId, String remoteAssigningAuthority, II localPatId) {
114 return create201302Patient(person, HL7DataTransformHelper.IIFactory(remoteAssigningAuthority, remotePatId), localPatId);
115 }
116
117 public static PRPAMT201302UVPatient create201302Patient(JAXBElement<PRPAMT201310UVPerson> person, II remotePatId, II localPatId) {
118 PRPAMT201302UVPatient patient = new PRPAMT201302UVPatient();
119
120 patient.setClassCode("PAT");
121 patient.setStatusCode(HL7DataTransformHelper.CSFactory("active"));
122
123 patient.getId().add(localPatId);
124
125 if (person.getValue() != null) {
126 PRPAMT201310UVPerson inputPerson = person.getValue();
127 JAXBElement<PRPAMT201302UVPerson> patientPerson = create201302PatientPerson(inputPerson.getAsOtherIDs(), inputPerson.getName().get(0), inputPerson.getAdministrativeGenderCode(), inputPerson.getBirthTime(), remotePatId);
128 patient.setPatientPerson(patientPerson);
129 }
130
131 patient.setProviderOrganization(null);
132
133 return patient;
134 }
135
136 public static JAXBElement<PRPAMT201301UVPerson> create201301PatientPerson(String patFirstName, String patLastName, String gender, String birthTime, String ssn) {
137 PNExplicit name = null;
138 if (NullChecker.isNotNullish(patFirstName) &&
139 NullChecker.isNotNullish(patLastName)) {
140 name = HL7DataTransformHelper.CreatePNExplicit(patFirstName, patLastName);
141 }
142
143 CE genderCode = null;
144 if (NullChecker.isNotNullish(gender)) {
145 genderCode = HL7DataTransformHelper.CEFactory(gender);
146 }
147
148 TSExplicit bday = null;
149 if (NullChecker.isNotNullish(birthTime)) {
150 bday = HL7DataTransformHelper.TSExplicitFactory(birthTime);
151 }
152
153 PRPAMT201301UVOtherIDs otherIds = null;
154 if (NullChecker.isNotNullish(ssn)) {
155 otherIds = createPRPAMT201301UVOtherIDs(ssn);
156 }
157
158 return create201301PatientPerson(name, genderCode, bday, otherIds);
159 }
160
161 public static JAXBElement<PRPAMT201301UVPerson> create201301PatientPerson(PNExplicit patName, CE gender, TSExplicit birthTime, PRPAMT201301UVOtherIDs otherIds) {
162 PRPAMT201301UVPerson person = new PRPAMT201301UVPerson();
163
164 // Set the Subject Name
165 if (patName != null) {
166 person.getName().add(patName);
167 }
168
169 // Set the Subject Gender
170 if (gender != null) {
171 person.setAdministrativeGenderCode(gender);
172 }
173
174 // Set the Birth Time
175 if (birthTime != null) {
176 person.setBirthTime(birthTime);
177 }
178
179 // Set the SSN
180 if (otherIds != null) {
181 person.getAsOtherIDs().add(otherIds);
182 }
183
184 javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
185 JAXBElement<PRPAMT201301UVPerson> result = new JAXBElement<PRPAMT201301UVPerson>(xmlqname, PRPAMT201301UVPerson.class, person);
186
187 return result;
188 }
189
190 public static JAXBElement<PRPAMT201310UVPerson> create201310PatientPerson(String patFirstName, String patLastName, String gender, String birthTime, String ssn) {
191 PNExplicit name = null;
192 if (NullChecker.isNotNullish(patFirstName) &&
193 NullChecker.isNotNullish(patLastName)) {
194 name = HL7DataTransformHelper.CreatePNExplicit(patFirstName, patLastName);
195 }
196
197 CE genderCode = null;
198 if (NullChecker.isNotNullish(gender)) {
199 genderCode = HL7DataTransformHelper.CEFactory(gender);
200 }
201
202 TSExplicit bday = null;
203 if (NullChecker.isNotNullish(birthTime)) {
204 bday = HL7DataTransformHelper.TSExplicitFactory(birthTime);
205 }
206
207 PRPAMT201310UVOtherIDs otherIds = null;
208 if (NullChecker.isNotNullish(ssn)) {
209 otherIds = createPRPAMT201310UVOtherIDs(ssn);
210 }
211
212 return create201310PatientPerson(name, genderCode, bday, otherIds);
213 }
214
215 public static JAXBElement<PRPAMT201310UVPerson> create201310PatientPerson(PNExplicit patName, CE gender, TSExplicit birthTime, PRPAMT201310UVOtherIDs otherIds) {
216 PRPAMT201310UVPerson person = new PRPAMT201310UVPerson();
217
218 // Set the Subject Name
219 if (patName != null) {
220 person.getName().add(patName);
221 }
222
223 // Set the Subject Gender
224 if (gender != null) {
225 person.setAdministrativeGenderCode(gender);
226 }
227
228 // Set the Birth Time
229 if (birthTime != null) {
230 person.setBirthTime(birthTime);
231 }
232
233 // Set the SSN
234 if (otherIds != null) {
235 person.getAsOtherIDs().add(otherIds);
236 }
237
238 javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
239 JAXBElement<PRPAMT201310UVPerson> result = new JAXBElement<PRPAMT201310UVPerson>(xmlqname, PRPAMT201310UVPerson.class, person);
240
241 return result;
242 }
243
244 public static JAXBElement<PRPAMT201302UVPerson> create201302PatientPerson(String patFirstName, String patLastName, String gender, String birthTime, String ssn, II remotePatId) {
245 PNExplicit name = null;
246 if (NullChecker.isNotNullish(patFirstName) &&
247 NullChecker.isNotNullish(patLastName)) {
248 name = HL7DataTransformHelper.CreatePNExplicit(patFirstName, patLastName);
249 }
250
251 CE genderCode = null;
252 if (NullChecker.isNotNullish(gender)) {
253 genderCode = HL7DataTransformHelper.CEFactory(gender);
254 }
255
256 TSExplicit bday = null;
257 if (NullChecker.isNotNullish(birthTime)) {
258 bday = HL7DataTransformHelper.TSExplicitFactory(birthTime);
259 }
260
261 PRPAMT201302UVOtherIDs otherIds = null;
262 if (NullChecker.isNotNullish(ssn) ||
263 (remotePatId != null &&
264 NullChecker.isNotNullish(remotePatId.getRoot()) &&
265 NullChecker.isNotNullish(remotePatId.getExtension()))) {
266 otherIds = createPRPAMT201302UVOtherIDs(ssn, remotePatId);
267 }
268
269 return create201302PatientPerson(name, genderCode, bday, otherIds);
270 }
271
272 public static JAXBElement<PRPAMT201302UVPerson> create201302PatientPerson(PNExplicit patName, CE gender, TSExplicit birthTime, List<PRPAMT201301UVOtherIDs> otherIds, II remotePatId) {
273 PRPAMT201302UVOtherIDs convertedOtherIds = null;
274 if (otherIds != null &&
275 otherIds.size() > 0 &&
276 otherIds.get(0) != null &&
277 otherIds.get(0).getId() != null &&
278 otherIds.get(0).getId().size() > 0 &&
279 otherIds.get(0).getId().get(0) != null &&
280 NullChecker.isNotNullish(otherIds.get(0).getId().get(0).getExtension())){
281 convertedOtherIds = createPRPAMT201302UVOtherIDs(otherIds.get(0).getId().get(0).getExtension(), remotePatId);
282 }
283 else if (remotePatId != null &&
284 NullChecker.isNotNullish(remotePatId.getRoot()) &&
285 NullChecker.isNotNullish(remotePatId.getExtension())) {
286 convertedOtherIds = createPRPAMT201302UVOtherIDs(null, remotePatId);
287 }
288
289 return create201302PatientPerson(patName, gender, birthTime, convertedOtherIds);
290 }
291
292 public static JAXBElement<PRPAMT201302UVPerson> create201302PatientPerson(List<PRPAMT201310UVOtherIDs> otherIds, PNExplicit patName, CE gender, TSExplicit birthTime, II remotePatId) {
293 PRPAMT201302UVOtherIDs convertedOtherIds = null;
294 if (otherIds != null &&
295 otherIds.size() > 0 &&
296 otherIds.get(0) != null &&
297 otherIds.get(0).getId() != null &&
298 otherIds.get(0).getId().size() > 0 &&
299 otherIds.get(0).getId().get(0) != null &&
300 NullChecker.isNotNullish(otherIds.get(0).getId().get(0).getExtension())) {
301 convertedOtherIds = createPRPAMT201302UVOtherIDs(otherIds.get(0).getId().get(0).getExtension(), remotePatId);
302 }
303 else if (remotePatId != null &&
304 NullChecker.isNotNullish(remotePatId.getRoot()) &&
305 NullChecker.isNotNullish(remotePatId.getExtension())) {
306 convertedOtherIds = createPRPAMT201302UVOtherIDs(null, remotePatId);
307 }
308
309 return create201302PatientPerson(patName, gender, birthTime, convertedOtherIds);
310 }
311
312 public static JAXBElement<PRPAMT201302UVPerson> create201302PatientPerson(PNExplicit patName, CE gender, TSExplicit birthTime, PRPAMT201302UVOtherIDs otherIds) {
313 PRPAMT201302UVPerson person = new PRPAMT201302UVPerson();
314
315 // Set the Subject Name
316 if (patName != null) {
317 person.getName().add(patName);
318 }
319
320 // Set the Subject Gender
321 if (gender != null) {
322 person.setAdministrativeGenderCode(gender);
323 }
324
325 // Set the Birth Time
326 if (birthTime != null) {
327 person.setBirthTime(birthTime);
328 }
329
330 // Set the SSN
331 if (otherIds != null) {
332 person.getAsOtherIDs().add(otherIds);
333 }
334
335 javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
336 JAXBElement<PRPAMT201302UVPerson> result = new JAXBElement<PRPAMT201302UVPerson>(xmlqname, PRPAMT201302UVPerson.class, person);
337
338 return result;
339 }
340 public static PRPAMT201305UVPatient create201305Patient(JAXBElement<PRPAMT201305UVPerson> person, II id) {
341 PRPAMT201305UVPatient patient = new PRPAMT201305UVPatient();
342
343 patient.setClassCode("PAT");
344 patient.setStatusCode(HL7DataTransformHelper.CSFactory("active"));
345
346 patient.getId().add(id);
347
348 patient.setPatientPerson(person);
349
350 patient.setProviderOrganization(null);
351
352 return patient;
353 }
354
355 public static JAXBElement<PRPAMT201305UVPerson> create201305PatientPerson(String patFirstName, String patLastName, String gender, String birthTime, String ssn, II inputII) {
356 PNExplicit name = null;
357 if (NullChecker.isNotNullish(patFirstName) &&
358 NullChecker.isNotNullish(patLastName)) {
359 name = HL7DataTransformHelper.CreatePNExplicit(patFirstName, patLastName);
360 }
361
362 CE genderCode = null;
363 if (NullChecker.isNotNullish(gender)) {
364 genderCode = HL7DataTransformHelper.CEFactory(gender);
365 }
366
367 TSExplicit bday = null;
368 if (NullChecker.isNotNullish(birthTime)) {
369 bday = HL7DataTransformHelper.TSExplicitFactory(birthTime);
370 }
371log.debug("= = = = = = inputII : " + inputII.getRoot() + " " + inputII.getExtension());
372 return create201305PatientPerson(name, genderCode, bday, inputII);
373 }
374
375 public static JAXBElement<PRPAMT201305UVPerson> create201305PatientPerson(PNExplicit patName, CE gender, TSExplicit birthTime, II otherId) {
376 PRPAMT201305UVPerson person = new PRPAMT201305UVPerson();
377
378 // Set the Subject Name
379 if (patName != null) {
380 person.getName().add(patName);
381 }
382
383 // Set the Subject Gender
384 if (gender != null) {
385 person.setAdministrativeGenderCode(gender);
386 }
387
388 // Set the Birth Time
389 if (birthTime != null) {
390 person.setBirthTime(birthTime);
391 }
392
393 // Set the II
394 if (otherId != null) {
395 person.getId().add(otherId);
396 log.debug("= = = = = = = setting person.getId to " + otherId.getExtension() + " " + otherId.getRoot());
397 }
398
399 javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
400 JAXBElement<PRPAMT201305UVPerson> result = new JAXBElement<PRPAMT201305UVPerson>(xmlqname, PRPAMT201305UVPerson.class, person);
401
402 return result;
403 }
404
405 public static PRPAMT201301UVOtherIDs createPRPAMT201301UVOtherIDs(String ssn) {
406 PRPAMT201301UVOtherIDs otherIds = new PRPAMT201301UVOtherIDs();
407
408 otherIds.setClassCode("PAT");
409
410 // Set the SSN
411 if (NullChecker.isNotNullish(ssn)) {
412 log.info("Setting Patient SSN: " + ssn);
413 otherIds.getId().add(HL7DataTransformHelper.IIFactory(HL7Constants.SSN_ID_ROOT, ssn));
414 }
415
416 return otherIds;
417 }
418
419 public static PRPAMT201310UVOtherIDs createPRPAMT201310UVOtherIDs(String ssn) {
420 PRPAMT201310UVOtherIDs otherIds = new PRPAMT201310UVOtherIDs();
421
422 otherIds.setClassCode("PAT");
423
424 // Set the SSN
425 if (NullChecker.isNotNullish(ssn)) {
426 log.info("Setting Patient SSN: " + ssn);
427 otherIds.getId().add(HL7DataTransformHelper.IIFactory(HL7Constants.SSN_ID_ROOT, ssn));
428 }
429
430 return otherIds;
431 }
432
433 public static PRPAMT201302UVOtherIDs createPRPAMT201302UVOtherIDs(String ssn, II remotePatId) {
434 PRPAMT201302UVOtherIDs otherIds = new PRPAMT201302UVOtherIDs();
435
436 otherIds.setClassCode("PAT");
437
438 // Set the SSN
439 if (NullChecker.isNotNullish(ssn)) {
440 log.info("Setting Patient SSN: " + ssn);
441 otherIds.getId().add(HL7DataTransformHelper.IIFactory(HL7Constants.SSN_ID_ROOT, ssn));
442 }
443
444 if (remotePatId != null &&
445 NullChecker.isNotNullish(remotePatId.getRoot()) &&
446 NullChecker.isNotNullish(remotePatId.getExtension())) {
447 log.info("Setting Remote Patient Id: " + remotePatId.getExtension());
448 log.info("Setting Remote Assigning Authority: " + remotePatId.getRoot());
449 otherIds.getId().add(remotePatId);
450 }
451
452 return otherIds;
453 }
454}
Note: See TracBrowser for help on using the repository browser.