Skip to content

Commit e1ed4e1

Browse files
committed
test for update
1 parent 5969962 commit e1ed4e1

File tree

3 files changed

+93
-219
lines changed

3 files changed

+93
-219
lines changed

backend/src/fhir_controller.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ def update_immunization(self, aws_event):
212212
if response := self.authorize_request(EndpointOperation.UPDATE, aws_event):
213213
return response
214214
imms_id = aws_event["pathParameters"]["id"]
215+
if "E-Tag" not in aws_event["headers"]:
216+
exp_error = create_operation_outcome(
217+
resource_id=str(uuid.uuid4()),
218+
severity=Severity.error,
219+
code=Code.invariant,
220+
diagnostics="Validation errors: Immunization resource version not specified in the request headers",
221+
)
222+
return self.create_response(400, json.dumps(exp_error))
215223
else:
216224
raise UnauthorizedError()
217225
except UnauthorizedError as unauthorized:

backend/src/fhir_service.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,18 @@ def reinstate_immunization(
157157
existing_resource_version: int,
158158
imms_vax_type_perms: str,
159159
supplier_system: str,
160-
is_imms_batch_app,
161160
) -> tuple[UpdateOutcome, Immunization]:
162161
immunization["id"] = imms_id
163-
164-
patient = None
165-
if not is_imms_batch_app:
166-
patient = self._validate_patient(immunization)
167-
if "diagnostics" in patient:
168-
return (None, patient)
162+
patient = self._validate_patient(immunization)
163+
if "diagnostics" in patient:
164+
return (None, patient)
169165
imms = self.immunization_repo.reinstate_immunization(
170166
imms_id,
171167
immunization,
172168
patient,
173169
existing_resource_version,
174170
imms_vax_type_perms,
175171
supplier_system,
176-
is_imms_batch_app,
177172
)
178173

179174
return UpdateOutcome.UPDATE, Immunization.parse_obj(imms)
@@ -206,14 +201,14 @@ def update_reinstated_immunization(
206201

207202
return UpdateOutcome.UPDATE, Immunization.parse_obj(imms)
208203

209-
def delete_immunization(self, imms_id, imms_vax_type_perms, supplier_system, is_imms_batch_app) -> Immunization:
204+
def delete_immunization(self, imms_id, imms_vax_type_perms, supplier_system) -> Immunization:
210205
"""
211206
Delete an Immunization if it exits and return the ID back if successful.
212207
Exception will be raised if resource didn't exit. Multiple calls to this method won't change
213208
the record in the database.
214209
"""
215210
imms = self.immunization_repo.delete_immunization(
216-
imms_id, imms_vax_type_perms, supplier_system, is_imms_batch_app
211+
imms_id, imms_vax_type_perms, supplier_system
217212
)
218213
return Immunization.parse_obj(imms)
219214

0 commit comments

Comments
 (0)