Search in sources :

Example 81 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project nia-patient-switching-standard-adaptor by NHSDigital.

the class BundleMapperServiceTest method setup.

@BeforeEach
public void setup() {
    when(bundleGenerator.generateBundle()).thenReturn(new Bundle());
    var agentResourceList = new ArrayList<DomainResource>();
    agentResourceList.add(new Organization());
    List mockedList = mock(List.class);
    Map<String, List<? extends DomainResource>> encounterResources = new HashMap<>();
    encounterResources.put(ENCOUNTER_KEY, new ArrayList<>());
    encounterResources.put(CONSULTATION_KEY, new ArrayList<>());
    encounterResources.put(TOPIC_KEY, new ArrayList<>());
    encounterResources.put(CATEGORY_KEY, new ArrayList<>());
    when(agentDirectoryMapper.mapAgentDirectory(any())).thenReturn(mockedList);
    when(mockedList.stream()).thenReturn(agentResourceList.stream());
    when(patientMapper.mapToPatient(any(RCMRMT030101UK04Patient.class), any(Organization.class))).thenReturn(new Patient());
    when(encounterMapper.mapEncounters(any(RCMRMT030101UK04EhrExtract.class), any(Patient.class), any(String.class))).thenReturn(encounterResources);
    when(organizationMapper.mapAuthorOrganization(anyString())).thenReturn(new Organization());
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) HashMap(java.util.HashMap) Bundle(org.hl7.fhir.dstu3.model.Bundle) ArrayList(java.util.ArrayList) RCMRMT030101UK04Patient(org.hl7.v3.RCMRMT030101UK04Patient) Patient(org.hl7.fhir.dstu3.model.Patient) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RCMRMT030101UK04Patient(org.hl7.v3.RCMRMT030101UK04Patient) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 82 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project CRD by HL7-DaVinci.

the class FhirBundleProcessor method createCriteriaList.

private List<CoverageRequirementRuleCriteria> createCriteriaList(CodeableConcept codeableConcept, List<Reference> insurance, List<Organization> payorList) {
    try {
        List<Coding> codings = codeableConcept.getCoding();
        if (codings.size() > 0) {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: code[0]: " + codings.get(0).getCode() + " - " + codings.get(0).getSystem());
        } else {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: empty codes list!");
        }
        List<Organization> payors = new ArrayList<>();
        if (insurance != null) {
            List<Coverage> coverages = insurance.stream().map(reference -> (Coverage) reference.getResource()).collect(Collectors.toList());
            // Remove null coverages that may not have resolved.
            coverages = coverages.stream().filter(coverage -> coverage != null).collect(Collectors.toList());
            payors = Utilities.getPayors(coverages);
        } else if (payorList != null) {
            payors = payorList;
        }
        if (payors.size() > 0) {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: payer[0]: " + payors.get(0).getName());
        } else {
            // default to CMS if no payer was provided
            logger.info("r4/FhirBundleProcessor::createCriteriaList: empty payers list, working around by adding CMS!");
            Organization org = new Organization().setName("Centers for Medicare and Medicaid Services");
            // how to get ID
            org.setId("75f39025-65db-43c8-9127-693cdf75e712");
            payors.add(org);
        // remove the exception to use CMS if no payer is provided
        // JIRA ticket https://jira.mitre.org/browse/DMEERX-894
        // throw new RequestIncompleteException("No Payer found in coverage resource, cannot find documentation.");
        }
        List<CoverageRequirementRuleCriteria> criteriaList = CoverageRequirementRuleCriteria.createQueriesFromR4(codings, payors);
        return criteriaList;
    } catch (RequestIncompleteException e) {
        // rethrow incomplete request exceptions
        throw e;
    } catch (Exception e) {
        // catch all remaining exceptions
        System.out.println(e);
        throw new RequestIncompleteException("Unable to parse list of codes, codesystems, and payors from a device request.");
    }
}
Also used : Logger(org.slf4j.Logger) CoverageRequirementRuleCriteria(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria) org.hl7.fhir.r4.model(org.hl7.fhir.r4.model) LoggerFactory(org.slf4j.LoggerFactory) RuleMapping(org.hl7.davinci.endpoint.database.RuleMapping) CqlExecutionContextBuilder(org.hl7.davinci.endpoint.cql.r4.CqlExecutionContextBuilder) FileStore(org.hl7.davinci.endpoint.files.FileStore) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) CoverageRequirementRuleResult(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleResult) CqlRule(org.hl7.davinci.endpoint.cql.CqlRule) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException) Utilities(org.hl7.davinci.r4.Utilities) CoverageRequirementRuleCriteria(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException) ArrayList(java.util.ArrayList) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException)

