示例#1
0
def remove_treatments_from_plan_and_est(om_gui, treatments, completed=False):
    '''
    remove treatments from the treatment plan and estimate.
    treatments is in the form ((att, shortcut),)
    '''
    LOGGER.debug((treatments, completed))
    pt = om_gui.pt
    courseno = pt.treatment_course.courseno
    for att, shortcut in treatments:
        if completed:
            txs = pt.treatment_course.__dict__["%scmp" % att]
            n_txs = txs.split(" ").count(shortcut)
            hash_ = localsettings.hash_func(
                "%s%s%s%s" % (courseno, att, n_txs, shortcut))
            tx_hash = TXHash(hash_, completed)
            tx_hash_reverse(om_gui, tx_hash)

        txs = "%s %s" % (
            pt.treatment_course.__dict__["%scmp" % att],
            pt.treatment_course.__dict__["%spl" % att]
        )

        n_txs = txs.split(" ").count(shortcut)
        hash_ = localsettings.hash_func(
            "%s%s%s%s" % (courseno, att, n_txs, shortcut))
        tx_hash = TXHash(hash_, completed=False)
        p_att = "%spl" % att
        val = pt.treatment_course.__dict__[p_att]
        new_val = val.replace("%s " % shortcut, "", 1)

        if re.match("[ul][lr][1-8]", att):
            n_txs = None

        if not complex_shortcut_removal_handled(om_gui, att, shortcut,
                                                n_txs, tx_hash):
            affected_ests = list(om_gui.pt.ests_from_hash(tx_hash))

            if not affected_ests:
                om_gui.advise(
                    "%s '%s' %s<hr />%s" % (
                        _("Couldn't find"),
                        "%s%s%s%s" % (courseno, att, n_txs, shortcut),
                        _("in the patient's estimate"),
                        _("This Shouldn't Happen!")), 2)

            for est in affected_ests:
                LOGGER.debug("removing reference to %s in estimate %s" % (
                    tx_hash, est))
                est.tx_hashes.remove(tx_hash)
                if est.tx_hashes == []:
                    om_gui.pt.estimates.remove(est)

        pt.treatment_course.__dict__[p_att] = new_val

        if re.match("[ul][lr[1-8]", att):
            plan = pt.treatment_course.__dict__["%spl" % att]
            cmp_ = pt.treatment_course.__dict__["%scmp" % att]
            charts_gui.updateChartsAfterTreatment(om_gui, att, plan, cmp_)
            om_gui.ui.toothPropsWidget.lineEdit.deleteProp(shortcut)
    om_gui.updateDetails()
示例#2
0
def remove_treatments_from_plan_and_est(om_gui, treatments, completed=False):
    '''
    remove treatments from the treatment plan and estimate.
    treatments is in the form ((att, shortcut),)
    '''
    LOGGER.debug((treatments, completed))
    pt = om_gui.pt
    courseno = pt.treatment_course.courseno
    for att, shortcut in treatments:
        if completed:
            txs = pt.treatment_course.__dict__["%scmp" % att]
            n_txs = txs.split(" ").count(shortcut)
            hash_ = localsettings.hash_func(
                "%s%s%s%s" % (courseno, att, n_txs, shortcut))
            tx_hash = TXHash(hash_, completed)
            tx_hash_reverse(om_gui, tx_hash)

        txs = "%s %s" % (
            pt.treatment_course.__dict__["%scmp" % att],
            pt.treatment_course.__dict__["%spl" % att]
        )

        n_txs = txs.split(" ").count(shortcut)
        hash_ = localsettings.hash_func(
            "%s%s%s%s" % (courseno, att, n_txs, shortcut))
        tx_hash = TXHash(hash_, completed=False)
        p_att = "%spl" % att
        val = pt.treatment_course.__dict__[p_att]
        new_val = val.replace("%s " % shortcut, "", 1)

        if re.match("[ul][lr][1-8]", att):
            n_txs = None

        if not complex_shortcut_removal_handled(om_gui, att, shortcut,
                                                n_txs, tx_hash):
            affected_ests = list(om_gui.pt.ests_from_hash(tx_hash))

            if not affected_ests:
                om_gui.advise(u"%s '%s' %s<hr />%s" % (
                              _("Couldn't find"),
                              "%s%s%s%s" % (courseno, att, n_txs, shortcut),
                              _("in the patient's estimate"),
                              _("This Shouldn't Happen!")), 2)

            for est in affected_ests:
                LOGGER.debug("removing reference to %s in estimate %s" % (
                    tx_hash, est))
                est.tx_hashes.remove(tx_hash)
                if est.tx_hashes == []:
                    om_gui.pt.estimates.remove(est)

        pt.treatment_course.__dict__[p_att] = new_val

        if re.match("[ul][lr[1-8]", att):
            plan = pt.treatment_course.__dict__["%spl" % att]
            cmp = pt.treatment_course.__dict__["%scmp" % att]
            charts_gui.updateChartsAfterTreatment(om_gui, att, plan, cmp)
    om_gui.updateDetails()
