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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations