Skip to content

Commit c6546b2

Browse files
authored
Merge branch 'develop' into feature/axkr1-NRL-518-validate-context
2 parents b1cba0a + 309c88a commit c6546b2

File tree

7 files changed

+94
-13
lines changed

7 files changed

+94
-13
lines changed

api/consumer/swagger.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ info:
3636
* [End of Life Care Coordination Summary](http://snomed.info/sct/861421000000109)
3737
* [Emergency health care plan](http://snomed.info/sct/887701000000100)
3838
* [Lloyd George record folder](http://snomed.info/sct/16521000000101)
39-
* [Advanced care plan](http://snomed.info/sct/736366004)
39+
* [Advance care plan](http://snomed.info/sct/736366004)
4040
* [Treatment escalation plan](http://snomed.info/sct/735324008)
4141
* [Summary record]("http://snomed.info/sct|824321000000109")
4242
* [Personalised Care and Support Plan]("http://snomed.info/sct|2181441000000107")
@@ -1593,8 +1593,8 @@ components:
15931593
SNOMED_CODES_LLOYD_GEORGE_RECORD_FOLDER:
15941594
summary: Lloyd George record folder
15951595
value: http://snomed.info/sct|16521000000101
1596-
SNOMED_CODES_ADVANCED_CARE_PLAN:
1597-
summary: Advanced care plan
1596+
SNOMED_CODES_ADVANCE_CARE_PLAN:
1597+
summary: Advance care plan
15981598
value: http://snomed.info/sct|736366004
15991599
SNOMED_CODES_TREATMENT_ESCALATION_PLAN:
16001600
summary: Treatment escalation plan

api/producer/swagger.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ info:
3636
* [End of Life Care Coordination Summary](http://snomed.info/sct/861421000000109)
3737
* [Emergency health care plan](http://snomed.info/sct/887701000000100)
3838
* [Lloyd George record folder](http://snomed.info/sct/16521000000101)
39-
* [Advanced care plan](http://snomed.info/sct/736366004)
39+
* [Advance care plan](http://snomed.info/sct/736366004)
4040
* [Treatment escalation plan](http://snomed.info/sct/735324008)
4141
* [Summary record]("http://snomed.info/sct|824321000000109")
4242
* [Personalised Care and Support Plan]("http://snomed.info/sct|2181441000000107")
@@ -2127,8 +2127,8 @@ components:
21272127
SNOMED_CODES_LLOYD_GEORGE_RECORD_FOLDER:
21282128
summary: Lloyd George record folder
21292129
value: http://snomed.info/sct|16521000000101
2130-
SNOMED_CODES_ADVANCED_CARE_PLAN:
2131-
summary: Advanced care plan
2130+
SNOMED_CODES_ADVANCE_CARE_PLAN:
2131+
summary: Advance care plan
21322132
value: http://snomed.info/sct|736366004
21332133
SNOMED_CODES_TREATMENT_ESCALATION_PLAN:
21342134
summary: Treatment escalation plan

layer/nrlf/core/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PointerTypes(Enum):
6060
CONTINGENCY_PLAN = "http://snomed.info/sct|325691000000100"
6161
EOL_CARE_PLAN = "http://snomed.info/sct|736373009"
6262
LLOYD_GEORGE_FOLDER = "http://snomed.info/sct|16521000000101"
63-
ADVANCED_CARE_PLAN = "http://snomed.info/sct|736366004"
63+
ADVANCE_CARE_PLAN = "http://snomed.info/sct|736366004"
6464
TREATMENT_ESCALATION_PLAN = "http://snomed.info/sct|735324008"
6565
SUMMARY_RECORD = "http://snomed.info/sct|824321000000109"
6666
PERSONALISED_CARE_AND_SUPPORT_PLAN = "http://snomed.info/sct|2181441000000107"
@@ -139,8 +139,8 @@ def coding_value(self):
139139
PointerTypes.LLOYD_GEORGE_FOLDER.value: {
140140
"display": "Lloyd George record folder",
141141
},
142-
PointerTypes.ADVANCED_CARE_PLAN.value: {
143-
"display": "Advanced care plan",
142+
PointerTypes.ADVANCE_CARE_PLAN.value: {
143+
"display": "Advance care plan",
144144
},
145145
PointerTypes.TREATMENT_ESCALATION_PLAN.value: {
146146
"display": "Treatment escalation plan",
@@ -169,7 +169,7 @@ def coding_value(self):
169169
PointerTypes.CONTINGENCY_PLAN.value: Categories.CARE_PLAN.value,
170170
PointerTypes.EOL_CARE_PLAN.value: Categories.CARE_PLAN.value,
171171
PointerTypes.LLOYD_GEORGE_FOLDER.value: Categories.CARE_PLAN.value,
172-
PointerTypes.ADVANCED_CARE_PLAN.value: Categories.CARE_PLAN.value,
172+
PointerTypes.ADVANCE_CARE_PLAN.value: Categories.CARE_PLAN.value,
173173
PointerTypes.TREATMENT_ESCALATION_PLAN.value: Categories.CARE_PLAN.value,
174174
PointerTypes.PERSONALISED_CARE_AND_SUPPORT_PLAN.value: Categories.CARE_PLAN.value,
175175
#

reports/find_invalid_pointers.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from datetime import datetime, timedelta, timezone
2+
from typing import Any
3+
4+
import boto3
5+
import fire
6+
7+
from nrlf.consumer.fhir.r4.model import DocumentReference
8+
from nrlf.core.logger import logger
9+
from nrlf.core.validators import DocumentReferenceValidator
10+
11+
dynamodb = boto3.client("dynamodb")
12+
paginator = dynamodb.get_paginator("scan")
13+
14+
logger.setLevel("ERROR")
15+
16+
17+
def _validate_document(document: str):
18+
docref = DocumentReference.model_validate_json(document)
19+
20+
validator = DocumentReferenceValidator()
21+
result = validator.validate(data=docref)
22+
23+
if not result.is_valid:
24+
raise Exception("Failed to validate document: " + str(result.issues))
25+
26+
27+
def _find_invalid_pointers(table_name: str) -> dict[str, float]:
28+
"""
29+
Find pointers in the given table that are invalid.
30+
Parameters:
31+
- table_name: The name of the pointers table to use.
32+
"""
33+
34+
print(f"Finding invalid pointers in table {table_name}....") # noqa
35+
36+
params: dict[str, Any] = {
37+
"TableName": table_name,
38+
"PaginationConfig": {"PageSize": 50},
39+
}
40+
41+
invalid_pointers = []
42+
total_scanned_count = 0
43+
44+
start_time = datetime.now(tz=timezone.utc)
45+
46+
for page in paginator.paginate(**params):
47+
for item in page["Items"]:
48+
id = item.get("id", {}).get("S")
49+
document = item.get("document", {}).get("S", "")
50+
try:
51+
_validate_document(document)
52+
except Exception as exc:
53+
invalid_pointers.append((id, exc))
54+
55+
total_scanned_count += page["ScannedCount"]
56+
57+
if total_scanned_count % 1000 == 0:
58+
print(".", end="", flush=True) # noqa
59+
60+
if total_scanned_count % 100000 == 0:
61+
print( # noqa
62+
f"scanned={total_scanned_count} invalid={len(invalid_pointers)}"
63+
)
64+
65+
end_time = datetime.now(tz=timezone.utc)
66+
67+
print("Writing invalid_pointers to file ./invalid_pointers.txt ...") # noqa
68+
with open("invalid_pointers.txt", "w") as f:
69+
for id, err in invalid_pointers:
70+
f.write(f"{id}: {err}\n")
71+
72+
print(" Done") # noqa
73+
return {
74+
"invalid_pointers": len(invalid_pointers),
75+
"scanned_count": total_scanned_count,
76+
"took-secs": timedelta.total_seconds(end_time - start_time),
77+
}
78+
79+
80+
if __name__ == "__main__":
81+
fire.Fire(_find_invalid_pointers)

resources/fhir/NRLF-RecordType-ValueSet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
{
5858
"code": "736366004",
59-
"display": "Advanced care plan"
59+
"display": "Advance care plan"
6060
},
6161
{
6262
"code": "735324008",

tests/features/producer/createDocumentReference-success.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Feature: Producer - createDocumentReference - Success Scenarios
211211
| 325691000000100 | 734163000 | CONTINGENCY_PLAN |
212212
| 736373009 | 734163000 | EOL_CARE_PLAN |
213213
| 16521000000101 | 734163000 | LLOYD_GEORGE_FOLDER |
214-
| 736366004 | 734163000 | ADVANCED_CARE_PLAN |
214+
| 736366004 | 734163000 | ADVANCE_CARE_PLAN |
215215
| 735324008 | 734163000 | TREATMENT_ESCALATION_PLAN |
216216
| 2181441000000107 | 734163000 | PERSONALISED_CARE_AND_SUPPORT_PLAN |
217217

tests/performance/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LogReference:
2929
"736373009": "End of life care plan",
3030
"861421000000109": "End of life care coordination summary",
3131
"887701000000100": "Emergency Health Care Plans",
32-
"736366004": "Advanced Care Plan",
32+
"736366004": "Advance Care Plan",
3333
"735324008": "Treatment Escalation Plan",
3434
"824321000000109": "Summary Record",
3535
"2181441000000107": "Personalised Care and Support Plan",

0 commit comments

Comments
 (0)