示例#3
0
def tx_hash_reverse(om_gui, tx_hash):
    '''
    reponds to a signal when the user completes an item of treatment by
    checking a checkbox on the estwidget
    '''
    LOGGER.debug(tx_hash)

    pt = om_gui.pt
    found = False
    for hash_, att, treat_code in pt.tx_hash_tups:
        LOGGER.debug("comparing %s with %s" % (hash_, tx_hash))
        if hash_ == tx_hash:
            found = True

            LOGGER.debug("MATCH!")

            if att == "exam":
                pt.treatment_course.examt = ""
                pt.treatment_course.examd = None
                pt.addHiddenNote("exam", treat_code, attempt_delete=True)
                for estimate in pt.estimates:
                    for est_tx_hash in estimate.tx_hashes:
                        if est_tx_hash == tx_hash:
                            pt.estimates.remove(estimate)
                            break
                break

            # convert back from deciduous here
            att = localsettings.convert_deciduous(att)

            old_completed = pt.treatment_course.__dict__[att + "cmp"]
            new_completed = old_completed.replace(treat_code, "", 1)
            pt.treatment_course.__dict__[att + "cmp"] = new_completed

            old_plan = pt.treatment_course.__dict__[att + "pl"]
            # doubly cautious here to ensure single space separation
            new_plan = "%s %s " % (old_plan.strip(" "), treat_code.strip(" "))
            pt.treatment_course.__dict__[att + "pl"] = new_plan

            if re.findall("[ul][lr][1-8]", att):
                charts_gui.updateChartsAfterTreatment(
                    om_gui, att, new_plan, new_completed)
                toothName = pt.chartgrid.get(att, "").upper()

                pt.addHiddenNote(
                    "chart_treatment", "%s %s" % (toothName, treat_code),
                    attempt_delete=True)
            elif att in ("xray", "perio"):
                pt.addHiddenNote("%s_treatment" % att, treat_code,
                                 attempt_delete=True)
            else:
                pt.addHiddenNote("treatment", treat_code,
                                 attempt_delete=True)

            break

    if not found:
        msg = "Error moving %s from completed to plan" % tx_hash
        om_gui.advise("<p>%s</p><p>This shouldn't happen</p>" % msg, 1)

    for estimate in pt.estimates:
        for est_tx_hash in estimate.tx_hashes:
            if est_tx_hash == tx_hash:
                est_tx_hash.completed = False

    om_gui.ui.toothPropsWidget.setTooth(
        om_gui.ui.toothPropsWidget.selectedTooth, om_gui.selectedChartWidget)

    om_gui.updateHiddenNotesLabel()
    om_gui.ui.estWidget.resetEstimate()
    om_gui.updateDetails()
