Repository: globaldothealth/list

Issue:
Import Peru case data
Uploaded Peru automated source, triggered retrieval and received this error:
Error: Request failed with status code 500

Comments:

Patch:
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index de288e1e..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "python.formatting.provider": "black"
-}
\ No newline at end of file
diff --git a/aws/curator.yaml b/aws/curator.yaml
index 73365f11..03aad401 100644
--- a/aws/curator.yaml
+++ b/aws/curator.yaml
@@ -114,7 +114,7 @@ spec:
     spec:
       containers:
         - name: curator
-          image: ghcr.io/globaldothealth/list/curatorservice:0.0.19
+          image: ghcr.io/globaldothealth/list/curatorservice:0.1.0
           ports:
             - containerPort: 3001
           livenessProbe:
diff --git a/aws/data.yaml b/aws/data.yaml
index 2e59af2f..11e8b59b 100644
--- a/aws/data.yaml
+++ b/aws/data.yaml
@@ -72,7 +72,7 @@ spec:
     spec:
       containers:
         - name: data
-          image: ghcr.io/globaldothealth/list/dataservice:0.0.19
+          image: ghcr.io/globaldothealth/list/dataservice:0.1.0
           ports:
             - containerPort: 3000
           livenessProbe:
diff --git a/ingestion/functions/parsing/peru/input_event.json b/ingestion/functions/parsing/peru/input_event.json
index 0de2fb20..9f084e37 100644
--- a/ingestion/functions/parsing/peru/input_event.json
+++ b/ingestion/functions/parsing/peru/input_event.json
@@ -1,8 +1,8 @@
 {
     "env": "local",
     "s3Bucket": "epid-sources-raw",
-    "s3Key": "test/peru/head200_content.csv",
-    "sourceUrl": "https://foo.bar",
-    "sourceId": "5f4fa7dc9767ff004b750977"
+    "s3Key": "5f61c2974228810028e6eb66/2020/09/16/0748/content.csv",
+    "sourceUrl": "https://cloud.minsa.gob.pe/s/Y8w3wHsEdYQSZRp/download",
+    "sourceId": "5f61c2974228810028e6eb66"
 }
 
diff --git a/ingestion/functions/parsing/peru/peru.py b/ingestion/functions/parsing/peru/peru.py
index 78e3c3e6..527882fc 100644
--- a/ingestion/functions/parsing/peru/peru.py
+++ b/ingestion/functions/parsing/peru/peru.py
@@ -47,6 +47,18 @@ def convert_location(raw_entry):
     return {"query":  ", ".join(query_terms)}
 
 
+def convert_demographics(age: str, sex: str):
+    demo = {}
+    if age:
+        demo["ageRange"] = {
+            "start": float(age),
+            "end": float(age)
+        }
+    if sex:
+        demo["gender"] = convert_gender(sex)
+    return demo or None
+
+
 def parse_cases(raw_data_file, source_id, source_url):
     """
     Parses G.h-format case data from raw API data.
@@ -80,13 +92,7 @@ def parse_cases(raw_data_file, source_id, source_url):
                         }
                     }
                 ],
-                "demographics": {
-                    "ageRange": {
-                        "start": float(entry["EDAD"]),
-                        "end": float(entry["EDAD"])
-                    },
-                    "gender": convert_gender(entry["SEXO"])
-                }
+                "demographics": convert_demographics(entry["EDAD"], entry["SEXO"]),
             }
             yield case
 
diff --git a/ingestion/functions/parsing/peru/sample_data.csv b/ingestion/functions/parsing/peru/sample_data.csv
index 40babb10..8ae8e064 100644
--- a/ingestion/functions/parsing/peru/sample_data.csv
+++ b/ingestion/functions/parsing/peru/sample_data.csv
@@ -4,3 +4,4 @@ e81602051997ace8340bb8c18fe24c65,ANCASH,SANTA,CHIMBOTE,PCR,53.0,FEMENINO,2020072
 cecdbf10074dbc011ae05b3cbd320a6f,LIMA,LIMA,ANCON,PCR,58.0,MASCULINO,20200723
 566af4276cbe9359abe93f9aa86396c3,CUSCO,CUSCO,CUSCO,PCR,58.0,MASCULINO,20200723
 027561e9d126e7c283d79c02cede562d,LIMA,EN INVESTIGACIÓN,EN INVESTIGACIÓN,PCR,28.0,MASCULINO,20200724
+027561e9d126e7c283d79c02cede562f,LIMA,EN INVESTIGACIÓN,EN INVESTIGACIÓN,PCR,,,20200724


Test patch:
diff --git a/ingestion/functions/parsing/peru/peru_test.py b/ingestion/functions/parsing/peru/peru_test.py
index 05fa05f5..a5149f37 100644
--- a/ingestion/functions/parsing/peru/peru_test.py
+++ b/ingestion/functions/parsing/peru/peru_test.py
@@ -59,6 +59,15 @@ class PeruTest(unittest.TestCase):
                                    'sourceUrl': 'place_holder'},
                  'location': {'query': 'LIMA, Peru'},
                  'demographics': {'ageRange': {'start': 28.0, 'end': 28.0}, 'gender': 'Male'},
+                 'events': [{'name': 'confirmed',
+                             'value': 'PCR test',
+                             'dateRange': {'start': '07/24/2020Z', 'end': '07/24/2020Z'}
+                             }]},
+                {'caseReference': {'sourceId': 'place_holder',
+                                   'sourceEntryId': '027561e9d126e7c283d79c02cede562f',
+                                   'sourceUrl': 'place_holder'},
+                 'location': {'query': 'LIMA, Peru'},
+                 'demographics': None,
                  'events': [{'name': 'confirmed',
                              'value': 'PCR test',
                              'dateRange': {'start': '07/24/2020Z', 'end': '07/24/2020Z'}