@@ -85,7 +85,7 @@ def __init__(self, table: Table):
8585 self .table = table
8686
8787 def get_immunization_by_identifier (
88- self , identifier_pk : str , imms_vax_type_perms : str , is_imms_batch_app
88+ self , identifier_pk : str , imms_vax_type_perms : str
8989 ) -> Optional [dict ]:
9090 response = self .table .query (
9191 IndexName = "IdentifierGSI" , KeyConditionExpression = Key ("IdentifierPK" ).eq (identifier_pk )
@@ -94,10 +94,9 @@ def get_immunization_by_identifier(
9494 item = response ["Items" ][0 ]
9595 resp = dict ()
9696 vaccine_type = self ._vaccine_type (item ["PatientSK" ])
97- if not is_imms_batch_app :
98- vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
99- vax_type_perm = self ._vaccine_permission (vaccine_type , "search" )
100- self ._check_permission (vax_type_perm , vax_type_perms )
97+ vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
98+ vax_type_perm = self ._vaccine_permission (vaccine_type , "search" )
99+ self ._check_permission (vax_type_perm , vax_type_perms )
101100 resource = json .loads (item ["Resource" ])
102101 resp ["id" ] = resource .get ("id" )
103102 resp ["version" ] = int (response ["Items" ][0 ]["Version" ])
@@ -166,15 +165,14 @@ def get_immunization_by_id_all(self, imms_id: str, imms: dict) -> Optional[dict]
166165 return None
167166
168167 def create_immunization (
169- self , immunization : dict , patient : any , imms_vax_type_perms , supplier_system , is_imms_batch_app
168+ self , immunization : dict , patient : any , imms_vax_type_perms , supplier_system
170169 ) -> dict :
171170 new_id = str (uuid .uuid4 ())
172171 immunization ["id" ] = new_id
173172 attr = RecordAttributes (immunization , patient )
174- if not is_imms_batch_app :
175- vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
176- vax_type_perm = self ._vaccine_permission (attr .vaccine_type , "create" )
177- self ._check_permission (vax_type_perm , vax_type_perms )
173+ vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
174+ vax_type_perm = self ._vaccine_permission (attr .vaccine_type , "create" )
175+ self ._check_permission (vax_type_perm , vax_type_perms )
178176 query_response = _query_identifier (self .table , "IdentifierGSI" , "IdentifierPK" , attr .identifier )
179177
180178 if query_response is not None :
@@ -206,10 +204,9 @@ def update_immunization(
206204 existing_resource_version : int ,
207205 imms_vax_type_perms : str ,
208206 supplier_system : str ,
209- is_imms_batch_app : bool ,
210207 ) -> dict :
211208 attr = RecordAttributes (immunization , patient )
212- self ._handle_permissions (is_imms_batch_app , imms_vax_type_perms , attr )
209+ self ._handle_permissions (imms_vax_type_perms , attr )
213210 update_exp = self ._build_update_expression (is_reinstate = False )
214211
215212 self ._check_duplicate_identifier (attr )
@@ -232,10 +229,10 @@ def reinstate_immunization(
232229 existing_resource_version : int ,
233230 imms_vax_type_perms : str ,
234231 supplier_system : str ,
235- is_imms_batch_app : bool ,
232+
236233 ) -> dict :
237234 attr = RecordAttributes (immunization , patient )
238- self ._handle_permissions (is_imms_batch_app , imms_vax_type_perms , attr )
235+ self ._handle_permissions (imms_vax_type_perms , attr )
239236 update_exp = self ._build_update_expression (is_reinstate = True )
240237
241238 self ._check_duplicate_identifier (attr )
@@ -258,10 +255,9 @@ def update_reinstated_immunization(
258255 existing_resource_version : int ,
259256 imms_vax_type_perms : str ,
260257 supplier_system : str ,
261- is_imms_batch_app : bool ,
262258 ) -> dict :
263259 attr = RecordAttributes (immunization , patient )
264- self ._handle_permissions (is_imms_batch_app , imms_vax_type_perms , attr )
260+ self ._handle_permissions (imms_vax_type_perms , attr )
265261 update_exp = self ._build_update_expression (is_reinstate = False )
266262
267263 self ._check_duplicate_identifier (attr )
@@ -276,11 +272,10 @@ def update_reinstated_immunization(
276272 update_reinstated = True ,
277273 )
278274
279- def _handle_permissions (self , is_imms_batch_app : bool , imms_vax_type_perms : str , attr : RecordAttributes ):
280- if not is_imms_batch_app :
281- vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
282- vax_type_perm = self ._vaccine_permission (attr .vaccine_type , "update" )
283- self ._check_permission (vax_type_perm , vax_type_perms )
275+ def _handle_permissions (self , imms_vax_type_perms : str , attr : RecordAttributes ):
276+ vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
277+ vax_type_perm = self ._vaccine_permission (attr .vaccine_type , "update" )
278+ self ._check_permission (vax_type_perm , vax_type_perms )
284279
285280 def _build_update_expression (self , is_reinstate : bool ) -> str :
286281 if is_reinstate :
@@ -365,7 +360,7 @@ def _perform_dynamo_update(
365360 )
366361
367362 def delete_immunization (
368- self , imms_id : str , imms_vax_type_perms : str , supplier_system : str , is_imms_batch_app
363+ self , imms_id : str , imms_vax_type_perms : str , supplier_system : str
369364 ) -> dict :
370365 now_timestamp = int (time .time ())
371366 try :
@@ -375,16 +370,14 @@ def delete_immunization(
375370 if "DeletedAt" in resp ["Item" ]:
376371 if resp ["Item" ]["DeletedAt" ] == "reinstated" :
377372 vaccine_type = self ._vaccine_type (resp ["Item" ]["PatientSK" ])
378- if not is_imms_batch_app :
379- vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
380- vax_type_perm = self ._vaccine_permission (vaccine_type , "delete" )
381- self ._check_permission (vax_type_perm , vax_type_perms )
382- else :
383- vaccine_type = self ._vaccine_type (resp ["Item" ]["PatientSK" ])
384- if not is_imms_batch_app :
385373 vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
386374 vax_type_perm = self ._vaccine_permission (vaccine_type , "delete" )
387375 self ._check_permission (vax_type_perm , vax_type_perms )
376+ else :
377+ vaccine_type = self ._vaccine_type (resp ["Item" ]["PatientSK" ])
378+ vax_type_perms = self ._parse_vaccine_permissions (imms_vax_type_perms )
379+ vax_type_perm = self ._vaccine_permission (vaccine_type , "delete" )
380+ self ._check_permission (vax_type_perm , vax_type_perms )
388381
389382 response = self .table .update_item (
390383 Key = {"PK" : _make_immunization_pk (imms_id )},
0 commit comments