Spaces:
Running
Running
fix age ranges
Browse files
trauma/api/chat/dto.py
CHANGED
@@ -10,7 +10,6 @@ class ModelType(Enum):
|
|
10 |
o1_preview = "o1-preview"
|
11 |
|
12 |
class EntityData(BaseModel):
|
13 |
-
|
14 |
-
ageMax: int | None = None
|
15 |
treatmentArea: str | None = None
|
16 |
treatmentMethod: str | None = None
|
|
|
10 |
o1_preview = "o1-preview"
|
11 |
|
12 |
class EntityData(BaseModel):
|
13 |
+
age: int | None = None
|
|
|
14 |
treatmentArea: str | None = None
|
15 |
treatmentMethod: str | None = None
|
trauma/api/message/ai/prompts.py
CHANGED
@@ -28,15 +28,13 @@ Je verzamelt informatie over een patiënt, hun ziekte en de behandelmethode zoda
|
|
28 |
|
29 |
```json
|
30 |
{
|
31 |
-
“
|
32 |
-
“ageMax”: integer,
|
33 |
“treatmentArea”: “string”,
|
34 |
“treatmentMethod”: “string”
|
35 |
}
|
36 |
```
|
37 |
|
38 |
-
- **[
|
39 |
-
- **[ageMax]**: Maximale leeftijd van de patiënt.
|
40 |
- **[treatmentArea]**: Het type mentale of fysieke ziekte/stoornis.
|
41 |
- **[treatmentMethod]**: Een methode voor het behandelen van de ziekte of stoornis.
|
42 |
|
|
|
28 |
|
29 |
```json
|
30 |
{
|
31 |
+
“age”: integer,
|
|
|
32 |
“treatmentArea”: “string”,
|
33 |
“treatmentMethod”: “string”
|
34 |
}
|
35 |
```
|
36 |
|
37 |
+
- **[age]**: leeftijd van de patiënt.
|
|
|
38 |
- **[treatmentArea]**: Het type mentale of fysieke ziekte/stoornis.
|
39 |
- **[treatmentMethod]**: Een methode voor het behandelen van de ziekte of stoornis.
|
40 |
|
trauma/api/message/db_requests.py
CHANGED
@@ -60,8 +60,8 @@ async def filter_entities_by_age(entity_data: dict) -> list[int]:
|
|
60 |
query = {
|
61 |
"ageGroups": {
|
62 |
"$elemMatch": {
|
63 |
-
"ageMin": {"$lte": entity_data['
|
64 |
-
"ageMax": {"$gte": entity_data['
|
65 |
}
|
66 |
}
|
67 |
}
|
|
|
60 |
query = {
|
61 |
"ageGroups": {
|
62 |
"$elemMatch": {
|
63 |
+
"ageMin": {"$lte": entity_data['age']},
|
64 |
+
"ageMax": {"$gte": entity_data['age']}
|
65 |
}
|
66 |
}
|
67 |
}
|
trauma/api/message/utils.py
CHANGED
@@ -44,10 +44,8 @@ def prepare_final_entities_str(entities: list[EntityModel]) -> str:
|
|
44 |
|
45 |
|
46 |
def pick_empty_field_instructions(empty_field: str) -> str:
|
47 |
-
if empty_field == "
|
48 |
-
return "
|
49 |
-
elif empty_field == "ageMax":
|
50 |
-
return "Maximale leeftijd van de patiënt."
|
51 |
elif empty_field == "treatmentArea":
|
52 |
return "Het type psychische of lichamelijke ziekte / stoornis."
|
53 |
elif empty_field == "treatmentMethod":
|
@@ -58,9 +56,9 @@ def find_matching_age_group(entity: EntityModel, entity_data: dict) -> AgeGroup:
|
|
58 |
age_groups = entity.ageGroups
|
59 |
best_match = None
|
60 |
for age_group in age_groups:
|
61 |
-
if age_group.ageMin <= entity_data['
|
62 |
return age_group
|
63 |
-
if age_group.ageMax < entity_data['
|
64 |
if best_match is None or age_group.ageMax > best_match.ageMax:
|
65 |
best_match = age_group
|
66 |
return best_match
|
|
|
44 |
|
45 |
|
46 |
def pick_empty_field_instructions(empty_field: str) -> str:
|
47 |
+
if empty_field == "age":
|
48 |
+
return "Leeftijd van de patiënt."
|
|
|
|
|
49 |
elif empty_field == "treatmentArea":
|
50 |
return "Het type psychische of lichamelijke ziekte / stoornis."
|
51 |
elif empty_field == "treatmentMethod":
|
|
|
56 |
age_groups = entity.ageGroups
|
57 |
best_match = None
|
58 |
for age_group in age_groups:
|
59 |
+
if age_group.ageMin <= entity_data['age'] <= age_group.ageMax:
|
60 |
return age_group
|
61 |
+
if age_group.ageMax < entity_data['age']:
|
62 |
if best_match is None or age_group.ageMax > best_match.ageMax:
|
63 |
best_match = age_group
|
64 |
return best_match
|