Search in sources :

Example 1 with MANUFACTURERNAME

use of org.hl7.fhir.r4.model.Device.DeviceNameType.MANUFACTURERNAME in project summary-care-record-api by NHSDigital.

the class DeviceMapper method mapDevice.

public Device mapDevice(Node deviceHl7) {
    Device deviceFhir = new Device();
    deviceFhir.setId(randomUUID());
    xmlUtils.getOptionalValueByXPath(deviceHl7, ID_EXTENSION_XPATH).ifPresent(id -> deviceFhir.addIdentifier().setValue(id));
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, CODE_ELEMENT_XPATH).ifPresent(code -> deviceFhir.setType(new CodeableConcept(new Coding().setCode(xmlUtils.getValueByXPath(code, CODE_ATTRIBUTE_XPATH)).setDisplay(xmlUtils.getValueByXPath(code, CODE_DISPLAY_XPATH)))));
    addName(deviceHl7, deviceFhir, NAME_XPATH, OTHER);
    addName(deviceHl7, deviceFhir, MANUFACTURER_MODE_NAME_XPATH, MANUFACTURERNAME);
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, DESCRIPTION_XPATH).ifPresent(descNode -> deviceFhir.addNote(new Annotation().setText(descNode.getTextContent())));
    xmlUtils.detachOptionalNodeByXPath(deviceHl7, SOFTWARE_NAME_XPATH).ifPresent(software -> deviceFhir.addVersion(new DeviceVersionComponent().setValue(software.getTextContent())));
    return deviceFhir;
}
Also used : DeviceVersionComponent(org.hl7.fhir.r4.model.Device.DeviceVersionComponent) Coding(org.hl7.fhir.r4.model.Coding) Device(org.hl7.fhir.r4.model.Device) Annotation(org.hl7.fhir.r4.model.Annotation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with MANUFACTURERNAME

use of org.hl7.fhir.r4.model.Device.DeviceNameType.MANUFACTURERNAME in project summary-care-record-api by NHSDigital.

the class ParticipantAgentMapper method setAgentDevice.

private static void setAgentDevice(Bundle bundle, Reference individual, Participant.Author1 author) {
    var organizationReference = individual.getReference();
    var organization = getResourceByReference(bundle, organizationReference, org.hl7.fhir.r4.model.Organization.class).orElseThrow(() -> new FhirValidationException("Bundle is missing Organization %s that is linked to PractitionerRole"));
    var device = getDomainResourceList(bundle, org.hl7.fhir.r4.model.Device.class).stream().filter(dev -> organizationReference.equals(dev.getOwner().getReference())).reduce((a, b) -> {
        throw new FhirValidationException(String.format("Bundle has more than 1 Device resource referencing %s", organizationReference));
    });
    var agentDevice = new AgentDevice();
    var code = organization.getTypeFirstRep().getCodingFirstRep().getCode();
    if (StringUtils.isNotBlank(code)) {
        var representedOrganization = new Organization("representedOrganization");
        representedOrganization.setIdRoot("1.2.826.0.1285.0.1.10");
        representedOrganization.setIdExtension(organization.getIdentifierFirstRep().getValue());
        representedOrganization.setCodeCode(code);
        representedOrganization.setName(organization.getName());
        representedOrganization.setTelecom(organization.getTelecomFirstRep().getValue());
        representedOrganization.setAddress(organization.getAddressFirstRep().getText());
        agentDevice.setOrganization(representedOrganization);
    } else {
        Identifier identifier = organization.getIdentifierFirstRep();
        if (ORG_SDS_SYSTEM.equals(identifier.getSystem()) && !identifier.hasValue()) {
            throw new FhirValidationException("Organization.identifier.value element is missing");
        }
        var representedOrganizationSDS = new OrganizationSDS("representedOrganizationSDS");
        representedOrganizationSDS.setIdRoot("1.2.826.0.1285.0.1.10");
        representedOrganizationSDS.setIdExtension(identifier.getValue());
        agentDevice.setOrganizationSDS(representedOrganizationSDS);
    }
    device.ifPresent(it -> {
        agentDevice.setIdRoot(it.getIdentifierFirstRep().getValue());
        if (SDS_DEVICE_SYSTEM.equals(it.getIdentifierFirstRep().getSystem())) {
            var agentDeviceSDS = new DeviceSDS("agentDeviceSDS");
            agentDeviceSDS.setIdRoot("1.2.826.0.1285.0.2.0.107");
            if (it.getIdentifierFirstRep().hasValue()) {
                agentDeviceSDS.setIdExtension(it.getIdentifierFirstRep().getValue());
            } else {
                throw new FhirValidationException("Device.identifier.value is missing");
            }
            agentDevice.setDeviceSDS(agentDeviceSDS);
        } else {
            var agentDevice1 = new Device("agentDevice");
            agentDevice1.setIdRoot("1.2.826.0.1285.0.2.0.107");
            agentDevice1.setIdExtension(it.getIdentifierFirstRep().getValue());
            setDeviceCoding(it, agentDevice1);
            it.getDeviceName().stream().filter(deviceName -> deviceName.getType() == OTHER).findFirst().map(org.hl7.fhir.r4.model.Device.DeviceDeviceNameComponent::getName).ifPresent(agentDevice1::setName);
            it.getDeviceName().stream().filter(deviceName -> deviceName.getType() == MANUFACTURERNAME).findFirst().map(org.hl7.fhir.r4.model.Device.DeviceDeviceNameComponent::getName).ifPresent(agentDevice1::setManufacturerModelName);
            agentDevice1.setDescription(it.getNoteFirstRep().getText());
            agentDevice1.setSoftwareName(it.getVersionFirstRep().getValue());
            agentDevice.setDevice(agentDevice1);
        }
    });
    author.setAgentDevice(agentDevice);
}
Also used : MANUFACTURERNAME(org.hl7.fhir.r4.model.Device.DeviceNameType.MANUFACTURERNAME) Organization(uk.nhs.adaptors.scr.models.xml.Organization) PersonSDS(uk.nhs.adaptors.scr.models.xml.PersonSDS) Identifier(org.hl7.fhir.r4.model.Identifier) DeviceSDS(uk.nhs.adaptors.scr.models.xml.DeviceSDS) NonAgentRole(uk.nhs.adaptors.scr.models.xml.NonAgentRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Reference(org.hl7.fhir.r4.model.Reference) StringUtils(org.apache.commons.lang3.StringUtils) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) OTHER(org.hl7.fhir.r4.model.Device.DeviceNameType.OTHER) Person(uk.nhs.adaptors.scr.models.xml.Person) HumanName(org.hl7.fhir.r4.model.HumanName) AgentPersonSDS(uk.nhs.adaptors.scr.models.xml.AgentPersonSDS) Device(uk.nhs.adaptors.scr.models.xml.Device) Practitioner(org.hl7.fhir.r4.model.Practitioner) AgentDevice(uk.nhs.adaptors.scr.models.xml.AgentDevice) DateUtil.formatDateToHl7(uk.nhs.adaptors.scr.utils.DateUtil.formatDateToHl7) AgentPerson(uk.nhs.adaptors.scr.models.xml.AgentPerson) FhirHelper.getDomainResourceList(uk.nhs.adaptors.scr.utils.FhirHelper.getDomainResourceList) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException) FhirHelper.getResourceByReference(uk.nhs.adaptors.scr.utils.FhirHelper.getResourceByReference) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Collectors(java.util.stream.Collectors) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Slf4j(lombok.extern.slf4j.Slf4j) Participant(uk.nhs.adaptors.scr.models.xml.Participant) Coding(org.hl7.fhir.r4.model.Coding) Optional(java.util.Optional) Bundle(org.hl7.fhir.r4.model.Bundle) OrganizationSDS(uk.nhs.adaptors.scr.models.xml.OrganizationSDS) Organization(uk.nhs.adaptors.scr.models.xml.Organization) Identifier(org.hl7.fhir.r4.model.Identifier) Device(uk.nhs.adaptors.scr.models.xml.Device) AgentDevice(uk.nhs.adaptors.scr.models.xml.AgentDevice) AgentDevice(uk.nhs.adaptors.scr.models.xml.AgentDevice) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException) OrganizationSDS(uk.nhs.adaptors.scr.models.xml.OrganizationSDS) DeviceSDS(uk.nhs.adaptors.scr.models.xml.DeviceSDS)

Aggregations

CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Coding (org.hl7.fhir.r4.model.Coding)2 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 Annotation (org.hl7.fhir.r4.model.Annotation)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 Device (org.hl7.fhir.r4.model.Device)1 MANUFACTURERNAME (org.hl7.fhir.r4.model.Device.DeviceNameType.MANUFACTURERNAME)1 OTHER (org.hl7.fhir.r4.model.Device.DeviceNameType.OTHER)1 DeviceVersionComponent (org.hl7.fhir.r4.model.Device.DeviceVersionComponent)1 EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)1 HumanName (org.hl7.fhir.r4.model.HumanName)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 Practitioner (org.hl7.fhir.r4.model.Practitioner)1 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)1 Reference (org.hl7.fhir.r4.model.Reference)1