Search in sources :

Example 41 with QuestionnaireResponse

use of org.hl7.fhir.r5.model.QuestionnaireResponse 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 42 with QuestionnaireResponse

use of org.hl7.fhir.r5.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.

the class PathwayUtil method getQuestionnaireResponses.

public List<QuestionnaireResponse> getQuestionnaireResponses(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Reference patient, Reference encounter) throws XmlException {
    List<QuestionnaireResponse> questionnaireResponseList = new ArrayList<>();
    String pathwaysCase = findPathwaysCase(clinicalDocument);
    if (pathwaysCase != null) {
        PathwaysCase pathwaysCaseDocument = PathwaysCaseDocument.Factory.parse(pathwaysCase).getPathwaysCase();
        TriageLine[] triageLineArray = pathwaysCaseDocument.getPathwayDetails().getPathwayTriageDetails().getPathwayTriageArray(0).getTriageLineDetails().getTriageLineArray();
        for (TriageLine traigeLine : triageLineArray) {
            questionnaireResponseList.add(questionnaireResponseMapper.mapQuestionnaireResponse(pathwaysCaseDocument, patient, encounter, traigeLine));
        }
        return questionnaireResponseList;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) TriageLine(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) PathwaysCase(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase)

Example 43 with QuestionnaireResponse

use of org.hl7.fhir.r5.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireResponseMapper method mapQuestionnaireResponse.

public QuestionnaireResponse mapQuestionnaireResponse(PathwaysCase pathwaysCase, Reference patient, Reference encounter, TriageLine triageLine) {
    QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
    Questionnaire questionnaire = questionnaireMapper.mapQuestionnaire(pathwaysCase, triageLine);
    questionnaireResponse.setIdElement(resourceUtil.newRandomUuid());
    questionnaireResponse.setQuestionnaire(resourceUtil.createReference(questionnaire)).setQuestionnaireTarget(questionnaire).setStatus(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED).setSubject(patient).setContext(encounter);
    if (pathwaysCase.getCaseDetails() != null) {
        if (pathwaysCase.getCaseDetails().isSetCaseId()) {
            questionnaireResponse.setIdentifier(new Identifier().setValue(pathwaysCase.getCaseDetails().getCaseId()));
        }
    }
    if (pathwaysCase.isSetCaseReceiveEnd()) {
        questionnaireResponse.setAuthored(DateUtil.parsePathwaysDate(pathwaysCase.getCaseReceiveEnd().toString()));
    }
    if (triageLine.getQuestion() != null) {
        questionnaireResponse.addItem(getItem(triageLine.getQuestion()));
    }
    return questionnaireResponse;
}
Also used : Questionnaire(org.hl7.fhir.dstu3.model.Questionnaire) Identifier(org.hl7.fhir.dstu3.model.Identifier) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse)

Example 44 with QuestionnaireResponse

use of org.hl7.fhir.r5.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.

the class ListMapperTest method setUp.

@BeforeEach
public void setUp() {
    effectiveTime.setValue(EFFECTIVE_DATE);
    HealthcareService healthcareService = new HealthcareService();
    healthcareService.setId("123456");
    QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
    questionnaireResponse.setId("654321");
    resourcesCreated = asList(healthcareService, questionnaireResponse);
    when(clinicalDocument.getSetId()).thenReturn(ii);
    when(ii.getRoot()).thenReturn("411910CF-1A76-4330-98FE-C345DDEE5553");
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    when(clinicalDocument.getEffectiveTime()).thenReturn(effectiveTime);
}
Also used : HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) IdType(org.hl7.fhir.dstu3.model.IdType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 45 with QuestionnaireResponse

use of org.hl7.fhir.r5.model.QuestionnaireResponse 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)

Aggregations

QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)15 ArrayList (java.util.ArrayList)14 Bundle (org.hl7.fhir.r4.model.Bundle)11 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)8 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)8 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)8 Test (org.junit.jupiter.api.Test)8 Reference (org.hl7.fhir.dstu3.model.Reference)7 Reference (org.hl7.fhir.r4.model.Reference)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 Map (java.util.Map)5 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)5 FhirUtil (org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil)5 Coding (org.hl7.fhir.r4.model.Coding)4 Date (java.util.Date)3 Getter (lombok.Getter)3 Bundle (org.hl7.fhir.dstu3.model.Bundle)3