def get(self): """Obtiene numero de pacientes activos, numero de terapistas y turnos del mes para el dashboard principal """ getPatientCount=conn.execute("SELECT COUNT(*) AS patient FROM pacientes").fetchone() getDoctorCount = conn.execute("SELECT COUNT(*) AS doctor FROM terapistas").fetchone() getAppointmentCount = conn.execute("SELECT COUNT(*) AS appointment FROM turnos").fetchone() getPatientCount.update(getDoctorCount) getPatientCount.update(getAppointmentCount) return getPatientCount
def put(self, id): """Actualiza un terapista por su ID""" doctorInput = request.get_json(force=True) ter_nombre = doctorInput['ter_nombre'] ter_apellido = doctorInput['ter_apellido'] ter_tel = doctorInput['ter_tel'] ter_dir = doctorInput['ter_dir'] conn.execute( "UPDATE terapistas SET ter_nombre=?,ter_apellido=?,ter_tel=?,ter_dir=? WHERE ter_id=?", (ter_nombre, ter_apellido, ter_tel, ter_dir, id)) conn.commit() return doctorInput
def put(self, id): """Api que actualiza un paciente por su id""" patientInput = request.get_json(force=True) pac_nombre = patientInput['pac_nombre'] pac_apellido = patientInput['pac_apellido'] pac_dni = patientInput['pac_dni'] pac_tel = patientInput['pac_tel'] pac_dir = patientInput['pac_dir'] conn.execute( "UPDATE pacientes SET pac_nombre=?,pac_apellido=?,pac_dni=?,pac_tel=?,pac_dir=? WHERE pac_id=?", (pac_nombre, pac_apellido, pac_dni, pac_tel, pac_dir, id)) conn.commit() return patientInput
def get(self): """Api que obtiene todos los pacientes de la base""" patients = conn.execute( "SELECT * FROM pacientes ORDER BY pac_crea_fecha DESC").fetchall( ) return patients
def post(self): """Agregar un nuevo Doctor""" doctorInput = request.get_json(force=True) ter_nombre = doctorInput['ter_nombre'] ter_apellido = doctorInput['ter_apellido'] ter_tel = doctorInput['ter_tel'] ter_dir = doctorInput['ter_dir'] doctorInput['ter_id'] = conn.execute( '''INSERT INTO terapistas(ter_nombre,ter_apellido,ter_tel,ter_dir) VALUES(?,?,?,?)''', (ter_nombre, ter_apellido, ter_tel, ter_dir)).lastrowid conn.commit() return doctorInput
def post(self): """Api para agregar un paciente a la base""" patientInput = request.get_json(force=True) pac_nombre = patientInput['pac_nombre'] pac_apellido = patientInput['pac_apellido'] pac_dni = patientInput['pac_dni'] pac_tel = patientInput['pac_tel'] pac_dir = patientInput['pac_dir'] patientInput['pac_id'] = conn.execute( '''INSERT INTO pacientes(pac_nombre,pac_apellido,pac_dni,pac_tel,pac_dir) VALUES(?,?,?,?,?)''', (pac_nombre, pac_apellido, pac_dni, pac_tel, pac_dir)).lastrowid conn.commit() return patientInput
def get(self): """Obtiene una lista de todos los terapistas""" doctors = conn.execute( "SELECT * FROM terapistas ORDER BY ter_cre_fecha DESC").fetchall() return doctors
def delete(self, id): """Borra un terapista por ID""" conn.execute("DELETE FROM terapistas WHERE ter_id=?", (id, )) conn.commit() return {'msg': 'sucessfully deleted'}
def get(self, id): """Obtiene los datos de un terapista por su ID""" doctor = conn.execute("SELECT * FROM terapistas WHERE ter_id=?", (id, )).fetchall() return doctor
def delete(self, id): """Api que borra un paciente por su ID""" conn.execute("DELETE FROM pacientes WHERE pac_id=?", (id, )) conn.commit() return {'msg': 'sucessfully deleted'}
def get(self, id): """api que obtiene todos los detalles de un paciente por ID""" patient = conn.execute("SELECT * FROM pacientes WHERE pac_id=?", (id, )).fetchall() return patient