@@ -52,6 +52,84 @@ describe 'Transaction', ->
5252 beforeEach ->
5353 schema .fhir_truncate_storage (plv8, resourceType : ' Patient' )
5454
55+ it ' update resource contention' , ->
56+ created = crud .fhir_create_resource (plv8, {
57+ " allowId" : true ,
58+ " resource" : {
59+ " resourceType" : " Patient" ,
60+ " name" : [{" given" : [" Foo" ]}],
61+ " id" : " patient-id"
62+ }
63+ })
64+
65+ bundle1 = {
66+ " resourceType" : " Bundle" ,
67+ " type" : " transaction" ,
68+ " entry" : [
69+ {
70+ " resource" : {" resourceType" : " Patient" , " name" : [{" given" : [" Bar" ]}]},
71+ " request" : {
72+ " ifMatch" : created .meta .versionId ,
73+ " method" : " PUT" ,
74+ " url" : " Patient/patient-id"
75+ }
76+ }
77+ ]
78+ }
79+
80+ transaction1 = transaction .fhir_transaction (plv8, bundle1)
81+ match (
82+ transaction1,
83+ {
84+ " resourceType" : " Bundle" ,
85+ " type" : " transaction-response" ,
86+ " entry" : [
87+ {
88+ " resource" : {
89+ " resourceType" : " Patient" ,
90+ " name" : [{" given" : [" Bar" ]}],
91+ " id" : " patient-id" ,
92+ }
93+ }
94+ ]
95+ }
96+ )
97+
98+ bundle2 = {
99+ " resourceType" : " Bundle" ,
100+ " type" : " transaction" ,
101+ " entry" : [
102+ {
103+ " resource" : {" resourceType" : " Patient" , " name" : [{" given" : [" Xyz" ]}]},
104+ " request" : {
105+ " ifMatch" : created .meta .versionId ,
106+ " method" : " PUT" ,
107+ " url" : " Patient/patient-id"
108+ }
109+ }
110+ ]
111+ }
112+
113+ transaction2 = transaction .fhir_transaction (plv8, bundle2)
114+ match (
115+ transaction2,
116+ {
117+ " resourceType" : " OperationOutcome" ,
118+ " issue" : [
119+ {
120+ " severity" : " error" ,
121+ " code" : " 409" ,
122+ " extension" : [
123+ {
124+ " url" : " http-status-code" ,
125+ " valueString" : " 409"
126+ }
127+ ]
128+ }
129+ ]
130+ }
131+ )
132+
55133 it ' search' , ->
56134 crud .fhir_create_resource (plv8,
57135 resource : {resourceType : ' Patient' , name : [{family : [' Foo bar' ]}]})
@@ -197,6 +275,18 @@ describe 'Transaction', ->
197275 }
198276 )
199277
278+ match (
279+ t,
280+ resourceType : ' OperationOutcome'
281+ issue : [
282+ {
283+ severity : ' error' ,
284+ code : ' not-found' ,
285+ diagnostics : ' Resource Id "id2" does not exist'
286+ }
287+ ]
288+ )
289+
200290 patient = crud .fhir_read_resource (plv8,
201291 {" resourceType" : " Patient" , " id" : " id1" })
202292
@@ -213,6 +303,7 @@ describe 'Transaction', ->
213303 url : ' /Patient/id1' ,
214304 method : ' POST'
215305 ]
306+
216307 match (
217308 transaction .fhir_transaction (plv8, bundle),
218309 resourceType : ' OperationOutcome'
0 commit comments