Skip to content

Resource Loading

Jonathan Percival edited this page Mar 1, 2022 · 5 revisions

Methods

HTTP Client

There are 2 different methods of uploading resources using an HTTP client.

  • PUT or POST a single resource PUT method is used to create a new resource with a specified ID or update an existing resource.

    PUT [base]/fhir/Practitioner/prac-123

    {
      "resourceType": "Practitioner",
      "id": "prac-123",
      "identifier": [
        {
          "system": "http://clinfhir.com/fhir/NamingSystem/practitioner",
          "value": "z1z1kXlcn3bhaZRsg7izSA1PYZm1"
        }
      ],
      "telecom": [
        {
          "system": "email",
          "value": "sruthi.v@collabnotes.com"
        }
      ]
    }

    Successful response

    {
      "resourceType": "OperationOutcome",
      "issue": [
        {
          "severity": "information", 
          "code": "informational",
          "diagnostics": "Successfully created resource \"Practitioner/prac-123/_history/1\" in 32ms"
        }
      ]
    }

    If the request results in an error, the "severity" will be specified as "error" and a message will be given in the "diagnostics" value field

    POST method is used to create a new resource with a generated ID.

    POST [base]/fhir/Practitioner

    {
      "resourceType": "Practitioner",
      "identifier": [
        {
          "system": "http://clinfhir.com/fhir/NamingSystem/practitioner",
          "value": "z1z1kXlcn3bhaZRsg7izSA1PYZm1"
        }
      ],
      "telecom": [
        {
          "system": "email",
          "value": "sruthi.v@collabnotes.com"
        }
      ]
    }

    The response will be the same as the PUT method.

  • POST a transaction Bundle

    The transaction operation loads all the resources within a transaction Bundle.

POST [base]/fhir

{
  "resourceType": "Bundle",
  "id": "example-transaction",
  "type": "transaction",
  "entry": [
    {
      "resource": {
        ...
      },
      "request": {
        "method": "PUT",
        "url": "[base]/fhir/Resource/ResourceID"
      }
    },
    ...
  ]
}

The response will be a Bundle containing the status and location for each uploaded resource if successful or an OperationOutcome if there were errors.

{
  "resourceType": "Bundle",
  "id": "...",
  "type": "transaction-response",
  "entry": [
    {
      "response": {
        "status": "201 Created",
        "location": "Resource/ResourceID/_history/1",
        ...
      },
      ...
    }
  ]
}

As an example, POST this bundle to https://cqm-sandbox.alphora.com/fhir.

HAPI provides a GUI, which provides a snapshot of the resources contained within the database as well as CRUD and transaction operations. Access the CRUD operations by clicking on a resource and then navigating to the "CRUD Operations" tab (here are the CRUD operations for Patient). You can also process transaction bundles in the "Server Actions" menu on the home page. Note that there is a size limit of 200 mb for transaction bundles. If your bundle exceeds that limit, you'll need to use an HTTP Client.