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