def treatment_item(self): ti = TreatmentItem(self.proc_code) practitioner = self.chosen_practitioner ti.set_px_clinician(practitioner.id) ti.set_tx_clinician(practitioner.id) ti.set_cmp_date(self.date) return ti
def get_records(self): ''' pulls all treatment items in the database (for the patient with the id specified during load_patient function) ''' ## long query - only time will tell if this is a performance hit if not self.patient_id: return query = '''select treatments.ix, patient_id, om_code, description, completed, comment, px_clinician, tx_clinician, tx_date, added_by from treatments left join procedure_codes on procedure_codes.code = treatments.om_code where patient_id = ?''' q_query = QtSql.QSqlQuery(SETTINGS.psql_conn) q_query.prepare(query) q_query.addBindValue(self.patient_id) q_query.exec_() while q_query.next(): record = q_query.record() treatment_item = TreatmentItem(record) self.add_treatment_item(treatment_item)
def proc_code_selected(self, proc_code): ''' a raw procedure code has been selected (from the :doc:`ProcCodeWidget`) convert to a :doc:`TreatmentItem`, validate and pass to :func:`add_treatment_item` ''' treatment_item = TreatmentItem(proc_code) self.add_treatment_item(treatment_item)
def chart_treatment_added(self, tooth_data, plan_or_cmp): ''' treatment has been added using the charts page if this is not understood, the following signal is emitted QtCore.SIGNAL("garbage chart tx") ''' proc_code = tooth_data.proc_code if proc_code == None: proc_code = SETTINGS.PROCEDURE_CODES.convert_user_shortcut( tooth_data.tx_input) if proc_code == None: self.emit(QtCore.SIGNAL("garbage chart tx")) return treatment_item = TreatmentItem(proc_code) treatment_item.set_teeth([tooth_data.tooth_id]) treatment_item.set_surfaces(tooth_data.surfaces) if plan_or_cmp == "Completed": treatment_item.set_completed(True) treatment_item.set_cmp_date(QtCore.QDate.currentDate()) self.add_treatment_item(treatment_item) self.emit(QtCore.SIGNAL("valid chart tx"))
return False if __name__ == "__main__": from lib_openmolar.common.db_orm import TreatmentItem from lib_openmolar.client.connect import DemoClientConnection app = QtGui.QApplication([]) cc = DemoClientConnection() cc.connect() dl = TreatmentItemFinaliseDialog() code = SETTINGS.PROCEDURE_CODES["D10"] item = TreatmentItem(code) #item.set_completed(True) while not item.is_valid: if not dl.get_info(item): break if False: for code in SETTINGS.PROCEDURE_CODES: item = TreatmentItem(code) item.set_px_clinician(1) if not item.is_valid: dl.get_info(item) print item print item.is_valid