@@ -97,6 +97,38 @@ def test_create_immunization_post_validation_error(self):
9797 self .assertTrue (expected_msg in error .exception .message )
9898 self .mock_repo .create_immunization .assert_not_called ()
9999
100+ def test_create_immunization_uplifts_legacy_identifier_system_tpp (self ):
101+ """it should recognise a legacy TPP identifier system and use the new style identifier"""
102+
103+ immunisation = create_covid_immunization_dict_no_id ()
104+ immunisation ["identifier" ][0 ]["system" ] = "YGA"
105+
106+ _ = self .service .create_immunization (
107+ immunization = immunisation ,
108+ supplier_system = "test_supplier" ,
109+ vax_type = "test_vax" ,
110+ table = self .mock_table ,
111+ is_present = True ,
112+ )
113+
114+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://tpp-uk.com/Id/ve/vacc" )
115+
116+ def test_create_immunization_uplifts_legacy_identifier_system_emis (self ):
117+ """it should recognise a legacy EMIS identifier system and use the new style identifier"""
118+
119+ immunisation = create_covid_immunization_dict_no_id ()
120+ immunisation ["identifier" ][0 ]["system" ] = "YGJ"
121+
122+ _ = self .service .create_immunization (
123+ immunization = immunisation ,
124+ supplier_system = "test_supplier" ,
125+ vax_type = "test_vax" ,
126+ table = self .mock_table ,
127+ is_present = True ,
128+ )
129+
130+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://emishealth.com/identifiers/vacc" )
131+
100132
101133class TestUpdateImmunizationBatchService (TestFhirBatchServiceBase ):
102134 def setUp (self ):
@@ -169,6 +201,38 @@ def test_update_immunization_post_validation_error(self):
169201 self .assertTrue (expected_msg in error .exception .message )
170202 self .mock_repo .update_immunization .assert_not_called ()
171203
204+ def test_update_immunization_uplifts_legacy_identifier_system_tpp (self ):
205+ """it should recognise a legacy TPP identifier system and use the new style identifier"""
206+
207+ immunisation = create_covid_immunization_dict_no_id ()
208+ immunisation ["identifier" ][0 ]["system" ] = "YGA"
209+
210+ _ = self .service .update_immunization (
211+ immunization = immunisation ,
212+ supplier_system = "test_supplier" ,
213+ vax_type = "test_vax" ,
214+ table = self .mock_table ,
215+ is_present = True ,
216+ )
217+
218+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://tpp-uk.com/Id/ve/vacc" )
219+
220+ def test_update_immunization_uplifts_legacy_identifier_system_emis (self ):
221+ """it should recognise a legacy EMIS identifier system and use the new style identifier"""
222+
223+ immunisation = create_covid_immunization_dict_no_id ()
224+ immunisation ["identifier" ][0 ]["system" ] = "YGJ"
225+
226+ _ = self .service .update_immunization (
227+ immunization = immunisation ,
228+ supplier_system = "test_supplier" ,
229+ vax_type = "test_vax" ,
230+ table = self .mock_table ,
231+ is_present = True ,
232+ )
233+
234+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://emishealth.com/identifiers/vacc" )
235+
172236
173237class TestDeleteImmunizationBatchService (unittest .TestCase ):
174238 def setUp (self ):
@@ -194,6 +258,38 @@ def test_delete_immunization_valid(self):
194258 )
195259 self .assertEqual (result , imms_id )
196260
261+ def test_delete_immunization_uplifts_legacy_identifier_system_tpp (self ):
262+ """it should recognise a legacy TPP identifier system and use the new style identifier"""
263+
264+ immunisation = create_covid_immunization_dict_no_id ()
265+ immunisation ["identifier" ][0 ]["system" ] = "YGA"
266+
267+ _ = self .service .delete_immunization (
268+ immunization = immunisation ,
269+ supplier_system = "test_supplier" ,
270+ vax_type = "test_vax" ,
271+ table = self .mock_table ,
272+ is_present = True ,
273+ )
274+
275+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://tpp-uk.com/Id/ve/vacc" )
276+
277+ def test_delete_immunization_uplifts_legacy_identifier_system_emis (self ):
278+ """it should recognise a legacy EMIS identifier system and use the new style identifier"""
279+
280+ immunisation = create_covid_immunization_dict_no_id ()
281+ immunisation ["identifier" ][0 ]["system" ] = "YGJ"
282+
283+ _ = self .service .delete_immunization (
284+ immunization = immunisation ,
285+ supplier_system = "test_supplier" ,
286+ vax_type = "test_vax" ,
287+ table = self .mock_table ,
288+ is_present = True ,
289+ )
290+
291+ self .assertEqual (immunisation ["identifier" ][0 ]["system" ], "https://emishealth.com/identifiers/vacc" )
292+
197293
198294if __name__ == "__main__" :
199295 unittest .main ()
0 commit comments