def add_treatments_to_plan(om_gui, treatments, completed=False): LOGGER.debug(treatments) if course_module.newCourseNeeded(om_gui): return pt = om_gui.pt for att, shortcut in treatments: LOGGER.debug("adding %s %s to treatment plan" % (att, shortcut)) existing_txs = "%s %s" % (pt.treatment_course.__dict__["%scmp" % att], pt.treatment_course.__dict__["%spl" % att] ) # count the existing number and add 1 for the new shortcut n_txs = existing_txs.split(" ").count(shortcut) + 1 courseno = pt.treatment_course.courseno hash_ = localsettings.hash_func( "%s%s%s%s" % (courseno, att, n_txs, shortcut)) tx_hash = TXHash(hash_) dentid = pt.course_dentist pt.treatment_course.__dict__["%spl" % att] += "%s " % shortcut # check for deciduous tooth. if re.match("[ul][lr][1-8]", att): n_txs = None tooth_name = pt.chartgrid.get(att) if tooth_name != att: LOGGER.debug("Deciduous tooth treatment! on %s" % tooth_name) att = "%s%s" % (att[:2], tooth_name[2]) complex_addition_handled, shortcut = complex_shortcut_addition( om_gui, att, shortcut, n_txs, tx_hash) if complex_addition_handled == FULLY_HANDLED: LOGGER.debug("complex addition handled the estimate in entirety") elif complex_addition_handled == PARTIALLY_HANDLED: LOGGER.debug("complex addition handled the estimate in part") add_treatment_to_estimate(om_gui, att, shortcut, dentid, [tx_hash]) else: LOGGER.debug("adding only as a standard shortcut") add_treatment_to_estimate(om_gui, att, shortcut, dentid, [tx_hash]) if completed: tx_hash_complete(om_gui, tx_hash) om_gui.update_plan_est()
def customAdd(om_gui, description=None): ''' add 'custom' items ''' if course_module.newCourseNeeded(om_gui): return pt = om_gui.pt courseno = pt.treatment_course.courseno Dialog = QtWidgets.QDialog(om_gui) dl = Ui_customTreatment.Ui_Dialog() dl.setupUi(Dialog) if description: dl.description_lineEdit.setText(description) if Dialog.exec_(): no = dl.number_spinBox.value() descr = dl.description_lineEdit.text() if descr == "": descr = "??" usercode = str(descr.replace(" ", "_"))[:20].upper() fee = localsettings.pencify(str(dl.fee_doubleSpinBox.value())) for i in range(no): pt.treatment_course.custompl += "%s " % usercode custom_txs = "%s %s" % (pt.treatment_course.customcmp, pt.treatment_course.custompl) n = custom_txs.split(" ").count(usercode) hash_ = localsettings.hash_func("%scustom%s%s" % (courseno, n, usercode)) tx_hash = TXHash(hash_) dentid = om_gui.pt.course_dentist add_treatment_to_estimate(om_gui, "custom", usercode, dentid, [tx_hash], itemcode="CUSTO", csetype="P", descr=descr, fee=fee, ptfee=fee) om_gui.update_plan_est()
def customAdd(om_gui, description=None): ''' add 'custom' items ''' if course_module.newCourseNeeded(om_gui): return pt = om_gui.pt courseno = pt.treatment_course.courseno Dialog = QtGui.QDialog(om_gui) dl = Ui_customTreatment.Ui_Dialog() dl.setupUi(Dialog) if description: dl.description_lineEdit.setText(description) if Dialog.exec_(): no = dl.number_spinBox.value() descr = unicode(dl.description_lineEdit.text(), "ascii", "ignore") if descr == "": descr = "??" usercode = str(descr.replace(" ", "_"))[:20].upper() fee = localsettings.pencify(str(dl.fee_doubleSpinBox.value())) for i in range(no): pt.treatment_course.custompl += "%s " % usercode custom_txs = "%s %s" % ( pt.treatment_course.customcmp, pt.treatment_course.custompl) n = custom_txs.split(" ").count(usercode) hash_ = localsettings.hash_func( "%scustom%s%s" % (courseno, n, usercode)) tx_hash = TXHash(hash_) dentid = om_gui.pt.course_dentist add_treatment_to_estimate(om_gui, "custom", usercode, dentid, [tx_hash], itemcode="CUSTO", csetype="P", descr=descr, fee=fee, ptfee=fee) om_gui.update_plan_est()
def fromFeeTable(om_gui, fee_item, sub_index): ''' add an item which has been selected from the fee table itself sub_index is when a child item has been added. ''' def show_help(): message = '''%s<ul> <li>%s %s %s %s <b>%s</b></li><li>%s %s</li><li>%s</li> </ul>''' % ( _("Choose"), _("OK to add"), att_, _("to patient attribute"), shortcut, _("Recommended"), _("Use Feescale Method"), _("to overide this behaviour"), _("Cancel to abandon this addition entirely")) QtGui.QMessageBox.information(mb, _("Help"), message) def confirm_selected_table(): ''' check that the user is happy to use the suggested table, not the current one. returns the selected table, or None to keep the current. ''' table = pt.fee_table if fee_item.table == table: return table message = '%s<br /><b>%s</b>%s<hr />%s<br />%s' % ( _("Confirm you wish to use feescale"), fee_item.table.briefName, _("for this item"), _("The patient's default table is"), table.briefName) if QtGui.QMessageBox.question( om_gui, _("Confirm"), message, QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Ok ) == QtGui.QMessageBox.Ok: return fee_item.table LOGGER.debug("fee_item %s, sub_index %s" % (fee_item, sub_index)) if course_module.newCourseNeeded(om_gui): return pt = om_gui.pt table = confirm_selected_table() if table is None: return att_ = fee_item.pt_attribute if att_ == "chart": atts = om_gui.chooseTooth() else: atts = [att_] if fee_item.shortcut is None or fee_item.is_regex: shortcut = "!FEE" else: shortcut = fee_item.shortcut if table == pt.fee_table and shortcut != "!FEE" and att_ != "exam": message = "%s %s<hr />%s" % (_( "You appear to be adding a relatively straightforward code to the" " patient's treatment plan using their default feescale"), _("It is normally advisable to add this code conventionally."), _("Would you like to do this now?") ) mb = QtGui.QMessageBox(None) mb.setWindowTitle(_("Confirm")) mb.setText(message) mb.setIcon(mb.Question) mb.addButton(_("Use Feescale Method"), mb.DestructiveRole) mb.addButton(mb.Cancel) mb.addButton(mb.Ok) mb.addButton(mb.Help) result = mb.exec_() while result == mb.Help: show_help() result = mb.exec_() if result == mb.Ok: LOGGER.warning("reverting to standard treatment adding methods") txs = [] message = "" for att in atts: txs.append((att, shortcut)) message += "<li>%s %s</li>" % (att, shortcut) add_treatments_to_plan(om_gui, txs) om_gui.advise( "%s <ul>%s</ul>%s" % (_("Treatments"), message, _("were added conventionally")), 1) return elif result == mb.Cancel: LOGGER.info("Feescale addition abandoned by user") return if not fee_item.allow_feescale_add: if att_ == "exam": reason = _("Exam items can never be added this way") else: reason = fee_item.forbid_reason message = "%s<hr /><em>%s</em>" % ( _("This item can not be added to the treatment plan " "using the feescale method, sorry"), reason) om_gui.advise(message, 1) return fee = fee_item.fees[sub_index] try: pt_fee = fee_item.ptFees[sub_index] except IndexError: pt_fee = fee dentid = pt.course_dentist cset = table.categories[0] for att in atts: if "%spl" % att not in pt.treatment_course.__dict__: att = "other" pt.treatment_course.__dict__[att + "pl"] += "%s " % shortcut new_plan = pt.treatment_course.__dict__[att + "pl"] descr = fee_item.description if re.match("[ul][lr][1-8]", att): om_gui.ui.planChartWidget.setToothProps(att, new_plan) tooth_name = pt.chartgrid.get(att).upper() descr = descr.replace("*", " %s" % tooth_name) existing_txs = "%s %s" % ( pt.treatment_course.__dict__["%scmp" % att], new_plan) n_txs = existing_txs.split(" ").count(shortcut) courseno = pt.treatment_course.courseno hash_ = localsettings.hash_func( "%s%s%s%s" % (courseno, att, n_txs, shortcut)) tx_hash = TXHash(hash_) add_treatment_to_estimate(om_gui, att, shortcut, dentid, [tx_hash], fee_item.itemcode, cset, descr, fee, pt_fee, table) om_gui.advise(u"<b>%s</b> %s (%s)" % ( fee_item.description, _("added to estimate"), _("from feescale")), 1) om_gui.update_plan_est()
def fromFeeTable(om_gui, fee_item, sub_index): ''' add an item which has been selected from the fee table itself sub_index is when a child item has been added. ''' def show_help(): message = '''%s<ul> <li>%s %s %s %s <b>%s</b></li><li>%s %s</li><li>%s</li> </ul>''' % (_("Choose"), _("OK to add"), att_, _("to patient attribute"), shortcut, _("Recommended"), _("Use Feescale Method"), _("to overide this behaviour"), _("Cancel to abandon this addition entirely")) QtWidgets.QMessageBox.information(mb, _("Help"), message) def confirm_selected_table(): ''' check that the user is happy to use the suggested table, not the current one. returns the selected table, or None to keep the current. ''' table = pt.fee_table if fee_item.table == table: return table message = '%s<br /><b>%s</b>%s<hr />%s<br />%s' % ( _("Confirm you wish to use feescale"), fee_item.table.briefName, _("for this item"), _("The patient's default table is"), table.briefName) if QtWidgets.QMessageBox.question( om_gui, _("Confirm"), message, QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Ok) == QtWidgets.QMessageBox.Ok: return fee_item.table LOGGER.debug("fee_item %s, sub_index %s" % (fee_item, sub_index)) if course_module.newCourseNeeded(om_gui): return pt = om_gui.pt table = confirm_selected_table() if table is None: return att_ = fee_item.pt_attribute if att_ == "chart": atts = om_gui.chooseTooth() else: atts = [att_] if fee_item.shortcut is None or fee_item.is_regex: shortcut = "!FEE" else: shortcut = fee_item.shortcut if table == pt.fee_table and shortcut != "!FEE" and att_ != "exam": message = "%s %s<hr />%s" % (_( "You appear to be adding a relatively straightforward code to the" " patient's treatment plan using their default feescale" ), _("It is normally advisable to add this code conventionally."), _("Would you like to do this now?")) mb = QtWidgets.QMessageBox(None) mb.setWindowTitle(_("Confirm")) mb.setText(message) mb.setIcon(mb.Question) mb.addButton(_("Use Feescale Method"), mb.DestructiveRole) mb.addButton(mb.Cancel) mb.addButton(mb.Ok) mb.addButton(mb.Help) result = mb.exec_() while result == mb.Help: show_help() result = mb.exec_() if result == mb.Ok: LOGGER.warning("reverting to standard treatment adding methods") txs = [] message = "" for att in atts: txs.append((att, shortcut)) message += "<li>%s %s</li>" % (att, shortcut) add_treatments_to_plan(om_gui, txs) om_gui.advise( "%s <ul>%s</ul>%s" % (_("Treatments"), message, _("were added conventionally")), 1) return elif result == mb.Cancel: LOGGER.info("Feescale addition abandoned by user") return if not fee_item.allow_feescale_add: if att_ == "exam": reason = _("Exam items can never be added this way") else: reason = fee_item.forbid_reason message = "%s<hr /><em>%s</em>" % (_( "This item can not be added to the treatment plan " "using the feescale method, sorry"), reason) om_gui.advise(message, 1) return fee = fee_item.fees[sub_index] try: pt_fee = fee_item.ptFees[sub_index] except IndexError: pt_fee = fee dentid = pt.course_dentist cset = table.categories[0] for att in atts: if "%spl" % att not in pt.treatment_course.__dict__: att = "other" pt.treatment_course.__dict__[att + "pl"] += "%s " % shortcut new_plan = pt.treatment_course.__dict__[att + "pl"] descr = fee_item.description if re.match("[ul][lr][1-8]", att): om_gui.ui.planChartWidget.setToothProps(att, new_plan) tooth_name = pt.chartgrid.get(att).upper() descr = descr.replace("*", " %s" % tooth_name) existing_txs = "%s %s" % (pt.treatment_course.__dict__["%scmp" % att], new_plan) n_txs = existing_txs.split(" ").count(shortcut) courseno = pt.treatment_course.courseno hash_ = localsettings.hash_func("%s%s%s%s" % (courseno, att, n_txs, shortcut)) tx_hash = TXHash(hash_) add_treatment_to_estimate(om_gui, att, shortcut, dentid, [tx_hash], fee_item.itemcode, cset, descr, fee, pt_fee, table) om_gui.advise( "<b>%s</b> %s (%s)" % (fee_item.description, _("added to estimate"), _("from feescale")), 1) om_gui.update_plan_est()