def fhir_api_exception_handler(exc, context): response = call_default_exception_handler(exc, context) request_path = __get_path_from_context(context) if 'api_fhir' in request_path: from api_fhir.converters import OperationOutcomeConverter fhir_outcome = OperationOutcomeConverter.to_fhir_obj(exc) if not response: response = __create_server_error_response() response.data = fhir_outcome.toDict() return response
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 create_test_fhir_instance(self): exc = self.create_test_imis_instance() return OperationOutcomeConverter.to_fhir_obj(exc)
def test_to_fhir_obj(self): exc = self.create_test_imis_instance() fhir_outcome = OperationOutcomeConverter.to_fhir_obj(exc) self.verify_fhir_instance(fhir_outcome)