use of org.hl7.fhir.r4b.model.HumanName in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method transformAuthor.
/**
* FHIR Reference to Author -> XDS Author
* @param author
* @param contained
* @return
*/
public Author transformAuthor(Reference author, List<Resource> contained, Identifiable authorRole) {
if (author == null || author.getReference() == null) {
if (authorRole != null) {
Author result = new Author();
Person person = new Person();
// CARA PMP
// At least an authorPerson, authorTelecommunication, or authorInstitution sub-attribute must be present
// Either authorPerson, authorInstitution or authorTelecom shall be specified in the SubmissionSet [IHE ITI Technical Framework Volume 3 (4.2.3.1.4)].
person.setName(transform(new HumanName().setFamily("---")));
result.setAuthorPerson(person);
result.getAuthorRole().add(authorRole);
return result;
}
return null;
}
Resource authorObj = findResource(author, contained);
if (authorObj instanceof Practitioner) {
Practitioner practitioner = (Practitioner) authorObj;
Author result = new Author();
result.setAuthorPerson(transform((Practitioner) authorObj));
for (ContactPoint contactPoint : practitioner.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
if (authorRole == null) {
authorRole = new Identifiable("HCP", new AssigningAuthority("2.16.756.5.30.1.127.3.10.1.41"));
}
result.getAuthorRole().add(authorRole);
return result;
} else if (authorObj instanceof Patient) {
Patient patient = (Patient) authorObj;
Author result = new Author();
result.setAuthorPerson(transform(patient));
for (ContactPoint contactPoint : patient.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
if (authorRole == null) {
authorRole = new Identifiable("PAT", new AssigningAuthority("2.16.756.5.30.1.127.3.10.1.41"));
}
result.getAuthorRole().add(authorRole);
return result;
} else if (authorObj instanceof PractitionerRole) {
Author result = new Author();
PractitionerRole role = (PractitionerRole) authorObj;
Practitioner practitioner = (Practitioner) findResource(role.getPractitioner(), contained);
if (practitioner != null)
result.setAuthorPerson(transform(practitioner));
Organization org = (Organization) findResource(role.getOrganization(), contained);
if (org != null)
result.getAuthorInstitution().add(transform(org));
for (CodeableConcept code : role.getCode()) result.getAuthorRole().add(transformToIdentifiable(code));
for (CodeableConcept speciality : role.getSpecialty()) result.getAuthorSpecialty().add(transformToIdentifiable(speciality));
for (ContactPoint contactPoint : role.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
return result;
} else
throw new InvalidRequestException("Author role not supported.");
// return null;
}
use of org.hl7.fhir.r4b.model.HumanName in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method transform.
/**
* FHIR HumanName -> XDS Name
* @param name
* @return
*/
public Name transform(HumanName name) {
Name targetName = new XpnName();
if (name.hasPrefix())
targetName.setPrefix(name.getPrefixAsSingleString());
if (name.hasSuffix())
targetName.setSuffix(name.getSuffixAsSingleString());
targetName.setFamilyName(name.getFamily());
List<StringType> given = name.getGiven();
if (given != null && !given.isEmpty()) {
targetName.setGivenName(given.get(0).getValue());
if (given.size() > 1) {
StringBuffer restOfName = new StringBuffer();
for (int part = 1; part < given.size(); part++) {
if (part > 1)
restOfName.append(" ");
restOfName.append(given.get(part).getValue());
}
targetName.setSecondAndFurtherGivenNames(restOfName.toString());
}
}
return targetName;
}
use of org.hl7.fhir.r4b.model.HumanName 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.r4b.model.HumanName in project camel-quarkus by apache.
the class FhirDstu2Hl7OrgResource method createTransactionBundle.
private Bundle createTransactionBundle() {
Bundle input = new Bundle();
input.setType(Bundle.BundleType.TRANSACTION);
input.addEntry().setResource(new Patient().addName(new HumanName().addGiven("Art").addFamily("Tatum"))).getRequest().setMethod(Bundle.HTTPVerb.POST);
return input;
}
use of org.hl7.fhir.r4b.model.HumanName in project camel-quarkus by apache.
the class FhirR4Resource method validateResourceAsString.
@Path("/validate/resourceAsString")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String validateResourceAsString() {
Patient patient = new Patient().addName(new HumanName().addGiven(PATIENT_FIRST_NAME).setFamily(PATIENT_LAST_NAME));
patient.getText().setStatus(NarrativeStatus.GENERATED);
patient.getText().setDivAsString("<div>This is the narrative text</div>");
String body = this.fhirContextInstance.get().newXmlParser().encodeResourceToString(patient);
MethodOutcome result = producerTemplate.requestBody("direct:validateResourceAsString-r4", body, MethodOutcome.class);
OperationOutcome operationOutcome = (OperationOutcome) result.getOperationOutcome();
return operationOutcome.getIssue().get(0).getDiagnostics();
}
Aggregations