---
title: "Create EHR"
method: POST
path: "/ehr"
tags: ["EHR"]
---

# Create EHR

`POST /ehr`

Create a new `EHR` with an auto-generated identifier.

An EHR_STATUS resource needs to be always created and committed in the new EHR.
This resource MAY be also supplied by the client as the request body. 
If not supplied, a default EHR_STATUS will be used by the service with following attributes:
  - `is_queryable`: true
  - `is_modifiable`: true
  - `subject`: a PARTY_SELF object

All other required EHR attributes and resources will be automatically created as needed by the [EHR creation semantics](https://specifications.openehr.org/releases/RM/latest/ehr.html#_ehr_creation_semantics).

## Headers

- `Prefer` 'return=representation' | 'return=minimal' | 'return=identifier'
- `Accept` 'application/json' | 'application/xml'
- `Content-Type` 'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'

## Request body

- EhrStatus
  - `_type` string

## Response `201`

`201 Created` is returned when the EHR has been successfully created, 
with the full resource in the body when `Prefer` header is `return=representation`, or only its identifiers when `Prefer` header is `return=identifier`.

- union
  - Ehr — An EHR resource
    - `system_id` HierObjectId
      - `_type` string
      - `value` string, required
    - `ehr_id` HierObjectId
      - `_type` string
      - `value` string, required
    - `ehr_status` ObjectRefOfObjectVersionId
      - `namespace` string, required
      - `type` string, required
      - `id` ObjectId, required
        - `_type` string
        - `value` string, required
    - `ehr_access` ObjectRefOfObjectVersionId
      - `namespace` string, required
      - `type` string, required
      - `id` ObjectId, required
        - `_type` string
        - `value` string, required
    - `time_created` DvDateTime
      - `_type` string
  - Identifier
    - `uid` string, required — The (version) resource identifier.

## Other responses

- `400` — `400 Bad Request` is returned when the request could not be parsed or is invalid (e.g. malformed request URL syntax, missing required header or parameter, or syntactically invalid header, parameter or content). The response body MAY contain error details.
- `409` — `409 Conflict` Unable to create a new EHR due to a conflict with an already existing EHR with the same subject id, namespace pair, whenever EHR_STATUS is supplied.

---

[API](https://skmtc.net/openehr/apis/ehr-api.md) · [All operations](https://skmtc.net/openehr/apis/ehr-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openehr/ehr-api/versions/a0e37a217524/schema)
