def test_examplePatientFromJSON(self): """Test loading and serializing a patient from/to JSON.""" jsonstring = fhir.get_example_data('patient-example', 'json') p = fhir.model.Patient.fromJSON(jsonstring) diff = jsondiff.diff(jsonstring, p.toJSON(), load=True) self.assertEquals(diff, {})
def test_exampleBundleFromJSON(self): """Test loading and serializing a patient from/to JSON.""" jsonstring = fhir.get_example_data('bundle-example', 'json') b = fhir.model.Bundle.fromJSON(jsonstring) diff = jsondiff.diff(jsonstring, b.toJSON(), load=True) self.assertEquals(diff, {})
def test_exampleQuestionnaireFromJSON(self): """Test loading and serializing a Questionnaire from/to JSON.""" jsonstring = fhir.get_example_data('questionnaire-TestNesting1', 'json') b = fhir.model.Questionnaire.fromJSON(jsonstring) diff = jsondiff.diff(jsonstring, b.toJSON(), load=True) self.assertEquals(diff, {})
def test_examplePatientFromXML(self): """Test loading and serializing a patient from/to XML.""" xmlstring = fhir.get_example_data('patient-example', 'xml') p = fhir.model.Patient.fromXML(xmlstring) # Cannot do a direct compare due to the fact namespaces can # be rendered in different ways. self.assertEquals(p.id, 'example') self.assertEquals(p.identifier[0].use, 'usual') self.assertEquals(p.identifier[0].value, '12345') self.assertEquals(p.active, True)
def test_exampleBundleFromXML(self): xmlstring = fhir.get_example_data('bundle-example', 'xml') b = fhir.model.Bundle.fromXML(xmlstring) # Cannot do a direct compare due to the fact namespaces can # be rendered in different ways. self.assertEquals(b.id, 'bundle-example') self.assertEquals(b.total, 3) self.assertTrue(len(b.entry), 2) self.assertTrue( isinstance(b.entry[0].resource, fhir.model.MedicationRequest)) self.assertTrue(isinstance(b.entry[1].resource, fhir.model.Medication))
def test_referenceAllowedProfiles(self): xmlstring = fhir.get_example_data('patient-example', 'xml') p = fhir.model.Patient.fromXML(xmlstring)