use of org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent in project MobileAccessGateway by i4mi.
the class Iti93AddRequestConverter method doCreate.
/**
* add a new patient
* @param header
* @param entriesByReference
* @return
* @throws JAXBException
*/
public String doCreate(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
PRPAIN201301UV02Type resultMsg = new PRPAIN201301UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201301UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201301UV02", null, "2.16.840.1.113883.1.18"));
for (BundleEntryComponent entry : entriesByReference.values()) {
if (entry.getResource() instanceof Patient) {
HTTPVerb method = entry.getRequest().getMethod();
if (method == null)
throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
Patient in = (Patient) entry.getResource();
PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient();
subject1.setPatient(patient);
patient.setClassCode("PAT");
// ???
patient.setStatusCode(new CS("active", null, null));
PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person();
patient.setPatientPerson(patientPerson);
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
patient.addId(patientIdentifier(id));
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
List<II> orgIds = new ArrayList<II>();
Organization managingOrg = getManagingOrganization(in);
// NULL POINTER CHECK
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201301UV02LanguageCommunication languageCommunication = new PRPAMT201301UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
// NULL POINTER EXCEPTION
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress())
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
assignedOrganization.setName(Collections.singletonList(name));
}
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201301UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
use of org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent in project MobileAccessGateway by i4mi.
the class Iti104AddRequestConverter method doCreate.
/**
* add a new patient
* @param header
* @param entriesByReference
* @return
* @throws JAXBException
*/
public String doCreate(Patient in, Identifier identifier) throws JAXBException {
PRPAIN201301UV02Type resultMsg = new PRPAIN201301UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201301UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201301UV02", null, "2.16.840.1.113883.1.18"));
PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient();
subject1.setPatient(patient);
patient.setClassCode("PAT");
// ???
patient.setStatusCode(new CS("active", null, null));
PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person();
patient.setPatientPerson(patientPerson);
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
patient.addId(patientIdentifier(identifier));
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
patient.addId(patientIdentifier(id));
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
List<II> orgIds = new ArrayList<II>();
Organization managingOrg = getManagingOrganization(in);
// NULL POINTER CHECK
if (managingOrg != null) {
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
}
} else {
Reference org = in.getManagingOrganization();
if (org != null && org.getIdentifier() != null) {
orgIds.add(new II(getScheme(org.getIdentifier().getSystem()), null));
}
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201301UV02LanguageCommunication languageCommunication = new PRPAMT201301UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
// NULL POINTER EXCEPTION
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg != null && managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
if (managingOrg != null) {
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress()) {
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
}
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
assignedOrganization.setName(Collections.singletonList(name));
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201301UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
use of org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent in project synthea by synthetichealth.
the class FhirR4 method basicInfo.
/**
* Map the given Person to a FHIR Patient resource, and add it to the given Bundle.
*
* @param person The Person
* @param bundle The Bundle to add to
* @param stopTime Time the simulation ended
* @return The created Entry
*/
@SuppressWarnings("rawtypes")
private static BundleEntryComponent basicInfo(Person person, Bundle bundle, long stopTime) {
Patient patientResource = new Patient();
patientResource.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue((String) person.attributes.get(Person.ID));
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
patientResource.setMeta(meta);
}
Code mrnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "MR", "Medical Record Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(mrnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hospital.smarthealthit.org").setValue((String) person.attributes.get(Person.ID));
Code ssnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "SS", "Social Security Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(ssnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hl7.org/fhir/sid/us-ssn").setValue((String) person.attributes.get(Person.IDENTIFIER_SSN));
if (person.attributes.get(Person.IDENTIFIER_DRIVERS) != null) {
Code driversCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "DL", "Driver's License");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(driversCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("urn:oid:2.16.840.1.113883.4.3.25").setValue((String) person.attributes.get(Person.IDENTIFIER_DRIVERS));
}
if (person.attributes.get(Person.IDENTIFIER_PASSPORT) != null) {
Code passportCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "PPN", "Passport Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(passportCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem(SHR_EXT + "passportNumber").setValue((String) person.attributes.get(Person.IDENTIFIER_PASSPORT));
}
if (person.attributes.get(Person.CONTACT_EMAIL) != null) {
ContactComponent contact = new ContactComponent();
HumanName contactName = new HumanName();
contactName.setUse(HumanName.NameUse.OFFICIAL);
contactName.addGiven((String) person.attributes.get(Person.CONTACT_GIVEN_NAME));
contactName.setFamily((String) person.attributes.get(Person.CONTACT_FAMILY_NAME));
contact.setName(contactName);
contact.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.CONTACT_EMAIL));
patientResource.addContact(contact);
}
if (USE_US_CORE_IG) {
// We do not yet account for mixed race
Extension raceExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race");
String race = (String) person.attributes.get(Person.RACE);
String raceDisplay;
switch(race) {
case "white":
raceDisplay = "White";
break;
case "black":
raceDisplay = "Black or African American";
break;
case "asian":
raceDisplay = "Asian";
break;
case "native":
raceDisplay = "American Indian or Alaska Native";
break;
case "hawaiian":
raceDisplay = "Native Hawaiian or Other Pacific Islander";
break;
default:
raceDisplay = "Other";
break;
}
String raceNum = (String) raceEthnicityCodes.get(race);
Extension raceCodingExtension = new Extension("ombCategory");
Coding raceCoding = new Coding();
if (raceDisplay.equals("Other")) {
raceCoding.setSystem("http://terminology.hl7.org/CodeSystem/v3-NullFlavor");
raceCoding.setCode("UNK");
raceCoding.setDisplay("Unknown");
} else {
raceCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
raceCoding.setCode(raceNum);
raceCoding.setDisplay(raceDisplay);
}
raceCodingExtension.setValue(raceCoding);
raceExtension.addExtension(raceCodingExtension);
Extension raceTextExtension = new Extension("text");
raceTextExtension.setValue(new StringType(raceDisplay));
raceExtension.addExtension(raceTextExtension);
patientResource.addExtension(raceExtension);
// We do not yet account for mixed ethnicity
Extension ethnicityExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity");
String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
String ethnicityDisplay;
if (ethnicity.equals("hispanic")) {
ethnicity = "hispanic";
ethnicityDisplay = "Hispanic or Latino";
} else {
ethnicity = "nonhispanic";
ethnicityDisplay = "Not Hispanic or Latino";
}
String ethnicityNum = (String) raceEthnicityCodes.get(ethnicity);
Extension ethnicityCodingExtension = new Extension("ombCategory");
Coding ethnicityCoding = new Coding();
ethnicityCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
ethnicityCoding.setCode(ethnicityNum);
ethnicityCoding.setDisplay(ethnicityDisplay);
ethnicityCodingExtension.setValue(ethnicityCoding);
ethnicityExtension.addExtension(ethnicityCodingExtension);
Extension ethnicityTextExtension = new Extension("text");
ethnicityTextExtension.setValue(new StringType(ethnicityDisplay));
ethnicityExtension.addExtension(ethnicityTextExtension);
patientResource.addExtension(ethnicityExtension);
}
String firstLanguage = (String) person.attributes.get(Person.FIRST_LANGUAGE);
Map languageMap = (Map) languageLookup.get(firstLanguage);
Code languageCode = new Code((String) languageMap.get("system"), (String) languageMap.get("code"), (String) languageMap.get("display"));
List<PatientCommunicationComponent> communication = new ArrayList<PatientCommunicationComponent>();
communication.add(new PatientCommunicationComponent(mapCodeToCodeableConcept(languageCode, (String) languageMap.get("system"))));
patientResource.setCommunication(communication);
HumanName name = patientResource.addName();
name.setUse(HumanName.NameUse.OFFICIAL);
name.addGiven((String) person.attributes.get(Person.FIRST_NAME));
name.setFamily((String) person.attributes.get(Person.LAST_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
name.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
name.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
if (person.attributes.get(Person.MAIDEN_NAME) != null) {
HumanName maidenName = patientResource.addName();
maidenName.setUse(HumanName.NameUse.MAIDEN);
maidenName.addGiven((String) person.attributes.get(Person.FIRST_NAME));
maidenName.setFamily((String) person.attributes.get(Person.MAIDEN_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
maidenName.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
maidenName.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
}
Extension mothersMaidenNameExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
String mothersMaidenName = (String) person.attributes.get(Person.NAME_MOTHER);
mothersMaidenNameExtension.setValue(new StringType(mothersMaidenName));
patientResource.addExtension(mothersMaidenNameExtension);
long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
patientResource.setBirthDate(new Date(birthdate));
Extension birthSexExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
if (person.attributes.get(Person.GENDER).equals("M")) {
patientResource.setGender(AdministrativeGender.MALE);
birthSexExtension.setValue(new CodeType("M"));
} else if (person.attributes.get(Person.GENDER).equals("F")) {
patientResource.setGender(AdministrativeGender.FEMALE);
birthSexExtension.setValue(new CodeType("F"));
} else if (person.attributes.get(Person.GENDER).equals("UNK")) {
patientResource.setGender(AdministrativeGender.UNKNOWN);
}
if (USE_US_CORE_IG) {
patientResource.addExtension(birthSexExtension);
}
String state = (String) person.attributes.get(Person.STATE);
if (USE_US_CORE_IG) {
state = Location.getAbbreviation(state);
}
Address addrResource = patientResource.addAddress();
addrResource.addLine((String) person.attributes.get(Person.ADDRESS)).setCity((String) person.attributes.get(Person.CITY)).setPostalCode((String) person.attributes.get(Person.ZIP)).setState(state);
if (COUNTRY_CODE != null) {
addrResource.setCountry(COUNTRY_CODE);
}
Address birthplace = new Address();
birthplace.setCity((String) person.attributes.get(Person.BIRTH_CITY)).setState((String) person.attributes.get(Person.BIRTH_STATE)).setCountry((String) person.attributes.get(Person.BIRTH_COUNTRY));
Extension birthplaceExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthPlace");
birthplaceExtension.setValue(birthplace);
patientResource.addExtension(birthplaceExtension);
if (person.attributes.get(Person.MULTIPLE_BIRTH_STATUS) != null) {
patientResource.setMultipleBirth(new IntegerType((int) person.attributes.get(Person.MULTIPLE_BIRTH_STATUS)));
} else {
patientResource.setMultipleBirth(new BooleanType(false));
}
patientResource.addTelecom().setSystem(ContactPointSystem.PHONE).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.TELECOM));
String maritalStatus = ((String) person.attributes.get(Person.MARITAL_STATUS));
if (maritalStatus != null) {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", maritalStatus, maritalStatus);
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
} else {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", "S", "Never Married");
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
}
Point2D.Double coord = person.getLonLat();
if (coord != null) {
Extension geolocation = addrResource.addExtension();
geolocation.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
geolocation.addExtension("latitude", new DecimalType(coord.getY()));
geolocation.addExtension("longitude", new DecimalType(coord.getX()));
}
if (!person.alive(stopTime)) {
patientResource.setDeceased(convertFhirDateTime((Long) person.attributes.get(Person.DEATHDATE), true));
}
String generatedBySynthea = "Generated by <a href=\"https://github.com/synthetichealth/synthea\">Synthea</a>." + "Version identifier: " + Utilities.SYNTHEA_VERSION + " . " + " Person seed: " + person.getSeed() + " Population seed: " + person.populationSeed;
patientResource.setText(new Narrative().setStatus(NarrativeStatus.GENERATED).setDiv(new XhtmlNode(NodeType.Element).setValue(generatedBySynthea)));
if (USE_SHR_EXTENSIONS) {
patientResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Patient"));
// Patient profile requires race, ethnicity, birthsex,
// MothersMaidenName, FathersName, Person-extension
patientResource.addExtension().setUrl(SHR_EXT + "shr-actor-FictionalPerson-extension").setValue(new BooleanType(true));
String fathersName = (String) person.attributes.get(Person.NAME_FATHER);
Extension fathersNameExtension = new Extension(SHR_EXT + "shr-entity-FathersName-extension", new HumanName().setText(fathersName));
patientResource.addExtension(fathersNameExtension);
String ssn = (String) person.attributes.get(Person.IDENTIFIER_SSN);
Extension ssnExtension = new Extension(SHR_EXT + "shr-demographics-SocialSecurityNumber-extension", new StringType(ssn));
patientResource.addExtension(ssnExtension);
}
// DALY and QALY values
// we only write the last(current) one to the patient record
Double dalyValue = (Double) person.attributes.get("most-recent-daly");
Double qalyValue = (Double) person.attributes.get("most-recent-qaly");
if (dalyValue != null) {
Extension dalyExtension = new Extension(SYNTHEA_EXT + "disability-adjusted-life-years");
DecimalType daly = new DecimalType(dalyValue);
dalyExtension.setValue(daly);
patientResource.addExtension(dalyExtension);
Extension qalyExtension = new Extension(SYNTHEA_EXT + "quality-adjusted-life-years");
DecimalType qaly = new DecimalType(qalyValue);
qalyExtension.setValue(qaly);
patientResource.addExtension(qalyExtension);
}
return newEntry(bundle, patientResource, (String) person.attributes.get(Person.ID));
}
use of org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent in project synthea by synthetichealth.
the class FhirStu3 method basicInfo.
/**
* Map the given Person to a FHIR Patient resource, and add it to the given Bundle.
*
* @param person The Person
* @param bundle The Bundle to add to
* @param stopTime Time the simulation ended
* @return The created Entry
*/
@SuppressWarnings("rawtypes")
private static BundleEntryComponent basicInfo(Person person, Bundle bundle, long stopTime) {
Patient patientResource = new Patient();
patientResource.addIdentifier().setSystem("https://github.com/synthetichealth/synthea").setValue((String) person.attributes.get(Person.ID));
Code mrnCode = new Code("http://hl7.org/fhir/v2/0203", "MR", "Medical Record Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(mrnCode, "http://hl7.org/fhir/v2/0203")).setSystem("http://hospital.smarthealthit.org").setValue((String) person.attributes.get(Person.ID));
Code ssnCode = new Code("http://hl7.org/fhir/identifier-type", "SB", "Social Security Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(ssnCode, "http://hl7.org/fhir/identifier-type")).setSystem("http://hl7.org/fhir/sid/us-ssn").setValue((String) person.attributes.get(Person.IDENTIFIER_SSN));
if (person.attributes.get(Person.IDENTIFIER_DRIVERS) != null) {
Code driversCode = new Code("http://hl7.org/fhir/v2/0203", "DL", "Driver's License");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(driversCode, "http://hl7.org/fhir/v2/0203")).setSystem("urn:oid:2.16.840.1.113883.4.3.25").setValue((String) person.attributes.get(Person.IDENTIFIER_DRIVERS));
}
if (person.attributes.get(Person.IDENTIFIER_PASSPORT) != null) {
Code passportCode = new Code("http://hl7.org/fhir/v2/0203", "PPN", "Passport Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(passportCode, "http://hl7.org/fhir/v2/0203")).setSystem(SHR_EXT + "passportNumber").setValue((String) person.attributes.get(Person.IDENTIFIER_PASSPORT));
}
if (person.attributes.get(Person.CONTACT_EMAIL) != null) {
ContactComponent contact = new ContactComponent();
HumanName contactName = new HumanName();
contactName.setUse(HumanName.NameUse.OFFICIAL);
contactName.addGiven((String) person.attributes.get(Person.CONTACT_GIVEN_NAME));
contactName.setFamily((String) person.attributes.get(Person.CONTACT_FAMILY_NAME));
contact.setName(contactName);
contact.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.CONTACT_EMAIL));
patientResource.addContact(contact);
}
// We do not yet account for mixed race
Extension raceExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race");
String race = (String) person.attributes.get(Person.RACE);
String raceDisplay;
switch(race) {
case "white":
raceDisplay = "White";
break;
case "black":
raceDisplay = "Black or African American";
break;
case "asian":
raceDisplay = "Asian";
break;
case "native":
raceDisplay = "American Indian or Alaska Native";
break;
case "hawaiian":
raceDisplay = "Native Hawaiian or Other Pacific Islander";
break;
default:
raceDisplay = "Other";
break;
}
String raceNum = (String) raceEthnicityCodes.get(race);
Extension raceCodingExtension = new Extension("ombCategory");
Coding raceCoding = new Coding();
if (raceDisplay.equals("Other")) {
raceCoding.setSystem("http://hl7.org/fhir/v3/NullFlavor");
raceCoding.setCode("UNK");
raceCoding.setDisplay("Unknown");
} else {
raceCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
raceCoding.setCode(raceNum);
raceCoding.setDisplay(raceDisplay);
}
raceCodingExtension.setValue(raceCoding);
raceExtension.addExtension(raceCodingExtension);
Extension raceTextExtension = new Extension("text");
raceTextExtension.setValue(new StringType(raceDisplay));
raceExtension.addExtension(raceTextExtension);
patientResource.addExtension(raceExtension);
// We do not yet account for mixed ethnicity
Extension ethnicityExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity");
String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
String ethnicityDisplay;
if (ethnicity.equals("hispanic")) {
ethnicity = "hispanic";
ethnicityDisplay = "Hispanic or Latino";
} else {
ethnicity = "nonhispanic";
ethnicityDisplay = "Not Hispanic or Latino";
}
String ethnicityNum = (String) raceEthnicityCodes.get(ethnicity);
Extension ethnicityCodingExtension = new Extension("ombCategory");
Coding ethnicityCoding = new Coding();
ethnicityCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
ethnicityCoding.setCode(ethnicityNum);
ethnicityCoding.setDisplay(ethnicityDisplay);
ethnicityCodingExtension.setValue(ethnicityCoding);
ethnicityExtension.addExtension(ethnicityCodingExtension);
Extension ethnicityTextExtension = new Extension("text");
ethnicityTextExtension.setValue(new StringType(ethnicityDisplay));
ethnicityExtension.addExtension(ethnicityTextExtension);
patientResource.addExtension(ethnicityExtension);
String firstLanguage = (String) person.attributes.get(Person.FIRST_LANGUAGE);
Map languageMap = (Map) languageLookup.get(firstLanguage);
Code languageCode = new Code((String) languageMap.get("system"), (String) languageMap.get("code"), (String) languageMap.get("display"));
List<PatientCommunicationComponent> communication = new ArrayList<PatientCommunicationComponent>();
communication.add(new PatientCommunicationComponent(mapCodeToCodeableConcept(languageCode, (String) languageMap.get("system"))));
patientResource.setCommunication(communication);
HumanName name = patientResource.addName();
name.setUse(HumanName.NameUse.OFFICIAL);
name.addGiven((String) person.attributes.get(Person.FIRST_NAME));
name.setFamily((String) person.attributes.get(Person.LAST_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
name.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
name.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
if (person.attributes.get(Person.MAIDEN_NAME) != null) {
HumanName maidenName = patientResource.addName();
maidenName.setUse(HumanName.NameUse.MAIDEN);
maidenName.addGiven((String) person.attributes.get(Person.FIRST_NAME));
maidenName.setFamily((String) person.attributes.get(Person.MAIDEN_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
maidenName.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
maidenName.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
}
Extension mothersMaidenNameExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
String mothersMaidenName = (String) person.attributes.get(Person.NAME_MOTHER);
mothersMaidenNameExtension.setValue(new StringType(mothersMaidenName));
patientResource.addExtension(mothersMaidenNameExtension);
long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
patientResource.setBirthDate(new Date(birthdate));
Extension birthSexExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
if (person.attributes.get(Person.GENDER).equals("M")) {
patientResource.setGender(AdministrativeGender.MALE);
birthSexExtension.setValue(new CodeType("M"));
} else if (person.attributes.get(Person.GENDER).equals("F")) {
patientResource.setGender(AdministrativeGender.FEMALE);
birthSexExtension.setValue(new CodeType("F"));
}
patientResource.addExtension(birthSexExtension);
String state = (String) person.attributes.get(Person.STATE);
Address addrResource = patientResource.addAddress();
addrResource.addLine((String) person.attributes.get(Person.ADDRESS)).setCity((String) person.attributes.get(Person.CITY)).setPostalCode((String) person.attributes.get(Person.ZIP)).setState(state);
if (COUNTRY_CODE != null) {
addrResource.setCountry(COUNTRY_CODE);
}
Address birthplace = new Address();
birthplace.setCity((String) person.attributes.get(Person.BIRTH_CITY)).setState((String) person.attributes.get(Person.BIRTH_STATE)).setCountry((String) person.attributes.get(Person.BIRTH_COUNTRY));
Extension birthplaceExtension = new Extension("http://hl7.org/fhir/StructureDefinition/birthPlace");
birthplaceExtension.setValue(birthplace);
patientResource.addExtension(birthplaceExtension);
if (person.attributes.get(Person.MULTIPLE_BIRTH_STATUS) != null) {
patientResource.setMultipleBirth(new IntegerType((int) person.attributes.get(Person.MULTIPLE_BIRTH_STATUS)));
} else {
patientResource.setMultipleBirth(new BooleanType(false));
}
patientResource.addTelecom().setSystem(ContactPoint.ContactPointSystem.PHONE).setUse(ContactPoint.ContactPointUse.HOME).setValue((String) person.attributes.get(Person.TELECOM));
String maritalStatus = ((String) person.attributes.get(Person.MARITAL_STATUS));
if (maritalStatus != null) {
Code maritalStatusCode = new Code("http://hl7.org/fhir/v3/MaritalStatus", maritalStatus, maritalStatus);
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://hl7.org/fhir/v3/MaritalStatus"));
} else {
Code maritalStatusCode = new Code("http://hl7.org/fhir/v3/MaritalStatus", "S", "Never Married");
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://hl7.org/fhir/v3/MaritalStatus"));
}
Point2D.Double coord = person.getLonLat();
if (coord != null) {
Extension geolocation = addrResource.addExtension();
geolocation.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
geolocation.addExtension("latitude", new DecimalType(coord.getY()));
geolocation.addExtension("longitude", new DecimalType(coord.getX()));
}
if (!person.alive(stopTime)) {
patientResource.setDeceased(convertFhirDateTime((Long) person.attributes.get(Person.DEATHDATE), true));
}
String generatedBySynthea = "Generated by <a href=\"https://github.com/synthetichealth/synthea\">Synthea</a>." + "Version identifier: " + Utilities.SYNTHEA_VERSION + " . " + " Person seed: " + person.getSeed() + " Population seed: " + person.populationSeed;
patientResource.setText(new Narrative().setStatus(NarrativeStatus.GENERATED).setDiv(new XhtmlNode(NodeType.Element).setValue(generatedBySynthea)));
if (USE_SHR_EXTENSIONS) {
patientResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Patient"));
// Patient profile requires race, ethnicity, birthsex,
// MothersMaidenName, FathersName, Person-extension
patientResource.addExtension().setUrl(SHR_EXT + "shr-actor-FictionalPerson-extension").setValue(new BooleanType(true));
String fathersName = (String) person.attributes.get(Person.NAME_FATHER);
Extension fathersNameExtension = new Extension(SHR_EXT + "shr-entity-FathersName-extension", new HumanName().setText(fathersName));
patientResource.addExtension(fathersNameExtension);
String ssn = (String) person.attributes.get(Person.IDENTIFIER_SSN);
Extension ssnExtension = new Extension(SHR_EXT + "shr-demographics-SocialSecurityNumber-extension", new StringType(ssn));
patientResource.addExtension(ssnExtension);
Basic personResource = new Basic();
// the only required field on this patient resource is code
Coding fixedCode = new Coding("http://standardhealthrecord.org/fhir/basic-resource-type", "shr-entity-Person", "shr-entity-Person");
personResource.setCode(new CodeableConcept().addCoding(fixedCode));
Meta personMeta = new Meta();
personMeta.addProfile(SHR_EXT + "shr-entity-Person");
personResource.setMeta(personMeta);
BundleEntryComponent personEntry = newEntry(person, bundle, personResource);
patientResource.addExtension().setUrl(SHR_EXT + "shr-entity-Person-extension").setValue(new Reference(personEntry.getFullUrl()));
}
// DALY and QALY values
// we only write the last(current) one to the patient record
Double dalyValue = (Double) person.attributes.get("most-recent-daly");
Double qalyValue = (Double) person.attributes.get("most-recent-qaly");
if (dalyValue != null) {
Extension dalyExtension = new Extension(SYNTHEA_EXT + "disability-adjusted-life-years");
DecimalType daly = new DecimalType(dalyValue);
dalyExtension.setValue(daly);
patientResource.addExtension(dalyExtension);
Extension qalyExtension = new Extension(SYNTHEA_EXT + "quality-adjusted-life-years");
DecimalType qaly = new DecimalType(qalyValue);
qalyExtension.setValue(qaly);
patientResource.addExtension(qalyExtension);
}
return newEntry(bundle, patientResource, (String) person.attributes.get(Person.ID));
}
use of org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent in project MobileAccessGateway by i4mi.
the class Iti104UpdateRequestConverter method doUpdate.
public String doUpdate(Patient in, Identifier identifier) throws JAXBException {
PRPAIN201302UV02Type resultMsg = new PRPAIN201302UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201302UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201302UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201302UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201302UV02", "2.16.840.1.113883.1.18", null));
PRPAIN201302UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201302UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201302UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201302UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
PRPAIN201302UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201302UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201302UV02Patient patient = new PRPAMT201302UV02Patient();
subject1.setPatient(patient);
patient.setClassCode("PAT");
PRPAMT201302UV02PatientStatusCode statusCode = new PRPAMT201302UV02PatientStatusCode();
statusCode.setCode("active");
// ???
patient.setStatusCode(statusCode);
PRPAMT201302UV02PatientPatientPerson patientPerson = new PRPAMT201302UV02PatientPatientPerson();
patient.setPatientPerson(patientPerson);
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
patientPerson.setAsOtherIDs(new ArrayList());
List<II> orgIds = new ArrayList<II>();
Set<String> mainIds = new HashSet<String>();
Organization managingOrg = getManagingOrganization(in);
// NULL POINTER CHECK
if (managingOrg != null) {
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
mainIds.add(id.getSystem());
}
} else {
Reference org = in.getManagingOrganization();
if (org != null && org.getIdentifier() != null) {
orgIds.add(new II(getScheme(org.getIdentifier().getSystem()), null));
mainIds.add(org.getIdentifier().getSystem());
}
}
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
boolean isOwn = mainIds.contains(id.getSystem());
if (isOwn)
patient.addId(patientIdentifierUpd(id));
else {
PRPAMT201302UV02OtherIDs asOtherIDs = new PRPAMT201302UV02OtherIDs();
PRPAMT201302UV02OtherIDsId id2 = new PRPAMT201302UV02OtherIDsId();
id2.setRoot(getScheme(id.getSystem()));
id2.setExtension(id.getValue());
asOtherIDs.setClassCode("PAT");
asOtherIDs.setId(Collections.singletonList(id2));
COCTMT150002UV01Organization scopingOrganization = new COCTMT150002UV01Organization();
scopingOrganization.setClassCode(EntityClassOrganization.ORG);
scopingOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
List<II> scopeOrgIds = new ArrayList<II>();
scopeOrgIds.add(new II(getScheme(id.getSystem()), null));
scopingOrganization.setId(scopeOrgIds);
asOtherIDs.setScopingOrganization(scopingOrganization);
patientPerson.addAsOtherIDs(asOtherIDs);
}
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201302UV02LanguageCommunication languageCommunication = new PRPAMT201302UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress())
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
assignedOrganization.setName(Collections.singletonList(name));
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201302UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
Aggregations