示例#1
0
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
示例#2
0
 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()
示例#3
0
 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)
示例#4
0
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)
示例#5
0
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
示例#6
0
 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)
示例#7
0
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))
示例#8
0
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)
示例#9
0
    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()
示例#10
0
    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(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 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
示例#14
0
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
示例#15
0
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']}]})
示例#16
0
def create_patient():
    request_data = request.get_json()
    patient = Patient(**request_data).save()
    return jsonify(patient)