Beispiel #1
0
def remove_estimate_item(om_gui, est_item):
    '''
    the estimate_item has been deleted...
    remove from the plan or completed also?
    '''
    LOGGER.debug("Deleting estimate item %s" % est_item)

    pt = om_gui.pt
    found = False

    for i, tx_hash in enumerate(est_item.tx_hashes):
        LOGGER.debug("est_item.tx_hash %d = %s" % (i, tx_hash))
        for hash_, att, treat_code in pt.tx_hash_tups:
            # LOGGER.debug("comparing %s with %s"% (hash_, tx_hash))
            if hash_ == tx_hash.hash:
                found = True

                LOGGER.debug(
                    "       MATCHING hash Found! removing....'%s' '%s'" % (
                        att, treat_code))

                att = localsettings.convert_deciduous(att)

                if est_item.is_exam:
                    LOGGER.debug("special case - removing exam")
                    pt.treatment_course.examt = ""
                    pt.treatment_course.examd = None
                    pt.addHiddenNote("exam", treat_code, attempt_delete=True)
                    for est in pt.ests_from_hash(tx_hash):
                        pt.estimates.remove(est)
                    om_gui.updateHiddenNotesLabel()
                elif treat_code.strip(" ") == "!FEE":
                    LOGGER.debug("special case - removing feescale added item")
                    if tx_hash.completed:
                        tx_hash_reverse(om_gui, tx_hash)
                    for est in pt.ests_from_hash(tx_hash):
                        pt.estimates.remove(est)
                else:
                    LOGGER.debug("not a special case")
                    remove_treatments_from_plan_and_est(
                        om_gui,
                        ((att, treat_code.strip(" ")),),
                        tx_hash.completed)

    if not found:
        LOGGER.debug("NO MATCHING hash FOUND!")
        om_gui.advise(
            u"%s - %s" % (_("couldn't pass on delete message for"),
                          est_item.description),
            1)
Beispiel #2
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()
Beispiel #3
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
    '''
    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()
Beispiel #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()
Beispiel #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()