Skip to content

Commit

Permalink
anaemia edit
Browse files Browse the repository at this point in the history
  • Loading branch information
cobaltB12 committed Jan 30, 2024
1 parent 919ba68 commit 71ad3ae
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 15 deletions.
Binary file modified __pycache__/anaemia.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/bmi.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/diabetes.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/image_loading.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/lipids_ranges.cpython-311.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions anaemia.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def anaemia_analysis (hbdict):
if hblevel < 7:
return ":large_orange_circle: Your haemoglobin level is dangerously low. Please visit a doctor immediately."
if hblevel < hbdict["hb"]["test_ref_min"]:
if not hbdict["mcv"]["test_found"] or not hbdict["rbc_count"]["test_found"]:
return ":large_orange_circle: You lkely have anaemia, but there is not enough information to determine the cause. Visit a doctor if you have any concerns of blood loss."
if not hbdict["mcv"]["test_found"]:
return ":large_orange_circle: You likely have anaemia, but there is not enough information to determine the cause. Visit a doctor if you have any concerns of blood loss."
mcv = hbdict["mcv"]["test_value"]
if mcv < hbdict["mcv"]["test_ref_min"]: #microcytic
if not hbdict["rbc_count"]["test_found"]:
return ":large_orange_circle: You likely have anaemia, but there is not enough information to determine the cause. Visit a doctor if you have any concerns of blood loss."
mentzer = mcv/ hbdict["rbc_count"]["test_value"]
if mentzer > 13:
output_phrase = ":large_orange_circle: You likely have anaemia, which could be due to iron deficiency. This can be caused by minor bleeding e.g. menstruation, or from the gastrointestinal tract. Visit your doctor for an assessment to rule out sources of bleeding. Consider taking iron supplements and foods rich in iron, such as green leafy vegetables, meat, especially red meat (beef, mutton, pork), seafood, and organs (kidney, liver)."
Expand Down
2 changes: 1 addition & 1 deletion image_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def remove_nric(text):
def extract_text(image,ocr_model):
ocr_start_time = time.time()
result = ocr_model.ocr(image)
result = result[0] #idk why this needs a result[0] instead of result for Github
result = result #idk why this needs a result[0] instead of result for Github
extracted_text = ''
for idx in range(len(result)):
txt = result[idx][1][0]
Expand Down
6 changes: 3 additions & 3 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from diabetes import get_dm_advice
from anaemia import anaemia_analysis
from bmi import bmi_advice
#from dotenv import load_dotenv
from dotenv import load_dotenv

#load_dotenv()
os.environ['API_KEY']='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'
load_dotenv()
#os.environ['API_KEY']='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'
API_KEY = os.environ['API_KEY'] # API_KEY in streamlit secret

client = OpenAI(api_key=API_KEY)
Expand Down
18 changes: 9 additions & 9 deletions testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
}

test_results = {
'ldl_cholesterol': {'test_found': True, 'test_value': 2.2, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'hdl_cholesterol': {'test_found': True, 'test_value': 1, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'total_cholesterol': {'test_found': True, 'test_value': 3.7, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'mcv': {'test_found': False, 'test_value': False, 'test_unit': False, 'test_ref_min': False, 'test_ref_max': False},
'hb': {'test_found': False, 'test_value': False, 'test_unit': 'g/dL', 'test_ref_min': False, 'test_ref_max': False},
'rbc_count': {'test_found': False, 'test_value': False, 'test_unit': False, 'test_ref_min': False, 'test_ref_max': False},
'ldl_cholesterol': {'test_found': False, 'test_value': 2.2, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'hdl_cholesterol': {'test_found': False, 'test_value': 1, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'total_cholesterol': {'test_found': False, 'test_value': 3.7, 'test_unit': 'mmol/l', 'test_ref_min': False, 'test_ref_max': False},
'mcv': {'test_found': True, 'test_value': 100, 'test_unit': False, 'test_ref_min': 85, 'test_ref_max': 90},
'hb': {'test_found': True, 'test_value': 10, 'test_unit': 'g/dL', 'test_ref_min': 11.5, 'test_ref_max': 15.5},
'rbc_count': {'test_found': True, 'test_value': 4.2, 'test_unit': False, 'test_ref_min': False, 'test_ref_max': False},
'glucose': {'test_found': False, 'test_value': False, 'test_unit': 'mmol/L', 'test_ref_min': False, 'test_ref_max': False},
'hba1c': {'test_found': True, 'test_value': 6.0, 'test_unit': '%', 'test_ref_min': False, 'test_ref_max': False},
'hba1c': {'test_found': False, 'test_value': 6.0, 'test_unit': '%', 'test_ref_min': False, 'test_ref_max': False},
'systolic_bp': {'test_found': False, 'test_value': False, 'test_unit': 'mmHg', 'test_ref_min': False, 'test_ref_max': False},
'diastolic_bp': {'test_found': False, 'test_value': False, 'test_unit': 'mmHg', 'test_ref_min': False, 'test_ref_max': False},
'height': {'test_found': True, 'test_value': 1.61, 'test_unit': 'm', 'test_ref_min': False, 'test_ref_max': False},
'weight': {'test_found': True, 'test_value': 58, 'test_unit': 'kg', 'test_ref_min': False, 'test_ref_max': False}
'height': {'test_found': False, 'test_value': 1.61, 'test_unit': 'm', 'test_ref_min': False, 'test_ref_max': False},
'weight': {'test_found': False, 'test_value': 58, 'test_unit': 'kg', 'test_ref_min': False, 'test_ref_max': False}
}

for key, value in test_results.items():
Expand Down

0 comments on commit 71ad3ae

Please sign in to comment.