Search in sources :

Example 36 with ListResource

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;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) Composition(org.hl7.fhir.dstu3.model.Composition) Bundle(org.hl7.fhir.dstu3.model.Bundle) Device(org.hl7.fhir.dstu3.model.Device) HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Consent(org.hl7.fhir.dstu3.model.Consent) Observation(org.hl7.fhir.dstu3.model.Observation) Encounter(org.hl7.fhir.dstu3.model.Encounter) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 37 with ListResource

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;
}
Also used : USUAL(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL) Reference(org.hl7.fhir.dstu3.model.Reference) Identifier(org.hl7.fhir.dstu3.model.Identifier) Resource(org.hl7.fhir.dstu3.model.Resource) Collection(java.util.Collection) Coding(org.hl7.fhir.dstu3.model.Coding) RequiredArgsConstructor(lombok.RequiredArgsConstructor) DateUtil(uk.nhs.adaptors.oneoneone.cda.report.util.DateUtil) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) ListResource(org.hl7.fhir.dstu3.model.ListResource) Encounter(org.hl7.fhir.dstu3.model.Encounter) List(java.util.List) Component(org.springframework.stereotype.Component) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) ResourceDateComparator(uk.nhs.adaptors.oneoneone.cda.report.comparator.ResourceDateComparator) ResourceUtil(uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil) POCDMT000002UK01ClinicalDocument1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1) WORKING(org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING) CURRENT(org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT) Identifier(org.hl7.fhir.dstu3.model.Identifier) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 38 with 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);
    }
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) ListResource(org.hl7.fhir.r4.model.ListResource) ListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent)

Example 39 with ListResource

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()));
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_VALUE_URL) Range(org.hl7.fhir.r4.model.Range) StringUtils(org.apache.commons.lang3.StringUtils) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) InvalidOperatorArgument(org.opencds.cqf.cql.engine.exception.InvalidOperatorArgument) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) HumanName(org.hl7.fhir.r4.model.HumanName) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) Map(java.util.Map) StringType(org.hl7.fhir.r4.model.StringType) Assert.fail(org.junit.Assert.fail) ParseException(java.text.ParseException) IntegerType(org.hl7.fhir.r4.model.IntegerType) Patient(org.hl7.fhir.r4.model.Patient) DefineReturnOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions.DefineReturnOptions) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) DateType(org.hl7.fhir.r4.model.DateType) TimeZone(java.util.TimeZone) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Period(org.hl7.fhir.r4.model.Period) MEASURE_PARAMETER_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_URL) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Collectors(java.util.stream.Collectors) PARAMETER_DEFAULT_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_DEFAULT_URL) TimeType(org.hl7.fhir.r4.model.TimeType) List(java.util.List) BooleanType(org.hl7.fhir.r4.model.BooleanType) Assert.assertFalse(org.junit.Assert.assertFalse) Coding(org.hl7.fhir.r4.model.Coding) WireMock.getRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor) Extension(org.hl7.fhir.r4.model.Extension) UriType(org.hl7.fhir.r4.model.UriType) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) UnsupportedFhirTypeException(com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) HashMap(java.util.HashMap) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) Measure(org.hl7.fhir.r4.model.Measure) ArrayList(java.util.ArrayList) Address(org.hl7.fhir.r4.model.Address) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) MEASURE_PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_VALUE_URL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Quantity(org.hl7.fhir.r4.model.Quantity) Ratio(org.hl7.fhir.r4.model.Ratio) MeasureSupplementalDataEvaluation(com.ibm.cohort.engine.cqfruler.MeasureSupplementalDataEvaluation) DecimalType(org.hl7.fhir.r4.model.DecimalType) Before(org.junit.Before) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) Assert.assertNotNull(org.junit.Assert.assertNotNull) ListResource(org.hl7.fhir.r4.model.ListResource) Library(org.hl7.fhir.r4.model.Library) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers(org.hamcrest.Matchers) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.Test) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) WireMock.verify(com.github.tomakehurst.wiremock.client.WireMock.verify) WireMock.urlMatching(com.github.tomakehurst.wiremock.client.WireMock.urlMatching) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) CDMConstants(com.ibm.cohort.engine.cdm.CDMConstants) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) InstantType(org.hl7.fhir.r4.model.InstantType) AdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) WireMock.urlEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo) Assert.assertEquals(org.junit.Assert.assertEquals) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) ArrayList(java.util.ArrayList) Measure(org.hl7.fhir.r4.model.Measure) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Library(org.hl7.fhir.r4.model.Library) ListResource(org.hl7.fhir.r4.model.ListResource) Test(org.junit.Test)

Example 40 with ListResource

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);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) FileOutputStream(java.io.FileOutputStream) Operation(org.hl7.fhir.definitions.model.Operation) ListResource(org.hl7.fhir.r5.model.ListResource) File(java.io.File)

Aggregations

ListResource (org.hl7.fhir.r5.model.ListResource)12 Element (org.w3c.dom.Element)12 ListResourceEntryComponent (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent)11 ListResource (org.hl7.fhir.dstu3.model.ListResource)10 Reference (org.hl7.fhir.dstu3.model.Reference)10 ListEntryComponent (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)9 ArrayList (java.util.ArrayList)8 ListResource (org.hl7.fhir.r4.model.ListResource)8 Reference (org.hl7.fhir.r4.model.Reference)6 HashMap (java.util.HashMap)5 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)5 SectionComponent (org.hl7.fhir.dstu3.model.Composition.SectionComponent)4 Patient (org.hl7.fhir.r4.model.Patient)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 List (java.util.List)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)2