Swolfyy commited on
Commit
c31103b
·
verified ·
1 Parent(s): 3f4644e

Upload 5 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ logo.png filter=lfs diff=lfs merge=lfs -text
logo.png ADDED

Git LFS Details

  • SHA256: ea3316fff925844fd9950890dab80e66e49814d8384fa06604b345be0e3f9f70
  • Pointer size: 131 Bytes
  • Size of remote file: 509 kB
mock_ehr_service.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # We need to tell Python to look one level up for our files
2
+ import sys
3
+ import os
4
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
5
+
6
+ # Now we can import our patient data
7
+ from patient_data import PATIENT_ZERO_DATA, PATIENT_ONE_DATA
8
+
9
+ def get_patient_data(patient_id: str):
10
+ """
11
+ Simulates fetching a patient's record from an EHR database.
12
+ """
13
+ print(f"--- [EHR Service] Fetching data for patient_id: {patient_id} ---")
14
+ if patient_id == "P0-12345":
15
+ return PATIENT_ZERO_DATA
16
+ elif patient_id == "P1-67890":
17
+ return PATIENT_ONE_DATA
18
+ else:
19
+ return None # Return nothing if the patient isn't found
orchestrator.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Click the "Copy" button in the top-right corner of this box.
2
+ from services.mock_ehr_service import get_patient_data
3
+ from services.mock_ai_service import get_readmission_prediction
4
+ import json
5
+
6
+ def run_patient_risk_analysis(patient_id: str):
7
+ """
8
+ Orchestrates the process of fetching patient data and getting a prediction.
9
+ """
10
+ print(f"--- [Orchestrator] Starting analysis for patient_id: {patient_id} ---")
11
+
12
+ # Step 1: Get patient data from the mock EHR service
13
+ patient_data = get_patient_data(patient_id)
14
+
15
+ if not patient_data:
16
+ print(f"--- [Orchestrator] Analysis failed: No data found for patient_id {patient_id} ---")
17
+ return None
18
+
19
+ # Step 2: Get a prediction from the mock AI service
20
+ prediction_json = get_readmission_prediction(patient_data)
21
+ prediction_data = json.loads(prediction_json) # Convert the JSON string to a dictionary
22
+
23
+ print(f"--- [Orchestrator] Analysis complete for patient_id: {patient_id} ---")
24
+
25
+ # Step 3: Return the final analysis data
26
+ return prediction_data
patient_data.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PATIENT_ZERO_DATA = {
2
+ "patient_id": "P0-12345",
3
+ "demographics": {
4
+ "age": 72,
5
+ "sex": "Male"
6
+ },
7
+ "recent_admission": {
8
+ "admission_date": "2024-06-15",
9
+ "discharge_date": "2024-06-22",
10
+ "primary_diagnosis": "Acute Myocardial Infarction",
11
+ "comorbidities": ["Hypertension", "Type 2 Diabetes", "Chronic Kidney Disease"],
12
+ "procedure_history": ["Coronary Artery Bypass Grafting"]
13
+ },
14
+ "lab_results": {
15
+ "hemoglobin_a1c": "7.8%",
16
+ "creatinine_level": "1.9 mg/dL",
17
+ "ejection_fraction": "45%"
18
+ },
19
+ "medications": [
20
+ "Lisinopril",
21
+ "Metformin",
22
+ "Aspirin",
23
+ "Atorvastatin"
24
+ ]
25
+ }
26
+
27
+ PATIENT_ONE_DATA = {
28
+ "patient_id": "P1-67890",
29
+ "demographics": {
30
+ "age": 55,
31
+ "sex": "Female"
32
+ },
33
+ "recent_admission": {
34
+ "admission_date": "2024-07-01",
35
+ "discharge_date": "2024-07-05",
36
+ "primary_diagnosis": "Pneumonia",
37
+ "comorbidities": ["Asthma"],
38
+ "procedure_history": []
39
+ },
40
+ "lab_results": {
41
+ "hemoglobin_a1c": "5.5%",
42
+ "creatinine_level": "0.8 mg/dL",
43
+ "ejection_fraction": "60%"
44
+ },
45
+ "medications": [
46
+ "Albuterol",
47
+ "Amoxicillin"
48
+ ]
49
+ }
services/mock_ai_service.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import json
3
+
4
+ def get_readmission_prediction(patient_data: dict):
5
+ """
6
+ Simulates calling the MedGemma API to get a readmission risk prediction.
7
+ """
8
+ patient_id = patient_data.get("patient_id")
9
+ print(f"--- [AI Service] Analyzing data for patient_id: {patient_id} ---")
10
+
11
+ # Based on the patient, return a different mock prediction
12
+ if patient_id == "P0-12345":
13
+ # Simulate a high-risk patient
14
+ mock_response = {
15
+ "risk_score": 0.85,
16
+ "confidence": "High",
17
+ "key_factors": [
18
+ "History of Acute Myocardial Infarction",
19
+ "High Hemoglobin A1c (7.8%)",
20
+ "Chronic Kidney Disease"
21
+ ],
22
+ "recommended_interventions": [
23
+ "Follow-up cardiology appointment within 7 days",
24
+ "Medication reconciliation by pharmacist",
25
+ "Telehealth check-in on day 3 post-discharge"
26
+ ]
27
+ }
28
+ elif patient_id == "P1-67890":
29
+ # Simulate a low-risk patient
30
+ mock_response = {
31
+ "risk_score": 0.15,
32
+ "confidence": "High",
33
+ "key_factors": [
34
+ "No major chronic conditions",
35
+ "Successful treatment for Pneumonia"
36
+ ],
37
+ "recommended_interventions": [
38
+ "Standard primary care follow-up within 30 days"
39
+ ]
40
+ }
41
+ else:
42
+ mock_response = {"error": "Patient data not valid"}
43
+
44
+ # The 'json.dumps' part formats the dictionary nicely, like a real API would
45
+ return json.dumps(mock_response, indent=4)