@@ -211,6 +211,110 @@ def test_create_single_mhds_document_reference_with_transaction_happy_path(
211211 }
212212
213213
214+ @mock_aws
215+ @mock_repository
216+ @freeze_time ("2024-03-21T12:34:56.789" )
217+ @freeze_uuid ("00000000-0000-0000-0000-000000000001" )
218+ def test_create_single_mhds_document_reference_imaging_format_with_transaction_happy_path (
219+ repository : DocumentPointerRepository ,
220+ ):
221+ raw_doc_ref = load_document_reference ("Y05868-736253002-Valid" ).model_dump (
222+ exclude_none = True
223+ )
224+
225+ raw_doc_ref .pop ("author" )
226+ raw_doc_ref .pop ("context" )
227+ raw_doc_ref ["content" ][0 ]["attachment" ]["contentType" ] = "application/dicom"
228+ raw_doc_ref ["content" ][0 ]["format" ][
229+ "system"
230+ ] = "https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html"
231+ raw_doc_ref ["content" ][0 ]["format" ]["code" ] = "direct"
232+ raw_doc_ref ["content" ][0 ]["format" ]["display" ] = "Direct"
233+
234+ request_bundle = Bundle (
235+ meta = Meta (
236+ profile = [
237+ ProfileItem (
238+ "http://hl7.org/fhir/profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.UnContained.Comprehensive.ProvideBundle"
239+ )
240+ ]
241+ ),
242+ entry = [
243+ BundleEntry (
244+ resource = raw_doc_ref , request = BundleEntryRequest (url = "/" , method = "POST" )
245+ )
246+ ],
247+ resourceType = "Bundle" ,
248+ type = "transaction" ,
249+ )
250+
251+ event = create_test_api_gateway_event (
252+ headers = create_headers (),
253+ body = request_bundle .model_dump_json (),
254+ )
255+
256+ result = handler (event , create_mock_context ())
257+ body = result .pop ("body" )
258+
259+ assert result == {
260+ "statusCode" : "200" ,
261+ "headers" : {
262+ ** default_response_headers (),
263+ },
264+ "isBase64Encoded" : False ,
265+ }
266+
267+ parsed_body = json .loads (body )
268+ assert parsed_body == {
269+ "resourceType" : "Bundle" ,
270+ "type" : "transaction-response" ,
271+ "entry" : [
272+ {
273+ "response" : {
274+ "status" : "201" ,
275+ "location" : "/producer/FHIR/R4/DocumentReference/Y05868-00000000-0000-0000-0000-000000000001" ,
276+ "outcome" : {
277+ "resourceType" : "OperationOutcome" ,
278+ "issue" : [
279+ {
280+ "severity" : "information" ,
281+ "code" : "informational" ,
282+ "details" : {
283+ "coding" : [
284+ {
285+ "system" : "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode" ,
286+ "code" : "RESOURCE_CREATED" ,
287+ "display" : "Resource created" ,
288+ }
289+ ]
290+ },
291+ "diagnostics" : "The document has been created" ,
292+ }
293+ ],
294+ },
295+ },
296+ },
297+ ],
298+ }
299+
300+ created_doc_pointer = repository .get_by_id (
301+ "Y05868-00000000-0000-0000-0000-000000000001"
302+ )
303+
304+ assert created_doc_pointer is not None
305+ assert created_doc_pointer .created_on == "2024-03-21T12:34:56.789Z"
306+ assert created_doc_pointer .updated_on is None
307+ assert json .loads (created_doc_pointer .document ) == {
308+ ** raw_doc_ref ,
309+ ** DEFAULT_MHDS_PROPERTIES ,
310+ "meta" : {
311+ "lastUpdated" : "2024-03-21T12:34:56.789Z" ,
312+ },
313+ "date" : "2024-03-21T12:34:56.789Z" ,
314+ "id" : "Y05868-00000000-0000-0000-0000-000000000001" ,
315+ }
316+
317+
214318@mock_aws
215319@mock_repository
216320@freeze_time ("2024-03-21T12:34:56.789" )
0 commit comments