Scenario: [1:16]
TC-BUN-001 | REQ-BUN-001 search returns searchset Bundle
ms: 5020
>>
Background:
13
* url baseUrl
0
21:55:04.810 baseUrl: https://hapi.fhir.org/baseR4
21:55:04.810 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
5011
21:55:04.823 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
21:55:09.827 response time in milliseconds: 5003
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:09 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: akPRNd1qEMppSvGZ
1 < Last-Modified: Tue, 21 Apr 2026 21:55:09 GMT
{
"resourceType": "Bundle",
"id": "37f8479a-e1f9-4ec9-b487-2ce7e74aef64",
"meta": {
"lastUpdated": "2026-04-21T21:55:09.782+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=37f8479a-e1f9-4ec9-b487-2ce7e74aef64&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset"
} ],
"entry": [ {
"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"
}
}, {
"fullUrl": "https://hapi.fhir.org/baseR4/Patient/90272570",
"resource": {
"resourceType": "Patient",
"id": "90272570",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:51.649+00:00",
"source": "#bxpiWhyO1eAHB347"
},
"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/90273727",
"resource": {
"resourceType": "Patient",
"id": "90273727",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:56.687+00:00",
"source": "#q9I5Ve6HcqoYlT81"
},
"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/90274720",
"resource": {
"resourceType": "Patient",
"id": "90274720",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:37:01.664+00:00",
"source": "#lYt4LxrDM2kYg2rY"
},
"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'
1
23
And match response.resourceType == 'Bundle'
0
24
And match response.type == 'searchset'
0
25
* karate.log('Bundle type: ' + response.type)
1
21:55:09.831 Bundle type: searchset
Scenario: [2:27]
TC-BUN-002 | REQ-BUN-002 searchset Bundle has total field
ms: 5195
>>
Background:
13
* url baseUrl
0
21:55:09.836 baseUrl: https://hapi.fhir.org/baseR4
21:55:09.836 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
5192
21:55:09.839 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
21:55:15.029 response time in milliseconds: 5189
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:14 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: A81cnrQfWZ7ZNhgn
1 < Last-Modified: Tue, 21 Apr 2026 21:55:13 GMT
{
"resourceType": "Bundle",
"id": "f3121f8c-ec4e-41d5-98e3-2c27cbc9b844",
"meta": {
"lastUpdated": "2026-04-21T21:55:13.783+00:00"
},
"type": "searchset",
"total": 32215,
"link": [ {
"relation": "self",
"url": "https://hapi.fhir.org/baseR4/Patient?_count=5&_total=accurate"
}, {
"relation": "next",
"url": "https://hapi.fhir.org/baseR4?_getpages=f3121f8c-ec4e-41d5-98e3-2c27cbc9b844&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset"
} ],
"entry": [ {
"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"
}
}, {
"fullUrl": "https://hapi.fhir.org/baseR4/Patient/90272570",
"resource": {
"resourceType": "Patient",
"id": "90272570",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:51.649+00:00",
"source": "#bxpiWhyO1eAHB347"
},
"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/90273727",
"resource": {
"resourceType": "Patient",
"id": "90273727",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:56.687+00:00",
"source": "#q9I5Ve6HcqoYlT81"
},
"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/90274720",
"resource": {
"resourceType": "Patient",
"id": "90274720",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:37:01.664+00:00",
"source": "#lYt4LxrDM2kYg2rY"
},
"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
21:55:15.031 Bundle total: 32215
Scenario: [3:36]
TC-BUN-003 | REQ-BUN-003 each entry has resource and fullUrl
ms: 205
>>
Background:
13
* url baseUrl
0
21:55:15.036 baseUrl: https://hapi.fhir.org/baseR4
21:55:15.036 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
200
21:55:15.038 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
21:55:15.237 response time in milliseconds: 199
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:15 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: g1teZZSszKWwgyZb
1 < Last-Modified: Tue, 21 Apr 2026 21:55:09 GMT
{
"resourceType": "Bundle",
"id": "37f8479a-e1f9-4ec9-b487-2ce7e74aef64",
"meta": {
"lastUpdated": "2026-04-21T21:55:09.782+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=37f8479a-e1f9-4ec9-b487-2ce7e74aef64&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset"
} ],
"entry": [ {
"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"
}
}, {
"fullUrl": "https://hapi.fhir.org/baseR4/Patient/90272570",
"resource": {
"resourceType": "Patient",
"id": "90272570",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:51.649+00:00",
"source": "#bxpiWhyO1eAHB347"
},
"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/90273727",
"resource": {
"resourceType": "Patient",
"id": "90273727",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:56.687+00:00",
"source": "#q9I5Ve6HcqoYlT81"
},
"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/90274720",
"resource": {
"resourceType": "Patient",
"id": "90274720",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:37:01.664+00:00",
"source": "#lYt4LxrDM2kYg2rY"
},
"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')
1
45
* if (hasEntry) karate.log('entry[0].fullUrl: ' + response.entry[0].fullUrl)
1
21:55:15.241 entry[0].fullUrl: https://hapi.fhir.org/baseR4/Patient/90270587
Scenario: [4:47]
TC-BUN-004 | REQ-BUN-004 valid transaction returns transaction-response Bundle
ms: 572
>>
Background:
13
* url baseUrl
0
21:55:15.246 baseUrl: https://hapi.fhir.org/baseR4
21:55:15.246 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
564
21:55:15.287 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-1776808515247"]}]},"request":{"method":"POST","url":"Patient"}}]}
21:55:15.813 response time in milliseconds: 525
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:15 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: Wbv0TpCUa9wXRQPq
1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/1b62a692-5962-4c5d-9f0c-c3c82a6b1636
1 < Location: https://hapi.fhir.org/baseR4/Bundle/1b62a692-5962-4c5d-9f0c-c3c82a6b1636
{
"resourceType": "Bundle",
"id": "1b62a692-5962-4c5d-9f0c-c3c82a6b1636",
"type": "transaction-response",
"link": [ {
"relation": "self",
"url": "https://hapi.fhir.org/baseR4"
} ],
"entry": [ {
"response": {
"status": "201 Created",
"location": "Patient/131945036/_history/1",
"etag": "1",
"lastModified": "2026-04-21T21:55:15.392+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 "Patient/131945036/_history/1". 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/131945036/_history/1\". Took 15ms."
} ]
}
}
} ]
}
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
21:55:15.816 transaction-response status: 201 Created
58
* karate.write(response, 'responses/bundle/bundle-transaction-response.json')
2
21:55:15.818 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: 418
>>
Background:
13
* url baseUrl
0
21:55:15.823 baseUrl: https://hapi.fhir.org/baseR4
21:55:15.823 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" } }] })
5
65
When method POST
136
21:55:15.830 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-1776808515824"]}]},"request":{"method":"POST","url":"Patient"}},{"resource":{"name":[{"family":"InvalidEntry-1776808515824"}]},"request":{"method":"POST","url":"Patient"}}]}
21:55:15.965 response time in milliseconds: 134
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:15 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: nm7aaSdmCuU9F8Ap
{
"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
21:55:15.966 TC-BUN-005 transaction rejected with: 400
68
* assert txStatus >= 400 && txStatus < 500
1
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
266
21:55:15.970 request:
2 > GET https://hapi.fhir.org/baseR4/Patient?family=AtomicityTestPatient&given=ShouldNotExist-1776808515824&_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
21:55:16.235 response time in milliseconds: 264
2 < 200
2 < Server: nginx/1.24.0 (Ubuntu)
2 < Date: Tue, 21 Apr 2026 21:55:16 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: 3nNs6pL7lcQi0zz8
2 < Last-Modified: Tue, 21 Apr 2026 21:55:16 GMT
{
"resourceType": "Bundle",
"id": "b0e34cd5-2762-4870-a6ad-2bcc0d297dbc",
"meta": {
"lastUpdated": "2026-04-21T21:55:16.201+00:00"
},
"type": "searchset",
"total": 0,
"link": [ {
"relation": "self",
"url": "https://hapi.fhir.org/baseR4/Patient?_count=1&family=AtomicityTestPatient&given=ShouldNotExist-1776808515824"
} ]
}
77
Then status 200
0
78
* karate.log('TC-BUN-005 atomicity confirmed — partial write count: ' + response.total)
1
21:55:16.236 TC-BUN-005 atomicity confirmed — partial write count: 0
79
And match response.total == 0
6
Scenario: [6:81]
TC-BUN-006 | REQ-GEN-001 captured bundle-transaction-response.json exists for HL7 Validator
ms: 246
>>
Background:
13
* url baseUrl
0
21:55:16.260 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.260 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" } }] })
5
86
When method POST
233
21:55:16.267 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-1776808516261"]}]},"request":{"method":"POST","url":"Patient"}}]}
21:55:16.499 response time in milliseconds: 231
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:16 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: u4xe3TdThsUyQwCq
1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/f5854247-66b4-4a42-8ec4-8f4c38725062
1 < Location: https://hapi.fhir.org/baseR4/Bundle/f5854247-66b4-4a42-8ec4-8f4c38725062
{
"resourceType": "Bundle",
"id": "f5854247-66b4-4a42-8ec4-8f4c38725062",
"type": "transaction-response",
"link": [ {
"relation": "self",
"url": "https://hapi.fhir.org/baseR4"
} ],
"entry": [ {
"response": {
"status": "201 Created",
"location": "Patient/131945037/_history/1",
"etag": "1",
"lastModified": "2026-04-21T21:55:16.368+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 "Patient/131945037/_history/1". Took 22ms.</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/131945037/_history/1\". Took 22ms."
} ]
}
}
} ]
}
87
Then status 200
0
88
* karate.write(response, 'responses/bundle/bundle-transaction-response.json')
4
21:55:16.503 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'))
3
90
* assert fileExists == true
0
Scenario: [7:92]
TC-BUN-007 | REQ-GEN-002b transaction response location confirms versionId tracking
ms: 263
>>
Background:
13
* url baseUrl
0
21:55:16.519 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.519 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" } }] })
2
97
When method POST
256
21:55:16.523 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-1776808516520"]}]},"request":{"method":"POST","url":"Patient"}}]}
21:55:16.777 response time in milliseconds: 253
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:16 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: MWQuLftb2Vfz9jP7
1 < Content-Location: https://hapi.fhir.org/baseR4/Bundle/6686cc88-7b92-4231-af6d-34d50bc6f8bc
1 < Location: https://hapi.fhir.org/baseR4/Bundle/6686cc88-7b92-4231-af6d-34d50bc6f8bc
{
"resourceType": "Bundle",
"id": "6686cc88-7b92-4231-af6d-34d50bc6f8bc",
"type": "transaction-response",
"link": [ {
"relation": "self",
"url": "https://hapi.fhir.org/baseR4"
} ],
"entry": [ {
"response": {
"status": "201 Created",
"location": "Patient/131945038/_history/1",
"etag": "1",
"lastModified": "2026-04-21T21:55:16.701+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 "Patient/131945038/_history/1". Took 21ms.</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/131945038/_history/1\". Took 21ms."
} ]
}
}
} ]
}
98
Then status 200
0
99
* def createdLocation = response.entry[0].response.location
1
100
* karate.log('TC-BUN-007 created resource location: ' + createdLocation)
3
21:55:16.782 TC-BUN-007 created resource location: Patient/131945038/_history/1
101
* match createdLocation == '#string'
0
Scenario: [8:103]
TC-BUN-008 | REQ-BUN-006 searchset Bundle contains self link relation
ms: 2429
>>
Background:
13
* url baseUrl
0
21:55:16.814 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.814 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
2424
21:55:16.819 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
21:55:19.239 response time in milliseconds: 2420
1 < 200
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:19 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: LqHqex95hCq05JCQ
1 < Last-Modified: Tue, 21 Apr 2026 21:55:09 GMT
{
"resourceType": "Bundle",
"id": "37f8479a-e1f9-4ec9-b487-2ce7e74aef64",
"meta": {
"lastUpdated": "2026-04-21T21:55:09.782+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=37f8479a-e1f9-4ec9-b487-2ce7e74aef64&_getpagesoffset=5&_count=5&_pretty=true&_bundletype=searchset"
} ],
"entry": [ {
"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"
}
}, {
"fullUrl": "https://hapi.fhir.org/baseR4/Patient/90272570",
"resource": {
"resourceType": "Patient",
"id": "90272570",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:51.649+00:00",
"source": "#bxpiWhyO1eAHB347"
},
"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/90273727",
"resource": {
"resourceType": "Patient",
"id": "90273727",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:36:56.687+00:00",
"source": "#q9I5Ve6HcqoYlT81"
},
"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/90274720",
"resource": {
"resourceType": "Patient",
"id": "90274720",
"meta": {
"versionId": "1",
"lastUpdated": "2026-02-09T18:37:01.664+00:00",
"source": "#lYt4LxrDM2kYg2rY"
},
"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)
0
21:55:19.244 Self link URL: https://hapi.fhir.org/baseR4/Patient?_count=5