Skip to content

Commit 449b15d

Browse files
committed
Add scenario to verify preservation of site and route codings in immunization event table
- Introduced a new scenario in the create.feature file to validate that site and route codings are preserved in the imms event table when the first coding system is invalid. - Implemented corresponding step definitions in test_create_steps.py to create a valid JSON payload with multiple SNOMED codings and validate the response against expected outcomes. - Enhanced the test to ensure that the delta table uses the first valid SNOMED site and route coding and that all codings from the request are preserved in the imms event table.
1 parent 857f720 commit 449b15d

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

tests/e2e_automation/features/APITests/create.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ Feature: Create the immunization event for a patient
9292
And The terms are mapped to correct instance of coding.display fields in imms delta table
9393
And MNS event will not be triggered for the event
9494

95+
@Delete_cleanUp @vaccine_type_RSV @patient_id_Random @supplier_name_Postman_Auth
96+
Scenario: Verify that site and route codings are preserved in imms event table when the first coding system is invalid
97+
Given Valid json payload is created where site and route have multiple SNOMED codings after an invalid system
98+
When Trigger the post create request
99+
Then The request will be successful with the status code '201'
100+
And The location key and Etag in header will contain the Immunization Id and version
101+
And The delta table will use the first valid SNOMED site and route coding
102+
And The imms event table will preserve every site and route coding from the request
103+
And MNS event will be triggered with correct data for created event
104+
95105
@smoke
96106
@Delete_cleanUp @vaccine_type_PERTUSSIS @patient_id_Random @supplier_name_EMIS
97107
Scenario: Verify that VACCINATION_PROCEDURE_TERM, VACCINE_PRODUCT_TERM, SITE_OF_VACCINATION_TERM, ROUTE_OF_VACCINATION_TERM fields are mapped to coding.display in imms delta table in case of only one instance of coding

tests/e2e_automation/features/APITests/steps/test_create_steps.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
parse_imms_int_imms_event_response,
1414
validate_imms_delta_record_with_created_event,
1515
)
16+
from src.objectModels.api_data_objects import CodeableConcept, Coding
1617
from src.objectModels.api_immunization_builder import (
1718
build_site_route,
1819
build_vaccine_procedure_code,
1920
build_vaccine_procedure_extension,
21+
create_extension,
2022
get_vaccine_details,
2123
)
2224
from utilities.api_fhir_immunization_helper import (
@@ -121,6 +123,81 @@ def createValidJsonPayloadWithProcedureMultipleCodingsDifferentSystem(context):
121123
context.immunization_object.route.coding[0].system = "http://example.com/different-system"
122124

123125

126+
def build_coding(system, code, display, value_string, value_id):
127+
return Coding(
128+
system=system,
129+
code=code,
130+
display=display,
131+
extension=[
132+
create_extension(
133+
"https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-CodingSCTDescDisplay",
134+
stringValue=value_string,
135+
),
136+
create_extension(
137+
"http://hl7.org/fhir/StructureDefinition/coding-sctdescid",
138+
idValue=value_id,
139+
),
140+
],
141+
)
142+
143+
144+
@given("Valid json payload is created where site and route have multiple SNOMED codings after an invalid system")
145+
def create_valid_json_payload_with_multiple_site_route_snomed_codings(context):
146+
valid_json_payload_is_created(context)
147+
context.immunization_object.site = CodeableConcept(
148+
coding=[
149+
build_coding(
150+
"http://snomed.info/test",
151+
"368208006",
152+
"Right upper arm structure (body structure)",
153+
"Test Value string site 111",
154+
"5306706018",
155+
),
156+
build_coding(
157+
"http://snomed.info/sct",
158+
"368209003",
159+
"Left upper arm structure (body structure)",
160+
"Test Value string site 222",
161+
"5306706020",
162+
),
163+
build_coding(
164+
"http://snomed.info/sct",
165+
"368208008",
166+
"Mid upper arm structure (body structure)",
167+
"Test Value string site 333",
168+
"5306706030",
169+
),
170+
],
171+
text="Test String for site",
172+
)
173+
context.immunization_object.route = CodeableConcept(
174+
coding=[
175+
build_coding(
176+
"http://snomed.info/test",
177+
"78421000",
178+
"Intramuscular route (qualifier value)",
179+
"Test Value string route 111",
180+
"5306706040",
181+
),
182+
build_coding(
183+
"http://snomed.info/sct",
184+
"78421000",
185+
"Intramuscular route (qualifier value)",
186+
"Test Value string route 222",
187+
"5306706050",
188+
),
189+
build_coding(
190+
"http://snomed.info/sct",
191+
"34206005",
192+
"Subcutaneous route (qualifier value)",
193+
"Test Value string route 333",
194+
"5306706060",
195+
),
196+
],
197+
text="Test String for route",
198+
)
199+
200+
124201
@given(
125202
"Valid json payload is created where vaccination terms has one instance of coding with no text or value string field"
126203
)
@@ -267,6 +344,37 @@ def validate_procedure_term_correct_coding_in_delta_table(context):
267344
)
268345

269346

347+
@then("The delta table will use the first valid SNOMED site and route coding")
348+
def validate_delta_table_uses_first_valid_snomed_site_route_coding(context):
349+
actual_terms = get_all_term_text(context)
350+
expected_site_term = context.create_object.site.coding[1].extension[0].valueString
351+
expected_route_term = context.create_object.route.coding[1].extension[0].valueString
352+
assert actual_terms["site_term"] == expected_site_term, (
353+
f"Expected site of vaccination term '{expected_site_term}', but got '{actual_terms['site_term']}'"
354+
)
355+
assert actual_terms["route_term"] == expected_route_term, (
356+
f"Expected route of vaccination term '{expected_route_term}', but got '{actual_terms['route_term']}'"
357+
)
358+
359+
360+
@then("The imms event table will preserve every site and route coding from the request")
361+
def validate_imms_event_table_preserves_all_site_route_codings(context):
362+
table_query_response = fetch_immunization_events_detail(context.aws_profile_name, context.ImmsID, context.S3_env)
363+
assert "Item" in table_query_response, f"Item not found in response for ImmsID: {context.ImmsID}"
364+
365+
resource_json_str = table_query_response["Item"].get("Resource")
366+
assert resource_json_str, "Resource field missing in item."
367+
resource = json.loads(resource_json_str)
368+
369+
for field_name in ("site", "route"):
370+
expected = context.request[field_name]
371+
actual = resource[field_name]
372+
assert len(actual["coding"]) == 3, (
373+
f"Expected {field_name}.coding to contain 3 entries, but got {len(actual['coding'])}"
374+
)
375+
assert actual == expected, f"Expected {field_name} to match request, but got {actual}"
376+
377+
270378
@then("The terms are mapped to correct coding.display fields in imms delta table")
271379
def validate_procedure_term_second_display_in_delta_table(context):
272380
actual_terms = get_all_term_text(context)

0 commit comments

Comments
 (0)