Skip to content

Instantly share code, notes, and snippets.

@ppazos
Created February 11, 2020 17:09
Show Gist options
  • Save ppazos/66401f99e6998322f5954267748d2d0b to your computer and use it in GitHub Desktop.
Save ppazos/66401f99e6998322f5954267748d2d0b to your computer and use it in GitHub Desktop.

Default

localhost 8080 /ehrbase/rest/openehr/v1/

Create EHR

POST /ehr Content-Type: application/json Prefer: return=representation Accept: application/json

Body (optional, this is a minimal EHR_STATUS):

{
  "_type": "EHR_STATUS",
  "subject": {
  },
  "is_modifiable": true,
  "is_queryable": false
}

Create EHR with UID

PUT /ehr/${ehr_id} Content-Type: application/json Prefer: return=representation Accept: application/json

Body (optional, this is a minimal EHR_STATUS):

{
  "_type": "EHR_STATUS",
  "subject": {
  },
  "is_modifiable": true,
  "is_queryable": false
}

Upload OPT

POST /definition/template/adl1.4 Content-Type: application/xml Prefer: return=representation Accept: application/json

Body:

<?xml version="1.0" encoding="utf-8"?>
<!--Operational template XML automatically generated by Ocean Template Designer Version 2.8.94Beta-->
<template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.openehr.org/v1">
  <language>
    <terminology_id>
      <value>ISO_639-1</value>
    </terminology_id>
    <code_string>en</code_string>
  </language>
  <description>
    <original_author id="Original Author">Not Specified</original_author>
    <lifecycle_state>Initial</lifecycle_state>
    <other_details id="MetaDataSet:Sample Set ">Template metadata sample set </other_details>
    <other_details id="Acknowledgements"></other_details>
    <other_details id="Business Process Level"></other_details>
    <other_details id="Care setting"></other_details>
    <other_details id="Client group"></other_details>
    <other_details id="Clinical Record Element"></other_details>
    <other_details id="Copyright"></other_details>
    <other_details id="Issues"></other_details>
    <other_details id="Owner"></other_details>
    <other_details id="Sign off"></other_details>
    <other_details id="Speciality"></other_details>
    <other_details id="User roles"></other_details>
    <details>
      <language>
        <terminology_id>
          <value>ISO_639-1</value>
        </terminology_id>
        <code_string>en</code_string>
      </language>
      <purpose>Not Specified</purpose>
    </details>
  </description>
  <uid>
    <value>711d7d49-b3c6-4a6a-a6b4-a4bd02fc353d</value>
  </uid>
  <template_id>
    <value>minimal_evaluation.en.v1</value>
  </template_id>
  <concept>Minimal evaluation</concept>
  <definition>
    <rm_type_name>COMPOSITION</rm_type_name>
    <occurrences>
      <lower_included>true</lower_included>
      <upper_included>true</upper_included>
      <lower_unbounded>false</lower_unbounded>
      <upper_unbounded>false</upper_unbounded>
      <lower>1</lower>
      <upper>1</upper>
    </occurrences>
    <node_id>at0000</node_id>
    <attributes xsi:type="C_SINGLE_ATTRIBUTE">
      <rm_attribute_name>category</rm_attribute_name>
      <existence>
        <lower_included>true</lower_included>
        <upper_included>true</upper_included>
        <lower_unbounded>false</lower_unbounded>
        <upper_unbounded>false</upper_unbounded>
        <lower>1</lower>
        <upper>1</upper>
      </existence>
      <children xsi:type="C_COMPLEX_OBJECT">
        <rm_type_name>DV_CODED_TEXT</rm_type_name>
        <occurrences>
          <lower_included>true</lower_included>
          <upper_included>true</upper_included>
          <lower_unbounded>false</lower_unbounded>
          <upper_unbounded>false</upper_unbounded>
          <lower>1</lower>
          <upper>1</upper>
        </occurrences>
        <node_id />
        <attributes xsi:type="C_SINGLE_ATTRIBUTE">
          <rm_attribute_name>defining_code</rm_attribute_name>
          <existence>
            <lower_included>true</lower_included>
            <upper_included>true</upper_included>
            <lower_unbounded>false</lower_unbounded>
            <upper_unbounded>false</upper_unbounded>
            <lower>1</lower>
            <upper>1</upper>
          </existence>
          <children xsi:type="C_CODE_PHRASE">
            <rm_type_name>CODE_PHRASE</rm_type_name>
            <occurrences>
              <lower_included>true</lower_included>
              <upper_included>true</upper_included>
              <lower_unbounded>false</lower_unbounded>
              <upper_unbounded>false</upper_unbounded>
              <lower>1</lower>
              <upper>1</upper>
            </occurrences>
            <node_id />
            <terminology_id>
              <value>openehr</value>
            </terminology_id>
            <code_list>433</code_list>
          </children>
        </attributes>
      </children>
    </attributes>
    <attributes xsi:type="C_MULTIPLE_ATTRIBUTE">
      <rm_attribute_name>content</rm_attribute_name>
      <existence>
        <lower_included>true</lower_included>
        <upper_included>true</upper_included>
        <lower_unbounded>false</lower_unbounded>
        <upper_unbounded>false</upper_unbounded>
        <lower>0</lower>
        <upper>1</upper>
      </existence>
      <children xsi:type="C_ARCHETYPE_ROOT">
        <rm_type_name>EVALUATION</rm_type_name>
        <occurrences>
          <lower_included>true</lower_included>
          <lower_unbounded>false</lower_unbounded>
          <upper_unbounded>true</upper_unbounded>
          <lower>0</lower>
        </occurrences>
        <node_id>at0000</node_id>
        <attributes xsi:type="C_SINGLE_ATTRIBUTE">
          <rm_attribute_name>data</rm_attribute_name>
          <existence>
            <lower_included>true</lower_included>
            <upper_included>true</upper_included>
            <lower_unbounded>false</lower_unbounded>
            <upper_unbounded>false</upper_unbounded>
            <lower>1</lower>
            <upper>1</upper>
          </existence>
          <children xsi:type="C_COMPLEX_OBJECT">
            <rm_type_name>ITEM_TREE</rm_type_name>
            <occurrences>
              <lower_included>true</lower_included>
              <upper_included>true</upper_included>
              <lower_unbounded>false</lower_unbounded>
              <upper_unbounded>false</upper_unbounded>
              <lower>1</lower>
              <upper>1</upper>
            </occurrences>
            <node_id>at0001</node_id>
            <attributes xsi:type="C_MULTIPLE_ATTRIBUTE">
              <rm_attribute_name>items</rm_attribute_name>
              <existence>
                <lower_included>true</lower_included>
                <upper_included>true</upper_included>
                <lower_unbounded>false</lower_unbounded>
                <upper_unbounded>false</upper_unbounded>
                <lower>0</lower>
                <upper>1</upper>
              </existence>
              <children xsi:type="C_COMPLEX_OBJECT">
                <rm_type_name>ELEMENT</rm_type_name>
                <occurrences>
                  <lower_included>true</lower_included>
                  <upper_included>true</upper_included>
                  <lower_unbounded>false</lower_unbounded>
                  <upper_unbounded>false</upper_unbounded>
                  <lower>0</lower>
                  <upper>1</upper>
                </occurrences>
                <node_id>at0002</node_id>
                <attributes xsi:type="C_SINGLE_ATTRIBUTE">
                  <rm_attribute_name>value</rm_attribute_name>
                  <existence>
                    <lower_included>true</lower_included>
                    <upper_included>true</upper_included>
                    <lower_unbounded>false</lower_unbounded>
                    <upper_unbounded>false</upper_unbounded>
                    <lower>0</lower>
                    <upper>1</upper>
                  </existence>
                  <children xsi:type="C_DV_QUANTITY">
                    <rm_type_name>DV_QUANTITY</rm_type_name>
                    <occurrences>
                      <lower_included>true</lower_included>
                      <upper_included>true</upper_included>
                      <lower_unbounded>false</lower_unbounded>
                      <upper_unbounded>false</upper_unbounded>
                      <lower>1</lower>
                      <upper>1</upper>
                    </occurrences>
                    <node_id />
                    <property>
                      <terminology_id>
                        <value>openehr</value>
                      </terminology_id>
                      <code_string>124</code_string>
                    </property>
                    <list>
                      <units>kg</units>
                    </list>
                    <list>
                      <units>mg</units>
                    </list>
                    <list>
                      <units>gm</units>
                    </list>
                  </children>
                </attributes>
              </children>
              <cardinality>
                <is_ordered>false</is_ordered>
                <is_unique>false</is_unique>
                <interval>
                  <lower_included>true</lower_included>
                  <lower_unbounded>false</lower_unbounded>
                  <upper_unbounded>true</upper_unbounded>
                  <lower>0</lower>
                </interval>
              </cardinality>
            </attributes>
          </children>
        </attributes>
        <archetype_id>
          <value>openEHR-EHR-EVALUATION.minimal.v1</value>
        </archetype_id>
        <term_definitions code="at0000">
          <items id="description">unknown</items>
          <items id="text">Minimal</items>
        </term_definitions>
        <term_definitions code="at0001">
          <items id="description">@ internal @</items>
          <items id="text">Arbol</items>
        </term_definitions>
        <term_definitions code="at0002">
          <items id="description">*</items>
          <items id="text">quantity</items>
        </term_definitions>
      </children>
      <cardinality>
        <is_ordered>false</is_ordered>
        <is_unique>false</is_unique>
        <interval>
          <lower_included>true</lower_included>
          <lower_unbounded>false</lower_unbounded>
          <upper_unbounded>true</upper_unbounded>
          <lower>0</lower>
        </interval>
      </cardinality>
    </attributes>
    <archetype_id>
      <value>openEHR-EHR-COMPOSITION.minimal.v1</value>
    </archetype_id>
    <template_id>
      <value>minimal_evaluation.en.v1</value>
    </template_id>
    <term_definitions code="at0000">
      <items id="description">unknown</items>
      <items id="text">Minimal</items>
    </term_definitions>
  </definition>
