Skip to content

Commit b1b0ffe

Browse files
Update Schematron Model and Processor to use new/updated Schematron Error Messages from APHL (#624)
## Description During testing APHL was able to find that many eICRs that should have been processed by TTC did not and were marked as 'No Schematron Errors to process' essentially. This was due to a mis-match in the Schematron Error Messages between what was being used in APHL's pipeline and the TTC code base. We received new Schematron files with updated ids and messages. I have updated the Schematron Model to use the new/update Schematron Error Messages. Tests were updated as well. We will have another ticket/PR to change from using the Error Message to using the AssertionID in the near future (this is already a WIP). ## Related Issues Closes #623 ## Additional Notes ## Checklist for Reviewers Please review and complete the following checklist during the review process: - [ ] The code follows best practices and conventions. - [ ] The changes implement the desired functionality or fix the reported issue. - [ ] The tests cover the new changes and pass successfully. - [ ] Any potential edge cases or error scenarios have been considered.
1 parent 65d6afb commit b1b0ffe

14 files changed

Lines changed: 95 additions & 46 deletions

File tree

e2e/assets/eicr_test/eicr_test_schematron_errors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Results xmlns="urn:gov:nist:cdaGuideValidator">
99
<validationResult xmlns="">
1010
<issue severity="errors">
11-
<message>Text to Code: Lab Test Name Ordered does not have a @code attribute</message>
11+
<message>Text to Code: Planned observation code data element has no @code attribute</message>
1212
<context>
1313
/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]</context>
1414
<test> not(cda:code) or cda:code/@code or cda:code/cda:translation/@code</test>

e2e/assets/namespace_preservation/namespace_preservation_schematron_errors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
<issue severity="text_to_code">
161161
<assertionID>ttc-labTestNameResulted-noCode</assertionID>
162162
<flag/>
163-
<message>Text to Code: Lab Test Name Resulted does not have a @code attribute</message>
163+
<message>Text to Code: Lab Test Name Resulted does not have a @code attribute.</message>
164164
<context>/ClinicalDocument[1]/component[1]/structuredBody[1]/component[6]/section[1]/entry[1]/organizer[1]/component[1]/observation[1]</context>
165165
<test> not(cda:code) or cda:code/@code or cda:code/cda:translation/@code</test>
166166
<specification/>

e2e/assets/sample7/eICR_Sample7_nullFlavorResultValues_schematron_errors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
<issue severity="text_to_code">
285285
<assertionID>ttc-labTestNameResulted-noCode</assertionID>
286286
<flag/>
287-
<message>Text to Code: Lab Test Name Resulted does not have a @code attribute</message>
287+
<message>Text to Code: Lab Test Name Resulted does not have a @code attribute.</message>
288288
<context>/ClinicalDocument[1]/component[1]/structuredBody[1]/component[8]/section[1]/entry[1]/organizer[1]/component[1]/observation[1]</context>
289289
<test> not(cda:code) or cda:code/@code or cda:code/cda:translation/@code</test>
290290
<specification/>
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
{"original_eicr_id": "c8516bdc-8bb2-40aa-8dae-20a77546488f", "augmented_eicr_id": "d44dc1c6-8a0c-5236-906e-12f6475589ec", "nonstandard_codes": [{"schematron_error": "Text to Code: Lab Test Name Ordered does not have a @code attribute", "schematron_error_xpath": "\n /ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]", "field_type": "Lab Test Name Ordered", "new_translation": {"code": "82041-5", "code_system": "2.16.840.1.113883.6.1", "code_system_name": "LOINC", "display_name": "Weed Allerg Mix3 IgE Qn", "value_set": null, "value_set_version": null, "original_text": "A custom code in display name."}, "new_translation_xpath": "/ClinicalDocument/component/structuredBody/component/section/entry/observation/code/translation"}], "error": null}
1+
{
2+
"original_eicr_id": "c8516bdc-8bb2-40aa-8dae-20a77546488f",
3+
"augmented_eicr_id": "d44dc1c6-8a0c-5236-906e-12f6475589ec",
4+
"nonstandard_codes": [
5+
{
6+
"schematron_error": "Text to Code: Planned observation code data element has no @code attribute",
7+
"schematron_error_xpath": "\n /ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]",
8+
"field_type": "Lab Test Name Ordered",
9+
"new_translation": {
10+
"code": "82041-5",
11+
"code_system": "2.16.840.1.113883.6.1",
12+
"code_system_name": "LOINC",
13+
"display_name": "Weed Allerg Mix3 IgE Qn",
14+
"value_set": null,
15+
"value_set_version": null,
16+
"original_text": "A custom code in display name."
17+
},
18+
"new_translation_xpath": "/ClinicalDocument/component/structuredBody/component/section/entry/observation/code/translation"
19+
}
20+
],
21+
"error": null
22+
}

packages/text-to-code-lambda/tests/assets/test_schematron_errors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Results xmlns="urn:gov:nist:cdaGuideValidator">
99
<validationResult xmlns="">
1010
<issue severity="errors">
11-
<message>Text to Code: Lab Test Name Ordered does not have a @code attribute</message>
11+
<message>Text to Code: Planned observation code data element has no @code attribute</message>
1212
<context>
1313
/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]</context>
1414
<test> not(cda:code) or cda:code/@code or cda:code/cda:translation/@code</test>

