Ejemplo n.º 1
0
    def add_person_header(self, person_id):
        """This function adds the person header to the given window based on the id number of the person given to the
        function.
        :param person_id: the identification number of the person being processed used to intake their data
        :type person_id: int
        """

        name = query.adat_person_key(person_id, '~1')[1]
        sex = query.adat_person_key(person_id, '~14')[1]
        sex = ld.get_text_from_dict(self.language, sex)
        age = query.adat_person_key(person_id, '~15')[1]
        name_lbl = Label(self.window, text=name, font=self.medium_font)
        sex_lbl = Label(self.window, text=sex, font=self.medium_font, width = self.width)
        age_lbl = Label(self.window, text=age, font=self.medium_font, width = self.width)

        name_lbl.grid(row=self.task_row, column=0, sticky='W', columnspan=2)
        sex_lbl.grid(row=self.task_row, column=2, sticky='W')
        age_lbl.grid(row=self.task_row, column=3, sticky='W')
        self.task_row += 1
Ejemplo n.º 2
0
def murphy005(person):
    """   receives a person and calculates and returns the BMI
    :param person: person
    :type person: str
    :return: BMI
    """
    a, b = query.adat_person_key(person, '~19')[1], query.adat_person_key(
        person, '~45')[1]  # get last height & wt
    a, b = float(a), float(b)
    result = round(a / b**2, 1)
    datas = {
        'data': [{
            'k': '~47',
            'v': (str(result)),
            'vt': 'f',
            'units': None
        }]
    }
    return datas
Ejemplo n.º 3
0
    def add_label(self, value, person_id):
        """this function adds a label to a given window
        :param person_id:  identification number of person (11, or 12) for (tina, tony)
        :type person_id: int
        :param value: a dictionary reference to a value that needs to be written in the form a label to the screen
        :type value: str
        """
        lbl = Label(self.window, text=ld.get_text_from_dict(self.language, value) + ': ', font=self.medium_font)
        lbl.grid(row=self.task_row, column=0, ipady=self.row_padding, sticky='W', columnspan = 2)
        lbl_val = query.adat_person_key(person_id, value)[1]
        lbl_info = Label(self.window, text=ld.get_text_from_dict(self.language, lbl_val), font = self.medium_font)

        lbl_info.grid(row=self.task_row, column=1, ipady=self.row_padding, sticky=S)
        self.task_row += 1
Ejemplo n.º 4
0
    def populate_task(self, task_id, person_id, task_window_info, token,
                      priority, status):
        """This function adds the buttons for the staffer's task to the task window.
        :param task_id: the value that corresponds to the task that the staffer needs to complete
        :type task_id: str
        :param person_id: the unique identification number of the person being processed by the staff member
        :type person_id: str
        :param task_window_info: contains a list of widget elements to be added to the task window for the staff member
        :type task_window_info: list
        :param token: the unique token id for the information handled by the staff member
        :type token: int
        :param priority: the current priority of a task
        :type priority: int
        :param status: the current status of the task being processed
        :type status: str (~vocab)
        """
        name = query.adat_person_key(
            person_id,
            '~1')[1]  # maybe list handling should be done in query.py
        if not self.dat.check_in_display(name):
            label_name = Label(self.window,
                               text=name,
                               font=self.widget_creator.medium_font)
            label_name.grid(column=0,
                            row=self.row_current,
                            columnspan=3,
                            sticky=W)
        self.row_current += 1
        btn_process: Button = Button(
            self.window,
            text='=>',
            command=lambda: self.write_task_screen(task_window_info, person_id,
                                                   token, task_id, priority),
            fg="black",
            bg="gray",
            width=self.width - 10)
        btn_process.grid(column=4, row=self.row_current, sticky=E)

        self.dat.add_token_row_name(self.row_current, name)
        btn_log: Button = Button(self.window,
                                 text=ld.get_text_from_dict(
                                     self.language, '~13'),
                                 width=self.width,
                                 command=lambda: self.view_log_data(token),
                                 fg="black",
                                 bg="gray")
        btn_log.grid(column=0, row=self.row_current)

        self.add_person_to_tasks(priority, token, status)
Ejemplo n.º 5
0
def murphy_mkv(person, murphy_num, maps_keys_values):
    """here the murphy is being told by the caller the murphy_num AND what values to evaluate
    this would typically be for a single key and for math operations: averages, trends, etc.
    :param person: person whose values to operate on
    :type person: str
    :param murphy_num: the murphy to do
    :type murphy_num: str
    :param maps_keys_values: which key(s) and time specification of which values (by last, earliest, latest) to use
    :type maps_keys_values: list
    :return: the output of the murphy
    """
    values = []
    for mkv in maps_keys_values:
        key = mkv[1]
        valuespec = mkv[2]
        if not valuespec:  # if there is not time specification of values to receive
            v = query.adat_person_key(person,
                                      key)  # default is to get the most recent
            values.append(v[1])
        if valuespec:
            try:
                last = valuespec[0]
            except:
                last = 1
            try:
                earliest = valuespec[1]
            except:
                earliest = None
            try:
                latest = valuespec[2]
            except:
                latest = None
            vs = query.adat_person_key_options(person, key, last, earliest,
                                               latest)
            for v in vs:
                values.append(v[1])
    result = func_dict[murphy_num](values)
    datas = {
        'data': [{
            'k': key,
            'v': (str(result)),
            'vt': 'f',
            'units': None
        }]
    }
    return datas
Ejemplo n.º 6
0
 def add_entry_with_text(self, value, person_id):
     """This function adds an entry with text prefilled to the given window.
      As it stands it only places the header for the entry box
      but entry box functionality will be added in the next update
     :param person_id: identification number of the person in question
     :type person_id: int
     :param value: a dictionary reference to a value that needs to be written in the form a label to the screen
     :type value: str
     """
     phone_number = query.adat_person_key(person_id, '~16')[1]
     lbl = Label(self.window, text=ld.get_text_from_dict(self.language, value) + ': ', font=self.medium_font)
     lbl.grid(row=self.task_row, column=0, ipady=self.row_padding, sticky='W')
     text_entered = StringVar()
     entry_box = Entry(self.window, textvariable=text_entered)
     entry_box.insert(0, phone_number)
     self.widgets.append((value, entry_box))
     entry_box.grid(row=self.task_row, column=1, sticky='W')
     self.task_row += 1
Ejemplo n.º 7
0
def decision(person, d_spec):
    """ receives the person and the decision spec from a caller, uses query to get the relevant data for the person,
        calls an evaluation function for each value and criteria, codes the results in a composite,
        which are is then evaluated by the table in the last lines.
    :param person: the person for whom the decision is needed
    :type person: str
    :param d_spec: values and criteria by which to evaluate them and what calls (if any) to return based on evals
    :type d_spec: list
    :return: what step(s) or protocol(s) to call
    """
    decision_spec = spec_dict.get(d_spec)
    var_values = []
    missed = 0
    vars_specs = decision_spec[0]
    for var_spec in vars_specs:
        if len(var_spec[0]
               ) == 1:  # if only the most recent value of the key is needed
            value = query.adat_person_key(
                person, var_spec[0][0][0])  # gather data with this call
        else:  # if some other criteria to get the value(s)
            value = query.adat_person_key_options(
                person, var_spec[0][0], var_spec[0][1], var_spec[0][2],
                var_spec[0][3])  # use this one
        if not value:  # if the query (whichever of the two) doesn't return a value
            value = 'missing'
            missed += 1
        var_values.append([var_spec[0], value])
    if missed > 0:  # if data for any variable was missing
        return ('missing report', var_values
                )  # stop here and return a missing report
    # now, since we made it past the above line, relevant data exists we continue and evaluate each
    var_cycles = len(
        var_values
    )  # setting up to to cycle through all the variables involved
    var_cycle = 0
    composite = []
    while var_cycle < var_cycles:  # starting the cycle through variables
        crit_cycles = len(
            decision_spec[0][var_cycle]
            [2])  # setting up to cycle through criteria on that variable
        crit_cycle = 0
        while crit_cycle < crit_cycles:  # starting the cycle through criteria
            ds = decision_spec[0][var_cycle][2][
                crit_cycle]  # gathering the test criteria to be used
            if len(ds) == 2:  # if there is one test criteria to be used
                result = evaluate_1test(var_values[var_cycle][1], ds)
            elif len(ds) == 4:  # if there are two test criteria to be used
                result = evaluate_2tests(var_values[var_cycle][1], ds)
            else:
                result = None
                print(
                    '\n\nERROR LURKING- length of decision criteria not within range\n\n'
                )
            coded_result = [
                'var' + str(var_cycle + 1) + str(crit_cycle + 1) + result
            ]  # create the coded string
            crit_cycle += 1
            composite = composite + coded_result  # compile the results (as a list of coded strings)
        var_cycle += 1
    # print('\n', person, composite)

    # finally, compare the composite generated with the table specifications, and return what should happen next
    table = decision_spec[1]
    for tab in table:  # go one by one through table until
        if tab[0] == composite:  # we find a match to the composite
            return tab[
                1]  # then return what the table specified as the decision, the call(s) to make