Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions backend/src/fhir_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@ def get_immunization_by_id(self, imms_id: str, imms_vax_type_perms: str) -> Opti

# Returns the Immunisation full resource with no obfuscation
resource = imms_resp.get("Resource", {})
imms_filtered_for_read = Filter.read(resource) if resource else {}


return {
"Version": imms_resp.get("Version", ""),
"Resource": Immunization.parse_obj(imms_filtered_for_read),
"Resource": Immunization.parse_obj(resource),
}

def get_immunization_by_id_all(self, imms_id: str, imms: dict) -> Optional[dict]:
Expand Down
7 changes: 0 additions & 7 deletions backend/src/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ def add_use_to_identifier(imms: dict) -> dict:

class Filter:
"""Functions for filtering a FHIR Immunization Resource"""

@staticmethod
def read(imms: dict) -> dict:
"""Apply filtering for READ request"""
imms.pop("identifier")
return imms

@staticmethod
def search(imms: dict, patient_full_url: str, bundle_patient: dict = None) -> dict:
"""Apply filtering for an individual FHIR Immunization Resource as part of SEARCH request"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"name": [
{
"family": "Nightingale",
"given": ["Florence"]
"given": [
"Florence"
]
}
]
},
Expand All @@ -23,7 +25,9 @@
"name": [
{
"family": "Taylor",
"given": ["Sarah"]
"given": [
"Sarah"
]
}
],
"gender": "unknown",
Expand All @@ -48,6 +52,12 @@
]
}
}
],
"identifier": [
{
"system": "https://supplierABC/identifiers/vacc",
"value": "ACME-vacc123456"
}
],
"status": "completed",
"vaccineCode": {
Expand Down Expand Up @@ -143,4 +153,4 @@
"doseNumberPositiveInt": 1
}
]
}
}
6 changes: 3 additions & 3 deletions backend/tests/test_fhir_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ def test_immunization_not_found(self):

def test_get_immunization_by_id_patient_not_restricted(self):
"""
Test that get_immunization_by_id returns a FHIR Immunization Resource which has been filtered for read,
but not for s-flag, when patient is not restricted
Test that get_immunization_by_id returns a FHIR Immunization Resource which has not been filtered for read,
and also dropped obfuscation for s-flag, when patient is not restricted
"""
imms_id = "non_restricted_id"

immunization_data = load_json_data("completed_covid19_immunization_event.json")
self.imms_repo.get_immunization_by_id.return_value = {"Resource": immunization_data}
self.fhir_service.pds_service.get_patient_details.return_value = {"meta": {"security": [{"code": "U"}]}}

expected_imms = load_json_data("completed_covid19_immunization_event_filtered_for_read.json")
expected_imms = load_json_data("completed_covid19_immunization_event_for_read.json")
expected_output = Immunization.parse_obj(expected_imms)

# When
Expand Down
6 changes: 0 additions & 6 deletions backend/tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ def test_replace_organization_values(self):
del expected_output_data["performer"][1]["actor"]["identifier"]
self.assertEqual(replace_organization_values(input_imms_data), expected_output_data)

def test_filter_read(self):
"""Tests to ensure Filter.read appropriately filters a FHIR Immunization Resource"""
unfiltered_imms = deepcopy(self.covid_19_immunization_event)
expected_output = load_json_data("completed_covid19_immunization_event_filtered_for_read.json")
self.assertEqual(Filter.read(unfiltered_imms), expected_output)

def test_filter_search(self):
"""Tests to ensure Filter.search appropriately filters a FHIR Immunization Resource"""
bundle_patient = deepcopy(self.bundle_patient_resource)
Expand Down
Loading