</template>

Commit Contribution

POST /ehr/${ehr_id}/contribution Content-Type: application/json Prefer: return=representation Accept: application/json

Body:

{
  "_type": "CONTRIBUTION",
  "versions": [
    {
      "_type": "ORIGINAL_VERSION",
      "commit_audit": {
        "_type": "AUDIT_DETAILS",
        "system_id": "test-system-id",
        "committer": {
          "_type": "PARTY_IDENTIFIED",
          "name": "<optional name of the committer>",
          "external_ref": {
            "id": {
              "_type": "GENERIC_ID",
              "value": "<OBJECT_ID>",
              "scheme": "<ID SCHEME NAME>"
            },
            "namespace": "demographic",
            "type": "PERSON"
          }
        },
        "change_type": {
          "value": "creation",
          "defining_code": {
            "terminology_id": {
              "value": "openehr"
            },
            "code_string": "249"
          }
        },
        "description": {
          "value": "optional audit description"
        }
      },
      "data": {
      	"_type": "COMPOSITION",
      	"name": {
      		"_type": "DV_TEXT",
      		"value": "Minimal"
      	},
      	"archetype_details": {
      		"_type": "ARCHETYPED",
      		"archetype_id": {
      			"_type": "ARCHETYPE_ID",
      			"value": "openEHR-EHR-COMPOSITION.minimal.v1"
      		},
      		"template_id": {
      			"_type": "TEMPLATE_ID",
      			"value": "minimal_evaluation.en.v1"
      		},
      		"rm_version": "1.0.2"
      	},
      	"archetype_node_id": "openEHR-EHR-COMPOSITION.minimal.v1",
      	"language": {
      		"_type": "CODE_PHRASE",
      		"terminology_id": {
      			"_type": "TERMINOLOGY_ID",
      			"value": "ISO_639-1"
      		},
      		"code_string": "en"
      	},
      	"territory": {
      		"_type": "CODE_PHRASE",
      		"terminology_id": {
      			"_type": "TERMINOLOGY_ID",
      			"value": "ISO_3166-1"
      		},
      		"code_string": "UY"
      	},
      	"category": {
      		"_type": "DV_CODED_TEXT",
      		"value": "event",
      		"defining_code": {
      			"_type": "CODE_PHRASE",
      			"terminology_id": {
      				"_type": "TERMINOLOGY_ID",
      				"value": "openehr"
      			},
      			"code_string": "433"
      		}
      	},
      	"composer": {
      		"_type": "PARTY_IDENTIFIED",
      		"external_ref": {
      			"_type": "PARTY_REF",
      			"id": {
      				"_type": "HIER_OBJECT_ID",
      				"value": "830f2fb4-1bbf-4376-9d52-77ef4b8f92e8"
      			},
      			"namespace": "DEMOGRAPHIC",
      			"type": "PERSON"
      		},
      		"name": "Dr. Yamamoto"
      	},
      	"context": {
      		"_type": "EVENT_CONTEXT",
      		"start_time": {
      			"_type": "DV_DATE_TIME",
      			"value": "2019-01-28T21:22:19,979+0000"
      		},
      		"setting": {
      			"_type": "DV_CODED_TEXT",
      			"value": "primary nursing care",
      			"defining_code": {
      				"_type": "CODE_PHRASE",
      				"terminology_id": {
      					"_type": "TERMINOLOGY_ID",
      					"value": "openehr"
      				},
      				"code_string": "229"
      			}
      		},
      		"participations": [{
      			"_type": "PARTICIPATION",
      			"function": {
      				"_type": "DV_TEXT",
      				"value": "companion"
      			},
      			"performer": {
      				"_type": "PARTY_RELATED",
      				"name": "Betty Bix",
      				"relationship": {
      					"_type": "DV_CODED_TEXT",
      					"value": "sister",
      					"defining_code": {
      						"_type": "CODE_PHRASE",
      						"terminology_id": {
      							"_type": "TERMINOLOGY_ID",
      							"value": "openehr"
      						},
      						"code_string": "24"
      					}
      				}
      			},
      			"mode": {
      				"_type": "DV_CODED_TEXT",
      				"value": "not specified",
      				"defining_code": {
      					"_type": "CODE_PHRASE",
      					"terminology_id": {
      						"_type": "TERMINOLOGY_ID",
      						"value": "openehr"
      					},
      					"code_string": "193"
      				}
      			}
      		}]
      	},
      	"content": [{
      		"_type": "EVALUATION",
      		"name": {
      			"_type": "DV_TEXT",
      			"value": "Minimal"
      		},
      		"archetype_node_id": "openEHR-EHR-EVALUATION.minimal.v1",
      		"language": {
      			"_type": "CODE_PHRASE",
      			"terminology_id": {
      				"_type": "TERMINOLOGY_ID",
      				"value": "ISO_639-1"
      			},
      			"code_string": "en"
      		},
      		"encoding": {
      			"_type": "CODE_PHRASE",
      			"terminology_id": {
      				"_type": "TERMINOLOGY_ID",
      				"value": "Unicode"
      			},
      			"code_string": "UTF-8"
      		},
      		"subject": {
      			"_type": "PARTY_SELF"
      		},
      		"data": {
      			"_type": "ITEM_TREE",
      			"name": {
      				"_type": "DV_TEXT",
      				"value": "Arbol"
      			},
      			"archetype_node_id": "at0001",
      			"items": [{
      				"_type": "ELEMENT",
      				"name": {
      					"_type": "DV_TEXT",
      					"value": "quantity"
      				},
      				"archetype_node_id": "at0002",
      				"value": {
      					"_type": "DV_QUANTITY",
      					"magnitude": 78.5,
      					"units": "kg"
      				}
      			}]
      		}
      	}]
      },
      "lifecycle_state": {
        "value": "complete",
        "defining_code": {
          "terminology_id": {
            "value": "openehr"
          },
          "code_string": "532"
        }
      }
    }
  ],
  "audit": {
    "_type": "AUDIT_DETAILS",
    "system_id": "test-system-id",
    "committer": {
      "_type": "PARTY_IDENTIFIED",
      "name": "optional name of the committer",
      "external_ref": {
        "id": {
          "_type": "GENERIC_ID",
          "value": "<OBJECT_ID>",
          "scheme": "<ID SCHEME NAME>"
        },
        "namespace": "demographic",
        "type": "PERSON"
      }
    },
    "change_type": {
      "value": "creation",
      "defining_code": {
        "terminology_id": {
          "value": "openehr"
        },
        "code_string": "249"
      }
    },
    "description": {
      "value": "optional audit description"
    }
  }
}
@testautomation
Copy link

be aware of https://github.com/ehrbase/project_management/issues/160 (POST and PUT with empty subject does not work yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment