def create(self, validated_data): chf_id = validated_data.get('chf_id') if Insuree.objects.filter(chf_id=chf_id).count() > 0: raise FHIRException( 'Exists patient with following chfid `{}`'.format(chf_id)) copied_data = copy.deepcopy(validated_data) del copied_data['_state'] return Insuree.objects.create(**copied_data)
def create(self, validated_data): code = validated_data.get('code') if ClaimAdmin.objects.filter(code=code).count() > 0: raise FHIRException( 'Exists practitioner with following code `{}`'.format(code)) copied_data = copy.deepcopy(validated_data) del copied_data['_state'] return ClaimAdmin.objects.create(**copied_data)
def fromJSON(cls, json_string): json_dict = json.loads(json_string) resource_type = json_dict.pop('resourceType') if resource_type != cls.__name__: class_ = eval_type(resource_type) if class_ is object or not issubclass(class_, cls): raise FHIRException( gettext('Cannot marshall a {} from a {}: not a subclass!'). format(class_, cls.__name__)) return class_()._fromDict(json_dict) return cls()._fromDict(json_dict)
def fromDict(cls, object_dict): if not object_dict.get('resourceType'): raise FHIRException(gettext('Missing `resourceType` attribute')) resource_type = object_dict.pop('resourceType') class_ = eval_type(resource_type) return class_()._fromDict(object_dict)