Search in sources :

Example 56 with Device

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

the class DeviceSdsMapper method mapDeviceSds.

public Device mapDeviceSds(Node deviceSdsHl7) {
    Device deviceFhir = new Device();
    deviceFhir.setId(randomUUID());
    deviceFhir.addIdentifier(new Identifier().setSystem(SDS_DEVICE_SYSTEM).setValue(xmlUtils.getValueByXPath(deviceSdsHl7, ID_EXTENSION_XPATH)));
    return deviceFhir;
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Device(org.hl7.fhir.r4.model.Device)

Example 57 with Device

use of org.hl7.fhir.dstu3.model.Device 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)

Example 58 with Device

use of org.hl7.fhir.dstu3.model.Device in project integration-adaptor-111 by nhsconnect.

the class EncounterReportBundleServiceTest method setUp.

@BeforeEach
public void setUp() throws XmlException {
    INT versionNumber = mock(INT.class);
    when(versionNumber.getValue()).thenReturn(VERSION);
    when(document.getVersionNumber()).thenReturn(versionNumber);
    when(document.getEffectiveTime()).thenReturn(ts);
    when(ts.getValue()).thenReturn(EFFECTIVE_TIME);
    List<QuestionnaireResponse> questionnaireResponseList = new ArrayList<>();
    questionnaireResponseList.add(QUESTIONNAIRE_RESPONSE);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    when(encounterMapper.mapEncounter(any(), any(), any(), any())).thenReturn(ENCOUNTER);
    when(conditionMapper.mapCondition(any(), any(), any())).thenReturn(CONDITION);
    when(compositionMapper.mapComposition(any(), any(), any(), any(), any(), any())).thenReturn(COMPOSITION);
    when(listMapper.mapList(any(), any(), any(), any())).thenReturn(LIST_RESOURCE);
    when(carePlanMapper.mapCarePlan(any(), any(), any())).thenReturn(singletonList(CAREPLAN));
    when(healthcareServiceMapper.mapHealthcareService(any())).thenReturn(singletonList(HEALTHCARE_SERVICE));
    when(consentMapper.mapConsent(any(), any())).thenReturn(CONSENT);
    when(pathwayUtil.getQuestionnaireResponses(any(), any(), any())).thenReturn(questionnaireResponseList);
    when(messageHeaderService.createMessageHeader(any(), any(), eq(EFFECTIVE_TIME))).thenReturn(MESSAGE_HEADER);
    when(referralRequestMapper.mapReferralRequest(any(), any(), any(), any(), any())).thenReturn(REFERRAL_REQUEST);
    when(observationMapper.mapObservations(any(), eq(ENCOUNTER))).thenReturn(Arrays.asList(OBSERVATION));
    when(practitionerRoleMapper.mapAuthorRoles(any())).thenReturn(singletonList(AUTHOR_ROLE));
    when(practitionerRoleMapper.mapResponsibleParty(any())).thenReturn(Optional.of(PRACTITIONER_ROLE));
    when(relatedPersonMapper.createEmergencyContactRelatedPerson(eq(document), eq(ENCOUNTER))).thenReturn(RELATED_PERSON);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    Encounter.DiagnosisComponent diagnosisComponent = new Encounter.DiagnosisComponent();
    diagnosisComponent.setCondition(new Reference());
    diagnosisComponent.setRole(new CodeableConcept());
    diagnosisComponent.setRank(1);
    diagnosisComponent.setConditionTarget(CONDITION);
    ENCOUNTER.addDiagnosis(diagnosisComponent);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.dstu3.model.Encounter) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) INT(uk.nhs.connect.iucds.cda.ucr.INT) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 59 with Device

use of org.hl7.fhir.dstu3.model.Device in project integration-adaptor-111 by nhsconnect.

the class EncounterReportBundleService method createEncounterBundle.

