use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project kindling by HL7.
the class XmlValidator method checkBySchema.
public Element checkBySchema(String fileToCheck, boolean wantThrow) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException, FHIRException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
factory.setSchema(schema);
DocumentBuilder builder = factory.newDocumentBuilder();
MyErrorHandler err = new MyErrorHandler(errors, fileToCheck);
builder.setErrorHandler(err);
CSFileInputStream f = new CSFileInputStream(new CSFile(fileToCheck));
Document doc = builder.parse(f);
if (wantThrow && err.getErrors().size() > 0)
throw new FHIRException("File " + fileToCheck + " failed schema validation");
return doc.getDocumentElement();
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project kindling by HL7.
the class FhirTurtleGenerator method genBaseMetadata.
/**
* Emit all the basic atoms that are implicit in the actual model
*/
private void genBaseMetadata() {
// Declare these for now - they will get filled in more completely later on
FHIRResource Resource = fact.fhir_class("Resource");
FHIRResource Element = fact.fhir_class("Element");
FHIRResource Reference = fact.fhir_class("Reference");
// Primitive isn't in the actual model - added here
fact.fhir_class("Primitive").addTitle("Types with only a value").addDefinition("Types with only a value and no additional elements as children").restriction(fact.fhir_restriction(value, RDFS.Literal));
// A resource can have an optional nodeRole
FHIRResource treeRoot = fact.fhir_class("treeRoot").addTitle("Class of FHIR base documents");
FHIRResource nodeRole = fact.fhir_objectProperty("nodeRole").addTitle("Identifies role of subject in context of a given document").domain(Resource).range(treeRoot.resource);
Resource.restriction(fact.fhir_cardinality_restriction(nodeRole.resource, treeRoot.resource, 0, 1));
// Any element can have an index to assign order in a list
FHIRResource index = fact.fhir_dataProperty("index").addTitle("Ordering value for list").domain(Element).range(XSD.nonNegativeInteger);
Element.restriction(fact.fhir_cardinality_restriction(index.resource, XSD.nonNegativeInteger, 0, 1));
// References have an optional link
FHIRResource link = fact.fhir_objectProperty("link").addTitle("URI of a reference");
Reference.restriction(fact.fhir_cardinality_restriction(link.resource, Resource.resource, 0, 1));
// XHTML is an XML Literal -- but it isn't recognized by OWL so we use string
FHIRResource NarrativeDiv = fact.fhir_dataProperty("Narrative.div");
fact.fhir_class("xhtml", "Primitive").restriction(fact.fhir_cardinality_restriction(value, fact.fhir_datatype(XSD.xstring).resource, 1, 1));
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_status_test.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_status_test(String segment) {
// Check TXA.19
// TXA.19 value maps to status; OBR.25 is ignored
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||||201801180346||<PHYSID1>||||||||PA||OB|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus status = report.getStatus();
// TXA.19
assertThat(status.toCode()).isEqualTo("superseded");
assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
// Check OBR.25 as fallback
// TXA.19 value is empty so OBR.25 is used
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|||||X\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA|||||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
status = report.getStatus();
// OBR.25
assertThat(status.toCode()).isEqualTo("entered-in-error");
assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
// Check default value case
// TXA.19 and OBR.25 values are empty so should fallback to "current"
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\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA\n" + "OBX|1|SN|||||||||X";
report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
status = report.getStatus();
// default value
assertThat(status.toCode()).isEqualTo("current");
assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT 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.r4.model.Bundle.BundleType.DOCUMENT in project quality-measure-and-cohort-service by Alvearie.
the class CqlEvaluatorIntegrationTest method testUOMEquivalence_demonstrateEqualityIssue.
/*
* The following `testUOMEquivalence` tests are intended to document the engine behavior
* when an author attempts to compare quantities with different UoM values.
*/
@Test
public void testUOMEquivalence_demonstrateEqualityIssue() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1983-12-02");
CqlEvaluator evaluator = setupTestFor(patient, "cql.uomequivalence");
String expression = "IsEqual";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestUOMCompare", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
// when you compare two quantities with different UoM, the
// the engine returns null.
expected.put(expression, null);
Assert.assertEquals(expected, actual.getExpressionResults());
}
Aggregations