|
13 | 13 | from typing import Optional |
14 | 14 |
|
15 | 15 |
|
16 | | -def process_csv_to_fhir(incoming_message_body: dict) -> None: |
| 16 | +def process_csv_to_fhir(incoming_message_body: dict) -> int: |
17 | 17 | """ |
18 | 18 | For each row of the csv, attempts to transform into FHIR format, sends a message to kinesis, |
19 | 19 | and documents the outcome for each row in the ack file. |
| 20 | + Returns the number of rows processed. While this is not used by the handler, the number of rows |
| 21 | + processed must be correct and therefore is returned for logging and test purposes. |
20 | 22 | """ |
21 | 23 | encoder = "utf-8" # default encoding |
22 | 24 | try: |
@@ -66,7 +68,6 @@ def process_csv_to_fhir(incoming_message_body: dict) -> None: |
66 | 68 | logger.error(f"Non-decode error: {err}. Cannot retry. Call someone.") |
67 | 69 | raise err |
68 | 70 |
|
69 | | - logger.info("Total rows processed: %s", row_count) |
70 | 71 | return row_count |
71 | 72 |
|
72 | 73 |
|
@@ -118,11 +119,13 @@ def main(event: str) -> None: |
118 | 119 | """Process each row of the file""" |
119 | 120 | logger.info("task started") |
120 | 121 | start = time.time() |
| 122 | + n_rows_processed = 0 |
121 | 123 | try: |
122 | | - process_csv_to_fhir(incoming_message_body=json.loads(event)) |
| 124 | + n_rows_processed = process_csv_to_fhir(incoming_message_body=json.loads(event)) |
123 | 125 | except Exception as error: # pylint: disable=broad-exception-caught |
124 | 126 | logger.error("Error processing message: %s", error) |
125 | 127 | end = time.time() |
| 128 | + logger.info("Total rows processed: %s", n_rows_processed) |
126 | 129 | logger.info("Total time for completion: %ss", round(end - start, 5)) |
127 | 130 |
|
128 | 131 |
|
|
0 commit comments