Search in sources :

Example 6 with Communication

use of org.hl7.fhir.r4.model.Communication in project Gravity-SDOH-Exchange-RI by FHIR.

the class PatientToDtoConverter method convert.

@Override
public PatientDto convert(PatientInfo patientInfo) {
    Patient patient = patientInfo.getPatient();
    PatientDto patientDto = new PatientDto();
    patientDto.setId(patient.getIdElement().getIdPart());
    patientDto.setName(patient.getNameFirstRep().getNameAsSingleString());
    // Get Date of Birth and Age
    if (patient.hasBirthDate()) {
        LocalDate dob = FhirUtil.toLocalDate(patient.getBirthDateElement());
        patientDto.setDob(dob);
        patientDto.setAge(Period.between(dob, LocalDate.now(ZoneOffset.UTC)).getYears());
    }
    // Get gender
    patientDto.setGender(ObjectUtils.defaultIfNull(patient.getGender(), Enumerations.AdministrativeGender.UNKNOWN).getDisplay());
    // Get communication language
    patientDto.setLanguage(patient.getCommunication().stream().filter(Patient.PatientCommunicationComponent::getPreferred).map(c -> c.getLanguage().getCodingFirstRep()).map(c -> c.getDisplay() != null ? c.getDisplay() : c.getCode()).filter(Objects::nonNull).findFirst().orElse(null));
    // Get Address full String. No need to compose it on UI side.
    patientDto.setAddress(patient.getAddress().stream().filter(a -> (patient.getAddress().size() == 1 && a.getUse() == null) || Address.AddressUse.HOME.equals(a.getUse())).map(this::convertAddress).findFirst().orElse(null));
    List<ContactPoint> telecom = patient.getTelecom();
    // Get phone numbers
    patientDto.getPhones().addAll(telecom.stream().filter(t -> ContactPoint.ContactPointSystem.PHONE.equals(t.getSystem())).map(cp -> {
        String display = cp.getUse() == null ? null : cp.getUse().getDisplay();
        return new PhoneDto(display, cp.getValue());
    }).collect(Collectors.toList()));
    // Get email addreses
    patientDto.getEmails().addAll(telecom.stream().filter(t -> ContactPoint.ContactPointSystem.EMAIL.equals(t.getSystem())).map(cp -> {
        String display = cp.getUse() == null ? null : cp.getUse().getDisplay();
        return new EmailDto(display, cp.getValue());
    }).collect(Collectors.toList()));
    if (patientInfo.getEmployment() != null) {
        String employmentStatus = patientInfo.getEmployment().getValueCodeableConcept().getCodingFirstRep().getDisplay();
        patientDto.setEmploymentStatus(employmentStatus);
    }
    if (patientInfo.getEducation() != null) {
        String education = patientInfo.getEducation().getValueCodeableConcept().getCodingFirstRep().getDisplay();
        patientDto.setEducation(education);
    }
    // Get race
    Extension race = patient.getExtensionByUrl(UsCorePatientExtensions.RACE);
    patientDto.setRace(convertExtension(race));
    // Get ethnicity
    Extension ethnicity = patient.getExtensionByUrl(UsCorePatientExtensions.ETHNICITY);
    patientDto.setEthnicity(convertExtension(ethnicity));
    // Get marital status
    Coding ms = patient.getMaritalStatus().getCodingFirstRep();
    patientDto.setMaritalStatus(Optional.ofNullable(ms.getDisplay()).orElse(Optional.ofNullable(ms.getCode()).orElse(null)));
    patientDto.getInsurances().addAll(convertPayors(patientInfo.getPayors()));
    return patientDto;
}
Also used : EmailDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.EmailDto) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Strings(com.google.common.base.Strings) Address(org.hl7.fhir.r4.model.Address) ObjectUtils(org.apache.commons.lang3.ObjectUtils) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringType(org.hl7.fhir.r4.model.StringType) PatientDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PatientDto) ZoneOffset(java.time.ZoneOffset) PatientInfo(org.hl7.gravity.refimpl.sdohexchange.info.PatientInfo) Patient(org.hl7.fhir.r4.model.Patient) Converter(org.springframework.core.convert.converter.Converter) Period(java.time.Period) Enumerations(org.hl7.fhir.r4.model.Enumerations) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Organization(org.hl7.fhir.r4.model.Organization) List(java.util.List) UsCorePatientExtensions(org.hl7.gravity.refimpl.sdohexchange.fhir.UsCorePatientExtensions) PhoneDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PhoneDto) Coding(org.hl7.fhir.r4.model.Coding) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Extension(org.hl7.fhir.r4.model.Extension) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Extension(org.hl7.fhir.r4.model.Extension) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) EmailDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.EmailDto) PhoneDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PhoneDto) LocalDate(java.time.LocalDate) PatientDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PatientDto)

