def create_patient(): # print request.json if not request.json or not 'name' in request.json: abort(400) user_name = auth.username() _user = User.objects.get(email=user_name) new_patient = Patient() new_patient.name = request.json['name'] new_patient.phone = request.json['phone'] new_patient.email = request.json['email'] new_patient.description = request.json['description'] new_patient.groups = request.json['groups'] new_patient.prevision = request.json['prevision'] new_patient.active = request.json['active'] new_patient.user = _user # Acá sacar la fecha y hora actual. new_patient.registry_date = request.json.get('registry_date', "") # Controlamos error en caso de que se inserte un usuario que ya existe try: new_patient.save() except Exception, e: print e abort(400)
def create_patient(): # print request.json if not request.json or not 'name' in request.json: abort(400) user_name = auth.username() _user = User.objects.get(email = user_name) new_patient = Patient() new_patient.name = request.json['name'] new_patient.phone = request.json['phone'] new_patient.email = request.json['email'] new_patient.description = request.json['description'] new_patient.groups = request.json['groups'] new_patient.prevision = request.json['prevision'] new_patient.active = request.json['active'] new_patient.user = _user # Acá sacar la fecha y hora actual. new_patient.registry_date = request.json.get('registry_date', "") # Controlamos error en caso de que se inserte un usuario que ya existe try: new_patient.save() except Exception, e: print e abort(400)
from ext_models.address import Address from models.extension import Extension from models.humanname import HumanName from models.patient import Patient p = Patient() p.name = [HumanName()] p.name[0].use = 'official' p.name[0].familyname = ['Reenen'] p.name[0].given = ['Hendrikus', 'Herman', 'Johannes'] p.name[0].extension = [Extension()] #niet zeker van juistheid hiervan p.name[0].extension[0].url = 'http://nictiz.org/huham_name_def_nl/prefix' p.name[0].extension[0].valueString = 'van' p.name[0].text = 'Hendrikus Herman Johannes van Reenen' , 'H', 'H', 'J'] p.active = True p.address = [Address.from_str("Reigersberg 10, 6865NL, Doorwerth, NL")] json = p.as_json() print(json) import json s = """{'name': [{'given': ['Pieter', 'H', 'H', 'J']}], 'resourceType': 'Patient'}""" json_acceptable_string = s.replace("'", "\"") d = json.loads(json_acceptable_string) p2 = Patient(d) json = p2.as_json() print(json) p4 = Patient({'resourceType': 'Patient', 'name': [{'given': ['Henk-Jan', 'H', 'H', 'J']}]})