use of org.hl7.fhir.r5.model.Composition in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_doc_status_test.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_doc_status_test(String segment) {
String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||PA||AV|||<PHYSID2>||\n" + "OBX|1|ST|100||This is content|||||||X\n";
DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
DocumentReference.ReferredDocumentStatus docStatus = report.getDocStatus();
// TXA.17
assertThat(docStatus.toCode()).isEqualTo("preliminary");
assertThat(docStatus.getDefinition()).contains("This is a preliminary composition or document (also known as initial or interim).");
assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
// Check OBX.11 as fallback
documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1|||555|||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||F";
report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
docStatus = report.getDocStatus();
// OBX.11
assertThat(docStatus.toCode()).isEqualTo("final");
assertThat(docStatus.getDefinition()).contains("This version of the composition is complete and verified by an appropriate person and no further work is planned.");
assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
// Check a value that is not mapped results is no docStatus
documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS\n" + "OBR|1|||555|||20170825010500|||||||||||||002|||||F\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
// OBX-11 'X' is not mapped
assertThat(report.getDocStatus()).isNull();
}
use of org.hl7.fhir.r5.model.Composition in project cqf-ruler by DBCG.
the class CareGapsProvider method patientReports.
// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
private Parameters.ParametersParameterComponent patientReports(RequestDetails requestDetails, String periodStart, String periodEnd, Patient patient, List<String> status, List<Measure> measures, String organization) {
// TODO: add organization to report, if it exists.
Composition composition = getComposition(patient);
List<DetectedIssue> detectedIssues = new ArrayList<>();
Map<String, Resource> evaluatedResources = new HashMap<>();
List<MeasureReport> reports = getReports(requestDetails, periodStart, periodEnd, patient, status, measures, composition, detectedIssues, evaluatedResources);
if (reports.isEmpty()) {
return null;
}
return initializePatientParameter(patient).setResource(addBundleEntries(requestDetails.getFhirServerBase(), composition, detectedIssues, reports, evaluatedResources));
}
use of org.hl7.fhir.r5.model.Composition in project summary-care-record-api by NHSDigital.
the class GpSummaryMapper method addAuthorOrganisation.
private void addAuthorOrganisation(Node document, List<Resource> resources, Composition composition) {
xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_SDS_XPATH).ifPresent(agentOrganisationSds -> {
Organization organisation = organisationSdsMapper.mapOrganizationSds(agentOrganisationSds);
resources.add(organisation);
composition.addAuthor(new Reference(organisation));
});
xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_XPATH).ifPresent(agentOrganisation -> {
List<? extends Resource> organisationResources = agentOrganisationMapper.map(agentOrganisation);
resources.addAll(organisationResources);
composition.addAuthor(findPractitionerRole(organisationResources));
});
}
use of org.hl7.fhir.r5.model.Composition in project summary-care-record-api by NHSDigital.
the class GpSummaryMapper method map.
@SneakyThrows
public List<Resource> map(Node document) {
var gpSummaryId = xmlUtils.getValueByXPath(document, GP_SUMMARY_ID_XPATH);
var gpSummaryCodeCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_CODE_XPATH);
var gpSummaryCodeDisplayName = xmlUtils.getValueByXPath(document, GP_SUMMARY_CODE_DISPLAY_NAME_XPATH);
var gpSummaryStatusCode = xmlUtils.getValueByXPath(document, GP_SUMMARY_STATUS_CODE_XPATH);
var gpSummaryEffectiveTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_EFFECTIVE_TIME_XPATH), InstantType.class);
var authorTime = parseDate(xmlUtils.getValueByXPath(document, GP_SUMMARY_AUTHOR_TIME_XPATH), DateTimeType.class);
var replacementOfPriorMessageRefIdRoot = xmlUtils.getOptionalValueByXPath(document, REPLACEMENT_OF_PRIOR_MESSAGE_REF_ID_ROOT_XPATH);
var pertinentRootCreTypeCodeCode = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_CODE_XPATH);
var pertinentRootCreTypeCodeDisplayName = xmlUtils.getValueByXPath(document, PERTINENT_ROOT_CRE_TYPE_CODE_DISPLAY_NAME_XPATH);
var presentationTextValue = xmlUtils.detachOptionalNodeByXPath(document, PRESENTATION_TEXT_VALUE);
var eventId = xmlUtils.getValueByXPath(document, EVENT_ID_XPATH);
List<Resource> resources = new ArrayList<>();
var composition = new Composition();
composition.setId(eventId);
composition.setIdentifier(new Identifier().setValue(gpSummaryId).setSystem("https://tools.ietf.org/html/rfc4122"));
composition.setType(new CodeableConcept().addCoding(new Coding().setCode(gpSummaryCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(gpSummaryCodeDisplayName)));
composition.setMeta(new Meta().setLastUpdatedElement(gpSummaryEffectiveTime));
composition.setStatus(mapCompositionStatus(gpSummaryStatusCode));
composition.setDateElement(authorTime);
replacementOfPriorMessageRefIdRoot.ifPresent(val -> composition.addRelatesTo(new Composition.CompositionRelatesToComponent().setTarget(new Identifier().setValue(val)).setCode(REPLACES)));
composition.addCategory(new CodeableConcept().addCoding(new Coding().setCode(pertinentRootCreTypeCodeCode).setSystem(SNOMED_SYSTEM).setDisplay(pertinentRootCreTypeCodeDisplayName)));
Map<String, List<String>> references = sectionReferences(document);
presentationTextValue.map(htmlParser::parse).map(Collection::stream).ifPresent(it -> it.forEach(section -> {
if (section.getTitle() != null && CODED_ENTRY_RESOURCE_MAP.keySet().contains(section.getTitle()) && references.containsKey(section.getTitle())) {
for (String codedEntryId : references.get(section.getTitle())) {
section.addEntry(new Reference(CODED_ENTRY_RESOURCE_MAP.get(section.getTitle()) + "/" + codedEntryId));
}
}
composition.addSection(section);
}));
resources.add(composition);
addAuthor(document, resources, composition);
return resources;
}
use of org.hl7.fhir.r5.model.Composition in project summary-care-record-api by NHSDigital.
the class GetScrService method setPatientReferences.
private void setPatientReferences(Resource resource, Patient patient) {
if (resource instanceof RelatedPerson) {
RelatedPerson relatedPerson = (RelatedPerson) resource;
relatedPerson.setPatient(new Reference(patient));
} else if (resource instanceof Composition) {
Composition composition = (Composition) resource;
composition.setSubject(new Reference(patient));
}
}
Aggregations