Fix processing of optional patient record #21

Merged
christian-monch merged 1 commit from fix-patient into master 2022-02-22 16:31:31 +00:00
2 changed files with 30 additions and 1 deletions

View file

@ -99,6 +99,18 @@ required_fields = [
]
required_patient_fields = [
"patient-year-first-symptom",
"patient-month-first-symptom",
"patient-day-first-symptom",
"patient-year-diagnosis",
"patient-month-diagnosis",
"patient-day-diagnosis",
"patient-main-disease",
"patient-stronger-impacted-hand"
]
# Browsers might not send disabled or empty input fields at all.
# All entries in auto_fields will be added to the incoming field
# set, if they are not present.
@ -295,6 +307,16 @@ def hand_message(value):
}[value]
def disease_message(value):
return {
"stroke": "Schlaganfall",
"parkinson": "Parkinson",
"tic": "Tic",
"depression": "Depression",
"alzheimer": "Alzheimer",
}[value]
def date_message(year, month, day):
return "-".join([
str(x)
@ -312,6 +334,7 @@ def create_result_page(commit_hash: str, time_stamp: float, json_top_data: dict,
reference=f"{time_stamp}-{commit_hash}",
record=json_top_data["data"],
date_message=date_message,
disease_message=disease_message,
hand_message=hand_message,
sex_message=sex_message,
subject_group_message=subject_group_message,
@ -640,6 +663,12 @@ def application(environ, start_response):
# This will throw an error, if the key is not available
json_object[key] = get_field_value(entered_data, key)
# Read keys dependent on subject-group
if json_object["subject-group"] == "patient":
for key in required_patient_fields:
# This will throw an error, if the key is not available
json_object[key] = get_field_value(entered_data, key)
time_stamp = time.time()
json_data = {

View file

@ -90,7 +90,7 @@
{% if record["subject-group"] == "patient" %}
{{ render_number("Haupterkrankung", "patient-main-disease") }}
{{ render_string("Haupterkrankung", disease_message(record["patient-main-disease"])) }}
{{ render_string("Datum Erstsymptom", date_message(record["patient-year-first-symptom"], record["patient-month-first-symptom"], record["patient-day-first-symptom"])) }}
{{ render_string("Datum Diagnose", date_message(record["patient-year-diagnosis"], record["patient-month-diagnosis"], record["patient-day-diagnosis"])) }}
{{ render_string("Stärker betroffene Hand", hand_message(record["patient-stronger-impacted-hand"])) }}