Search in sources :

Example 31 with CarePlan

use of org.hl7.fhir.dstu3.model.CarePlan 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 32 with CarePlan

use of org.hl7.fhir.dstu3.model.CarePlan 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 33 with CarePlan

use of org.hl7.fhir.dstu3.model.CarePlan 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 34 with CarePlan

use of org.hl7.fhir.dstu3.model.CarePlan in project integration-adaptor-111 by nhsconnect.

the class CarePlanMapperTest method shouldMapITKReportToCarePlan.

@Test
public void shouldMapITKReportToCarePlan() {
    mockSection();
    List<CarePlan> carePlans = carePlanMapper.mapCarePlan(clinicalDocument, encounter, condition);
    assertThat(carePlans).isNotEmpty();
    CarePlan carePlan = carePlans.get(0);
    assertThat(carePlan.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(carePlan.getStatus()).isEqualTo(CarePlan.CarePlanStatus.COMPLETED);
    assertThat(carePlan.getIntent()).isEqualTo(CarePlan.CarePlanIntent.PLAN);
    assertThat(carePlan.getContext().getResource()).isEqualTo(encounter);
    assertThat(carePlan.getContextTarget()).isEqualTo(encounter);
    assertThat(carePlan.getPeriod()).isEqualTo(period);
    assertThat(carePlan.getSubject()).isEqualTo(encounter.getSubject());
    assertThat(carePlan.getSubjectTarget()).isEqualTo(encounter.getSubjectTarget());
    assertThat(carePlan.getLanguage()).isEqualTo(LANG);
    assertThat(carePlan.getTitle()).isEqualTo(TITLE);
    assertThat(carePlan.getDescription()).isEqualTo(DESCRIPTION);
    assertThat(carePlan.getAuthor().get(0)).isEqualTo(organization);
    assertThat(carePlan.getAddresses().get(0).getResource()).isEqualTo(condition);
}
Also used : CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Test(org.junit.jupiter.api.Test)

Example 35 with CarePlan

use of org.hl7.fhir.dstu3.model.CarePlan in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCarePlan.

protected void composeCarePlan(Complex parent, String parentType, String name, CarePlan element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "CarePlan", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "CarePlan", "identifier", element.getIdentifier().get(i), i);
    if (element.hasSubject())
        composeReference(t, "CarePlan", "subject", element.getSubject(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "CarePlan", "status", element.getStatusElement(), -1);
    if (element.hasContext())
        composeReference(t, "CarePlan", "context", element.getContext(), -1);
    if (element.hasPeriod())
        composePeriod(t, "CarePlan", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "CarePlan", "author", element.getAuthor().get(i), i);
    if (element.hasModifiedElement())
        composeDateTime(t, "CarePlan", "modified", element.getModifiedElement(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "CarePlan", "category", element.getCategory().get(i), i);
    if (element.hasDescriptionElement())
        composeString(t, "CarePlan", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getAddresses().size(); i++) composeReference(t, "CarePlan", "addresses", element.getAddresses().get(i), i);
    for (int i = 0; i < element.getSupport().size(); i++) composeReference(t, "CarePlan", "support", element.getSupport().get(i), i);
    for (int i = 0; i < element.getRelatedPlan().size(); i++) composeCarePlanCarePlanRelatedPlanComponent(t, "CarePlan", "relatedPlan", element.getRelatedPlan().get(i), i);
    for (int i = 0; i < element.getParticipant().size(); i++) composeCarePlanCarePlanParticipantComponent(t, "CarePlan", "participant", element.getParticipant().get(i), i);
    for (int i = 0; i < element.getGoal().size(); i++) composeReference(t, "CarePlan", "goal", element.getGoal().get(i), i);
    for (int i = 0; i < element.getActivity().size(); i++) composeCarePlanCarePlanActivityComponent(t, "CarePlan", "activity", element.getActivity().get(i), i);
    if (element.hasNote())
        composeAnnotation(t, "CarePlan", "note", element.getNote(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

Test (org.junit.jupiter.api.Test)14 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)10 CarePlan (org.hl7.fhir.dstu3.model.CarePlan)8 Reference (org.hl7.fhir.dstu3.model.Reference)7 ArrayList (java.util.ArrayList)6 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 Reference (org.hl7.fhir.r4.model.Reference)4 Date (java.util.Date)3 Composition (org.hl7.fhir.dstu3.model.Composition)3 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)3 Encounter (org.hl7.fhir.dstu3.model.Encounter)3 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)3 CarePlan (org.hl7.fhir.r4.model.CarePlan)3 CarePlan (org.mitre.synthea.world.concepts.HealthRecord.CarePlan)3 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)2 Operation (ca.uhn.fhir.rest.annotation.Operation)2 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 Bundle (org.hl7.fhir.dstu3.model.Bundle)2 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)2