[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.adaptercomponentmpi.hl7parsers;
|
---|
| 6 |
|
---|
| 7 | import gov.hhs.fha.nhinc.mpilib.*;
|
---|
| 8 | import gov.hhs.fha.nhinc.properties.PropertyAccessor;
|
---|
| 9 | import java.math.BigInteger;
|
---|
| 10 | import java.util.List;
|
---|
| 11 | import java.util.TimeZone;
|
---|
| 12 | import java.util.GregorianCalendar;
|
---|
| 13 | //import javax.xml.datatype.XMLGregorianCalendar;
|
---|
| 14 | //import javax.xml.datatype.DatatypeFactory;
|
---|
| 15 | import javax.xml.bind.JAXBElement;
|
---|
| 16 | import org.apache.commons.logging.Log;
|
---|
| 17 | import org.apache.commons.logging.LogFactory;
|
---|
| 18 | import org.hl7.v3.*;
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | *
|
---|
| 23 | * @author Jon Hoppesch
|
---|
| 24 | */
|
---|
| 25 | public class HL7Parser201306 {
|
---|
| 26 |
|
---|
| 27 | private static Log log = LogFactory.getLog(HL7Parser201306.class);
|
---|
| 28 | private static final String PROPERTY_FILE = "adapter";
|
---|
| 29 | private static final String PROPERTY_NAME = "assigningAuthorityId";
|
---|
| 30 | private static final String DEFAULT_AA_OID = "1.1";
|
---|
| 31 |
|
---|
| 32 | public static PRPAIN201306UV BuildMessageFromMpiPatient(Patient patient, PRPAIN201305UV query) {
|
---|
| 33 | log.debug("Entering HL7Parser201306.BuildMessageFromMpiPatient method...");
|
---|
| 34 |
|
---|
| 35 | PRPAIN201306UV msg = new PRPAIN201306UV();
|
---|
| 36 |
|
---|
| 37 | // Set up message header fields
|
---|
| 38 | msg.setITSVersion("XML_1.0");
|
---|
| 39 |
|
---|
| 40 | II id = new II();
|
---|
| 41 | try {
|
---|
| 42 | id.setRoot(PropertyAccessor.getProperty(PROPERTY_FILE, PROPERTY_NAME));
|
---|
| 43 | }
|
---|
| 44 | catch (Exception e) {
|
---|
| 45 | id.setRoot(DEFAULT_AA_OID);
|
---|
| 46 | }
|
---|
| 47 | id.setExtension(MessageIdGenerator.GenerateMessageId());
|
---|
| 48 | msg.setId(id);
|
---|
| 49 |
|
---|
| 50 | // Set up the creation time string
|
---|
| 51 | String timestamp = "";
|
---|
| 52 | try {
|
---|
| 53 | GregorianCalendar today = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
---|
| 54 |
|
---|
| 55 | timestamp = String.valueOf(today.get(GregorianCalendar.YEAR)) +
|
---|
| 56 | String.valueOf(today.get(GregorianCalendar.MONTH)+1) +
|
---|
| 57 | String.valueOf(today.get(GregorianCalendar.DAY_OF_MONTH)) +
|
---|
| 58 | String.valueOf(today.get(GregorianCalendar.HOUR_OF_DAY)) +
|
---|
| 59 | String.valueOf(today.get(GregorianCalendar.MINUTE)) +
|
---|
| 60 | String.valueOf(today.get(GregorianCalendar.SECOND));
|
---|
| 61 | } catch (Exception e) {
|
---|
| 62 | log.error("Exception when creating XMLGregorian Date");
|
---|
| 63 | log.error(" message: " + e.getMessage());
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | TSExplicit creationTime = new TSExplicit();
|
---|
| 67 | creationTime.setValue(timestamp);
|
---|
| 68 | msg.setCreationTime(creationTime);
|
---|
| 69 |
|
---|
| 70 | II interactionId = new II();
|
---|
| 71 | interactionId.setRoot("2.16.840.1.113883.1.6");
|
---|
| 72 | interactionId.setExtension("PRPA_IN201306UV");
|
---|
| 73 | msg.setInteractionId(interactionId);
|
---|
| 74 |
|
---|
| 75 | CS processingCode = new CS();
|
---|
| 76 | processingCode.setCode("P");
|
---|
| 77 | msg.setProcessingCode(processingCode);
|
---|
| 78 |
|
---|
| 79 | CS processingModeCode = new CS();
|
---|
| 80 | processingModeCode.setCode("R");
|
---|
| 81 | msg.setProcessingModeCode(processingModeCode);
|
---|
| 82 |
|
---|
| 83 | CS ackCode = new CS();
|
---|
| 84 | ackCode.setCode("AL");
|
---|
| 85 | msg.setAcceptAckCode(ackCode);
|
---|
| 86 |
|
---|
| 87 | msg.getAcknowledgement().add(createAck(query));
|
---|
| 88 |
|
---|
| 89 | // Set the receiver and sender
|
---|
| 90 | msg.getReceiver().add(createReceiver(query.getSender()));
|
---|
| 91 | msg.setSender(createSender(query.getReceiver().get(0)));
|
---|
| 92 |
|
---|
| 93 | msg.setControlActProcess(createControlActProcess(patient, query));
|
---|
| 94 |
|
---|
| 95 | log.debug("Exiting HL7Parser201306.BuildMessageFromMpiPatient method...");
|
---|
| 96 | return msg;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | private static PRPAIN201306UVMFMIMT700711UV01ControlActProcess createControlActProcess(Patient patient, PRPAIN201305UV query) {
|
---|
| 100 | PRPAIN201306UVMFMIMT700711UV01ControlActProcess controlActProcess = new PRPAIN201306UVMFMIMT700711UV01ControlActProcess();
|
---|
| 101 |
|
---|
| 102 | controlActProcess.setMoodCode("EVN");
|
---|
| 103 |
|
---|
| 104 | CD code = new CD();
|
---|
| 105 | code.setCode("PRPA_TE201306UV");
|
---|
| 106 | code.setCodeSystem("2.16.840.1.113883.1.6");
|
---|
| 107 | controlActProcess.setCode(code);
|
---|
| 108 |
|
---|
| 109 | controlActProcess.getSubject().add(createSubject(patient, query));
|
---|
| 110 |
|
---|
| 111 | controlActProcess.setQueryAck(createQueryAck(query));
|
---|
| 112 |
|
---|
| 113 | return controlActProcess;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | private static MFMIMT700711UV01QueryAck createQueryAck(PRPAIN201305UV query) {
|
---|
| 117 | MFMIMT700711UV01QueryAck result = new MFMIMT700711UV01QueryAck();
|
---|
| 118 |
|
---|
| 119 | if (query.getControlActProcess() != null &&
|
---|
| 120 | query.getControlActProcess().getQueryByParameter() != null &&
|
---|
| 121 | query.getControlActProcess().getQueryByParameter().getValue() != null &&
|
---|
| 122 | query.getControlActProcess().getQueryByParameter().getValue().getQueryId() != null) {
|
---|
| 123 | result.setQueryId(query.getControlActProcess().getQueryByParameter().getValue().getQueryId());
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | CS respCode = new CS();
|
---|
| 127 | respCode.setCode("OK");
|
---|
| 128 | result.setQueryResponseCode(respCode);
|
---|
| 129 |
|
---|
| 130 | INT totalQuanity = new INT();
|
---|
| 131 | totalQuanity.setValue(BigInteger.valueOf(1));
|
---|
| 132 | result.setResultTotalQuantity(totalQuanity);
|
---|
| 133 |
|
---|
| 134 | INT currQuanity = new INT();
|
---|
| 135 | currQuanity.setValue(BigInteger.valueOf(1));
|
---|
| 136 | result.setResultCurrentQuantity(currQuanity);
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | INT remainQuanity = new INT();
|
---|
| 140 | remainQuanity.setValue(BigInteger.valueOf(0));
|
---|
| 141 | result.setResultRemainingQuantity(remainQuanity);
|
---|
| 142 |
|
---|
| 143 | return result;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | private static PRPAIN201306UVMFMIMT700711UV01Subject1 createSubject(Patient patient, PRPAIN201305UV query) {
|
---|
| 147 | PRPAIN201306UVMFMIMT700711UV01Subject1 subject = new PRPAIN201306UVMFMIMT700711UV01Subject1();
|
---|
| 148 |
|
---|
| 149 | subject.getTypeCode().add("SUBJ");
|
---|
| 150 |
|
---|
| 151 | subject.setRegistrationEvent(createRegEvent(patient, query));
|
---|
| 152 |
|
---|
| 153 | return subject;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | private static PRPAIN201306UVMFMIMT700711UV01RegistrationEvent createRegEvent(Patient patient, PRPAIN201305UV query) {
|
---|
| 157 | PRPAIN201306UVMFMIMT700711UV01RegistrationEvent regEvent = new PRPAIN201306UVMFMIMT700711UV01RegistrationEvent();
|
---|
| 158 |
|
---|
| 159 | regEvent.getNullFlavor().add("NA");
|
---|
| 160 |
|
---|
| 161 | CS statusCode = new CS();
|
---|
| 162 | statusCode.setCode("active");
|
---|
| 163 |
|
---|
| 164 | regEvent.setStatusCode(statusCode);
|
---|
| 165 |
|
---|
| 166 | regEvent.setSubject1(createSubject1(patient, query));
|
---|
| 167 |
|
---|
| 168 | regEvent.setCustodian(createCustodian(patient));
|
---|
| 169 |
|
---|
| 170 | return regEvent;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | private static MFMIMT700711UV01Custodian createCustodian (Patient patient) {
|
---|
| 174 | MFMIMT700711UV01Custodian result = new MFMIMT700711UV01Custodian();
|
---|
| 175 |
|
---|
| 176 | result.setAssignedEntity(createAssignEntity(patient));
|
---|
| 177 |
|
---|
| 178 | return result;
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | private static COCTMT090003UVAssignedEntity createAssignEntity (Patient patient) {
|
---|
| 182 | COCTMT090003UVAssignedEntity assignedEntity = new COCTMT090003UVAssignedEntity();
|
---|
| 183 |
|
---|
| 184 | II id = new II();
|
---|
| 185 | id.setRoot(patient.getIdentifiers().get(0).getOrganizationId());
|
---|
| 186 | assignedEntity.getId().add(id);
|
---|
| 187 |
|
---|
| 188 | return assignedEntity;
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | private static PRPAIN201306UVMFMIMT700711UV01Subject2 createSubject1(Patient patient, PRPAIN201305UV query) {
|
---|
| 192 | PRPAIN201306UVMFMIMT700711UV01Subject2 subject = new PRPAIN201306UVMFMIMT700711UV01Subject2();
|
---|
| 193 |
|
---|
| 194 | // Add in patient
|
---|
| 195 | subject.setPatient(createPatient(patient, query));
|
---|
| 196 |
|
---|
| 197 | // Add in query parameters
|
---|
| 198 | if (query.getControlActProcess() != null &&
|
---|
| 199 | query.getControlActProcess().getQueryByParameter() != null &&
|
---|
| 200 | query.getControlActProcess().getQueryByParameter().getValue() != null) {
|
---|
| 201 | subject.setQueryByParameter(query.getControlActProcess().getQueryByParameter().getValue());
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | return subject;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | private static PRPAMT201310UVPatient createPatient(Patient patient, PRPAIN201305UV query) {
|
---|
| 208 | PRPAMT201310UVPatient subjectPatient = new PRPAMT201310UVPatient();
|
---|
| 209 |
|
---|
| 210 | subjectPatient.setClassCode("PAT");
|
---|
| 211 |
|
---|
| 212 | // TODO: Temporary value until confirmation can be made on the actual value
|
---|
| 213 | CS statusCode = new CS();
|
---|
| 214 | statusCode.setCode("SD");
|
---|
| 215 | subjectPatient.setStatusCode(statusCode);
|
---|
| 216 |
|
---|
| 217 | // Add in patient id
|
---|
| 218 | subjectPatient.getId().add(createSubjectId(patient));
|
---|
| 219 |
|
---|
| 220 | // Add in patient person
|
---|
| 221 | subjectPatient.setPatientPerson(createPatientPerson(patient, query));
|
---|
| 222 |
|
---|
| 223 | // Add in provider organization
|
---|
| 224 | subjectPatient.setProviderOrganization(createProviderOrg(patient));
|
---|
| 225 |
|
---|
| 226 | // Add in query match observation
|
---|
| 227 | subjectPatient.getSubjectOf1().add(createSubjectOf1());
|
---|
| 228 |
|
---|
| 229 | return subjectPatient;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | private static PRPAMT201310UVSubject createSubjectOf1 () {
|
---|
| 233 | PRPAMT201310UVSubject result = new PRPAMT201310UVSubject();
|
---|
| 234 |
|
---|
| 235 | result.setQueryMatchObservation(createQueryMatch());
|
---|
| 236 | return result;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | private static PRPAMT201310UVQueryMatchObservation createQueryMatch () {
|
---|
| 240 | PRPAMT201310UVQueryMatchObservation queryMatch = new PRPAMT201310UVQueryMatchObservation();
|
---|
| 241 |
|
---|
| 242 | CD code = new CD();
|
---|
| 243 | code.setCode("IHE_PDQ");
|
---|
| 244 | queryMatch.setCode(code);
|
---|
| 245 |
|
---|
| 246 | INT intValue = new INT();
|
---|
| 247 | intValue.setValue(BigInteger.valueOf(100));
|
---|
| 248 | queryMatch.setValue(intValue);
|
---|
| 249 |
|
---|
| 250 | return queryMatch;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | private static JAXBElement<COCTMT150003UV03Organization> createProviderOrg (Patient patient) {
|
---|
| 254 | COCTMT150003UV03Organization org = new COCTMT150003UV03Organization();
|
---|
| 255 |
|
---|
| 256 | II id = new II();
|
---|
| 257 |
|
---|
| 258 | if (patient.getIdentifiers() != null &&
|
---|
| 259 | patient.getIdentifiers().size() > 0 &&
|
---|
| 260 | patient.getIdentifiers().get(0).getOrganizationId() != null &&
|
---|
| 261 | patient.getIdentifiers().get(0).getOrganizationId().length() > 0) {
|
---|
| 262 | id.setRoot(patient.getIdentifiers().get(0).getOrganizationId());
|
---|
| 263 | }
|
---|
| 264 | org.getId().add(id);
|
---|
| 265 |
|
---|
| 266 | org.getContactParty().add(null);
|
---|
| 267 |
|
---|
| 268 | javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "providerOrganization");
|
---|
| 269 | JAXBElement<COCTMT150003UV03Organization> result = new JAXBElement<COCTMT150003UV03Organization>(xmlqname, COCTMT150003UV03Organization.class, org);
|
---|
| 270 |
|
---|
| 271 | return result;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | private static II createSubjectId (Patient patient) {
|
---|
| 275 | II id = new II();
|
---|
| 276 |
|
---|
| 277 | if (patient.getIdentifiers() != null &&
|
---|
| 278 | patient.getIdentifiers().size() > 0 &&
|
---|
| 279 | patient.getIdentifiers().get(0) != null) {
|
---|
| 280 |
|
---|
| 281 | if (patient.getIdentifiers().get(0).getOrganizationId() != null &&
|
---|
| 282 | patient.getIdentifiers().get(0).getOrganizationId().length() > 0) {
|
---|
| 283 | log.info("Setting Patient Id root in 201306: " + patient.getIdentifiers().get(0).getOrganizationId());
|
---|
| 284 | id.setRoot(patient.getIdentifiers().get(0).getOrganizationId());
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | if (patient.getIdentifiers().get(0).getId() != null &&
|
---|
| 288 | patient.getIdentifiers().get(0).getId().length() > 0) {
|
---|
| 289 | log.info("Setting Patient Id extension in 201306: " + patient.getIdentifiers().get(0).getId());
|
---|
| 290 | id.setExtension(patient.getIdentifiers().get(0).getId());
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | return id;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | private static JAXBElement<PRPAMT201310UVPerson> createPatientPerson (Patient patient, PRPAIN201305UV query) {
|
---|
| 298 | PRPAMT201310UVPerson person = new PRPAMT201310UVPerson();
|
---|
| 299 |
|
---|
| 300 | // Set the Subject Gender
|
---|
| 301 | if (patient.getGender() != null &&
|
---|
| 302 | patient.getGender().length() > 0) {
|
---|
| 303 | person.setAdministrativeGenderCode(createGender(patient));
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 | // Set the Subject Name
|
---|
| 307 | person.getName().add(createSubjectName(patient));
|
---|
| 308 |
|
---|
| 309 | // Set the Birth Time
|
---|
| 310 | if (patient.getDateOfBirth() != null &&
|
---|
| 311 | patient.getDateOfBirth().length() > 0) {
|
---|
| 312 | person.setBirthTime(createBirthTime(patient));
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | // Set the Address
|
---|
| 316 | if (patient.getAddress() != null) {
|
---|
| 317 | person.getAddr().add(createAddress(patient));
|
---|
| 318 | }
|
---|
| 319 |
|
---|
| 320 | // Set the SSN
|
---|
| 321 | if (patient.getSSN() != null &&
|
---|
| 322 | patient.getSSN().length() > 0) {
|
---|
| 323 | person.getAsOtherIDs().add(createOtherIds(patient));
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
|
---|
| 327 | JAXBElement<PRPAMT201310UVPerson> result = new JAXBElement<PRPAMT201310UVPerson>(xmlqname, PRPAMT201310UVPerson.class, person);
|
---|
| 328 |
|
---|
| 329 | return result;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | private static ADExplicit createAddress (Patient patient) {
|
---|
| 333 | org.hl7.v3.ObjectFactory factory = new org.hl7.v3.ObjectFactory();
|
---|
| 334 | ADExplicit address = (ADExplicit) (factory.createADExplicit());
|
---|
| 335 | List addrlist = address.getContent();
|
---|
| 336 |
|
---|
| 337 | if (patient.getAddress() != null) {
|
---|
| 338 | if (patient.getAddress().getCity() != null &&
|
---|
| 339 | patient.getAddress().getCity().length() > 0) {
|
---|
| 340 | AdxpExplicitCity city = new AdxpExplicitCity();
|
---|
| 341 | city.setContent(patient.getAddress().getCity());
|
---|
| 342 |
|
---|
| 343 | addrlist.add(factory.createADExplicitCity(city));
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | if (patient.getAddress().getState() != null &&
|
---|
| 347 | patient.getAddress().getState().length() > 0) {
|
---|
| 348 | AdxpExplicitState state = new AdxpExplicitState();
|
---|
| 349 | state.setContent(patient.getAddress().getState());
|
---|
| 350 |
|
---|
| 351 | addrlist.add(factory.createADExplicitState(state));
|
---|
| 352 | }
|
---|
| 353 |
|
---|
| 354 | if (patient.getAddress().getStreet1() != null &&
|
---|
| 355 | patient.getAddress().getStreet1().length() > 0) {
|
---|
| 356 | AdxpExplicitStreetAddressLine street = new AdxpExplicitStreetAddressLine();
|
---|
| 357 | street.setContent(patient.getAddress().getStreet1());
|
---|
| 358 |
|
---|
| 359 | addrlist.add(factory.createADExplicitStreetAddressLine(street));
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | if (patient.getAddress().getZip() != null &&
|
---|
| 363 | patient.getAddress().getZip().length() > 0) {
|
---|
| 364 | AdxpExplicitPostalCode zip = new AdxpExplicitPostalCode();
|
---|
| 365 | zip.setContent(patient.getAddress().getZip());
|
---|
| 366 |
|
---|
| 367 | addrlist.add(factory.createADExplicitPostalCode(zip));
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | return address;
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | private static PRPAMT201310UVOtherIDs createOtherIds (Patient patient) {
|
---|
| 375 | PRPAMT201310UVOtherIDs otherIds = new PRPAMT201310UVOtherIDs();
|
---|
| 376 |
|
---|
| 377 | // TODO: Temporary assignment until actual value can be determined
|
---|
| 378 | otherIds.setClassCode("SD");
|
---|
| 379 |
|
---|
| 380 | // Set the SSN
|
---|
| 381 | if (patient.getSSN() != null &&
|
---|
| 382 | patient.getSSN().length() > 0) {
|
---|
| 383 | II ssn = new II();
|
---|
| 384 | ssn.setExtension(patient.getSSN());
|
---|
| 385 | ssn.setRoot("2.16.840.1.113883.4.1");
|
---|
| 386 | log.info("Setting Patient SSN in 201306: " + patient.getSSN());
|
---|
| 387 | otherIds.getId().add(ssn);
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | return otherIds;
|
---|
| 391 | }
|
---|
| 392 |
|
---|
| 393 |
|
---|
| 394 | private static TSExplicit createBirthTime (Patient patient) {
|
---|
| 395 | TSExplicit birthTime = new TSExplicit();
|
---|
| 396 |
|
---|
| 397 | if (patient.getDateOfBirth() != null &&
|
---|
| 398 | patient.getDateOfBirth().length() > 0) {
|
---|
| 399 | log.info("Setting Patient Birthday in 201306: " + patient.getDateOfBirth());
|
---|
| 400 | birthTime.setValue(patient.getDateOfBirth());
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | return birthTime;
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | private static PNExplicit createSubjectName (Patient patient) {
|
---|
| 407 | org.hl7.v3.ObjectFactory factory = new org.hl7.v3.ObjectFactory();
|
---|
| 408 | PNExplicit name = (PNExplicit) (factory.createPNExplicit());
|
---|
| 409 | List namelist = name.getContent();
|
---|
| 410 |
|
---|
| 411 | if (patient.getName().getLastName() != null &&
|
---|
| 412 | patient.getName().getLastName().length() > 0) {
|
---|
| 413 | EnExplicitFamily familyName = new EnExplicitFamily();
|
---|
| 414 | familyName.setPartType("FAM");
|
---|
| 415 | familyName.setContent(patient.getName().getLastName());
|
---|
| 416 | log.info("Setting Patient Lastname in 201306: " + patient.getName().getLastName());
|
---|
| 417 | namelist.add(factory.createPNExplicitFamily(familyName));
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | if (patient.getName().getFirstName() != null &&
|
---|
| 421 | patient.getName().getFirstName().length() > 0) {
|
---|
| 422 | EnExplicitGiven givenName = new EnExplicitGiven();
|
---|
| 423 | givenName.setPartType("GIV");
|
---|
| 424 | givenName.setContent(patient.getName().getFirstName());
|
---|
| 425 | log.info("Setting Patient Firstname in 201306: " + patient.getName().getFirstName());
|
---|
| 426 | namelist.add(factory.createPNExplicitGiven(givenName));
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | return name;
|
---|
| 430 | }
|
---|
| 431 | private static CE createGender (Patient patient) {
|
---|
| 432 | CE gender = new CE();
|
---|
| 433 |
|
---|
| 434 | if (patient.getGender() != null &&
|
---|
| 435 | patient.getGender().length() > 0) {
|
---|
| 436 | log.info("Setting Patient Gender in 201306: " + patient.getGender());
|
---|
| 437 | gender.setCode(patient.getGender());
|
---|
| 438 | }
|
---|
| 439 | return gender;
|
---|
| 440 | }
|
---|
| 441 | private static MCCIMT000300UV01Acknowledgement createAck(PRPAIN201305UV query) {
|
---|
| 442 | MCCIMT000300UV01Acknowledgement ack = new MCCIMT000300UV01Acknowledgement();
|
---|
| 443 | ack.setTypeId(query.getInteractionId());
|
---|
| 444 |
|
---|
| 445 | CS typeCode = new CS();
|
---|
| 446 | typeCode.setCode("AA");
|
---|
| 447 |
|
---|
| 448 | ack.setTypeCode(typeCode);
|
---|
| 449 |
|
---|
| 450 | return ack;
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 | private static MCCIMT000300UV01Receiver createReceiver(MCCIMT000100UV01Sender querySender) {
|
---|
| 454 | MCCIMT000300UV01Receiver receiver = new MCCIMT000300UV01Receiver();
|
---|
| 455 |
|
---|
| 456 | receiver.setTypeCode(CommunicationFunctionType.RCV);
|
---|
| 457 |
|
---|
| 458 | MCCIMT000300UV01Device device = new MCCIMT000300UV01Device();
|
---|
| 459 | device.setDeterminerCode("INSTANCE");
|
---|
| 460 |
|
---|
| 461 | if (querySender.getDevice() != null &&
|
---|
| 462 | querySender.getDevice().getId() != null &&
|
---|
| 463 | querySender.getDevice().getId().size() > 0 &&
|
---|
| 464 | querySender.getDevice().getId().get(0) != null) {
|
---|
| 465 | device.getId().add(querySender.getDevice().getId().get(0));
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | receiver.setDevice(device);
|
---|
| 469 |
|
---|
| 470 | return receiver;
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | private static MCCIMT000300UV01Sender createSender(MCCIMT000100UV01Receiver queryReceiver) {
|
---|
| 474 | MCCIMT000300UV01Sender sender = new MCCIMT000300UV01Sender();
|
---|
| 475 |
|
---|
| 476 | sender.setTypeCode(CommunicationFunctionType.SND);
|
---|
| 477 |
|
---|
| 478 | MCCIMT000300UV01Device device = new MCCIMT000300UV01Device();
|
---|
| 479 | device.setDeterminerCode("INSTANCE");
|
---|
| 480 |
|
---|
| 481 | if (queryReceiver.getDevice() != null &&
|
---|
| 482 | queryReceiver.getDevice().getId() != null &&
|
---|
| 483 | queryReceiver.getDevice().getId().size() > 0 &&
|
---|
| 484 | queryReceiver.getDevice().getId().get(0) != null) {
|
---|
| 485 | device.getId().add(queryReceiver.getDevice().getId().get(0));
|
---|
| 486 | }
|
---|
| 487 |
|
---|
| 488 | sender.setDevice(device);
|
---|
| 489 |
|
---|
| 490 | return sender;
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | }
|
---|