Yes, you can use the Batch API.
-
The Bundle.entry must include a request object pointing at URL
<RESOURCE>/$validate
with methodPOST
. -
The Resource that is validated must be wrapped in a Parameters object and added to the
Parameters.parameter.resource
{
"resourceType": "Parameters",
"parameter": [
{
"name": "resource",
"resource": <COPY HERE>
}
]
}
- Embed it at
Bundle.entry.resource
, and make a request to the server root.
curl --location --request POST 'https://localhost:9443/fhir-server/api/v4' \
--header 'Authorization: Basic ...' \
--header 'Content-Type: application/json' \
--data-raw '{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "Patient/$validate",
"resource": {
"resourceType": "Parameters",
"parameter": [
{
"name": "resource",
"resource": {
"resourceType": "Patient",
"id": "example",
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}
]
}
}
],
"meta": {
"tag": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
"code": "HTEST",
"display": "test health data"
}
]
}
},
"request": {
"method": "POST",
"url": "Patient/$validate"
}
}
]
}'
- You’ll get a response like this, note the HTTP Status Code is 200 coming back… You have to look at
Bundle.entry.resource.response.issue
to check the severity and details to see why the validation is failing.
{
"resourceType": "Bundle",
"type": "transaction-response",
"entry": [
{
"resource": {
"resourceType": "OperationOutcome",
"id": "NoError",
"text": {
"status": "additional",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>No error</p></div>"
},
"issue": [
{
"severity": "warning",
"code": "invariant",
"details": {
"text": "dom-6: A resource should have narrative for robust management"
},
"expression": [
"Patient"
]
}
]
},
"response": {
"status": "200",
"outcome": {
"resourceType": "OperationOutcome",
"id": "NoError",
"text": {
"status": "additional",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>No error</p></div>"
},
"issue": [
{
"severity": "warning",
"code": "invariant",
"details": {
"text": "dom-6: A resource should have narrative for robust management"
},
"expression": [
"Patient"
]
}
]
}
}
}
]
}
You should add entries for each Resource you want to validate in the Batch.