Summary| Tags| Feature: bundle/bundle.feature| Bundle Resource Validation
Scenario: [1:16] TC-BUN-001 | REQ-BUN-001 search returns searchset Bundle
ms: 5015
>>
Background:
13
* url baseUrl
0
03:39:46.355 baseUrl: https://hapi.fhir.org/baseR4 03:39:46.356 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
6
17
Given path 'Patient'
0
18
And param _count = '5'
0
19
When method GET
5006
03:39:46.364 request: 1 > GET https://hapi.fhir.org/baseR4/Patient?_count=5 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate 03:39:51.368 response time in milliseconds: 5003 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:51 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: WS2osmBHXbGkpw91 1 < Last-Modified: Thu, 16 Apr 2026 03:39:51 GMT { "resourceType": "Bundle", "id": "eb0875f4-f545-48ef-a829-42e435cf7112", "meta": { "lastUpdated": "2026-04-16T03:39:51.318+00:00" }, "type": "searchset", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=5" }, { "relation": "next", "url": "https://hapi.fhir.org/baseR4?_getpages=eb0875f4-f545-48ef-a829-42e435cf7112&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset" } ], "entry": [ { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90264223", "resource": { "resourceType": "Patient", "id": "90264223", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:06.639+00:00", "source": "#nV78G4bswjDzmYjA" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90267492", "resource": { "resourceType": "Patient", "id": "90267492", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:26.647+00:00", "source": "#49sZqf0T7mu6yulB" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90269459", "resource": { "resourceType": "Patient", "id": "90269459", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:36.647+00:00", "source": "#cKWjQnicqwkZFoLg" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90270587", "resource": { "resourceType": "Patient", "id": "90270587", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:41.642+00:00", "source": "#TGA68OVVF6gisl3w" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90271469", "resource": { "resourceType": "Patient", "id": "90271469", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:46.653+00:00", "source": "#V7SsR0HXgswQ4VV0" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } } ] }
20
Then status 200
0
21
And assert responseTime < 10000
1
22
And match responseHeaders['Content-Type'][0] contains 'application/fhir+json'
0
23
And match response.resourceType == 'Bundle'
0
24
And match response.type == 'searchset'
0
25
* karate.log('Bundle type: ' + response.type)
1
03:39:51.371 Bundle type: searchset
Scenario: [2:27] TC-BUN-002 | REQ-BUN-002 searchset Bundle has total field
ms: 4104
>>
Background:
13
* url baseUrl
0
03:39:51.375 baseUrl: https://hapi.fhir.org/baseR4 03:39:51.375 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
28
Given path 'Patient'
0
29
And param _count = '5'
0
30
And param _total = 'accurate'
0
31
When method GET
4101
03:39:51.377 request: 1 > GET https://hapi.fhir.org/baseR4/Patient?_count=5&_total=accurate 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate 03:39:55.477 response time in milliseconds: 4100 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:55 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: U9ahaVx86w0ihsiy 1 < Last-Modified: Thu, 16 Apr 2026 03:39:55 GMT { "resourceType": "Bundle", "id": "78a6a7e1-09f4-4614-9ef4-cb696c15537d", "meta": { "lastUpdated": "2026-04-16T03:39:55.318+00:00" }, "type": "searchset", "total": 30209, "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=5&_total=accurate" }, { "relation": "next", "url": "https://hapi.fhir.org/baseR4?_getpages=78a6a7e1-09f4-4614-9ef4-cb696c15537d&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset" } ], "entry": [ { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90264223", "resource": { "resourceType": "Patient", "id": "90264223", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:06.639+00:00", "source": "#nV78G4bswjDzmYjA" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90267492", "resource": { "resourceType": "Patient", "id": "90267492", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:26.647+00:00", "source": "#49sZqf0T7mu6yulB" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90269459", "resource": { "resourceType": "Patient", "id": "90269459", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:36.647+00:00", "source": "#cKWjQnicqwkZFoLg" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90270587", "resource": { "resourceType": "Patient", "id": "90270587", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:41.642+00:00", "source": "#TGA68OVVF6gisl3w" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90271469", "resource": { "resourceType": "Patient", "id": "90271469", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:46.653+00:00", "source": "#V7SsR0HXgswQ4VV0" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } } ] }
32
Then status 200
0
33
And match response.total == '#notnull'
1
34
* karate.log('Bundle total: ' + response.total)
1
03:39:55.479 Bundle total: 30209
Scenario: [3:36] TC-BUN-003 | REQ-BUN-003 each entry has resource and fullUrl
ms: 883
>>
Background:
13
* url baseUrl
0
03:39:55.483 baseUrl: https://hapi.fhir.org/baseR4 03:39:55.483 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
37
Given path 'Patient'
0
38
And param _count = '5'
0
39
When method GET
879
03:39:55.486 request: 1 > GET https://hapi.fhir.org/baseR4/Patient?_count=5 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate 03:39:56.363 response time in milliseconds: 876 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:56 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Cache: HIT from https://hapi.fhir.org/baseR4 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: xhfRywioyjqqpXSb 1 < Last-Modified: Thu, 16 Apr 2026 03:39:51 GMT { "resourceType": "Bundle", "id": "eb0875f4-f545-48ef-a829-42e435cf7112", "meta": { "lastUpdated": "2026-04-16T03:39:51.318+00:00" }, "type": "searchset", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=5" }, { "relation": "next", "url": "https://hapi.fhir.org/baseR4?_getpages=eb0875f4-f545-48ef-a829-42e435cf7112&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset" } ], "entry": [ { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90264223", "resource": { "resourceType": "Patient", "id": "90264223", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:06.639+00:00", "source": "#nV78G4bswjDzmYjA" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90267492", "resource": { "resourceType": "Patient", "id": "90267492", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:26.647+00:00", "source": "#49sZqf0T7mu6yulB" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90269459", "resource": { "resourceType": "Patient", "id": "90269459", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:36.647+00:00", "source": "#cKWjQnicqwkZFoLg" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90270587", "resource": { "resourceType": "Patient", "id": "90270587", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:41.642+00:00", "source": "#TGA68OVVF6gisl3w" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90271469", "resource": { "resourceType": "Patient", "id": "90271469", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:46.653+00:00", "source": "#V7SsR0HXgswQ4VV0" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } } ] }
40
Then status 200
0
41
* def hasEntry = response.entry != null && response.entry.length > 0
1
42
* if (!hasEntry) karate.log('TC-BUN-003: SKIP — search returned zero entries')
0
43
* if (hasEntry) karate.match(response.entry[0].fullUrl, '#present')
1
44
* if (hasEntry) karate.match(response.entry[0].resource, '#present')
0
45
* if (hasEntry) karate.log('entry[0].fullUrl: ' + response.entry[0].fullUrl)
1
03:39:56.366 entry[0].fullUrl: https://hapi.fhir.org/baseR4/Patient/90264223
Scenario: [4:47] TC-BUN-004 | REQ-BUN-004 valid transaction returns transaction-response Bundle
ms: 272
>>
Background:
13
* url baseUrl
0
03:39:56.371 baseUrl: https://hapi.fhir.org/baseR4 03:39:56.372 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
48
Given url baseUrl
0
49
And header Content-Type = 'application/fhir+json'
0
50
And request ({ "resourceType": "Bundle", "type": "transaction", "entry": [{ "resource": { "resourceType": "Patient", "name": [{ "family": "BundleTestPatient", "given": ["TC-BUN-004-" + uniqueSuffix] }] }, "request": { "method": "POST", "url": "Patient" } }] })
1
51
When method POST
264
03:39:56.424 request: 1 > POST https://hapi.fhir.org/baseR4 1 > Content-Type: application/fhir+json; charset=UTF-8 1 > Content-Length: 217 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate {"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"family":"BundleTestPatient","given":["TC-BUN-004-1776310796373"]}]},"request":{"method":"POST","url":"Patient"}}]} 03:39:56.639 response time in milliseconds: 213 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:56 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: SMWrVKMqdgdydP3j 1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/638a60f7-8abe-4913-8772-f0a753934654 1 < Location: https://hapi.fhir.org/baseR4/Bundle/638a60f7-8abe-4913-8772-f0a753934654 { "resourceType": "Bundle", "id": "638a60f7-8abe-4913-8772-f0a753934654", "type": "transaction-response", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4" } ], "entry": [ { "response": { "status": "201 Created", "location": "Patient/131931816/_history/1", "etag": "1", "lastModified": "2026-04-16T03:39:56.558+00:00", "outcome": { "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">INFORMATION</td><td>[]</td><td>Successfully created resource &quot;Patient/131931816/_history/1&quot;. Took 14ms.</td></tr></table></div>" }, "issue": [ { "severity": "information", "code": "informational", "details": { "coding": [ { "system": "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code", "code": "SUCCESSFUL_CREATE", "display": "Create succeeded." } ] }, "diagnostics": "Successfully created resource \"Patient/131931816/_history/1\". Took 14ms." } ] } } } ] }
52
Then status 200
0
53
And match response.resourceType == 'Bundle'
1
54
And match response.type == 'transaction-response'
0
55
And match response.entry == '#[_ > 0]'
1
56
And match response.entry[0].response.status == '#regex 201.*'
0
57
* karate.log('transaction-response status: ' + response.entry[0].response.status)
1
03:39:56.642 transaction-response status: 201 Created
58
* karate.write(response, 'responses/bundle/bundle-transaction-response.json')
2
03:39:56.644 write to file: target/responses/bundle/bundle-transaction-response.json
Scenario: [5:60] TC-BUN-005 | REQ-BUN-005 invalid transaction entry fails entire transaction and is atomic
ms: 722
>>
Background:
13
* url baseUrl
0
03:39:56.649 baseUrl: https://hapi.fhir.org/baseR4 03:39:56.649 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
# Step 1: POST a transaction with one valid and one invalid entry (missing resourceType)
62
Given url baseUrl
0
63
And header Content-Type = 'application/fhir+json'
0
64
And request ({ "resourceType": "Bundle", "type": "transaction", "entry": [{ "resource": { "resourceType": "Patient", "name": [{ "family": "AtomicityTestPatient", "given": ["ShouldNotExist-" + uniqueSuffix] }] }, "request": { "method": "POST", "url": "Patient" } }, { "resource": { "name": [{ "family": "InvalidEntry-" + uniqueSuffix }] }, "request": { "method": "POST", "url": "Patient" } }] })
1
65
When method POST
172
03:39:56.652 request: 1 > POST https://hapi.fhir.org/baseR4 1 > Content-Type: application/fhir+json; charset=UTF-8 1 > Content-Length: 332 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate {"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"family":"AtomicityTestPatient","given":["ShouldNotExist-1776310796650"]}]},"request":{"method":"POST","url":"Patient"}},{"resource":{"name":[{"family":"InvalidEntry-1776310796650"}]},"request":{"method":"POST","url":"Patient"}}]} 03:39:56.823 response time in milliseconds: 171 1 < 400 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:56 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: 2Iuo43Q7dIFC3ZHU { "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1843: Missing required element 'resourceType' from JSON resource object, unable to parse</td></tr></table></div>" }, "issue": [ { "severity": "error", "code": "processing", "diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1843: Missing required element 'resourceType' from JSON resource object, unable to parse" } ] }
66
* def txStatus = responseStatus
0
67
* karate.log('TC-BUN-005 transaction rejected with: ' + txStatus)
1
03:39:56.825 TC-BUN-005 transaction rejected with: 400
68
* assert txStatus >= 400 && txStatus < 500
2
69
And match response.resourceType == 'OperationOutcome'
0
# Step 2: Confirm atomicity — the valid Patient entry MUST NOT have been written
71
Given url baseUrl
0
72
And path 'Patient'
0
73
And param family = 'AtomicityTestPatient'
0
74
And param given = 'ShouldNotExist-' + uniqueSuffix
0
75
And param _count = '1'
0
76
When method GET
542
03:39:56.828 request: 2 > GET https://hapi.fhir.org/baseR4/Patient?family=AtomicityTestPatient&given=ShouldNotExist-1776310796650&_count=1 2 > Host: hapi.fhir.org 2 > Connection: Keep-Alive 2 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 2 > Accept-Encoding: gzip,deflate 03:39:57.369 response time in milliseconds: 540 2 < 200 2 < Server: nginx/1.24.0 (Ubuntu) 2 < Date: Thu, 16 Apr 2026 03:39:57 GMT 2 < Content-Type: application/fhir+json;charset=utf-8 2 < Transfer-Encoding: chunked 2 < Connection: keep-alive 2 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 2 < X-Request-ID: JqPju0aiC1L00mF6 2 < Last-Modified: Thu, 16 Apr 2026 03:39:57 GMT { "resourceType": "Bundle", "id": "96bc00f5-b03f-4e6b-a1f3-cc32e9655e36", "meta": { "lastUpdated": "2026-04-16T03:39:57.317+00:00" }, "type": "searchset", "total": 0, "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=1&family=AtomicityTestPatient&given=ShouldNotExist-1776310796650" } ] }
77
Then status 200
0
78
* karate.log('TC-BUN-005 atomicity confirmed — partial write count: ' + response.total)
1
03:39:57.370 TC-BUN-005 atomicity confirmed — partial write count: 0
79
And match response.total == 0
1
Scenario: [6:81] TC-BUN-006 | REQ-GEN-001 captured bundle-transaction-response.json exists for HL7 Validator
ms: 229
>>
Background:
13
* url baseUrl
0
03:39:57.377 baseUrl: https://hapi.fhir.org/baseR4 03:39:57.377 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
# Self-contained: POST transaction, write, then assert file exists
83
Given url baseUrl
0
84
And header Content-Type = 'application/fhir+json'
0
85
And request ({ "resourceType": "Bundle", "type": "transaction", "entry": [{ "resource": { "resourceType": "Patient", "name": [{ "family": "BundleTestPatient", "given": ["TC-BUN-006-" + uniqueSuffix] }] }, "request": { "method": "POST", "url": "Patient" } }] })
1
86
When method POST
215
03:39:57.381 request: 1 > POST https://hapi.fhir.org/baseR4 1 > Content-Type: application/fhir+json; charset=UTF-8 1 > Content-Length: 217 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate {"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"family":"BundleTestPatient","given":["TC-BUN-006-1776310797378"]}]},"request":{"method":"POST","url":"Patient"}}]} 03:39:57.590 response time in milliseconds: 209 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:57 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: 43lewfou0cfoZR7Z 1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/f3b5ae68-3c0b-4075-ac2a-bad25e793965 1 < Location: https://hapi.fhir.org/baseR4/Bundle/f3b5ae68-3c0b-4075-ac2a-bad25e793965 { "resourceType": "Bundle", "id": "f3b5ae68-3c0b-4075-ac2a-bad25e793965", "type": "transaction-response", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4" } ], "entry": [ { "response": { "status": "201 Created", "location": "Patient/131931817/_history/1", "etag": "1", "lastModified": "2026-04-16T03:39:57.519+00:00", "outcome": { "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">INFORMATION</td><td>[]</td><td>Successfully created resource &quot;Patient/131931817/_history/1&quot;. Took 14ms.</td></tr></table></div>" }, "issue": [ { "severity": "information", "code": "informational", "details": { "coding": [ { "system": "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code", "code": "SUCCESSFUL_CREATE", "display": "Create succeeded." } ] }, "diagnostics": "Successfully created resource \"Patient/131931817/_history/1\". Took 14ms." } ] } } } ] }
87
Then status 200
0
88
* karate.write(response, 'responses/bundle/bundle-transaction-response.json')
5
03:39:57.599 write to file: target/responses/bundle/bundle-transaction-response.json
89
* def fileExists = java.nio.file.Files.exists(java.nio.file.Paths.get('target/responses/bundle/bundle-transaction-response.json'))
7
90
* assert fileExists == true
0
Scenario: [7:92] TC-BUN-007 | REQ-GEN-002b transaction response location confirms versionId tracking
ms: 249
>>
Background:
13
* url baseUrl
0
03:39:57.622 baseUrl: https://hapi.fhir.org/baseR4 03:39:57.622 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
# Self-contained: POST transaction and inspect location in the same scenario
94
Given url baseUrl
0
95
And header Content-Type = 'application/fhir+json'
0
96
And request ({ "resourceType": "Bundle", "type": "transaction", "entry": [{ "resource": { "resourceType": "Patient", "name": [{ "family": "BundleTestPatient", "given": ["TC-BUN-007-" + uniqueSuffix] }] }, "request": { "method": "POST", "url": "Patient" } }] })
1
97
When method POST
245
03:39:57.637 request: 1 > POST https://hapi.fhir.org/baseR4 1 > Content-Type: application/fhir+json; charset=UTF-8 1 > Content-Length: 217 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate {"resourceType":"Bundle","type":"transaction","entry":[{"resource":{"resourceType":"Patient","name":[{"family":"BundleTestPatient","given":["TC-BUN-007-1776310797628"]}]},"request":{"method":"POST","url":"Patient"}}]} 03:39:57.874 response time in milliseconds: 236 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:39:57 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: CFqXYTSxVSsIV2T0 1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/77931157-b510-44ee-b42f-2011a3a31933 1 < Location: https://hapi.fhir.org/baseR4/Bundle/77931157-b510-44ee-b42f-2011a3a31933 { "resourceType": "Bundle", "id": "77931157-b510-44ee-b42f-2011a3a31933", "type": "transaction-response", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4" } ], "entry": [ { "response": { "status": "201 Created", "location": "Patient/131931818/_history/1", "etag": "1", "lastModified": "2026-04-16T03:39:57.807+00:00", "outcome": { "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">INFORMATION</td><td>[]</td><td>Successfully created resource &quot;Patient/131931818/_history/1&quot;. Took 15ms.</td></tr></table></div>" }, "issue": [ { "severity": "information", "code": "informational", "details": { "coding": [ { "system": "https://hapifhir.io/fhir/CodeSystem/hapi-fhir-storage-response-code", "code": "SUCCESSFUL_CREATE", "display": "Create succeeded." } ] }, "diagnostics": "Successfully created resource \"Patient/131931818/_history/1\". Took 15ms." } ] } } } ] }
98
Then status 200
0
99
* def createdLocation = response.entry[0].response.location
1
100
* karate.log('TC-BUN-007 created resource location: ' + createdLocation)
1
03:39:57.878 TC-BUN-007 created resource location: Patient/131931818/_history/1
101
* match createdLocation == '#string'
0
Scenario: [8:103] TC-BUN-008 | REQ-BUN-006 searchset Bundle contains self link relation
ms: 3482
>>
Background:
13
* url baseUrl
0
03:39:57.888 baseUrl: https://hapi.fhir.org/baseR4 03:39:57.888 fhirVersion: 4.0.1
14
* def uniqueSuffix = java.lang.System.currentTimeMillis() + ''
1
104
Given path 'Patient'
0
105
And param _count = '5'
0
106
When method GET
3477
03:39:57.897 request: 1 > GET https://hapi.fhir.org/baseR4/Patient?_count=5 1 > Host: hapi.fhir.org 1 > Connection: Keep-Alive 1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18) 1 > Accept-Encoding: gzip,deflate 03:40:01.367 response time in milliseconds: 3469 1 < 200 1 < Server: nginx/1.24.0 (Ubuntu) 1 < Date: Thu, 16 Apr 2026 03:40:01 GMT 1 < Content-Type: application/fhir+json;charset=utf-8 1 < Transfer-Encoding: chunked 1 < Connection: keep-alive 1 < X-Cache: HIT from https://hapi.fhir.org/baseR4 1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4) 1 < X-Request-ID: jntO1nQuXLRBlexV 1 < Last-Modified: Thu, 16 Apr 2026 03:39:51 GMT { "resourceType": "Bundle", "id": "eb0875f4-f545-48ef-a829-42e435cf7112", "meta": { "lastUpdated": "2026-04-16T03:39:51.318+00:00" }, "type": "searchset", "link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=5" }, { "relation": "next", "url": "https://hapi.fhir.org/baseR4?_getpages=eb0875f4-f545-48ef-a829-42e435cf7112&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset" } ], "entry": [ { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90264223", "resource": { "resourceType": "Patient", "id": "90264223", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:06.639+00:00", "source": "#nV78G4bswjDzmYjA" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90267492", "resource": { "resourceType": "Patient", "id": "90267492", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:26.647+00:00", "source": "#49sZqf0T7mu6yulB" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90269459", "resource": { "resourceType": "Patient", "id": "90269459", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:36.647+00:00", "source": "#cKWjQnicqwkZFoLg" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90270587", "resource": { "resourceType": "Patient", "id": "90270587", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:41.642+00:00", "source": "#TGA68OVVF6gisl3w" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } }, { "fullUrl": "https://hapi.fhir.org/baseR4/Patient/90271469", "resource": { "resourceType": "Patient", "id": "90271469", "meta": { "versionId": "1", "lastUpdated": "2026-02-09T18:36:46.653+00:00", "source": "#V7SsR0HXgswQ4VV0" }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Nuñez <b>KARLA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>02 January 1980</span></td></tr></tbody></table></div>" }, "name": [ { "family": "Karla", "given": [ "Nuñez" ] } ], "gender": "female", "birthDate": "1980-01-02" }, "search": { "mode": "match" } } ] }
107
Then status 200
0
108
And assert responseTime < 10000
0
109
And match responseHeaders['Content-Type'][0] contains 'application/fhir+json'
0
110
* def selfLink = response.link.filter(l => l.relation == 'self')[0]
2
111
* match selfLink == '#present'
0
112
* karate.log('Self link URL: ' + selfLink.url)
1
03:40:01.371 Self link URL: https://hapi.fhir.org/baseR4/Patient?_count=5