Skip to content

Resource Loading

c-schuler edited this page Oct 15, 2017 · 5 revisions

Resource Loading

Methods

This project provides an interface to load resources. To access it, run the following command:

$ mvn exec:java -Dexec.mainClass="org.opencds.cqf.helpers.ResourceLoaderGUI"

The following dialog box should appear:

Resource Loader GUI

As you can see, there are 3 different methods provided for loading resources.

  1. Single Resource - moves a single resource from one data provider to another.

    • Specify "Source URL" and "Destination URL" and select "Single resource" from the dropdown menu.

    Single Resource Home

    • Specify the "Resource ID" and the "Resource Type" and click "Load".

    Single Resource Load

  2. List of Resources - moves a list of resources for one data provider to another.

    • Specify "Source URL" and "Destination URL" and select "List of resources" from the dropdown menu.

    List Resources Home

    • Specify resources as a comma separated list with the resource ID followed by the resource type and click "Load".

    List Resources Load

  3. Bundle from File - loads a Bundle of resources from a JSON file into a data provider.

    • Specify "Destination URL" and select "Bundle from file".

    Bundle Home

    • Specify absolute file path to Bundle JSON file and click "Load".

    Bundle Load

The console will display any errors that occur.

HTTP Client

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

  1. 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]/baseDstu3/Practitioner/prac-123

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

    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]/baseDstu3/Practitioner

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

    The response will be the same as the PUT method.

  2. POST a transaction Bundle

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

    POST [base]/baseDstu3

    {
      "resourceType": "Bundle",
      "id": "example-transaction",
      "type": "transaction",
      "entry": [
        {
          "resource": {
            ...
          },
          "request": {
            "method": "PUT",
            "url": "[base]/baseDstu3/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 http://measure.eval.kanvix.com/cqf-ruler/baseDstu3.

Clone this wiki locally