assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("022.22"), ("022", "22"))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("333.3"), ("333", "3"))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("444"), ("444", ""))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("9.9"), ("009", "9"))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("88.88"), ("088", "88"))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("777.6"), ("777", "6"))])) assert (all( [x == y for x, y in zip(icd9.decimal_to_parts("009.9"), ("009", "9"))])) assert (icd9.short_to_decimal("0010") == "1.0") assert (icd9.short_to_decimal("001") == "1") assert (icd9.short_to_decimal("022") == "22") assert (icd9.short_to_decimal("345") == "345") assert (icd9.short_to_decimal("001") == "1") assert (icd9.short_to_decimal("0011") == "1.1") assert (icd9.short_to_decimal("00123") == "1.23") assert (icd9.short_to_decimal("081") == "81") assert (icd9.short_to_decimal("0811") == "81.1") assert (icd9.short_to_decimal("08123") == "81.23") assert (icd9.short_to_decimal("991") == "991") assert (icd9.short_to_decimal("9911") == "991.1") assert (icd9.short_to_decimal("99123") == "991.23") assert (icd9.short_to_decimal("V013") == "V01.3") assert (all(
conn = psycopg2.connect("dbname='mimic' user='******' host='localhost' password='******'") except: print("I am unable to connect to the database") tree = ICD92('codes.json') cur = conn.cursor() cur.execute("""set search_path to mimiciii""") cur.execute("""SELECT * from allevents where event_type='diagnosis'""") rows = cur.fetchall() index = 0 for row in rows: if row[4][0:1] == "V": continue newcode = icd9.short_to_decimal(row[4]) if newcode.find(".") == 2: newcode = "0"+newcode elif newcode.find(".") == 1: newcode = "00" + newcode try: try: if newcode[0:2] == "28": parents = ["ROOT", "280-289", newcode[0:3], newcode] else: parents = [x.code for x in tree.find(newcode).parents] except (KeyboardInterrupt, SystemExit): raise except: parents = [x.code for x in tree.find(newcode[:-1]).parents]
assert(all([x == y for x, y in zip(icd9.decimal_to_parts("0"), ("000", ""))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("000"), ("000", ""))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("V1.2"), ("V01", "2"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("1.1"), ("001", "1"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("001.1"), ("001", "1"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("22.22"), ("022", "22"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("022.22"), ("022", "22"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("333.3"), ("333", "3"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("444"), ("444", ""))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("9.9"), ("009", "9"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("88.88"), ("088", "88"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("777.6"), ("777", "6"))])) assert(all([x == y for x, y in zip(icd9.decimal_to_parts("009.9"), ("009", "9"))])) assert(icd9.short_to_decimal("0010") == "1.0") assert(icd9.short_to_decimal("001") == "1") assert(icd9.short_to_decimal("022") == "22") assert(icd9.short_to_decimal("345") == "345") assert(icd9.short_to_decimal("001") == "1") assert(icd9.short_to_decimal("0011") == "1.1") assert(icd9.short_to_decimal("00123") == "1.23") assert(icd9.short_to_decimal("081") == "81") assert(icd9.short_to_decimal("0811") == "81.1") assert(icd9.short_to_decimal("08123") == "81.23") assert(icd9.short_to_decimal("991") == "991") assert(icd9.short_to_decimal("9911") == "991.1") assert(icd9.short_to_decimal("99123") == "991.23") assert(icd9.short_to_decimal("V013") == "V01.3") assert(all([x == y for x, y in zip(icd9.short_to_parts("E000"), ("E000", ""))]))