use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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;
}
use of org.hl7.fhir.dstu2.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);
}
use of org.hl7.fhir.dstu2.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());
}
Aggregations