Search in sources :

Example 96 with Identifier

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

the class GpSummaryMapper method map.

@SneakyThrows
public List<Resource> map(Node document) {
    var gpSummaryId = xmlUtils.getValueByXPath(document, GP_SUMMARY_ID_XPATH);
    var gpSummaryCodeCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_CODE_XPATH);
    var gpSummaryCodeDisplayName = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_DISPLAY_NAME_XPATH);
    var gpSummaryStatusCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_STATUS_CODE_XPATH);
    var gpSummaryEffectiveTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_EFFECTIVE_TIME_XPATH), InstantType.class);
    var authorTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_AUTHOR_TIME_XPATH), DateTimeType.class);
    var replacementOfPriorMessageRefIdRoot = xmlUtils.getOptionalValueByXPath(document, REPLACEMENT_OF_PRIOR_MESSAGE_REF_ID_ROOT_XPATH);
    var pertinentRootCreTypeCodeCode = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_CODE_XPATH);
    var pertinentRootCreTypeCodeDisplayName = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_DISPLAY_NAME_XPATH);
    var presentationTextValue = xmlUtils.detachOptionalNodeByXPath(document, PRESENTATION_TEXT_VALUE);
    var eventId = xmlUtils.getValueByXPath(document, EVENT_ID_XPATH);
    List<Resource> resources = new ArrayList<>();
    var composition = new Composition();
    composition.setId(eventId);
    composition.setIdentifier(new Identifier().setValue(gpSummaryId).setSystem("https://tools.ietf.org/html/rfc4122"));
    composition.setType(new CodeableConcept().addCoding(new Coding().setCode(gpSummaryCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(gpSummaryCodeDisplayName)));
    composition.setMeta(new Meta().setLastUpdatedElement(gpSummaryEffectiveTime));
    composition.setStatus(mapCompositionStatus(gpSummaryStatusCode));
    composition.setDateElement(authorTime);
    replacementOfPriorMessageRefIdRoot.ifPresent(val -> composition.addRelatesTo(new Composition.CompositionRelatesToComponent().setTarget(new Identifier().setValue(val)).setCode(REPLACES)));
    composition.addCategory(new CodeableConcept().addCoding(new Coding().setCode(pertinentRootCreTypeCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(pertinentRootCreTypeCodeDisplayName)));
    Map<String, List<String>> references = sectionReferences(document);
    presentationTextValue.map(htmlParser::parse).map(Collection::stream).ifPresent(it -> it.forEach(section -> {
        if (section.getTitle() != null && CODED_ENTRY_RESOURCE_MAP.keySet().contains(section.getTitle()) && references.containsKey(section.getTitle())) {
            for (String codedEntryId : references.get(section.getTitle())) {
                section.addEntry(new Reference(CODED_ENTRY_RESOURCE_MAP.get(section.getTitle()) + "/" + codedEntryId));
            }
        }
        composition.addSection(section);
    }));
    resources.add(composition);
    addAuthor(document, resources, composition);
    return resources;
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Collection(java.util.Collection) Identifier(org.hl7.fhir.r4.model.Identifier) RequiredArgsConstructor(lombok.RequiredArgsConstructor) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Resource(org.hl7.fhir.r4.model.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Composition(org.hl7.fhir.r4.model.Composition) Reference(org.hl7.fhir.r4.model.Reference) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) ArrayList(java.util.ArrayList) Organization(org.hl7.fhir.r4.model.Organization) List(java.util.List) InstantType(org.hl7.fhir.r4.model.InstantType) Component(org.springframework.stereotype.Component) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) Map(java.util.Map) Node(org.w3c.dom.Node) REPLACES(org.hl7.fhir.r4.model.Composition.DocumentRelationshipType.REPLACES) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) Meta(org.hl7.fhir.r4.model.Meta) Meta(org.hl7.fhir.r4.model.Meta) Composition(org.hl7.fhir.r4.model.Composition) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) ArrayList(java.util.ArrayList) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) List(java.util.List) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) SneakyThrows(lombok.SneakyThrows)

Example 97 with Identifier

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

the class GetScrService method buildPatientResource.

private Patient buildPatientResource(String nhsNumber) {
    Patient patient = new Patient();
    String patientResourceId = randomUUID();
    patient.setId(patientResourceId);
    patient.setIdentifier(asList(new Identifier().setSystem(NHS_ID_SYSTEM).setValue(nhsNumber)));
    return patient;
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Patient(org.hl7.fhir.r4.model.Patient)

Example 98 with Identifier

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

the class OrganisationSdsMapper method mapOrganizationSds.

public Organization mapOrganizationSds(Node organisationSds) {
    var org = new Organization();
    org.setId(randomUUID());
    var orgIdentifier = new Identifier().setValue(xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_XPATH));
    var rootId = xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_ROOT_XPATH);
    if (HL7_ORG_OID.equals(rootId)) {
        orgIdentifier.setSystem(ORG_SDS_SYSTEM);
    }
    org.addIdentifier(orgIdentifier);
    xmlUtils.detachOptionalNodeByXPath(organisationSds, ORG_NAME_XPATH).ifPresent(nameNode -> org.setName(nameNode.getTextContent()));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Identifier(org.hl7.fhir.r4.model.Identifier)

Example 99 with Identifier

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

the class PersonSdsMapper method mapPractitioner.

public Practitioner mapPractitioner(Node personSds) {
    var practitioner = new Practitioner();
    practitioner.setId(randomUUID());
    practitioner.addIdentifier(new Identifier().setSystem(SDS_USER_ID).setValue(xmlUtils.getValueByXPath(personSds, ID_EXTENSION_XPATH)));
    var name = xmlUtils.getOptionalValueByXPath(personSds, PERSON_NAME_XPATH);
    if (name.isPresent()) {
        practitioner.addName(new HumanName().setText(name.get()));
    }
    return practitioner;
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) Identifier(org.hl7.fhir.r4.model.Identifier)

Example 100 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project openmrs-module-fhir2 by openmrs.

the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByIdentifier.

@Test
public void shouldSearchForPractitionersByIdentifier() {
    TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(IDENTIFIER));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
    when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
    when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
    IBundleProvider results = practitionerService.searchForPractitioners(identifier, null, null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SimpleBundleProvider(ca.uhn.fhir.rest.server.SimpleBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)203 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)109 Test (org.junit.jupiter.api.Test)83 ArrayList (java.util.ArrayList)63 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)63 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Patient (org.hl7.fhir.r4.model.Patient)53 Reference (org.hl7.fhir.r4.model.Reference)53 List (java.util.List)47 Coding (org.hl7.fhir.r4.model.Coding)47 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)41 Date (java.util.Date)40 Practitioner (org.hl7.fhir.r4.model.Practitioner)40 Collectors (java.util.stream.Collectors)38 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)31