use of org.hl7.fhir.r4.model.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());
}
use of org.hl7.fhir.r4.model.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.");
}
}
use of org.hl7.fhir.r4.model.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;
}
use of org.hl7.fhir.r4.model.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;
}
use of org.hl7.fhir.r4.model.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);
}
Aggregations