示例#4
0
def tx_hash_complete(om_gui, tx_hash):
    '''
    reponds to a signal when the user completes an item of treatment by
    checking a checkbox on the estwidget
    '''
    if localsettings.clinicianNo == 0:
        om_gui.advise(
            _("You have no clinician login. "
              "Treatments cannot be completed by you!"),
            2)
        return

    LOGGER.debug(tx_hash)

    pt = om_gui.pt
    found = False
    for hash_, att, treat_code in pt.tx_hash_tups:
        # print "comparing %s with %s"% (hash_, tx_hash)
        if hash_ == tx_hash:
            found = True

            # convert back from deciduous here
            att = localsettings.convert_deciduous(att)
            plan = pt.treatment_course.__dict__[att + "pl"].replace(
                treat_code, "", 1)
            pt.treatment_course.__dict__[att + "pl"] = plan

            completed = pt.treatment_course.__dict__[att + "cmp"] \
                + treat_code
            pt.treatment_course.__dict__[att + "cmp"] = completed

            if re.match("[ul][lr][1-8]", att):
                charts_gui.updateChartsAfterTreatment(
                    om_gui, att, plan, completed)
                toothName = pt.chartgrid.get(att, "").upper()

                pt.addHiddenNote(
                    "chart_treatment", "%s %s" % (toothName, treat_code))

            elif att in ("xray", "perio"):
                pt.addHiddenNote("%s_treatment" % att, treat_code)

            else:
                pt.addHiddenNote("treatment", treat_code)

            break

    if not found:
        msg = "Error moving %s from plan to completed" % tx_hash
        om_gui.advise("<p>%s</p><hr />This shouldn't happen!" % msg, 2)
        return

    found = False
    for estimate in pt.estimates:
        for est_tx_hash in estimate.tx_hashes:
            if est_tx_hash == tx_hash:
                found = True
                est_tx_hash.completed = True
                if treat_code.strip(" ") == "!FEE":
                    om_gui.addNewNote(
                        "%s %s\n" % (_("Completed"), estimate.description))

    if not found:
        msg = "This item '%s' was not found in the patient's estimate" % tx_hash
        om_gui.advise("<p>%s</p><hr />This shouldn't happen!" % msg, 2)
        return

    om_gui.ui.toothPropsWidget.setTooth(
        om_gui.ui.toothPropsWidget.selectedTooth, om_gui.selectedChartWidget)

    om_gui.updateHiddenNotesLabel()
    om_gui.ui.estWidget.resetEstimate()
    om_gui.updateDetails()
示例#5
0
def tx_hash_reverse(om_gui, tx_hash):
    '''
    reponds to a signal when the user completes an item of treatment by
    checking a checkbox on the estwidget
    '''
    LOGGER.debug(tx_hash)

    pt = om_gui.pt
    found = False
    for hash_, att, treat_code in pt.tx_hash_tups:
        LOGGER.debug("comparing %s with %s", hash_, tx_hash)
        if hash_ == tx_hash:
            found = True

            LOGGER.debug("MATCH!")

            if att == "exam":
                pt.treatment_course.examt = ""
                pt.treatment_course.examd = None
                pt.addHiddenNote("exam", treat_code, attempt_delete=True)
                for estimate in pt.estimates:
                    for est_tx_hash in estimate.tx_hashes:
                        if est_tx_hash == tx_hash:
                            pt.estimates.remove(estimate)
                            break
                break

            # convert back from deciduous here
            att = localsettings.convert_deciduous(att)

            old_completed = pt.treatment_course.__dict__[att + "cmp"]
            new_completed = old_completed.replace(treat_code, "", 1)
            pt.treatment_course.__dict__[att + "cmp"] = new_completed

            old_plan = pt.treatment_course.__dict__[att + "pl"]
            # doubly cautious here to ensure single space separation
            new_plan = "%s %s " % (old_plan.strip(" "), treat_code.strip(" "))
            pt.treatment_course.__dict__[att + "pl"] = new_plan

            if re.findall("[ul][lr][1-8]", att):
                charts_gui.updateChartsAfterTreatment(om_gui, att, new_plan,
                                                      new_completed)
                toothName = pt.chartgrid.get(att, "").upper()

                pt.addHiddenNote("chart_treatment",
                                 "%s %s" % (toothName, treat_code),
                                 attempt_delete=True)
            elif att in ("xray", "perio"):
                pt.addHiddenNote("%s_treatment" % att,
                                 treat_code,
                                 attempt_delete=True)
            else:
                pt.addHiddenNote("treatment", treat_code, attempt_delete=True)

            break

    if not found:
        msg = "Error moving %s from completed to plan" % tx_hash
        om_gui.advise("<p>%s</p><p>This shouldn't happen</p>" % msg, 1)

    for estimate in pt.estimates:
        for est_tx_hash in estimate.tx_hashes:
            if est_tx_hash == tx_hash:
                est_tx_hash.completed = False

    om_gui.ui.toothPropsWidget.setTooth(
        om_gui.ui.toothPropsWidget.selectedTooth, om_gui.selectedChartWidget)

    om_gui.updateHiddenNotesLabel()
    om_gui.ui.estWidget.resetEstimate()
    om_gui.updateDetails()
