Skip to content

Commit f5c1a6f

Browse files
committed
log rows returned
1 parent d3b3147 commit f5c1a6f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

recordprocessor/src/batch_processor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
from typing import Optional
1414

1515

16-
def process_csv_to_fhir(incoming_message_body: dict) -> None:
16+
def process_csv_to_fhir(incoming_message_body: dict) -> int:
1717
"""
1818
For each row of the csv, attempts to transform into FHIR format, sends a message to kinesis,
1919
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.
2022
"""
2123
encoder = "utf-8" # default encoding
2224
try:
@@ -66,7 +68,6 @@ def process_csv_to_fhir(incoming_message_body: dict) -> None:
6668
logger.error(f"Non-decode error: {err}. Cannot retry. Call someone.")
6769
raise err
6870

69-
logger.info("Total rows processed: %s", row_count)
7071
return row_count
7172

7273

@@ -118,11 +119,13 @@ def main(event: str) -> None:
118119
"""Process each row of the file"""
119120
logger.info("task started")
120121
start = time.time()
122+
n_rows_processed = 0
121123
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))
123125
except Exception as error: # pylint: disable=broad-exception-caught
124126
logger.error("Error processing message: %s", error)
125127
end = time.time()
128+
logger.info("Total rows processed: %s", n_rows_processed)
126129
logger.info("Total time for completion: %ss", round(end - start, 5))
127130

128131

0 commit comments

Comments
 (0)