public Bundle createEncounterBundle(POCDMT000002UK01ClinicalDocument1 clinicalDocument, ItkReportHeader header, String messageId) throws XmlException {
    Bundle bundle = createBundle(clinicalDocument);
    MessageHeader messageHeader = messageHeaderService.createMessageHeader(header, messageId, clinicalDocument.getEffectiveTime().getValue());
    List<HealthcareService> healthcareServiceList = healthcareServiceMapper.mapHealthcareService(clinicalDocument);
    List<PractitionerRole> authorPractitionerRoles = practitionerRoleMapper.mapAuthorRoles(clinicalDocument.getAuthorArray());
    Optional<PractitionerRole> responsibleParty = practitionerRoleMapper.mapResponsibleParty(clinicalDocument);
    Encounter encounter = encounterMapper.mapEncounter(clinicalDocument, authorPractitionerRoles, responsibleParty, messageHeader.getEvent());
    Consent consent = consentMapper.mapConsent(clinicalDocument, encounter);
    List<QuestionnaireResponse> questionnaireResponseList = pathwayUtil.getQuestionnaireResponses(clinicalDocument, encounter.getSubject(), resourceUtil.createReference(encounter));
    Condition condition = conditionMapper.mapCondition(clinicalDocument, encounter, questionnaireResponseList);
    List<CarePlan> carePlans = carePlanMapper.mapCarePlan(clinicalDocument, encounter, condition);
    Device device = deviceMapper.mapDevice();
    ReferralRequest referralRequest = referralRequestMapper.mapReferralRequest(clinicalDocument, encounter, healthcareServiceList, resourceUtil.createReference(condition), resourceUtil.createReference(device));
    Composition composition = compositionMapper.mapComposition(clinicalDocument, encounter, carePlans, questionnaireResponseList, referralRequest, authorPractitionerRoles);
    List<Observation> observations = observationMapper.mapObservations(clinicalDocument, encounter);
    RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocument, encounter);
    addMessageHeader(bundle, messageHeader);
    addEncounter(bundle, encounter);
    addServiceProvider(bundle, encounter);
    addParticipants(bundle, encounter);
    addLocation(bundle, encounter);
    addSubject(bundle, encounter);
    addHealthcareService(bundle, healthcareServiceList);
    addIncomingReferral(bundle, referralRequest);
    addAppointment(bundle, encounter);
    addEntry(bundle, composition);
    addCarePlan(bundle, carePlans);
    addEntry(bundle, consent);
    addEntry(bundle, condition);
    addQuestionnaireResponses(bundle, questionnaireResponseList);
    addObservations(bundle, observations);
    addPractitionerRoles(bundle, authorPractitionerRoles, responsibleParty);
    addRelatedPerson(bundle, relatedPerson);
    addEntry(bundle, device);
    ListResource listResource = getReferenceFromBundle(bundle, clinicalDocument, encounter, device);
    addEntry(bundle, listResource);
    return bundle;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) Composition(org.hl7.fhir.dstu3.model.Composition) Bundle(org.hl7.fhir.dstu3.model.Bundle) Device(org.hl7.fhir.dstu3.model.Device) HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Consent(org.hl7.fhir.dstu3.model.Consent) Observation(org.hl7.fhir.dstu3.model.Observation) Encounter(org.hl7.fhir.dstu3.model.Encounter) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 60 with Device

use of org.hl7.fhir.dstu3.model.Device in project integration-adaptor-111 by nhsconnect.

the class DeviceMapperTest method shouldMapDevice.

@Test
public void shouldMapDevice() {
    Device device = deviceMapper.mapDevice();
    assertThat(device.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(device.getVersion()).isEqualTo(VERSION);
    assertThat(device.getModel()).isEqualTo(MODEL);
}
Also used : Device(org.hl7.fhir.dstu3.model.Device) Test(org.junit.jupiter.api.Test)

Aggregations

Device (com.google.api.services.cloudiot.v1.model.Device)21 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)13 JsonFactory (com.google.api.client.json.JsonFactory)13 CloudIot (com.google.api.services.cloudiot.v1.CloudIot)13 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)13 GoogleCredentials (com.google.auth.oauth2.GoogleCredentials)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13 Test (org.junit.jupiter.api.Test)9 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)7 Device (org.hl7.fhir.r4.model.Device)7 Practitioner (org.hl7.fhir.r4.model.Practitioner)7 Reference (org.hl7.fhir.r4.model.Reference)7 ArrayList (java.util.ArrayList)6 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)6 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)6 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)6 DeviceCredential (com.google.api.services.cloudiot.v1.model.DeviceCredential)5 PublicKeyCredential (com.google.api.services.cloudiot.v1.model.PublicKeyCredential)5 Coding (org.hl7.fhir.r4.model.Coding)5 Identifier (org.hl7.fhir.r4.model.Identifier)5