Post Data

Any FHIR resource designated read/write in the reference documentation (see https://[YOUR_FHIR_ENDPOINT]/documentation) will support the POST operation. Data are posted in a Bundle with type transaction. It is important to provide relevant patient demographics and identifiers to enable matching to patients which may already exist on the FHIR server.

Creating a Transaction to POST

To write/create/update FHIR patient data, POST a Bundle with type transaction. Each Bundle contains an entry array of resources.

For example, to write a weight observation, POST a payload to the base URL https://[YOUR_FHIR_ENDPOINT]/ (typically .../api/fhir; ensure use of the intended endpoint version, eg DSTU2 versus R4):

{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "fullUrl": "patient1",
      "resource": {
        "resourceType": "Patient",
        "identifier": [
          {"value": "6995d608-8544-ea11-815b-0a69c1b3225b"}
        ],
        "name": [
          {
            "use": "official",
            "family": "Demoski",
            "given": ["Fran"]
          }
        ],
        "gender": "female",
        "birthDate": "1995-09-27"
      },
      "request": {
        "method": "POST",
        "url": "Patient"
      }
    },
    {
      "fullUrl": "obs1",
      "resource": {
        "resourceType": "Observation",
        "status": "final",
        "code": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "3141-9",
              "display": "Weight Measured"
            }
          ]
        },
        "subject": {
          "reference": "patient1"
        },
        "valueQuantity": {
          "value": 135,
          "unit": "lbs",
          "system": "http://unitsofmeasure.org",
          "code": "[lb_av]"
        }
      },
      "request": {
        "method": "POST",
        "url": "Observation"
      }
    }
  ]
}

A successful response would indicate that two resources have been created ("status": "201") and specify their complete FHIR URLs:

{
    "resourceType": "Bundle",
    "id": "urn:uuid:132fa74f-9167-4ca6-a163-ae852a1fc4c1",
    "type": "transaction-response",
    "entry": [
        {
            "fullUrl": "patient1",
            "response": {
                "status": "201",
                "location": "https://fhir.careevolution.com/Master.Adapter1.WebClient/api/fhir-r4/Patient/89dd7176-1306-45f8-97f8-a51826add3a2"
            }
        },
        {
            "fullUrl": "obs1",
            "response": {
                "status": "201",
                "location": "https://fhir.careevolution.com/Master.Adapter1.WebClient/api/fhir-r4/Observation/1.ba11c848bf5eec1181870a69c1b3225b"
            }
        }
    ]
}

Specifying Patient Demographics and Identifiers

It is recommended that each Bundle always contains a Patient resource with any available demographic information to facilitate patient matching to existing data when applicable.

Patient demographic identifiers (e.g. medical record numbers, patient IDs, social security numbers, etc.) are specified as FHIR identifiers, mapping their type to FHIR system URIs. A listing of system URIs can be found at https://[YOUR_FHIR_ENDPOINT]/documentation.

For example, to set an SSN and MemberID:

   "identifier": [
        {"value": "P-1002"},
        {
            "system": "http://hl7.org/fhir/sid/us-ssn",
            "value": "123-45-6789"
        },
        {
            "system": "http://fhir.careevolution.com/identifiers/CareEvolution/MemberID",
            "value": "Member1001"
...

Specifying Full URLs

The ”fullurl” elements are arbitrary strings that must be unique within the transaction. They are used to specify references between different resource in the transaction - so in the example above the patient has

"fullUrl": "patient1",

and its observation has: "subject": {"reference": "patient1"},

Full URLs also match each transaction resource with its corresponding response:

    {
        "fullUrl": "patient1",
        "response": {
            "status": "201",
            "location": "https://fhir.careevolution.com/Master.Adapter1.WebClient/api/fhir/Patient/89dd7176-1306-45f8-97f8-a51826add3a2"
...

Special Case: Labs in DiagnosticReports

FHIR labs are Observation resources with laboratory category in the http://hl7.org/fhir/observation-category system:

        "category": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/observation-category",
              "code": "laboratory"
...

Stand-alone labs are not supported, they must always be posted as part of a lab report - that is a FHIR DiagnosticReport with LAB category in the http://hl7.org/fhir/v2/0074 system.

Here is a complete transaction to create a lab report with a single WBC value:

{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "fullUrl": "patient1",
      "resource": {
        "resourceType": "Patient",
        "identifier": [
          {"value": "6995d608-8544-ea11-815b-0a69c1b3225b"}
        ],
        "name": [
          {
            "use": "official",
            "family": "Demoski",
            "given": ["Fran"]
          }
        ],
        "gender": "female",
        "birthDate": "1995-09-27"
      },
      "request": {
        "method": "POST",
        "url": "Patient"
      }
    },
    {
      "fullUrl": "labreport1",
      "resource": {
        "resourceType": "DiagnosticReport",
        "status":  "final",
        "identifier": [
          {
            "type": {
              "coding": [
                {
                  "system": "http://hl7.org/fhir/identifier-type",
                  "code": "PLAC"
                }
              ]
            },
            "system": "http://fhir.carevolution.com/identifiers/CareEvolution/MRN/DemoRecordAuthority",
            "value": "2"
          }
        ],
        "category": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/v2/0074",
              "code": "LAB"
            }
          ]
        },
        "code": {
          "coding": [
            {
              "system": "http://fhir.carevolution.com/codes/DemoNamespace/LabService",
              "code": "Lab"
            }
          ]
        },
        "subject": {
          "reference": "patient1"
        },
        "effectiveDateTime": "2019-03-03T23:32:00-05:00",
        "issued": "2019-03-03T23:32:00-05:00",
        "result": [
          {
            "reference": "labobs1"
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "DiagnosticReport"
      }
    },
    {
      "fullUrl": "labobs1",
      "resource": {
        "resourceType": "Observation",
        "status": "final",
        "category": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/observation-category",
              "code": "laboratory"
            }
          ]
        },
        "code": {
          "coding": [
            {
              "system": "http://fhir.carevolution.com/codes/DemoNamespace/LabObservationType",
              "code": "WBC"
            }
          ]
        },
        "subject": {
          "reference": "patient1"
        },
        "effectiveDateTime": "2019-03-03T23:32:00-05:00",
        "issued": "2019-03-03T23:32:00-05:00",
        "valueQuantity": {
          "value": 16.6,
          "unit": "K/CUMM"
        }
      },
      "request": {
        "method": "POST",
        "url": "Observation"
      }
    }
  ]
}

Note how the DiagnosticReport references the Observation:

 "result": [
          {
            "reference": "labobs1"
...

Also note how the report placer identifier is represented:

       "identifier": [
          {
            "type": {
              "coding": [
                {
                  "system": "http://hl7.org/fhir/identifier-type",
                  "code": "PLAC"
                }
              ]
            },
            "system": "http://fhir.carevolution.com/identifiers/CareEvolution/MRN/DemoRecordAuthority",
            "value": "2"
...