def get_status(patient_id, patientRecord):
    """Determines whether patient is tachycardic and returns latest timestamp.

    :param patient_id: patient id as string
    :param patientRecord: dictionary of all records to date
    :returns: dictionary of status and latest timestamp
    """
    from validate import check_patient_id
    patient_id = check_patient_id(patient_id)
    if patient_id in patientRecord:
        from tachycardia import is_tachycardic
        allHRdata = patientRecord[patient_id][2]
        HRs = allHRdata[0]
        if not HRs:
            raise ValueError
        else:
            HRs.reverse()
            yesOrNo = is_tachycardic(patientRecord[patient_id][1], HRs[0])
            timestamps = allHRdata[1]
            timestamps.reverse()
            latest = timestamps[0].strftime("%Y-%m-%d %H:%M:%S.%f")
            timestamps.reverse()
            HRs.reverse()
            return {
                "Is {} tachycardic?".format(patient_id): yesOrNo,
                "Time of latest heart rate measurement": latest
            }
    else:
        raise ValueError
Ejemplo n.º 2
0
def test_tachycardia():
    from tachycardia import is_tachycardic

    result = is_tachycardic("tachycardia")
    expected = False

    assert result == expected
def add_heart_rate(new_HR, patientRecord):
    """Adds new HR measurement and timestamp to appropriate patient record.

    :param newHR: Python object of received JSON
    :param patientRecord: dictionary of all records to date
    :returns: updated dictionary of all records
    """
    from validate import validate_new_HR
    newHR = validate_new_HR(new_HR)
    if newHR["patient_id"] in patientRecord:
        patient_id = newHR["patient_id"]
        patientRecord[patient_id][2][0].append(newHR["heart_rate"])
        patientRecord[patient_id][2][1].append(datetime.now())
        from tachycardia import is_tachycardic, send_email
        if is_tachycardic(patientRecord[patient_id][1],
                          newHR["heart_rate"]) == "Yes.":
            send_email(patientRecord[patient_id][0], patient_id)
        return patientRecord
    else:
        raise ValueError
Ejemplo n.º 4
0
def test_is_tachycardic_varinput_parametrize(a, expected):
    from tachycardia import is_tachycardic
    answer = is_tachycardic(a)
    assert answer == expected
Ejemplo n.º 5
0
def test_is_tachycardic_not():
    from tachycardia import is_tachycardic
    answer = is_tachycardic(" cardic?!. ")
    expected = False
    assert answer == expected
Ejemplo n.º 6
0
def test_is_tachycardic_punctuation():
    from tachycardia import is_tachycardic
    answer = is_tachycardic("TA.cHyCARDic?!.")
    expected = True
    assert answer == expected
Ejemplo n.º 7
0
def test_is_tachycardic_upper():
    from tachycardia import is_tachycardic
    answer = is_tachycardic("TACHYCARDIC")
    expected = True
    assert answer == expected
def test_is_tachycardic3(a, expected):
    from tachycardia import is_tachycardic
    result = is_tachycardic(a)
    assert result == expected
def test_is_tachycardic_param(in_word, expected):
    from tachycardia import is_tachycardic

    answer = is_tachycardic(in_word)
    assert answer == expected
Ejemplo n.º 10
0
def test_is_tachycardic():
    ans_1 = is_tachycardic('tachycardic')
    exp_1 = True
    assert ans_1 == exp_1
Ejemplo n.º 11
0
def test_5():
    ans_5 = is_tachycardic('TachyCardic  ')
    exp_5 = True
    assert ans_5 == exp_5
Ejemplo n.º 12
0
def test_4():
    ans_4 = is_tachycardic('tachycardi')
    exp_4 = False
    assert ans_4 == exp_4
Ejemplo n.º 13
0
def test_3():
    ans_3 = is_tachycardic('tachycardic.')
    exp_3 = True
    assert ans_3 == exp_3
def test_tachycardia(s, soln):
    from tachycardia import is_tachycardic
    ans = is_tachycardic(s)
    assert ans == soln
Ejemplo n.º 15
0
def test_not_close_tachycardic(word, expected):
    answer = is_tachycardic(word)
    assert answer == expected
Ejemplo n.º 16
0
def test_missingOneLetter_is_tachycardic(stringToCheck, expected):
    result = is_tachycardic(stringToCheck)
    assert result is expected
def test_correct_spelling(input, expected):
    from tachycardia import is_tachycardic
    outcome = is_tachycardic(input)
    assert outcome == expected
Ejemplo n.º 18
0
def test_6():
    ans_6 = is_tachycardic('TACHYCARDIC')
    exp_6 = True
    assert ans_6 == exp_6
def test_is_tachycardic_unit():
    from tachycardia import is_tachycardic

    result = is_tachycardic('tachycardic')  # test lower case
    assert result is True
Ejemplo n.º 20
0
def test_7():
    ans_7 = is_tachycardic(6)
    exp_7 = False
    assert ans_7 == exp_7
Ejemplo n.º 21
0
def test_is_tachycardic(inputString, expected):
    from tachycardia import is_tachycardic

    isTachycardicTest = is_tachycardic(inputString)
    assert isTachycardicTest == expected
Ejemplo n.º 22
0
def test_2():
    ans_2 = is_tachycardic('  tachycardic')
    exp_2 = True
    assert ans_2 == exp_2
Ejemplo n.º 23
0
def test_is_tachycardic_mixed():
    from tachycardia import is_tachycardic
    answer = is_tachycardic("TAcHyCARDic")
    expected = True
    assert answer == expected
Ejemplo n.º 24
0
def test_uppercase_is_tachycardic(stringToCheck, expected):
    result = is_tachycardic(stringToCheck)
    assert result is expected
Ejemplo n.º 25
0
def test_is_tachycardic_whitespace():
    from tachycardia import is_tachycardic
    answer = is_tachycardic(" TA.cHyCARDic?!. ")
    expected = True
    assert answer == expected
Ejemplo n.º 26
0
def test_addedTwoLetters_is_tachycardic(stringToCheck, expected):
    result = is_tachycardic(stringToCheck)
    assert result is expected
Ejemplo n.º 27
0
def test_is_tachycardic_lower():
    from tachycardia import is_tachycardic
    answer = is_tachycardic("tachycardic")
    expected = True
    assert answer == expected
Ejemplo n.º 28
0
def test_subThreeLetters_is_tachycardic(stringToCheck, expected):
    result = is_tachycardic(stringToCheck)
    assert result is expected
Ejemplo n.º 29
0
def test_is_tachycardic_misspelled_parametrize(b, expected):
    from tachycardia import is_tachycardic
    answer = is_tachycardic(b)
    assert answer == expected
Ejemplo n.º 30
0
def test_leadTrail_is_tachycardic(stringToCheck, expected):
    result = is_tachycardic(stringToCheck)
    assert result is expected