def reverse_txs(om_gui, treatments, confirm_multiples=True): LOGGER.debug(treatments) pt = om_gui.pt courseno = pt.treatment_course.courseno if len(treatments) > 1 and confirm_multiples: txs = [] for att, treat in treatments: txs.append((att, treat, True)) dl = CompleteTreatmentDialog(txs, om_gui) if not dl.exec_(): return treatments = dl.uncompleted_treatments deleted_treatments = dl.deleted_treatments else: deleted_treatments = [] for att, treatment in treatments: completed = pt.treatment_course.__dict__["%scmp" % att] treat = treatment.strip(" ") count = completed.split(" ").count(treat) LOGGER.debug( "creating tx_hash using %s %s %s" % (att, count, treat)) hash_ = localsettings.hash_func( "%s%s%s%s" % (courseno, att, count, treat)) tx_hash = TXHash(hash_) tx_hash_reverse(om_gui, tx_hash) for att, treat, completed in deleted_treatments: remove_treatments_from_plan_and_est( om_gui, ((att, treat.strip(" ")),), completed)
def reverse_txs(om_gui, treatments, confirm_multiples=True): LOGGER.debug(treatments) pt = om_gui.pt courseno = pt.treatment_course.courseno if len(treatments) > 1 and confirm_multiples: txs = [] for att, treat in treatments: txs.append((att, treat, True)) dl = CompleteTreatmentDialog(txs, om_gui) if not dl.exec_(): return treatments = dl.uncompleted_treatments deleted_treatments = dl.deleted_treatments else: deleted_treatments = iter([]) for att, treatment in treatments: completed = pt.treatment_course.__dict__["%scmp" % att] treat = treatment.strip(" ") count = completed.split(" ").count(treat) LOGGER.debug("creating tx_hash using %s %s %s", att, count, treat) hash_ = localsettings.hash_func("%s%s%s%s" % (courseno, att, count, treat)) tx_hash = TXHash(hash_) tx_hash_reverse(om_gui, tx_hash) for att, treat, completed in deleted_treatments: remove_treatments_from_plan_and_est(om_gui, ((att, treat.strip(" ")), ), completed)
def complete_txs(om_gui, treatments, confirm_multiples=True): ''' complete tooth treatment #args is a list - ["ul5","MOD","RT",] args is a list - [("ul5","MOD"),("ul5", "RT"), ("perio", "SP")] ''' if localsettings.clinicianNo == 0: om_gui.advise( _("You have no clinician login. " "Treatments cannot be completed by you!"), 2) return LOGGER.debug(treatments) pt = om_gui.pt courseno = pt.treatment_course.courseno if len(treatments) > 1 and confirm_multiples: txs = [] for att, treat in treatments: txs.append((att, treat, False)) dl = CompleteTreatmentDialog(txs, om_gui) dl.hide_reverse_all_but() if not dl.exec_(): return treatments = dl.completed_treatments deleted_treatments = dl.deleted_treatments else: deleted_treatments = [] for att, treatment in treatments: existingcompleted = pt.treatment_course.__dict__["%scmp" % att] newcompleted = existingcompleted + treatment treat = treatment.strip(" ") count = newcompleted.split(" ").count(treat) LOGGER.debug( "creating tx_hash using %s %s %s" % (att, count, treat)) hash_ = localsettings.hash_func( "%s%s%s%s" % (courseno, att, count, treat)) tx_hash = TXHash(hash_) tx_hash_complete(om_gui, tx_hash) for att, treat, completed in deleted_treatments: remove_treatments_from_plan_and_est( om_gui, ((att, treat.strip(" ")),), completed)
def complete_txs(om_gui, treatments, confirm_multiples=True): ''' complete tooth treatment #args is a list - ["ul5","MOD","RT",] args is a list - [("ul5","MOD"),("ul5", "RT"), ("perio", "SP")] ''' if localsettings.clinicianNo == 0: om_gui.advise( _("You have no clinician login. " "Treatments cannot be completed by you!"), 2) return LOGGER.debug(treatments) pt = om_gui.pt courseno = pt.treatment_course.courseno if len(treatments) > 1 and confirm_multiples: txs = [] for att, treat in treatments: txs.append((att, treat, False)) dl = CompleteTreatmentDialog(txs, om_gui) dl.hide_reverse_all_but() if not dl.exec_(): return treatments = dl.completed_treatments deleted_treatments = dl.deleted_treatments else: deleted_treatments = iter([]) for att, treatment in treatments: existingcompleted = pt.treatment_course.__dict__["%scmp" % att] newcompleted = existingcompleted + treatment treat = treatment.strip(" ") count = newcompleted.split(" ").count(treat) LOGGER.debug("creating tx_hash using %s %s %s", att, count, treat) hash_ = localsettings.hash_func("%s%s%s%s" % (courseno, att, count, treat)) tx_hash = TXHash(hash_) tx_hash_complete(om_gui, tx_hash) for att, treat, completed in deleted_treatments: remove_treatments_from_plan_and_est(om_gui, ((att, treat.strip(" ")), ), completed)
def raise_multi_treatment_dialog(self, est_item_widget): ''' show treatments for this item ''' LOGGER.debug("raise_multi_treatment_dialog") tx_hashes = [] for item in est_item_widget.est_items: tx_hashes += item.tx_hashes assert len(tx_hashes) > 0, \ "no treatments found.. this shouldn't happen" txs = [] for hash_, att, tx in self.pt.tx_hash_tups: for tx_hash in tx_hashes: if hash_ == tx_hash: txs.append((att, tx, tx_hash.completed)) dl = CompleteTreatmentDialog(txs, self) if not dl.exec_(): return for att, treat in dl.completed_treatments: LOGGER.debug("checking completed %s %s" % (att, treat)) found = False # only complete 1 treatment!! for hash_, att_, tx in self.pt.tx_hash_tups: if found: break if att == att_ and tx == treat: LOGGER.debug("att and treat match... checking hashes") for item in est_item_widget.est_items: LOGGER.debug("Checking hashes of item %s" % item) for tx_hash in item.tx_hashes: if tx_hash == hash_ and not tx_hash.completed: LOGGER.debug("%s == %s" % (tx_hash, hash_)) tx_hash.completed = True self.tx_hash_complete(tx_hash) found = True break if found: break for att, treat in dl.uncompleted_treatments: LOGGER.debug("checking completed %s %s" % (att, treat)) found = False # only complete 1 treatment!! for hash_, att_, tx in reversed(list(self.pt.tx_hash_tups)): if found: break if att == att_ and tx == treat: LOGGER.debug("att and treat match... checking hashes") for item in est_item_widget.est_items: LOGGER.debug("Checking hashes of item %s" % item) for tx_hash in item.tx_hashes: if tx_hash == hash_ and tx_hash.completed: LOGGER.debug("%s == %s" % (tx_hash, hash_)) tx_hash.completed = False self.tx_hash_complete(tx_hash) found = True break if found: break for att, treat, already_completed in dl.deleted_treatments: LOGGER.debug("checking deleted %s %s" % (att, treat)) manipulate_plan.remove_treatments_from_plan_and_est( self.om_gui, ((att, treat.strip(" ")), ), already_completed) self.resetEstimate()
def raise_multi_treatment_dialog(self, est_item_widget): ''' show treatments for this item ''' LOGGER.debug("raise_multi_treatment_dialog") tx_hashes = [] for item in est_item_widget.est_items: tx_hashes += item.tx_hashes assert len(tx_hashes) >0 , \ "no treatments found.. this shouldn't happen" txs = [] for hash_, att, tx in self.pt.tx_hash_tups: for tx_hash in tx_hashes: if hash_ == tx_hash: txs.append((att, tx, tx_hash.completed)) dl = CompleteTreatmentDialog(txs, self) if not dl.exec_(): return for att, treat in dl.completed_treatments: LOGGER.debug("checking completed %s %s"% (att, treat)) found = False #only complete 1 treatment!! for hash_, att_, tx in self.pt.tx_hash_tups: if found: break if att == att_ and tx == treat: LOGGER.debug("att and treat match... checking hashes") for item in est_item_widget.est_items: LOGGER.debug("Checking hashes of item %s"% item) for tx_hash in item.tx_hashes: if tx_hash == hash_ and not tx_hash.completed: LOGGER.debug("%s == %s"% (tx_hash, hash_)) tx_hash.completed = True self.tx_hash_complete(tx_hash) found = True break if found: break for att, treat in dl.uncompleted_treatments: LOGGER.debug("checking completed %s %s"% (att, treat)) found = False #only complete 1 treatment!! for hash_, att_, tx in reversed(list(self.pt.tx_hash_tups)): if found: break if att == att_ and tx == treat: LOGGER.debug("att and treat match... checking hashes") for item in est_item_widget.est_items: LOGGER.debug("Checking hashes of item %s"% item) for tx_hash in item.tx_hashes: if tx_hash == hash_ and tx_hash.completed: LOGGER.debug("%s == %s"% (tx_hash, hash_)) tx_hash.completed = False self.tx_hash_complete(tx_hash) found = True break if found: break for att, treat, already_completed in dl.deleted_treatments: LOGGER.debug("checking deleted %s %s"% (att, treat)) manipulate_plan.remove_treatments_from_plan_and_est( self.om_gui, ((att, treat.strip(" ")),), already_completed) self.resetEstimate()