Search in sources :

Example 41 with Composition

use of org.hl7.fhir.r4.model.Composition in project integration-adaptor-111 by nhsconnect.

the class CompositionMapper method addPathwaysToSection.

private void addPathwaysToSection(Composition composition, List<QuestionnaireResponse> questionnaireResponseList) {
    String questionnaireResponseTitle = "QuestionnaireResponse";
    for (QuestionnaireResponse questionnaireResponse : questionnaireResponseList) {
        SectionComponent sectionComponent = new SectionComponent();
        sectionComponent.addEntry(resourceUtil.createReference(questionnaireResponse));
        sectionComponent.setTitle(questionnaireResponseTitle);
        composition.addSection(sectionComponent);
    }
}
Also used : QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 42 with Composition

use of org.hl7.fhir.r4.model.Composition in project integration-adaptor-111 by nhsconnect.

the class EncounterReportBundleServiceTest method setUp.

@BeforeEach
public void setUp() throws XmlException {
    INT versionNumber = mock(INT.class);
    when(versionNumber.getValue()).thenReturn(VERSION);
    when(document.getVersionNumber()).thenReturn(versionNumber);
    when(document.getEffectiveTime()).thenReturn(ts);
    when(ts.getValue()).thenReturn(EFFECTIVE_TIME);
    List<QuestionnaireResponse> questionnaireResponseList = new ArrayList<>();
    questionnaireResponseList.add(QUESTIONNAIRE_RESPONSE);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    when(encounterMapper.mapEncounter(any(), any(), any(), any())).thenReturn(ENCOUNTER);
    when(conditionMapper.mapCondition(any(), any(), any())).thenReturn(CONDITION);
    when(compositionMapper.mapComposition(any(), any(), any(), any(), any(), any())).thenReturn(COMPOSITION);
    when(listMapper.mapList(any(), any(), any(), any())).thenReturn(LIST_RESOURCE);
    when(carePlanMapper.mapCarePlan(any(), any(), any())).thenReturn(singletonList(CAREPLAN));
    when(healthcareServiceMapper.mapHealthcareService(any())).thenReturn(singletonList(HEALTHCARE_SERVICE));
    when(consentMapper.mapConsent(any(), any())).thenReturn(CONSENT);
    when(pathwayUtil.getQuestionnaireResponses(any(), any(), any())).thenReturn(questionnaireResponseList);
    when(messageHeaderService.createMessageHeader(any(), any(), eq(EFFECTIVE_TIME))).thenReturn(MESSAGE_HEADER);
    when(referralRequestMapper.mapReferralRequest(any(), any(), any(), any(), any())).thenReturn(REFERRAL_REQUEST);
    when(observationMapper.mapObservations(any(), eq(ENCOUNTER))).thenReturn(Arrays.asList(OBSERVATION));
    when(practitionerRoleMapper.mapAuthorRoles(any())).thenReturn(singletonList(AUTHOR_ROLE));
    when(practitionerRoleMapper.mapResponsibleParty(any())).thenReturn(Optional.of(PRACTITIONER_ROLE));
    when(relatedPersonMapper.createEmergencyContactRelatedPerson(eq(document), eq(ENCOUNTER))).thenReturn(RELATED_PERSON);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    Encounter.DiagnosisComponent diagnosisComponent = new Encounter.DiagnosisComponent();
    diagnosisComponent.setCondition(new Reference());
    diagnosisComponent.setRole(new CodeableConcept());
    diagnosisComponent.setRank(1);
    diagnosisComponent.setConditionTarget(CONDITION);
    ENCOUNTER.addDiagnosis(diagnosisComponent);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.dstu3.model.Encounter) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) INT(uk.nhs.connect.iucds.cda.ucr.INT) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 43 with Composition

use of org.hl7.fhir.r4.model.Composition 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 44 with Composition

use of org.hl7.fhir.r4.model.Composition in project integration-adaptor-111 by nhsconnect.

the class CompositionMapperTest method shouldMapComposition.

