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
示例#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
def test_is_tachycardic_varinput_parametrize(a, expected):
    from tachycardia import is_tachycardic
    answer = is_tachycardic(a)
    assert answer == expected
def test_is_tachycardic_not():
    from tachycardia import is_tachycardic
    answer = is_tachycardic(" cardic?!. ")
    expected = False
    assert answer == expected
def test_is_tachycardic_punctuation():
    from tachycardia import is_tachycardic
    answer = is_tachycardic("TA.cHyCARDic?!.")
    expected = True
    assert answer == expected
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
示例#10
0
def test_is_tachycardic():
    ans_1 = is_tachycardic('tachycardic')
    exp_1 = True
    assert ans_1 == exp_1
示例#11
0
def test_5():
    ans_5 = is_tachycardic('TachyCardic  ')
    exp_5 = True
    assert ans_5 == exp_5
示例#12
0
def test_4():
    ans_4 = is_tachycardic('tachycardi')
    exp_4 = False
    assert ans_4 == exp_4
示例#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
示例#15
0
def test_not_close_tachycardic(word, expected):
    answer = is_tachycardic(word)
    assert answer == expected
示例#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
示例#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
示例#20
0
def test_7():
    ans_7 = is_tachycardic(6)
    exp_7 = False
    assert ans_7 == exp_7
示例#21
0
def test_is_tachycardic(inputString, expected):
    from tachycardia import is_tachycardic

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