Exemplo n.º 1
0
 def getPatients(self):
     """function to get the existent patients from the db"""
     if not self.patients.choices:
         db = DBStorage()
         options = []
         for patient in db.all_patients():
             options.append((patient.id, '{} {}'.format(
                 patient.name, patient.last_name)))
         self.patients.choices = options
         self.patients.default = 1
Exemplo n.º 2
0
 def getPatients(self):
     if not self.patients.choices:
         db = DBStorage()
         options = []
         for patient in db.all_patients():
             options.append(
                 (patient.id, '{} {}'.format(patient.name,
                                             patient.last_name)))
         self.patients.choices = options
         self.patients.default = 1
Exemplo n.º 3
0
 def prescriptionsWithoutTasks(self):
     """ verify every prescription without task
     if there is not a task it is created and the relationship
     if there is a task just the relationship is created """
     db = DBStorage()
     patients = db.all_patients()
     task = []
     for patient in patients:
         if not patient.prescriptions:
             print('there is not prescription for pacient {}'.format(
                 patient.name))
         else:
             for prescription in patient.prescriptions:
                 if not prescription.task_x_prescriptions:
                     task = self.findMyTask(prescription.frequency,
                                            prescription.start_dt)
                     if not task:
                         t = Task()
                         command = 'python3 job.py'
                         command = ' {} {}'.format(command,
                                                   prescription.frequency)
                         command = '{} {}'.format(command,
                                                  prescription.start_dt)
                         t.task_command = command
                         t.task_comment = 'medr-{}'.format(prescription.id)
                         t.last_dt = datetime.now()
                         t.status = 'NEW0'
                         db.add_task(t)
                         print('Task created succesfully')
                         db.add_task_x_prescription(
                             Task_x_prescription(
                                 task_id=t.id,
                                 prescription_id=prescription.id))
                     else:
                         t = task[0]
                         print("""One task match with the frequency {} and
                         the start date {}
                         proceding to set the configuration""".format(
                             prescription.frequency, prescription.start_dt))
                         db.add_task_x_prescription(
                             Task_x_prescription(
                                 task_id=t.id,
                                 prescription_id=prescription.id))
                         print("""The relation between task and
                         prescription was established""")
Exemplo n.º 4
0
 def getPatients(self):
     """function that get the patients info from the wtforms"""
     db = DBStorage()
     self.patients = db.all_patients()