packages/text-to-code-lambda/tests/snapshots/test_lambda_function/test_handler_adds_unmatched_error_when_selected_candidate_has_no_opensearch_hits/no_opensearch_hits_none_metadata_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"field_type": "Lab Test Name Ordered",
2525
"issue_context": "/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]",
2626
"issue_id": null,
27-
"issue_message": "Text to Code: Lab Test Name Ordered does not have a @code attribute",
27+
"issue_message": "Text to Code: Planned observation code data element has no @code attribute",
2828
"issue_test": "not(cda:code) or cda:code/@code or cda:code/cda:translation/@code",
2929
"new_translation": null,
3030
"opensearch_retrieved_scores": {

packages/text-to-code-lambda/tests/snapshots/test_lambda_function/test_handler_continues_when_selected_candidate_is_none/continues_selected_candidate_none_metadata_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"field_type": "Lab Test Name Ordered",
2121
"issue_context": "/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]",
2222
"issue_id": null,
23-
"issue_message": "Text to Code: Lab Test Name Ordered does not have a @code attribute",
23+
"issue_message": "Text to Code: Planned observation code data element has no @code attribute",
2424
"issue_test": "not(cda:code) or cda:code/@code or cda:code/cda:translation/@code",
2525
"new_translation": null,
2626
"opensearch_retrieved_scores": null,

packages/text-to-code-lambda/tests/snapshots/test_lambda_function/test_handler_reranker_returns_empty/reranker_returns_empty_ttc_metadata_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"field_type": "Lab Test Name Ordered",
2525
"issue_context": "/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]",
2626
"issue_id": null,
27-
"issue_message": "Text to Code: Lab Test Name Ordered does not have a @code attribute",
27+
"issue_message": "Text to Code: Planned observation code data element has no @code attribute",
2828
"issue_test": "not(cda:code) or cda:code/@code or cda:code/cda:translation/@code",
2929
"new_translation": null,
3030
"opensearch_retrieved_scores": {

packages/text-to-code-lambda/tests/snapshots/test_lambda_function/test_handler_success/handler_success_ttc_metadata_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"field_type": "Lab Test Name Ordered",
2525
"issue_context": "/ClinicalDocument/component[1]/structuredBody[1]/component[1]/section[1]/entry[1]/observation[1]",
2626
"issue_id": null,
27-
"issue_message": "Text to Code: Lab Test Name Ordered does not have a @code attribute",
27+
"issue_message": "Text to Code: Planned observation code data element has no @code attribute",
2828
"issue_test": "not(cda:code) or cda:code/@code or cda:code/cda:translation/@code",
2929
"new_translation": {
3030
"code": "82041-5",

packages/text-to-code/src/text_to_code/models/schematron.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77
class LabTestNameOrderedSchematronErrors(Enum):
88
"""The list of Schematron error messages relevant to the lab test name ordered data field."""
99

10-
MISSING_CODE_ATTRIBUTE = "Text to Code: Lab Test Name Ordered does not have a @code attribute"
11-
INVALID_CODE_SYSTEM = "Text to Code: Lab Test Name Ordered code and translation data elements @codeSystem attribute are not LOINC 2.16.840.1.113883.6.1"
10+
MISSING_CODE_ATTRIBUTE = (
11+
"Text to Code: Planned observation code data element has no @code attribute"
12+
)
13+
INVALID_CODE_SYSTEM = "Text to Code: Lab Test Name Resulted code and translation data elements @codeSystem attribute are not LOINC (2.16.840.1.113883.6.1), SNOMED CT (2.16.840.1.113883.6.96), CPT-4 (2.16.840.1.113883.6.12), ICD10 PCS (2.16.840.1.113883.6.4) or CDT-2 (2.16.840.1.113883.6.13)"
14+
BLANK_CODE = "Text to Code: Planned observation code data element @code attribute is blank"
15+
NULL_FLAVOR_CODE = "Text to Code: Planned observation code data element is nullFlavor"
1216

1317

1418
class LabTestNameResultedSchematronErrors(Enum):
1519
"""The list of Schematron error messages relevant to the lab test name resulted data field."""
1620

17-
MISSING_CODE_ATTRIBUTE = "Text to Code: Lab Test Name Resulted does not have a @code attribute"
21+
MISSING_CODE_ATTRIBUTE = "Text to Code: Lab Test Name Resulted does not have a @code attribute."
1822
INVALID_CODE_SYSTEM = "Text to Code: Lab Test Name Resulted code and translation data elements @codeSystem attribute are not LOINC 2.16.840.1.113883.6.1"
23+
BLANK_CODE = "Text to Code: Result observation code data element @code attribute is blank."
24+
NULL_FLAVOR_CODE = "Text to Code: Result observation code data element is nullFlavor."
1925

2026

2127
SchematronErrors = LabTestNameOrderedSchematronErrors | LabTestNameResultedSchematronErrors

0 commit comments

Comments
 (0)