def new_patient(self, name, details, date=datetime.datetime.utcnow()): patient = Patient(hospital_id=self._id, name=name, details=details, controller=self.controller, created_date=date) patient.save_to_mongo()
def delete_all(): Sample.objects.all().delete() Collect.objects().all().delete() LoanHistory.objects().all().delete() Equipment.objects().all().delete() Sensor.objects().all().delete() Patient.objects().all().delete() return jsonify({'message': 'deleted with success.'})
def new_patient(hospital_id): if request.method == 'GET': return render_template('new_patient.html', hospital_id=hospital_id) else: name = request.form['title'] details = request.form['content'] user = User.get_by_email(session['email']) new_patient = Patient(hospital_id, name, details, user.email) new_patient.save_to_mongo() return make_response(hospital_patients(hospital_id))
async def create_patient(patient: Patient, user: User = Depends(get_current_active_user)): if hasattr(patient, 'id'): delattr(patient, 'id') year, month, day = str(patient.birth_date).split('-') date = datetime(int(year), int(month), int(day)) patient.birth_date = date _patient = db.patients.insert_one(patient.dict(by_alias=True)) patient.id = _patient.inserted_id return patient
def create_patient(): """Creates a patient entity :return: a success message """ details = json.loads(request.data) patient = Patient( first_name=details["first_name"], last_name=details["last_name"] ) patient.save() return make_response(jsonify({"message": "Patient added successfully"}), 201)
def create_patient(self): name = self.name.data address = self.address.data uchastok = self.uchastok.data cardno = self.cardno.data patient = Patient(None, name, address, uchastok, cardno) self._repository.create(patient)
async def list_patients(user: User = Depends(get_current_active_user)): patients = [] await get_patient_collects() for patient in db.patients.find(): patients.append(Patient(**patient)) return patients
def SavePatientData(self): exercises = dict((ex.code, ex.assigned_key[0]) for ex in self.exercises) patient = Patient( self.subject, self.age, exercises ) self.firestore.set_patient_data(patient)
def get_patient(id): try: db = Database(config) row = db.read_patient(id) p = Patient() p.name=[HumanName(), HumanName()] p.name[0].family = [row['achternaam']] p.name[0].prefix = [row['tussenvoegsel']] p.name[1].family = [row['partnerachternaam']] p.name[1].prefix = [row['partnertussenvoegsel']] p.gender = str(row['geslacht']).lower().replace('m', 'male').replace('v', 'female') p.birthDate = FHIRDate(row['geboortedatum'][:10]) p.identifier = [Identifier(), Identifier()] p.identifier[0].value = row['patientid'] p.identifier[0].use = 'usual' p.identifier[0].system = 'https://www.promedico-asp.nl/his/' p.identifier[1].value = row['bsn'] p.identifier[1].use = 'official' p.identifier[1].system = 'http://fhir.nl/fhir/NamingSystem/bsn' json = p.as_json() if not json: return "niet gevonden", 404 return jsonify(json) except Exception as ex: print(ex.args[0]) return 'Er is een fout: ' + ex.args[0], 500
def get_patient(id): try: db = Database(config) row = db.read_patient(id) p = Patient() p.name = [HumanName()] p.name[0].family = [row['achternaam']] # p.address = [Address()] # p.address[0].city = row['plaats'] # p.address[0].country = row['land'] # p.address[0].line = [row['straat'] ] json = p.as_json() if not json: return "niet gevonden", 404 return jsonify(json) except Exception as ex: print(ex.args[0]) return 'Er is een fout' + ex.args[0], 500
def __init__(self, parent=None): super(TrainWidget, self).__init__(parent) self.ui = Ui_TrainPanel() self.subject = "" self.classifyExercises = None if parent is not None: self.classifyExercises = parent.classifyExercises self.infoLabel = parent.infoLabel self.patients = [] self.selectedPatient = Patient("", "", {}) self.ui.setupUi(self) self.connections()
def loadPatientList(self): self.listFiles.clear() self.parent.patients.clear() files = [ f for f in listdir(PATIENTS_PATH) if isfile(join(PATIENTS_PATH, f)) ] for x, ind in zip(files, range(0, len(files))): item = QListWidgetItem(x.split('.')[0]) item.setTextAlignment(Qt.Alignment.AlignHCenter) self.listFiles.addItem(item) with open(PATIENTS_PATH + x, 'r') as f: person_dict = json.load(f) patient = Patient(person_dict['Name'], person_dict['Age'], person_dict['Exercises']) self.parent.patients.append(patient) print(self.parent.patients)
def get(self, mobile_number): patient = None if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE with connection.cursor() as cur: cur.execute('select * from patient where mobile_number = :mob',{'mob':mobile_number}) record = cur.fetchone() if record is None: connection.close() return {'message':"Not Found"}, HTTPStatus.NOT_FOUND else: patient = Patient(*record) connection.close() return {'data': patient.data }, HTTPStatus.OK
def get_patient(): """ :return: A list of objects of all the patients available """ patients = Patient.get_all() if patients: get_results = [] for patient in patients: patient_object = { "patient_id": patient.id, "first_name": patient.first_name, "last_name": patient.last_name } get_results.append(patient_object) return make_response(jsonify({"patients": get_results})), 200 else: return make_response(jsonify({"message": "No patient records found"}), 404)
def get(self): if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE data =[] with connection.cursor() as cur: cur.execute('select * from patient') records = cur.fetchall() if len(records) == 0: return {'message':"Not Found"}, HTTPStatus.NOT_FOUND for row in records: patient = Patient(*list(row)) data.append(patient.data) connection.close() return {'data': data }, HTTPStatus.OK
def get(self, patient_id): patient = None if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE data =[] with connection.cursor() as cur: cur.execute('select * from patient where patient_id = :id',{'id':patient_id}) record = cur.fetchone() if record is None: connection.close() return {'message':"Not Found"}, HTTPStatus.NOT_FOUND else: patient = Patient(*record) connection.close() return {'data': patient.data }, HTTPStatus.OK
def find_all_patient(): result = Patient.find_all_patient() return result
from models import * 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']}]})
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 get_patient(cls, user_id): return Patient.find_patient(user_id)
def register_patient(cls, age, gender, phone): user_id = User._get_last_registered_status_patient() return Patient.create_new_patient(user_id, age, gender, phone)
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 get_patients(self): return Patient.from_hospital(self._id)
#!/usr/bin/env python # -*- coding: utf-8 -*- from models.fhirsearch import FHIRSearch if '__main__' == __name__: from models.patient import Patient print('1 '+FHIRSearch(Patient, {'name': 'Willis'}).construct()) print('1 '+Patient.where({'name': 'Willis'}).construct()) # print('1 '+Patient.where().name('Willis').construct()) print('= Patient?name=Willis') print('') print('2 '+FHIRSearch(Patient, {'name': {'$exact': 'Willis'}}).construct()) print('= Patient?name:exact=Willis') print('') print('3 '+FHIRSearch(Patient, {'name': {'$or': ['Willis', 'Wayne', 'Bruce']}}).construct()) print('= Patient?name=Willis,Wayne,Bruce') print('') print('4 '+FHIRSearch(Patient, {'name': {'$and': ['Willis', {'$exact': 'Bruce'}]}}).construct()) print('= Patient?name=Willis&name:exact=Bruce') print('') print('5 '+FHIRSearch(Patient, {'birthDate': {'$gt': '1950', '$lte': '1970'}}).construct()) print('= Patient?birthDate=>1950&birthDate=<=1970') print('') print('6 '+FHIRSearch(Patient, {'subject.name': {'$exact': 'Willis'}}).construct()) print('= Patient?subject.name:exact=Willis') print('') srch = FHIRSearch(Patient, {'subject': {'$type': 'Patient', 'name': 'Willis', 'birthDate': {'$gt': '1950', '$lte': '1970'}}}) print('7 '+srch.construct()) srch = Patient.where({'subject': {'$type': 'Patient', 'name': 'Willis', 'birthDate': {'$gt': '1950', '$lte': '1970'}}}) print('7 '+srch.construct())
def create_patient(): request_data = request.get_json() patient = Patient(**request_data).save() return jsonify(patient)
def get_patient(): patient = Patient.objects().all() return jsonify(patient)