---
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'

## Request body

- EhrStatus
  - `_type` string

## Response `201`

`201 Created` is returned when the EHR has been successfully created. 
The new EHR resource is returned in the body when the request's `Prefer` header value is `return=representation`, otherwise only headers are returned.

- Ehr — An EHR resource
  - `system_id` HierObjectId
    - `_type` string
    - `value` string, required
  - `ehr_id` HierObjectId
    - `_type` string
    - `value` string, required
  - `ehr_status` ObjectRef
    - `_type` string
    - `namespace` string, required
    - `type` string, required
    - `id` ObjectId, required
      - `_type` string
      - `value` string, required
  - `ehr_access` ObjectRef
    - `_type` string
    - `namespace` string, required
    - `type` string, required
    - `id` ObjectId, required
      - `_type` string
      - `value` string, required
  - `time_created` DvDateTime
    - `_type` string

## Other responses

- `400` — `400 Bad Request` is returned when the request URL or body (if provided) could not be parsed or has invalid content.
- `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.

## Changes

- **2022-11-16** `0db68c21be77` — 60 breaking, 44 info
  - removed the enum value `ACTOR` of the request property `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/feeder_system_audit/location/allOf[subschema #1: PARTY_PROXY]/external_ref/type`
  - removed the enum value `ACTOR` of the request property `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/feeder_system_audit/provider/allOf[subschema #1: PARTY_PROXY]/external_ref/type`
  - removed the enum value `ACTOR` of the request property `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/feeder_system_audit/subject/external_ref/type`
  - removed the enum value `ACTOR` of the request property `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/originating_system_audit/location/allOf[subschema #1: PARTY_PROXY]/external_ref/type`
  - …100 more

[Change history](https://skmtc.dev/openehr/apis/ehr-api/changes/ehr/post.md)

---

[API](https://skmtc.dev/openehr/apis/ehr-api.md) · [All operations](https://skmtc.dev/openehr/apis/ehr-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/openehr/ehr-api/revisions/0db68c21be77/schema)
