Skip to content

Commit

Permalink
reduced date errors to the first instance (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jp3477 authored Sep 15, 2021
1 parent 646a0c9 commit 73eb1e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
2 changes: 2 additions & 0 deletions omop_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def run_checks(file_path, f):
actual=value,
expected=meta_column_type)
result['errors'].append(e)
#only return the first error
break

# Check if any nulls present in a required field
if meta_column_required and df[submission_column].isnull(
Expand Down
3 changes: 1 addition & 2 deletions tests/resources/examples_erroneous/errors/results.csv
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
"observation.csv","Observation","Type mismatch line number 5","observation_id","23.890+11","integer"
"observation.csv","Observation","Invalid date format. Expecting ""YYYY-MM-DD"": line number 5","observation_date","01-31-1963","date"
"observation.csv","Observation","Invalid timestamp format. Expecting ""YYYY-MM-DD HH:MM:SS[.SSSSSS]"": line number 1","observation_datetime","1989-10-07 22:13:11.1533266","timestamp"
"observation.csv","Observation","Invalid timestamp format. Expecting ""YYYY-MM-DD HH:MM:SS[.SSSSSS]"": line number 3","observation_datetime","1987-04-15 06:06:30.6260548","timestamp"
"observation.csv","Observation","Invalid timestamp format. Expecting ""YYYY-MM-DD HH:MM:SS[.SSSSSS]"": line number 5","observation_datetime","1983-05-13 15:31:52.3905384","timestamp"
"observation.csv","Observation","Type mismatch line number 3","observation_type_concept_id","unknown","integer"
"visit_detail.csv","Visit Detail","NULL values are not allowed for column","visit_occurrence_id","",""
24 changes: 8 additions & 16 deletions tests/resources/examples_erroneous/errors/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,6 @@ <h1>Local File Validation Error Results</h1><table id="dataframe" style="width:8
<td>1989-10-07 22:13:11.1533266</td>
<td>timestamp</td>
</tr>
<tr>
<td>observation.csv</td>
<td>Observation</td>
<td>Invalid timestamp format. Expecting "YYYY-MM-DD HH:MM:SS[.SSSSSS]": line number 3</td>
<td>observation_datetime</td>
<td>1987-04-15 06:06:30.6260548</td>
<td>timestamp</td>
</tr>
<tr>
<td>observation.csv</td>
<td>Observation</td>
<td>Invalid timestamp format. Expecting "YYYY-MM-DD HH:MM:SS[.SSSSSS]": line number 5</td>
<td>observation_datetime</td>
<td>1983-05-13 15:31:52.3905384</td>
<td>timestamp</td>
</tr>
<tr>
<td>observation.csv</td>
<td>Observation</td>
Expand All @@ -266,6 +250,14 @@ <h1>Local File Validation Error Results</h1><table id="dataframe" style="width:8
<td>unknown</td>
<td>integer</td>
</tr>
<tr>
<td>visit_detail.csv</td>
<td>Visit Detail</td>
<td>NULL values are not allowed for column</td>
<td>visit_occurrence_id</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</body>
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def test_error_list(self):
column_name="observation_type_concept_id",
expected="integer")

# "observation.csv" has has invalid date formats in rows 4 and 5
# "observation.csv" has has invalid date formats in row 5
self.check_invalid_date(error_map[f_name], column_name='observation_date', linenumber=5)

# "observation.csv" has has invalid timestamp formats in rows 1, 3, and 5
self.check_invalid_timestamp(error_map[f_name], column_name='observation_datetime', linenumber=3)
self.check_invalid_timestamp(error_map[f_name], column_name='observation_datetime', linenumber=1)

# "measurement.csv" has "person_id" as NULL in row 3 (line number 4) but it is a required value
f_name = "measurement.csv"
Expand Down

0 comments on commit 73eb1e2

Please sign in to comment.