diff --git a/dbignite/fhir_mapping_model.py b/dbignite/fhir_mapping_model.py index 73bf676..d7cd37f 100644 --- a/dbignite/fhir_mapping_model.py +++ b/dbignite/fhir_mapping_model.py @@ -99,7 +99,7 @@ def us_core_fhir_resource_mapping(cls): # def custom_fhir_resource_mapping(self, resource_list: list[str]) -> "FhirSchemaModel": custom_mapping = { - resource_type: FhirSchemaModel.__read_schema(schema_path) + resource_type: FhirSchemaModel._read_schema(schema_path) for resource_type, schema_path in self._get_schema_paths() if resource_type in resource_list } diff --git a/tests/test_writers.py b/tests/test_writers.py index a89a365..c345eef 100644 --- a/tests/test_writers.py +++ b/tests/test_writers.py @@ -10,13 +10,13 @@ def test_encoder(self): from dbignite.writer.fhir_encoder import FhirEncoder e = FhirEncoder(False, False, lambda x: int(x.strip())) assert( e.f("123") == 123 ) - assert( e.f("12a") is None ) + assert( e.f("12a") == "" ) def test_encoder_manager(self): from dbignite.writer.fhir_encoder import FhirEncoderManager, SchemaDataType, FhirEncoder em = FhirEncoderManager() assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("1234") == 1234) - assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("abcdefg") == None) + assert(em.get_encoder("string", ["Patient", "multipleBirthInteger"]).f("abcdefg") == "") #test overrides em = FhirEncoderManager(override_encoders = {"Patient.multipleBirthInteger": FhirEncoder(False, False, lambda x: float(x) + 1)}) @@ -27,7 +27,8 @@ def test_target_datatype(self): from dbignite.writer.fhir_encoder import SchemaDataType from dbignite.fhir_mapping_model import FhirSchemaModel field = "Patient.name.given" - tgt_schema = FhirSchemaModel.custom_fhir_resource_mapping(field.split(".")[0]).schema(field.split(".")[0]) + s = FhirSchemaModel() + tgt_schema = s.custom_fhir_resource_mapping(field.split(".")[0]).schema(field.split(".")[0]) result = SchemaDataType.traverse_schema(field.split(".")[1:], tgt_schema) assert( result == "array")