# Import a CodeSystem

Canonical page: https://docs.ovok.com/primitives/import-codesystem

`$import` adds terminology concepts and their metadata to a CodeSystem. This operation changes server data; invoke it with `POST`. FHIR R4 does not define a standard `CodeSystem/$import` operation, so its availability and exact input constraints are implementation-specific.

| Method | Path |
| --- | --- |
| `POST` | `/fhir/R4/CodeSystem/$import` |

## POST request [#post-request]

The import request is a FHIR `Parameters` resource. This example supplies a CodeSystem canonical URL, one concept, a property, and a German designation.

```bash
curl --request POST \
  --url 'https://api.sandbox.ovok.com/fhir/R4/CodeSystem/$import' \
  --header "Authorization: Bearer ${OVOK_TOKEN}" \
  --header 'Content-Type: application/fhir+json' \
  --data @import-codesystem-parameters.json
```

Example `import-codesystem-parameters.json`:

```json
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "system",
      "valueUri": "https://example.org/fhir/CodeSystem/vitals"
    },
    {
      "name": "concept",
      "valueCoding": {
        "code": "HR",
        "display": "Heart rate"
      }
    },
    {
      "name": "property",
      "part": [
        { "name": "code", "valueCode": "HR" },
        { "name": "property", "valueCode": "unit" },
        { "name": "value", "valueString": "bpm" }
      ]
    },
    {
      "name": "designation",
      "part": [
        { "name": "code", "valueCode": "HR" },
        { "name": "language", "valueCode": "de" },
        { "name": "value", "valueString": "Herzfrequenz" }
      ]
    }
  ]
}
```

- `system` identifies the CodeSystem by canonical URL. If using a CodeSystem-instance operation instead, the resource id identifies the target.
- Each `concept` parameter adds a code and optional display.
- Each `property` parameter associates metadata with a concept. Its parts identify the concept `code`, property name, and typed `value`.
- Each `designation` parameter adds an alternate display or translation. Its parts identify the concept code, optional language, and text value.

## Successful response [#successful-response]

The operation returns the `CodeSystem` resource that received the imported concepts. The exact response depends on existing CodeSystem content.

| Response path | Example | Meaning |
| --- | --- | --- |
| `resourceType` | `CodeSystem` | Identifies the returned FHIR resource. |
| `url` | `https://example.org/fhir/CodeSystem/vitals` | Canonical URL of the CodeSystem. |
| `status` | `active` | Status of the returned CodeSystem. |
| `content` | `fragment` | Indicates the resource contains a partial code system. |
| `concept[].code`, `concept[].display` | `HR`, `Heart rate` | Imported concept code and display. |
| `concept[].property[]` | `unit` = `bpm` | Additional typed metadata for the concept. |
| `concept[].designation[]` | `language=de`, `value=Herzfrequenz` | Alternate designation and language. |

The returned `CodeSystem` is the updated resource; `concept` contains imported concepts and their properties/designations. Use the resource `url` or `id` to read it afterward.

This is an implementation-specific Ovok compatibility operation, not a standard FHIR R4 operation. The `system`, `concept`, `property`, and `designation` inputs reflect the contract currently exposed by Ovok and may vary by deployment and release. Check the target environment's Ovok API reference for its advertised capabilities.

## GET: read the CodeSystem after import [#get-read-the-codesystem-after-import]

`GET` does not invoke `$import`. Use a regular CodeSystem search to inspect a resource after the write:

```bash
curl --get 'https://api.sandbox.ovok.com/fhir/R4/CodeSystem' \
  --header "Authorization: Bearer ${OVOK_TOKEN}" \
  --data-urlencode 'url=https://example.org/fhir/CodeSystem/vitals'
```

This returns a FHIR searchset `Bundle`; its `entry[].resource` contains the matching CodeSystem. The `CodeSystem/$import` operation itself is POST-only because it changes server data.

Use the Ovok API reference and the target environment's CapabilityStatement to confirm that this operation is available.