Example 7 with Communication

use of org.hl7.fhir.r4.model.Communication in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composePatient.

protected void composePatient(Complex parent, String parentType, String name, Patient element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Patient", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Patient", "identifier", element.getIdentifier().get(i), i);
    if (element.hasActiveElement())
        composeBoolean(t, "Patient", "active", element.getActiveElement(), -1);
    for (int i = 0; i < element.getName().size(); i++) composeHumanName(t, "Patient", "name", element.getName().get(i), i);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "Patient", "telecom", element.getTelecom().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "Patient", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "Patient", "birthDate", element.getBirthDateElement(), -1);
    if (element.hasDeceased())
        composeType(t, "Patient", "deceased", element.getDeceased(), -1);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "Patient", "address", element.getAddress().get(i), i);
    if (element.hasMaritalStatus())
        composeCodeableConcept(t, "Patient", "maritalStatus", element.getMaritalStatus(), -1);
    if (element.hasMultipleBirth())
        composeType(t, "Patient", "multipleBirth", element.getMultipleBirth(), -1);
    for (int i = 0; i < element.getPhoto().size(); i++) composeAttachment(t, "Patient", "photo", element.getPhoto().get(i), i);
    for (int i = 0; i < element.getContact().size(); i++) composePatientContactComponent(t, "Patient", "contact", element.getContact().get(i), i);
    if (element.hasAnimal())
        composePatientAnimalComponent(t, "Patient", "animal", element.getAnimal(), -1);
    for (int i = 0; i < element.getCommunication().size(); i++) composePatientPatientCommunicationComponent(t, "Patient", "communication", element.getCommunication().get(i), i);
    for (int i = 0; i < element.getGeneralPractitioner().size(); i++) composeReference(t, "Patient", "generalPractitioner", element.getGeneralPractitioner().get(i), i);
    if (element.hasManagingOrganization())
        composeReference(t, "Patient", "managingOrganization", element.getManagingOrganization(), -1);
    for (int i = 0; i < element.getLink().size(); i++) composePatientPatientLinkComponent(t, "Patient", "link", element.getLink().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 8 with Communication

use of org.hl7.fhir.r4.model.Communication in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCommunication.

protected void composeCommunication(Complex parent, String parentType, String name, Communication element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Communication", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Communication", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getDefinition().size(); i++) composeReference(t, "Communication", "definition", element.getDefinition().get(i), i);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "Communication", "basedOn", element.getBasedOn().get(i), i);
    for (int i = 0; i < element.getPartOf().size(); i++) composeReference(t, "Communication", "partOf", element.getPartOf().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Communication", "status", element.getStatusElement(), -1);
    if (element.hasNotDoneElement())
        composeBoolean(t, "Communication", "notDone", element.getNotDoneElement(), -1);
    if (element.hasNotDoneReason())
        composeCodeableConcept(t, "Communication", "notDoneReason", element.getNotDoneReason(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "Communication", "category", element.getCategory().get(i), i);
    for (int i = 0; i < element.getMedium().size(); i++) composeCodeableConcept(t, "Communication", "medium", element.getMedium().get(i), i);
    if (element.hasSubject())
        composeReference(t, "Communication", "subject", element.getSubject(), -1);
    for (int i = 0; i < element.getRecipient().size(); i++) composeReference(t, "Communication", "recipient", element.getRecipient().get(i), i);
    for (int i = 0; i < element.getTopic().size(); i++) composeReference(t, "Communication", "topic", element.getTopic().get(i), i);
    if (element.hasContext())
        composeReference(t, "Communication", "context", element.getContext(), -1);
    if (element.hasSentElement())
        composeDateTime(t, "Communication", "sent", element.getSentElement(), -1);
    if (element.hasReceivedElement())
        composeDateTime(t, "Communication", "received", element.getReceivedElement(), -1);
    if (element.hasSender())
        composeReference(t, "Communication", "sender", element.getSender(), -1);
    for (int i = 0; i < element.getReasonCode().size(); i++) composeCodeableConcept(t, "Communication", "reasonCode", element.getReasonCode().get(i), i);
    for (int i = 0; i < element.getReasonReference().size(); i++) composeReference(t, "Communication", "reasonReference", element.getReasonReference().get(i), i);
    for (int i = 0; i < element.getPayload().size(); i++) composeCommunicationCommunicationPayloadComponent(t, "Communication", "payload", element.getPayload().get(i), i);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "Communication", "note", element.getNote().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 9 with Communication

use of org.hl7.fhir.r4.model.Communication in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composePractitioner.

protected void composePractitioner(Complex parent, String parentType, String name, Practitioner element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Practitioner", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Practitioner", "identifier", element.getIdentifier().get(i), i);
    if (element.hasActiveElement())
        composeBoolean(t, "Practitioner", "active", element.getActiveElement(), -1);
    for (int i = 0; i < element.getName().size(); i++) composeHumanName(t, "Practitioner", "name", element.getName().get(i), i);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "Practitioner", "telecom", element.getTelecom().get(i), i);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "Practitioner", "address", element.getAddress().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "Practitioner", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "Practitioner", "birthDate", element.getBirthDateElement(), -1);
    for (int i = 0; i < element.getPhoto().size(); i++) composeAttachment(t, "Practitioner", "photo", element.getPhoto().get(i), i);
    for (int i = 0; i < element.getPractitionerRole().size(); i++) composePractitionerPractitionerPractitionerRoleComponent(t, "Practitioner", "practitionerRole", element.getPractitionerRole().get(i), i);
    for (int i = 0; i < element.getQualification().size(); i++) composePractitionerPractitionerQualificationComponent(t, "Practitioner", "qualification", element.getQualification().get(i), i);
    for (int i = 0; i < element.getCommunication().size(); i++) composeCodeableConcept(t, "Practitioner", "communication", element.getCommunication().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 10 with Communication

use of org.hl7.fhir.r4.model.Communication in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeRelatedPerson.

protected void composeRelatedPerson(Complex parent, String parentType, String name, RelatedPerson element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "RelatedPerson", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "RelatedPerson", "identifier", element.getIdentifier().get(i), i);
    if (element.hasActiveElement())
        composeBoolean(t, "RelatedPerson", "active", element.getActiveElement(), -1);
    if (element.hasPatient())
        composeReference(t, "RelatedPerson", "patient", element.getPatient(), -1);
    for (int i = 0; i < element.getRelationship().size(); i++) composeCodeableConcept(t, "RelatedPerson", "relationship", element.getRelationship().get(i), i);
    for (int i = 0; i < element.getName().size(); i++) composeHumanName(t, "RelatedPerson", "name", element.getName().get(i), i);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "RelatedPerson", "telecom", element.getTelecom().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "RelatedPerson", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "RelatedPerson", "birthDate", element.getBirthDateElement(), -1);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "RelatedPerson", "address", element.getAddress().get(i), i);
    for (int i = 0; i < element.getPhoto().size(); i++) composeAttachment(t, "RelatedPerson", "photo", element.getPhoto().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "RelatedPerson", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getCommunication().size(); i++) composeRelatedPersonRelatedPersonCommunicationComponent(t, "RelatedPerson", "communication", element.getCommunication().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)8 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Reference (org.hl7.fhir.r4.model.Reference)4 Meta (org.hl7.fhir.r4.model.Meta)3 Patient (org.hl7.fhir.r4.model.Patient)3 StringType (org.hl7.fhir.r4.model.StringType)3 Point2D (java.awt.geom.Point2D)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)2 Reference (org.hl7.fhir.dstu3.model.Reference)2 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)2 Address (org.hl7.fhir.r4.model.Address)2 BooleanType (org.hl7.fhir.r4.model.BooleanType)2 Coding (org.hl7.fhir.r4.model.Coding)2 Extension (org.hl7.fhir.r4.model.Extension)2