use of org.hl7.fhir.dstu3.model.ListResource 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.ListResource in project integration-adaptor-111 by nhsconnect.
the class ListMapper method mapList.
public ListResource mapList(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, Collection<Resource> resourcesCreated, Reference deviceRef) {
ListResource listResource = new ListResource();
listResource.setIdElement(resourceUtil.newRandomUuid());
Identifier docIdentifier = new Identifier();
docIdentifier.setUse(USUAL);
docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
listResource.setStatus(CURRENT).setTitle(LIST_TITLE).setMode(WORKING).setCode(createCodeConcept()).setSubject(encounter.getSubject()).setSourceTarget(encounter.getSubjectTarget()).setEncounter(resourceUtil.createReference(encounter)).setEncounterTarget(encounter).setDateElement(DateUtil.parse(clinicalDocument.getEffectiveTime().getValue())).setSource(deviceRef).setOrderedBy(createOrderByConcept());
resourcesCreated.stream().sorted(resourceDateComparator).filter(it -> TRIAGE_RESOURCES.contains(it.getResourceType()) && it.hasId()).map(resourceUtil::createReference).map(ListResource.ListEntryComponent::new).forEach(listResource::addEntry);
return listResource;
}
use of org.hl7.fhir.dstu3.model.ListResource in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluation method addPopulationCriteriaReport.
private void addPopulationCriteriaReport(MeasureReport report, MeasureReport.MeasureReportGroupComponent reportGroup, Measure.MeasureGroupPopulationComponent populationCriteria, int populationCount, Iterable<Patient> patientPopulation) {
if (populationCriteria != null) {
MeasureReport.MeasureReportGroupPopulationComponent populationReport = new MeasureReport.MeasureReportGroupPopulationComponent();
populationReport.setCode(populationCriteria.getCode());
if (report.getType() == MeasureReport.MeasureReportType.SUBJECTLIST && patientPopulation != null) {
ListResource subjectList = new ListResource();
subjectList.setId(UUID.randomUUID().toString());
populationReport.setSubjectResults(new Reference().setReference("#" + subjectList.getId()));
for (Patient patient : patientPopulation) {
ListResource.ListEntryComponent entry = new ListResource.ListEntryComponent().setItem(new Reference().setReference(patient.getIdElement().getIdPart().startsWith("Patient/") ? patient.getIdElement().getIdPart() : String.format("Patient/%s", patient.getIdElement().getIdPart())).setDisplay(patient.getNameFirstRep().getNameAsSingleString()));
subjectList.addEntry(entry);
}
report.addContained(subjectList);
}
populationReport.setCount(populationCount);
reportGroup.addPopulation(populationReport);
}
}
use of org.hl7.fhir.dstu3.model.ListResource in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_patient_list_report_generated.
@Test
public void measure_patient_list_report_generated() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient1 = getPatient("1", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient1);
Patient patient2 = getPatient("2", AdministrativeGender.FEMALE, "1970-10-10");
mockFhirResourceRetrieval(patient2);
List<String> patientIds = new ArrayList<>();
patientIds.add(patient1.getId());
patientIds.add(patient2.getId());
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.cql", "text/cql", "cql/fhir-measure/test-dummy-populations.xml", "application/elm+xml");
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
MeasureReport report = evaluator.evaluatePatientListMeasure(patientIds, measure, null, null);
assertNotNull(report);
List<ListResource.ListEntryComponent> patientList = ((ListResource) report.getContained().get(0)).getEntry();
List<String> actualPatientIds = patientList.stream().map(a -> StringUtils.removeStart(a.getItem().getReference(), "Patient/")).collect(Collectors.toList());
assertThat(actualPatientIds, Matchers.containsInAnyOrder(patient1.getId(), patient2.getId()));
}
use of org.hl7.fhir.dstu3.model.ListResource in project kindling by HL7.
the class Regenerator method generateOperations.
public void generateOperations(ResourceDefn r, String root) throws IOException {
ListResource list = new ListResource();
list.setId(r.getName() + "-operations");
list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.WORKING);
for (Operation op : r.getOperations()) {
ListResourceEntryComponent li = list.addEntry();
li.getItem().setReference("OperationDefinition/" + r.getName() + "-" + op.getName());
}
File fn = new File(Utilities.path(root, list.fhirType().toLowerCase() + "-" + list.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), list);
fn.setLastModified(r.getTimestamp());
for (Operation op : r.getOperations()) {
generateOperation(root, r, op);
}
}
Aggregations