Skip to content

Commit f7c9fdd

Browse files
committed
date conversion
1 parent 81720ac commit f7c9fdd

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

azure/templates/post-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ steps:
206206

207207
displayName: Run full batch test suite
208208
workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/e2e_batch"
209-
condition: eq(1, 2) # Disable task but make this step visible in the pipeline
209+
# condition: eq(1, 2) # Disable task but make this step visible in the pipeline
210210

211211
- task: PublishTestResults@2
212212
displayName: 'Publish test results'

delta_backend/src/ConversionChecker.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,8 @@ def _convertToDate(self, expressionRule, fieldName, fieldValue, summarise, repor
121121
if report_unexpected_exception:
122122
self._log_error(fieldName, fieldValue, "Value is not a string")
123123
return ""
124-
125-
# 2. Use Expression Rule Format to parse the date, remove dashes and slashes
126-
if expressionRule == "%Y%m%d":
127-
fieldValue = fieldValue.split("T")[0]
128-
fieldValue = fieldValue.replace("-", "").replace("/", "")
129-
if not re.match(r"^\d{8}$", fieldValue):
130-
if report_unexpected_exception:
131-
self._log_error(fieldName, fieldValue, "Date must be in YYYYMMDD format")
132-
return ""
133124
try:
134-
# Converts raw fieldvalue without delimiters to a date-time object
135-
dt = datetime.strptime(fieldValue, expressionRule)
125+
dt = datetime.fromisoformat(fieldValue)
136126
return dt.strftime(expressionRule)
137127
except ValueError as e:
138128
# 5. Unexpected parsing errors
@@ -182,8 +172,6 @@ def _convertToDateTime(self, expressionRule, fieldName, fieldValue, summarise, r
182172

183173
# Not Empty Validate - Returns exactly what is in the extracted fields no parsing or logic needed
184174
def _convertToNotEmpty(self, expressionRule, fieldName, fieldValue, summarise, report_unexpected_exception):
185-
if not fieldValue:
186-
return ""
187175
try:
188176
if isinstance(fieldValue, str) and fieldValue.strip():
189177
return fieldValue
@@ -193,7 +181,7 @@ def _convertToNotEmpty(self, expressionRule, fieldName, fieldValue, summarise, r
193181
if report_unexpected_exception:
194182
message = ExceptionMessages.MESSAGES[ExceptionMessages.UNEXPECTED_EXCEPTION] % (e.__class__.__name__, e)
195183
self._log_error(fieldName, fieldValue, message)
196-
return
184+
return ""
197185

198186
# NHSNumber Validate
199187
def _convertToNHSNumber(self, expressionRule, fieldName, fieldValue, summarise, report_unexpected_exception):

delta_backend/tests/sample_data/fhir_sample.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
],
3030
"gender": "other",
31-
"birthDate": "2024-03-10",
31+
"birthDate": "2026-03-10",
3232
"address": [
3333
{
3434
"use": "home",
@@ -73,7 +73,7 @@
7373
"reference": "#Pat1"
7474
},
7575
"occurrenceDateTime": "2021-02-07T13:28:17+00:00",
76-
"recorded": "2029-01-01",
76+
"recorded": "2025-02-07",
7777
"primarySource": "True",
7878
"manufacturer": {
7979
"display": "AstraZeneca Ltd"

delta_backend/tests/test_convert_to_flat_json.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def test_convert_to_date(self, MockLookUpData):
382382
self.assertEqual(result, "20220101")
383383

384384
# 2.Full ISO date should be transformed to YYYYMMDD
385-
result = checker._convertToDate("%Y%m%d", "fieldName", "2022-01-01T12:00:00+00:0", False, True)
385+
result = checker._convertToDate("%Y%m%d", "fieldName", "2022-01-01T12:00:00+00:00", False, True)
386386
self.assertEqual(result, "20220101")
387387

388388
# 3. Invalid string date format (should trigger "Date must be in YYYYMMDD format")
@@ -405,7 +405,6 @@ def test_convert_to_date(self, MockLookUpData):
405405
messages = [err["message"] for err in checker.errorRecords]
406406
print(f"Error Test Case, {messages}")
407407

408-
self.assertIn("Date must be in YYYYMMDD format", messages)
409408
self.assertIn("Value is not a string", messages)
410409

411410
# Confirm Total Errors Per conversion

0 commit comments

Comments
 (0)