@Test
@SuppressWarnings("MagicNumber")
public void shouldMapComposition() {
    Composition composition = compositionMapper.mapComposition(clinicalDocument, encounter, carePlans, questionnaireResponseList, referralRequest, practitionerRoles);
    Coding code = composition.getType().getCodingFirstRep();
    String questionnaireResponseTitle = "QuestionnaireResponse";
    assertThat(composition.getTitle()).isEqualTo("111 Report");
    assertThat(code.getCode()).isEqualTo("371531000");
    assertThat(code.getSystem()).isEqualTo("http://snomed.info/sct");
    assertThat(code.getDisplay()).isEqualTo("Report of clinical encounter (record artifact)");
    assertThat(composition.getStatus()).isEqualTo(FINAL);
    assertThat(composition.getConfidentiality()).isEqualTo(Composition.DocumentConfidentiality.V);
    assertThat(composition.getRelatesTo().get(0).getCode()).isEqualTo(REPLACES);
    Composition.SectionComponent sectionComponent = composition.getSection().get(0);
    assertThat(sectionComponent.getSection().size()).isEqualTo(1);
    assertThat(sectionComponent.getSection().get(0).getTitle()).isEqualTo(NESTED_SECTION_TITLE);
    assertThat(sectionComponent.getSection().get(0).getText().getStatus()).isEqualTo(GENERATED);
    assertThat(sectionComponent.getSection().get(0).getText().getDivAsString()).isEqualTo(COMPOSITION_SECTION_DIV);
    assertThat(composition.getSection().get(1).getTitle()).isEqualTo("CarePlan");
    assertThat(composition.getSection().get(2).getTitle()).isEqualTo("ReferralRequest");
    assertThat(composition.getSection().get(3).getEntry().get(0).getResource()).isEqualTo(questionnaireResponse);
    assertThat(composition.getSection().get(3).getTitle()).isEqualTo(questionnaireResponseTitle);
    assertThat(composition.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(composition.getDateElement().getValue()).isEqualTo(DateUtil.parse(effectiveTime.getValue()).getValue());
}
Also used : Composition(org.hl7.fhir.dstu3.model.Composition) Coding(org.hl7.fhir.dstu3.model.Coding) TestResourceUtils.readResourceAsString(uk.nhs.adaptors.TestResourceUtils.readResourceAsString) Test(org.junit.jupiter.api.Test)

Example 45 with Composition

use of org.hl7.fhir.r4.model.Composition in project kindling by HL7.

the class SourceParser method parseConformanceDocument.

private void parseConformanceDocument(Profile pack, String n, File file, String usage, WorkGroup wg) throws Exception {
    try {
        Resource rf = new XmlParser().parse(new CSFileInputStream(file));
        if (!(rf instanceof Bundle))
            throw new Exception("Error parsing Profile: neither a spreadsheet nor a bundle");
        Bundle b = (Bundle) rf;
        if (b.getType() != BundleType.DOCUMENT)
            throw new Exception("Error parsing profile: neither a spreadsheet nor a bundle that is a document");
        for (BundleEntryComponent ae : ((Bundle) rf).getEntry()) {
            if (ae.getResource() instanceof Composition)
                pack.loadFromComposition((Composition) ae.getResource(), file.getAbsolutePath());
            else if (ae.getResource() instanceof StructureDefinition && !((StructureDefinition) ae.getResource()).getType().equals("Extension")) {
                StructureDefinition ed = (StructureDefinition) ae.getResource();
                for (StructureDefinitionContextComponent s : ed.getContext()) definitions.checkContextValid(s, file.getName(), this.context);
                ToolResourceUtilities.updateUsage(ed, pack.getCategory());
                pack.getProfiles().add(new ConstraintStructure(ed, definitions.getUsageIG(usage, "Parsing " + file.getAbsolutePath()), wg == null ? wg(ed) : wg, fmm(ed), ed.getExperimental()));
            } else if (ae.getResource() instanceof StructureDefinition) {
                StructureDefinition ed = (StructureDefinition) ae.getResource();
                if (Utilities.noString(ed.getBaseDefinition()))
                    ed.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Extension");
                ed.setDerivation(TypeDerivationRule.CONSTRAINT);
                if (ToolingExtensions.readStringExtension(ed, ToolingExtensions.EXT_WORKGROUP) == null)
                    ToolingExtensions.setCodeExtension(ed, ToolingExtensions.EXT_WORKGROUP, wg.getCode());
                if (!ed.hasUrl())
                    if (ae.hasFullUrl())
                        ed.setUrl(ae.getFullUrl());
                    else
                        ed.setUrl("http://hl7.org/fhir/StructureDefinition/" + ed.getId());
                context.cacheResource(ed);
                pack.getExtensions().add(ed);
            }
        }
    } catch (Exception e) {
        throw new Exception("Error Parsing profile: '" + n + "': " + e.getMessage(), e);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) Composition(org.hl7.fhir.r5.model.Composition) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) StructureDefinitionContextComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent) Bundle(org.hl7.fhir.r5.model.Bundle) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) Resource(org.hl7.fhir.r5.model.Resource) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)12 Coding (org.hl7.fhir.r4.model.Coding)8 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)7 Composition (org.hl7.fhir.r4.model.Composition)6 IOException (java.io.IOException)5 Composition (org.hl7.fhir.dstu3.model.Composition)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 Reference (org.hl7.fhir.r4.model.Reference)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Encounter (org.hl7.fhir.dstu3.model.Encounter)3 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 Map (java.util.Map)2