Example 83 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project nia-patient-switching-standard-adaptor by NHSDigital.

the class PatientMapper method mapToPatient.

public Patient mapToPatient(RCMRMT030101UK04Patient patient, Organization organization) {
    String nhsNumber = patient.getId().getExtension();
    Patient mappedPatient = createPatient(nhsNumber);
    if (organization != null) {
        mappedPatient.setManagingOrganization(new Reference(organization));
    }
    return mappedPatient;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) RCMRMT030101UK04Patient(org.hl7.v3.RCMRMT030101UK04Patient) Patient(org.hl7.fhir.dstu3.model.Patient)

Example 84 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project nia-patient-switching-standard-adaptor by NHSDigital.

the class DocumentReferenceMapper method mapDocumentReference.

private DocumentReference mapDocumentReference(RCMRMT030101UK04NarrativeStatement narrativeStatement, RCMRMT030101UK04EhrComposition ehrComposition, Patient patient, RCMRMT030101UK04EhrExtract ehrExtract, List<Encounter> encounterList, Organization organization) {
    DocumentReference documentReference = new DocumentReference();
    var id = narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot();
    documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
    documentReference.setId(id);
    documentReference.getMeta().addProfile(META_PROFILE);
    documentReference.setStatus(DocumentReferenceStatus.CURRENT);
    documentReference.setType(getType(narrativeStatement));
    documentReference.setSubject(new Reference(patient));
    documentReference.setIndexedElement(getIndexed(ehrExtract));
    documentReference.setDescription(buildDescription(narrativeStatement));
    documentReference.setCustodian(new Reference(organization));
    getAuthor(narrativeStatement, ehrComposition).ifPresent(documentReference::addAuthor);
    if (narrativeStatement.hasAvailabilityTime() && narrativeStatement.getAvailabilityTime().hasValue()) {
        documentReference.setCreatedElement(DateFormatUtil.parseToDateTimeType(narrativeStatement.getAvailabilityTime().getValue()));
    }
    var encounterReference = encounterList.stream().filter(encounter -> encounter.getId().equals(ehrComposition.getId().getRoot())).findFirst().map(Reference::new);
    if (encounterReference.isPresent()) {
        DocumentReference.DocumentReferenceContextComponent documentReferenceContextComponent = new DocumentReference.DocumentReferenceContextComponent().setEncounter(encounterReference.get());
        documentReference.setContext(documentReferenceContextComponent);
    }
    setContentAttachments(documentReference, narrativeStatement);
    return documentReference;
}
Also used : ParticipantReferenceUtil.getParticipantReference(uk.nhs.adaptors.pss.translator.util.ParticipantReferenceUtil.getParticipantReference) Reference(org.hl7.fhir.dstu3.model.Reference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference) DocumentReference(org.hl7.fhir.dstu3.model.DocumentReference)

Example 85 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AgentDirectoryMapperTest method mapAgentDirectoryOnlyAgentOrganizationUnknownName.

@Test
public void mapAgentDirectoryOnlyAgentOrganizationUnknownName() {
    var agentDirectory = unmarshallAgentDirectoryElement("agent_org_no_name_example.xml");
    List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory);
    assertThat(mappedAgents.size()).isEqualTo(1);
    var organization = (Organization) mappedAgents.get(0);
    assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA");
    assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE);
    assertThat(organization.getName()).isEqualTo("Unknown");
    assertThat(organization.getIdentifier().size()).isEqualTo(0);
    assertThat(organization.getTelecom().size()).isEqualTo(0);
    assertThat(organization.getAddress().size()).isEqualTo(0);
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16