Beispiel #1
0
 def test_primitives(self):
     """
     FHIR periodically makes changes to the fhir data types.  This test determines whether there are any FHIR
     primitive types that aren't anchored in the XML space
     """
     g = FHIRGraph()
     tests = [
         self.is_xsd_primitive(p, g)
         for p in g.subjects(RDFS.subClassOf, FHIR.Primitive)
     ]
     self.assertTrue(all(tests))
Beispiel #2
0
 def setUpClass(cls):
     from tests.utils.base_test_case import FHIRGraph
     cls.fhir_ontology = FHIRGraph()
     cls.test_input_directory = os.path.join(
         os.path.split(os.path.abspath(__file__))[0], '..', 'data')
     cls.test_output_directory = os.path.join(
         os.path.split(os.path.abspath(__file__))[0], 'data_out')
Beispiel #3
0
 def test_decimal(self):
     test_json = loads(json_data)
     from fhirtordf.loaders.fhirresourceloader import FHIRResource
     test_rdf = FHIRResource(FHIRGraph(), None, "http://hl7.org/fhir", test_json, add_ontology_header=False)
     g = test_rdf.graph
     self.assertEqual({URIRef('http://hl7.org/fhir/Bundle/bundle-example'),
                       URIRef('https://example.com/base/MedicationRequest/3123')},
                      set(s for s in g.subjects() if isinstance(s, URIRef)))
Beispiel #4
0
 def test_reference(self):
     test_json = loads(data)
     from fhirtordf.loaders.fhirresourceloader import FHIRResource
     test_rdf = FHIRResource(FHIRGraph(), None, "http://hl7.org/fhir", test_json)
     g = test_rdf.graph
     expected_graph = Graph()
     diffs = rdf_compare(expected_graph, test_rdf.graph, ignore_owl_version=True, ignore_type_arcs=True)
     self.assertEqual("", diffs)
Beispiel #5
0
 def test_reference(self):
     test_json = loads(data)
     from fhirtordf.loaders.fhirresourceloader import FHIRResource
     test_rdf = FHIRResource(FHIRGraph(), None, "http://hl7.org/fhir",
                             test_json)
     g = test_rdf.graph
     subj = URIRef("http://hl7.org/fhir/EligibilityResponse/E2500")
     self.assertEqual(
         "http://www.BenefitsInc.com/fhir/eligibility/225476332402",
         str(
             g.value(g.value(subj, FHIR.EligibilityResponse.request),
                     FHIR.link)))
Beispiel #6
0
    def test_decimal(self):
        test_json = loads(json_data)
        from fhirtordf.loaders.fhirresourceloader import FHIRResource
        test_rdf = FHIRResource(FHIRGraph(), None, "http://hl7.org/fhir",
                                test_json)
        g = test_rdf.graph
        # rdflib supports decimal precision if you create the data as a string.
        self.assertNotEqual(Literal("2.00", datatype=XSD.decimal),
                            Literal("2.0", datatype=XSD.decimal))
        self.assertEqual(Literal(2.00), Literal(2.0))

        # FHIR requires that *all* decimals use the first form.  While the diopter example above
        # would work, issues arise in situations where numbers really ARE decimal...
        self.assertEqual(
            Literal("2.00", datatype=XSD.decimal),
            g.value(
                g.value(
                    g.value(
                        URIRef("http://hl7.org/fhir/VisionPrescription/33123"),
                        FHIR.VisionPrescription.dispense),
                    FHIR.VisionPrescription.dispense.add), FHIR.value))
 def setUpClass(cls):
     from tests.utils.base_test_case import FHIRGraph
     cls.fhir_ontology = FHIRGraph()
Beispiel #8
0
# Copyright (c) 2017, Mayo Clinic
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
#     list of conditions and the following disclaimer.
#
#     Redistributions in binary form must reproduce the above copyright notice,
#     this list of conditions and the following disclaimer in the documentation
#     and/or other materials provided with the distribution.
#
#     Neither the name of the Mayo Clinic nor the names of its contributors
#     may be used to endorse or promote products derived from this software
#     without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
from tests.utils.base_test_case import FHIRGraph

shared_graph = FHIRGraph()
 def test_fhir_graph(self):
     from tests.utils.base_test_case import FHIRGraph
     from fhirtordf.rdfsupport.namespaces import FHIR, W5
     g = FHIRGraph()
     self.assertTrue(FHIR.Account in g.subjects())
Beispiel #10
0
 def setUpClass(cls):
     cls.g = FHIRGraph()
     cls.g.parse(bmi_graph, format="turtle")