def init_listes_questions(self): id_patient = model_global.get_user_id() #Récupère la liste des question de la rubrique self.liste_parametres = dao_question.dao_Question().get_questions_niveau(0) #Récupère les données du dernier questionnaire self.reponses_parametres = dao_reponse.dao_Reponse().get_last_reponse_patient(id_patient, 0) #Récupère les valeurs par défaut des questions si première saisie if len(self.reponses_parametres) == 0 : self.liste_parametres = dao_question.dao_Question().get_questions_niveau(0) self.reponses_parametres = [] for quest in self.liste_parametres : rep = reponse.Reponse() rep.set_id_question(quest.get_id()) rep.set_reponse(quest.get_valeur()) self.reponses_parametres.append(rep) #Symptomes fréquents self.liste_sympt_frequents = dao_question.dao_Question().get_questions_niveau(1) self.reponses_sympt_frequents = dao_reponse.dao_Reponse().get_last_reponse_patient(id_patient, 1) if len(self.reponses_sympt_frequents) == 0 : self.liste_sympt_frequents = dao_question.dao_Question().get_questions_niveau(1) self.reponses_sympt_frequents = [] for quest in self.liste_sympt_frequents : rep = reponse.Reponse() rep.set_id_question(quest.get_id()) rep.set_reponse(quest.get_valeur()) self.reponses_sympt_frequents.append(rep) #Symptomes moins fréquents self.liste_sympt_moins_frequents = dao_question.dao_Question().get_questions_niveau(2) self.reponses_sympt_moins_frequents = dao_reponse.dao_Reponse().get_last_reponse_patient(id_patient, 2) if len(self.reponses_sympt_moins_frequents) == 0 : self.liste_sympt_moins_frequents = dao_question.dao_Question().get_questions_niveau(2) self.reponses_sympt_moins_frequents = [] for quest in self.liste_sympt_moins_frequents : rep = reponse.Reponse() rep.set_id_question(quest.get_id()) rep.set_reponse(quest.get_valeur()) self.reponses_sympt_moins_frequents.append(rep) #Symptomes graves self.liste_sympt_graves = dao_question.dao_Question().get_questions_niveau(3) self.reponses_sympt_graves = dao_reponse.dao_Reponse().get_last_reponse_patient(id_patient, 3) if len(self.reponses_sympt_graves) == 0 : self.liste_sympt_graves = dao_question.dao_Question().get_questions_niveau(3) self.reponses_sympt_graves = [] for quest in self.liste_sympt_graves : rep = reponse.Reponse() rep.set_id_question(quest.get_id()) rep.set_reponse(quest.get_valeur()) self.reponses_sympt_graves.append(rep) #Commentaire quest = dao_questionnaire.dao_Questionnaire().get_last_questionnaire(id_patient) if not (quest == None) : self.questionnaire_jour.set_commentaire(quest.get_commentaire())
def get_reponse(self, id): base = db.SQLiteManager() cursor = base.connect() cursor.execute( "SELECT id, reponse, id_question, id_questionnaire FROM reponses WHERE id = " + str(id)) result = cursor.fetchall() p = None if len(result) > 0: p = per.Reponse() p.set_reponse2(result[0][0], result[0][1], result[0][2], result[0][3]) base.close() return p
def get_all_reponses(self): base = db.SQLiteManager() cursor = base.connect() cursor.execute( "SELECT id, reponse, id_question, id_questionnaire FROM reponses") result = cursor.fetchall() p = [] pcur = None for cur in result: pcur = per.Reponse() pcur.set_reponse2(cur[0], cur[1], cur[2], cur[3]) p.append(pcur) base.close() return p
def get_last_reponse_patient(self, id_patient, niveau): base = db.SQLiteManager() cursor = base.connect() cursor.execute('''SELECT rep.reponse, rep.id_question FROM reponses AS rep JOIN questions AS qu ON rep.id_question = qu.id JOIN questionnaires AS quest ON rep.id_questionnaire = quest.id WHERE quest.id_patient = ''' + str(id_patient) + ''' AND qu.niveau = ''' + str(niveau) + ''' AND quest.id=(SELECT MAX(id) FROM questionnaires WHERE id_patient = ''' + str(id_patient) + ''')''') result = cursor.fetchall() p = [] pcur = None for cur in result: pcur = per.Reponse() pcur.set_reponse(cur[0]) pcur.set_id_question(cur[1]) p.append(pcur) base.close() return p
def get_reponses_questionnaire2(self, id_questionnaire): base = db.SQLiteManager() cursor = base.connect() cursor.execute( '''SELECT rep.id, rep.reponse, rep.id_question, rep.id_questionnaire, qu.id FROM reponses AS rep JOIN questions AS qu ON rep.id_question = qu.id JOIN questionnaires AS quest ON rep.id_questionnaire = quest.id WHERE quest.id = ''' + str(id_questionnaire) + ''' ORDER BY qu.id''') result = cursor.fetchall() p = [] pcur = None for cur in result: pcur = per.Reponse() pcur.set_id(cur[0]) pcur.set_reponse(cur[1]) pcur.set_id_question(cur[2]) pcur.set_id_questionnaire(cur[3]) p.append(pcur) base.close() return p