def build_fhir_telecom_for_person(cls, phone=None, email=None): telecom = [] if phone is not None: phone = BaseFHIRConverter.build_fhir_contact_point( phone, ContactPointSystem.PHONE.value, ContactPointUse.HOME.value) telecom.append(phone) if email is not None: email = BaseFHIRConverter.build_fhir_contact_point( email, ContactPointSystem.EMAIL.value, ContactPointUse.HOME.value) telecom.append(email) return telecom
class BaseFHIRSerializer(serializers.Serializer): fhirConverter = BaseFHIRConverter() def to_representation(self, obj): if isinstance(obj, HttpResponseBase): return OperationOutcomeConverter.to_fhir_obj(obj).toDict() elif isinstance(obj, FHIRBaseObject): return obj.toDict() return self.fhirConverter.to_fhir_obj(obj).toDict() def to_internal_value(self, data): audit_user_id = self.get_audit_user_id() if isinstance(data, dict): data = FHIRBaseObject.fromDict(data) return self.fhirConverter.to_imis_obj(data, audit_user_id).__dict__ def create(self, validated_data): raise NotImplementedError( '`create()` must be implemented.') # pragma: no cover def update(self, instance, validated_data): raise NotImplementedError( '`update()` must be implemented.') # pragma: no cover def get_audit_user_id(self): request = self.context.get("request") audit_user_id = request.query_params.get('auditUserId', None) if audit_user_id is None: audit_user_id = GeneralConfiguration.get_default_audit_user_id() return audit_user_id
def get_id_for_created_resource(self, response): result = None fhir_obj = FHIRBaseObject.loads(response.content, 'json') if hasattr(fhir_obj, 'identifier'): result = BaseFHIRConverter.get_fhir_identifier_by_code(fhir_obj.identifier, Stu3IdentifierConfig.get_fhir_id_type_code()) return result
def create_test_imis_instance(self): errors = [] BaseFHIRConverter.valid_condition(self.__VALID_CONDITION, self.__ERROR_MESSAGE, errors) return FHIRRequestProcessException(errors)