Skip to content

Commit cc19856

Browse files
committed
[NRL-1279] Fix sonarcloud warnings. Add EOLCP and EHCP samples from care homes
1 parent 41dd84b commit cc19856

File tree

3 files changed

+298
-27
lines changed

3 files changed

+298
-27
lines changed

scripts/redact_live_pointers.py

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,48 @@
2020
type_to_name = {pointer_type.value: pointer_type.name for pointer_type in PointerTypes}
2121

2222

23+
def _redact_timestamps(docref: DocumentReference) -> None:
24+
mock_timestamp = create_fhir_instant()
25+
docref.meta.lastUpdated = mock_timestamp
26+
docref.date = mock_timestamp
27+
28+
29+
def _redact_ids(docref: DocumentReference) -> None:
30+
ods_code = docref.custodian.identifier.value
31+
32+
mock_id = "c2a99222-eb50-4451-ad6e-1e951627800e"
33+
docref.subject.identifier.value = "9999999999"
34+
docref.id = f"{ods_code}-{mock_id}"
35+
if docref.masterIdentifier:
36+
docref.masterIdentifier.value = f"mid_{mock_id}"
37+
if docref.relatesTo:
38+
for relates_to in docref.relatesTo:
39+
relates_to.target.identifier.value = f"rel_{mock_id}"
40+
41+
42+
def _redact_content(docref: DocumentReference) -> None:
43+
mock_timestamp = create_fhir_instant()
44+
for content in docref.content:
45+
if content.attachment.url.startswith("ssp://"):
46+
content.attachment.url = "ssp://content.test.local/content"
47+
else:
48+
content.attachment.url = "https://content.test.local/content"
49+
content.attachment.creation = mock_timestamp
50+
51+
52+
def _redact_context(docref: DocumentReference) -> None:
53+
if docref.context.related:
54+
for related in docref.context.related:
55+
related.identifier.value = "012345678910"
56+
57+
mock_timestamp = create_fhir_instant()
58+
if docref.context.period:
59+
if docref.context.period.start:
60+
docref.context.period.start = mock_timestamp
61+
if docref.context.period.end:
62+
docref.context.period.end = mock_timestamp
63+
64+
2365
def _redact_pointers(src_path: str, dest_path: str) -> None:
2466
"""
2567
Redact pointers in .json files in from the source path and write the redacted pointer to the destination path.
@@ -40,33 +82,10 @@ def _redact_pointers(src_path: str, dest_path: str) -> None:
4082
type_coding = docref.type.coding[0]
4183
pointer_type = type_to_name[f"{type_coding.system}|{type_coding.code}"]
4284

43-
mock_timestamp = create_fhir_instant()
44-
docref.meta.lastUpdated = mock_timestamp
45-
docref.date = mock_timestamp
46-
47-
mock_id = f"c2a99222-eb50-4451-ad6e-1e951627800e"
48-
docref.subject.identifier.value = "9999999999"
49-
docref.id = f"{ods_code}-{mock_id}"
50-
if docref.masterIdentifier:
51-
docref.masterIdentifier.value = f"mid_{mock_id}"
52-
if docref.relatesTo:
53-
for relates_to in docref.relatesTo:
54-
relates_to.target.identifier.value = f"rel_{mock_id}"
55-
56-
for content in docref.content:
57-
if content.attachment.url.startswith("ssp://"):
58-
content.attachment.url = "ssp://content.test.local/content"
59-
else:
60-
content.attachment.url = "https://content.test.local/content"
61-
content.attachment.creation = mock_timestamp
62-
if docref.context.related:
63-
for related in docref.context.related:
64-
related.identifier.value = "012345678910"
65-
if docref.context.period:
66-
if docref.context.period.start:
67-
docref.context.period.start = mock_timestamp
68-
if docref.context.period.end:
69-
docref.context.period.end = mock_timestamp
85+
_redact_ids(docref)
86+
_redact_timestamps(docref)
87+
_redact_content(docref)
88+
_redact_context(docref)
7089

7190
month_year = datetime.now().strftime("%b%y")
7291
filename = f"{dest_path}/{ods_code}_{pointer_type}_{month_year}.json"
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "VM8W7-c2a99222-eb50-4451-ad6e-1e951627800e",
4+
"meta": {
5+
"lastUpdated": "2025-02-11T12:25:44.382Z"
6+
},
7+
"masterIdentifier": {
8+
"system": "urn:ietf:rfc:3986",
9+
"value": "mid_c2a99222-eb50-4451-ad6e-1e951627800e"
10+
},
11+
"status": "current",
12+
"type": {
13+
"coding": [
14+
{
15+
"system": "http://snomed.info/sct",
16+
"code": "887701000000100",
17+
"display": "Emergency health care plan"
18+
}
19+
]
20+
},
21+
"category": [
22+
{
23+
"coding": [
24+
{
25+
"system": "http://snomed.info/sct",
26+
"code": "734163000",
27+
"display": "Care plan"
28+
}
29+
]
30+
}
31+
],
32+
"subject": {
33+
"identifier": {
34+
"system": "https://fhir.nhs.uk/Id/nhs-number",
35+
"value": "9999999999"
36+
}
37+
},
38+
"date": "2025-02-11T12:25:44.382Z",
39+
"author": [
40+
{
41+
"identifier": {
42+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
43+
"value": "VM8W7"
44+
}
45+
}
46+
],
47+
"custodian": {
48+
"identifier": {
49+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
50+
"value": "VM8W7"
51+
}
52+
},
53+
"content": [
54+
{
55+
"attachment": {
56+
"contentType": "application/pdf",
57+
"url": "ssp://content.test.local/content",
58+
"creation": "2025-02-11T12:25:44.382Z"
59+
},
60+
"format": {
61+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
62+
"code": "urn:nhs-ic:unstructured",
63+
"display": "Unstructured Document"
64+
},
65+
"extension": [
66+
{
67+
"valueCodeableConcept": {
68+
"coding": [
69+
{
70+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
71+
"code": "static",
72+
"display": "Static"
73+
}
74+
]
75+
},
76+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
77+
}
78+
]
79+
},
80+
{
81+
"attachment": {
82+
"contentType": "text/html",
83+
"url": "https://content.test.local/content",
84+
"creation": "2025-02-11T12:25:44.382Z"
85+
},
86+
"format": {
87+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
88+
"code": "urn:nhs-ic:record-contact",
89+
"display": "Contact details (HTTP Unsecured)"
90+
},
91+
"extension": [
92+
{
93+
"valueCodeableConcept": {
94+
"coding": [
95+
{
96+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
97+
"code": "static",
98+
"display": "Static"
99+
}
100+
]
101+
},
102+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
103+
}
104+
]
105+
}
106+
],
107+
"context": {
108+
"practiceSetting": {
109+
"coding": [
110+
{
111+
"system": "http://snomed.info/sct",
112+
"code": "224891009",
113+
"display": "Healthcare services"
114+
}
115+
]
116+
},
117+
"related": [
118+
{
119+
"identifier": {
120+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
121+
"value": "012345678910"
122+
}
123+
}
124+
]
125+
}
126+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "VM8W7-c2a99222-eb50-4451-ad6e-1e951627800e",
4+
"meta": {
5+
"lastUpdated": "2025-02-11T12:25:44.435Z"
6+
},
7+
"masterIdentifier": {
8+
"system": "urn:ietf:rfc:3986",
9+
"value": "mid_c2a99222-eb50-4451-ad6e-1e951627800e"
10+
},
11+
"status": "current",
12+
"type": {
13+
"coding": [
14+
{
15+
"system": "http://snomed.info/sct",
16+
"code": "861421000000109",
17+
"display": "End of life care coordination summary"
18+
}
19+
]
20+
},
21+
"category": [
22+
{
23+
"coding": [
24+
{
25+
"system": "http://snomed.info/sct",
26+
"code": "734163000",
27+
"display": "Care plan"
28+
}
29+
]
30+
}
31+
],
32+
"subject": {
33+
"identifier": {
34+
"system": "https://fhir.nhs.uk/Id/nhs-number",
35+
"value": "9999999999"
36+
}
37+
},
38+
"date": "2025-02-11T12:25:44.435Z",
39+
"author": [
40+
{
41+
"identifier": {
42+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
43+
"value": "VM8W7"
44+
}
45+
}
46+
],
47+
"custodian": {
48+
"identifier": {
49+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
50+
"value": "VM8W7"
51+
}
52+
},
53+
"content": [
54+
{
55+
"attachment": {
56+
"contentType": "application/pdf",
57+
"url": "ssp://content.test.local/content",
58+
"creation": "2025-02-11T12:25:44.435Z"
59+
},
60+
"format": {
61+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
62+
"code": "urn:nhs-ic:unstructured",
63+
"display": "Unstructured Document"
64+
},
65+
"extension": [
66+
{
67+
"valueCodeableConcept": {
68+
"coding": [
69+
{
70+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
71+
"code": "static",
72+
"display": "Static"
73+
}
74+
]
75+
},
76+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
77+
}
78+
]
79+
},
80+
{
81+
"attachment": {
82+
"contentType": "text/html",
83+
"url": "https://content.test.local/content",
84+
"creation": "2025-02-11T12:25:44.435Z"
85+
},
86+
"format": {
87+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
88+
"code": "urn:nhs-ic:record-contact",
89+
"display": "Contact details (HTTP Unsecured)"
90+
},
91+
"extension": [
92+
{
93+
"valueCodeableConcept": {
94+
"coding": [
95+
{
96+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
97+
"code": "static",
98+
"display": "Static"
99+
}
100+
]
101+
},
102+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
103+
}
104+
]
105+
}
106+
],
107+
"context": {
108+
"practiceSetting": {
109+
"coding": [
110+
{
111+
"system": "http://snomed.info/sct",
112+
"code": "224891009",
113+
"display": "Healthcare services"
114+
}
115+
]
116+
},
117+
"related": [
118+
{
119+
"identifier": {
120+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
121+
"value": "012345678910"
122+
}
123+
}
124+
]
125+
}
126+
}

0 commit comments

Comments
 (0)