示例#6
0
def tx_hash_complete(om_gui, tx_hash):
    '''
    reponds to a signal when the user completes an item of treatment by
    checking a checkbox on the estwidget
    '''
    if localsettings.clinicianNo == 0:
        om_gui.advise(
            _("You have no clinician login. "
              "Treatments cannot be completed by you!"), 2)
        return

    LOGGER.debug(tx_hash)

    pt = om_gui.pt
    found = False
    for hash_, att, treat_code in pt.tx_hash_tups:
        # print "comparing %s with %s"% (hash_, tx_hash)
        if hash_ == tx_hash:
            found = True

            # convert back from deciduous here
            att = localsettings.convert_deciduous(att)
            plan = pt.treatment_course.__dict__[att + "pl"].replace(
                treat_code, "", 1)
            pt.treatment_course.__dict__[att + "pl"] = plan

            completed = pt.treatment_course.__dict__[att + "cmp"] \
                + treat_code
            pt.treatment_course.__dict__[att + "cmp"] = completed

            if re.match("[ul][lr][1-8]", att):
                charts_gui.updateChartsAfterTreatment(om_gui, att, plan,
                                                      completed)
                toothName = pt.chartgrid.get(att, "").upper()

                pt.addHiddenNote("chart_treatment",
                                 "%s %s" % (toothName, treat_code))

            elif att in ("xray", "perio"):
                pt.addHiddenNote("%s_treatment" % att, treat_code)

            else:
                pt.addHiddenNote("treatment", treat_code)

            break

    if not found:
        msg = "Error moving %s from plan to completed" % tx_hash
        om_gui.advise("<p>%s</p><hr />This shouldn't happen!" % msg, 2)
        return

    found = False
    for estimate in pt.estimates:
        for est_tx_hash in estimate.tx_hashes:
            if est_tx_hash == tx_hash:
                found = True
                est_tx_hash.completed = True
                if treat_code.strip(" ") == "!FEE":
                    om_gui.addNewNote("%s %s\n" %
                                      (_("Completed"), estimate.description))

    if not found:
        om_gui.advise(
            "<p>%s '%s' %s</p><hr />%s" %
            (_("This item"), tx_hash,
             _("was not found in the patient's estimate"),
             _("This shouldn't happen!")), 2)
        return

    om_gui.ui.toothPropsWidget.setTooth(
        om_gui.ui.toothPropsWidget.selectedTooth, om_gui.selectedChartWidget)

    om_gui.updateHiddenNotesLabel()
    om_gui.ui.estWidget.resetEstimate()
    om_gui.updateDetails()