Spaces:
Runtime error
Runtime error
natexcvi
commited on
Commit
•
ff37931
1
Parent(s):
ed8f052
Add adherence_history endpoint
Browse files
main.py
CHANGED
@@ -61,6 +61,22 @@ class DB:
|
|
61 |
),
|
62 |
]
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
|
66 |
db = DB()
|
@@ -99,6 +115,13 @@ async def get_patient_adherence_status(patient_id: str) -> AdherenceStatus | Res
|
|
99 |
)
|
100 |
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
@app.get("/{patient_id}/issues", response_model=list[PatientIssue])
|
103 |
async def get_patient_issues(patient_id: str) -> list[PatientIssue] | Response:
|
104 |
if patient_id not in db.issues:
|
|
|
61 |
),
|
62 |
]
|
63 |
}
|
64 |
+
self.adherence_history = {
|
65 |
+
"123": AdherenceHistory(
|
66 |
+
history=[
|
67 |
+
AdherenceHistoryRecord(date="2021-01-01", adherence=0.9),
|
68 |
+
AdherenceHistoryRecord(date="2021-01-02", adherence=0.85),
|
69 |
+
AdherenceHistoryRecord(date="2021-01-03", adherence=0.87),
|
70 |
+
AdherenceHistoryRecord(date="2021-01-04", adherence=0.79),
|
71 |
+
AdherenceHistoryRecord(date="2021-01-05", adherence=0.77),
|
72 |
+
AdherenceHistoryRecord(date="2021-01-06", adherence=0.8),
|
73 |
+
AdherenceHistoryRecord(date="2021-01-07", adherence=0.75),
|
74 |
+
AdherenceHistoryRecord(date="2021-01-08", adherence=0.78),
|
75 |
+
AdherenceHistoryRecord(date="2021-01-09", adherence=0.80),
|
76 |
+
AdherenceHistoryRecord(date="2021-01-10", adherence=0.85),
|
77 |
+
]
|
78 |
+
)
|
79 |
+
}
|
80 |
|
81 |
|
82 |
db = DB()
|
|
|
115 |
)
|
116 |
|
117 |
|
118 |
+
@app.get("/{patient_id}/adherence_history", response_model=AdherenceHistory)
|
119 |
+
async def get_patient_adherence_history(patient_id: str) -> Response:
|
120 |
+
if patient_id not in db.adherence_history:
|
121 |
+
return Response(status_code=status.HTTP_404_NOT_FOUND)
|
122 |
+
return db.adherence_history[patient_id]
|
123 |
+
|
124 |
+
|
125 |
@app.get("/{patient_id}/issues", response_model=list[PatientIssue])
|
126 |
async def get_patient_issues(patient_id: str) -> list[PatientIssue] | Response:
|
127 |
if patient_id not in db.issues:
|
schema.py
CHANGED
@@ -26,3 +26,12 @@ class PatientIssue(BaseModel):
|
|
26 |
|
27 |
class AdherenceStatus(BaseModel):
|
28 |
adherence: float
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
class AdherenceStatus(BaseModel):
|
28 |
adherence: float
|
29 |
+
|
30 |
+
|
31 |
+
class AdherenceHistoryRecord(BaseModel):
|
32 |
+
date: str
|
33 |
+
adherence: float
|
34 |
+
|
35 |
+
|
36 |
+
class AdherenceHistory(BaseModel):
|
37 |
+
history: list[AdherenceHistoryRecord]
|