use of org.hl7.fhir.r4b.model.ContactPoint 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.ContactPoint 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.ContactPoint in project MobileAccessGateway by i4mi.
the class Iti78ResponseConverter method transform.
public ContactPoint transform(TEL telecom) {
ContactPoint contactPoint = new ContactPoint();
String use = telecom.getUse();
if (use != null) {
switch(use) {
case "HP":
contactPoint.setUse(ContactPoint.ContactPointUse.HOME);
break;
}
}
contactPoint.setValue(telecom.getValue());
return contactPoint;
}
use of org.hl7.fhir.r4b.model.ContactPoint in project synthea by synthetichealth.
the class FhirR4 method practitioner.
/**
* Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle.
* @param rand Source of randomness to use when generating ids etc
* @param bundle The Bundle to add to
* @param clinician The clinician
* @return The added Entry
*/
protected static BundleEntryComponent practitioner(RandomNumberGenerator rand, Bundle bundle, Clinician clinician) {
Practitioner practitionerResource = new Practitioner();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner");
practitionerResource.setMeta(meta);
}
practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi);
practitionerResource.setActive(true);
practitionerResource.addName().setFamily((String) clinician.attributes.get(Clinician.LAST_NAME)).addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME)).addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));
String email = (String) clinician.attributes.get(Clinician.FIRST_NAME) + "." + (String) clinician.attributes.get(Clinician.LAST_NAME) + "@example.com";
practitionerResource.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.WORK).setValue(email);
if (USE_US_CORE_IG) {
practitionerResource.getTelecomFirstRep().addExtension().setUrl("http://hl7.org/fhir/us/core/StructureDefinition/us-core-direct").setValue(new BooleanType(true));
}
Address address = new Address().addLine((String) clinician.attributes.get(Clinician.ADDRESS)).setCity((String) clinician.attributes.get(Clinician.CITY)).setPostalCode((String) clinician.attributes.get(Clinician.ZIP)).setState((String) clinician.attributes.get(Clinician.STATE));
if (COUNTRY_CODE != null) {
address.setCountry(COUNTRY_CODE);
}
practitionerResource.addAddress(address);
if (clinician.attributes.get(Person.GENDER).equals("M")) {
practitionerResource.setGender(AdministrativeGender.MALE);
} else if (clinician.attributes.get(Person.GENDER).equals("F")) {
practitionerResource.setGender(AdministrativeGender.FEMALE);
}
BundleEntryComponent practitionerEntry = newEntry(bundle, practitionerResource, clinician.getResourceID());
if (USE_US_CORE_IG) {
// generate an accompanying PractitionerRole resource
PractitionerRole practitionerRole = new PractitionerRole();
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole");
practitionerRole.setMeta(meta);
practitionerRole.setPractitioner(new Reference().setIdentifier(new Identifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi)).setDisplay(practitionerResource.getNameFirstRep().getNameAsSingleString()));
practitionerRole.setOrganization(new Reference().setIdentifier(new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(clinician.getOrganization().getResourceID())).setDisplay(clinician.getOrganization().name));
practitionerRole.addCode(mapCodeToCodeableConcept(new Code("http://nucc.org/provider-taxonomy", "208D00000X", "General Practice"), null));
practitionerRole.addSpecialty(mapCodeToCodeableConcept(new Code("http://nucc.org/provider-taxonomy", "208D00000X", "General Practice"), null));
practitionerRole.addLocation().setIdentifier(new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(clinician.getOrganization().getResourceLocationID())).setDisplay(clinician.getOrganization().name);
if (clinician.getOrganization().phone != null && !clinician.getOrganization().phone.isEmpty()) {
practitionerRole.addTelecom(new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(clinician.getOrganization().phone));
}
practitionerRole.addTelecom(practitionerResource.getTelecomFirstRep());
newEntry(rand, bundle, practitionerRole);
}
return practitionerEntry;
}
use of org.hl7.fhir.r4b.model.ContactPoint in project synthea by synthetichealth.
the class FhirR4 method providerLocation.
/**
* Map the Provider into a FHIR Location resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param bundle The Bundle to add to
* @param provider The Provider
* @return The added Entry or null if the bundle already contains this provider location
*/
protected static org.hl7.fhir.r4.model.Location providerLocation(RandomNumberGenerator rand, Bundle bundle, Provider provider) {
org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-location");
location.setMeta(meta);
}
location.setStatus(LocationStatus.ACTIVE);
location.setName(provider.name);
// set telecom
if (provider.phone != null && !provider.phone.isEmpty()) {
ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
location.addTelecom(contactPoint);
} else if (USE_US_CORE_IG) {
ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue("(555) 555-5555");
location.addTelecom(contactPoint);
}
// set address
Address address = new Address().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
if (COUNTRY_CODE != null) {
address.setCountry(COUNTRY_CODE);
}
location.setAddress(address);
LocationPositionComponent position = new LocationPositionComponent();
position.setLatitude(provider.getY());
position.setLongitude(provider.getX());
location.setPosition(position);
location.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceLocationID());
Identifier organizationIdentifier = new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceID());
location.setManagingOrganization(new Reference().setIdentifier(organizationIdentifier).setDisplay(provider.name));
return location;
}
Aggregations