CONTRIBUTION

Create CONTRIBUTION

We will use the relaxed CONTRIBUTION with the following optional attributes:

  • uid: when provided, it will be accepted in case is not in-use, otherwise error will be returned
  • audit.time_committed: server will always set it
  • audit.system_id: when provided, it will be validated

The audit and each versions[i].commit_audit are UPDATE_AUDIT objects: structurally an AUDIT_DETAILS minus the server-assigned attributes (time_committed, and the optional system_id). Clients SHOULD send _type: "UPDATE_AUDIT"; for interoperability servers SHOULD additionally accept _type: "AUDIT_DETAILS" or an omitted _type for this attribute. The audit.change_type and each versions[i].lifecycle_state are DV_CODED_TEXT values coded against the openEHR terminology.

Simplified Formats (FLAT / STRUCTURED)

The Content-Type and Accept headers MAY be set to one of the Simplified Formats MIME types - application/openehr.wt.flat+json or application/openehr.wt.structured+json - in addition to the canonical application/json / application/xml.

When a Simplified Formats MIME type is used, the CONTRIBUTION envelope itself remains canonical JSON (i.e. uid, versions[] metadata, and audit follow the canonical RM serialization). Only the inner versioned payload - each versions[i].data (the embedded COMPOSITION, EHR_STATUS, or FOLDER) - is serialized in the chosen FLAT or STRUCTURED form. See Simplified Formats for the rules that apply to that inner payload.

post/ehr/{ehr_id}/contribution

Path parameters

ehr_idstring uuid required
Example:7d44b88c-4199-4bad-97dc-d78268e01398

EHR identifier taken from EHR.ehr_id.value.

Headers

Prefer'return=representation' | 'return=minimal' | 'return=identifier'

Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation, or only the resource identifier (e.g., the uid) when the value is return=identifier.

Accept'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'
Content-Type'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'

Request body

Example request

{
  "versions": [
    {
      "attestations": [
        {
          "_type": "UPDATE_AUDIT",
          "change_type": {
            "value": "creation",
            "defining_code": {
              "terminology_id": {
                "value": "openehr"
              },
              "code_string": "249"
            }
          },
          "description": "Description text",
          "committer": {
            "_type": "PARTY_IDENTIFIED",
            "name": "A user name"
          }
        }
      ],
      "commit_audit": {
        "_type": "UPDATE_AUDIT",
        "change_type": {
          "value": "creation",
          "defining_code": {
            "terminology_id": {
              "value": "openehr"
            },
            "code_string": "249"
          }
        },
        "description": "Description text",
        "committer": {
          "_type": "PARTY_IDENTIFIED",
          "name": "A user name"
        }
      }
    }
  ],
  "audit": {
    "_type": "UPDATE_AUDIT",
    "change_type": {
      "value": "creation",
      "defining_code": {
        "terminology_id": {
          "value": "openehr"
        },
        "code_string": "249"
      }
    },
    "description": "Description text",
    "committer": {
      "_type": "PARTY_IDENTIFIED",
      "name": "A user name"
    }
  }
}

Response

201 Created is returned when the CONTRIBUTION is successfully created. If Prefer header is return=representation, the full resource is included in the response body; if is return=identifier, only its unique identifier is included. If the Prefer header is missing or set to return=minimal, the body is empty.

When the request Accept header selects a Simplified Formats MIME type (application/openehr.wt.flat+json or application/openehr.wt.structured+json) and Prefer: return=representation, the response body is still a canonical CONTRIBUTION envelope; only each versions[i].data payload is serialized in the requested FLAT or STRUCTURED form.

OR

Example response

{
  "uid": {
    "value": "0826851c-c4c2-4d61-92b9-410fb8275ff0"
  },
  "versions": [
    {
      "id": {
        "_type": "OBJECT_VERSION_ID",
        "value": "fb458d9c-1323-42bc-b7f8-787f3660a0b5::openEHRSys.example.com::1"
      },
      "namespace": "local",
      "type": "COMPOSITION"
    },
    {
      "id": {
        "_type": "OBJECT_VERSION_ID",
        "value": "abcdefgh-1323-42bc-b7f8-787f3660a0ba::openEHRSys.example.com::1"
      },
      "namespace": "local",
      "type": "FOLDER"
    }
  ],
  "audit": {
    "system_id": "9624982A-9F42-41A5-9318-AE13D5F5031F",
    "committer": {
      "_type": "PARTY_IDENTIFIED",
      "name": "A user name"
    },
    "time_committed": {
      "value": "2017-08-15T10:37:15.422+02:00"
    },
    "change_type": {
      "value": "creation",
      "defining_code": {
        "terminology_id": {
          "value": "openehr"
        },
        "code_string": "249"
      }
    },
    "description": {
      "value": "Description text"
    }
  }
}