<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=References%2FObservation_Definition</id>
	<title>References/Observation Definition - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=References%2FObservation_Definition"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Observation_Definition&amp;action=history"/>
	<updated>2026-07-06T05:20:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.4</generator>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Observation_Definition&amp;diff=406&amp;oldid=prev</id>
		<title>Admin: Automated edit (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Observation_Definition&amp;diff=406&amp;oldid=prev"/>
		<updated>2026-07-06T04:02:53Z</updated>

		<summary type="html">&lt;p&gt;Automated edit (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:32, 6 July 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 329:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 329:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt; codings follow UCUM, but Care never converts between units at display time — store data in the unit you intend to read.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt; codings follow UCUM, but Care never converts between units at display time — store data in the unit you intend to read.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;convert_od_to_observation&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;observation.py&amp;lt;/code&amp;gt;) builds an [[References/Observation|&amp;lt;code&amp;gt;Observation&amp;lt;/code&amp;gt;]] from a definition for a given encounter, carrying over &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; and defaulting &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;final&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;convert_od_to_observation&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;observation.py&amp;lt;/code&amp;gt;) builds an [[References/Observation|&amp;lt;code&amp;gt;Observation&amp;lt;/code&amp;gt;]] from a definition for a given encounter, carrying over &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; and defaulting &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;final&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Navbox definitions}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Observation_Definition&amp;diff=150&amp;oldid=prev</id>
		<title>Admin: OHC identity seed</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Observation_Definition&amp;diff=150&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:40Z</updated>

		<summary type="html">&lt;p&gt;OHC identity seed&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Doc header&lt;br /&gt;
|type=reference&lt;br /&gt;
|domain=definitions&lt;br /&gt;
|title=Observation Definition&lt;br /&gt;
|order=4&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=ObservationDefinition&lt;br /&gt;
|reference=References/Base models &amp;amp;amp; conventions&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
An &amp;lt;code&amp;gt;ObservationDefinition&amp;lt;/code&amp;gt; is master data describing &amp;#039;&amp;#039;how&amp;#039;&amp;#039; a particular observation is captured — its code, permitted data type, unit, method, body site, and (interpretation) reference ranges. You create one when you need a measurement collected consistently across forms; questionnaires reference it so the same observation (blood pressure, say) is recorded the same way everywhere, whether instance-wide or within a single facility. One observation code can back several definitions. The model loosely follows the [&amp;lt;nowiki/&amp;gt;https://build.fhir.org/observationdefinition.html FHIR ObservationDefinition] resource.&lt;br /&gt;
&lt;br /&gt;
The Django model is only storage: &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;method&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;component&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;qualified_ranges&amp;lt;/code&amp;gt; are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s. The shape you write against — enums, value-set bindings, read/write contracts — lives in the Pydantic resource specs (&amp;lt;code&amp;gt;care/emr/resources/observation_definition/spec.py&amp;lt;/code&amp;gt;), built on the &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; base.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Source:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* Model: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/models/observation_definition.py &amp;lt;code&amp;gt;care/emr/models/observation_definition.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Resource spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/observation_definition/spec.py &amp;lt;code&amp;gt;care/emr/resources/observation_definition/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Helper: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/observation_definition/observation.py &amp;lt;code&amp;gt;care/emr/resources/observation_definition/observation.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Model&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ObservationDefinition&amp;lt;/code&amp;gt;&lt;br /&gt;
| Master-data definition of how an observation is coded, typed, and measured&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ObservationDefinition&amp;lt;/code&amp;gt; extends [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;]], which adds facility-scoped slug helpers on top of &amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;. From &amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt; it inherits &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;, soft-delete via &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;, and the &amp;lt;code&amp;gt;history&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt; JSON fields.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;ObservationDefinition&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Identity &amp;amp;amp; scope ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=facility|type=FK → Facility (PROTECT)|notes=Nullable, &amp;lt;code&amp;gt;default=None&amp;lt;/code&amp;gt;. Set means the definition is scoped to that facility; &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; means instance-wide. Excluded from the base spec (&amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt;) and set server-side from the &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; UUID on create}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=version|type=IntegerField|notes=Defaults to &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;. Read-only — appears in &amp;lt;code&amp;gt;...ReadSpec&amp;lt;/code&amp;gt; only, never accepted on write}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=slug|type=CharField(255)|notes=Set server-side from &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;, then namespaced. See [[#slug-behaviour}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=title|type=CharField(1024)|notes=Required. Display name shown when authoring questionnaires; not the observation &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=status|type=CharField(255)|notes=Required. Lifecycle code from &amp;lt;code&amp;gt;ObservationStatusChoices&amp;lt;/code&amp;gt; — see [[#status-values}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=description|type=TextField|notes=Required. Natural-language (markdown) description}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Identity &amp;amp;amp; scope|name=derived_from_uri|type=TextField|notes=External URI this definition was derived from. Optional (&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;, default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Coding &amp;amp;amp; measurement ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=category|type=CharField(255)|notes=Nullable in the model, but &amp;#039;&amp;#039;&amp;#039;required&amp;#039;&amp;#039;&amp;#039; in the API as &amp;lt;code&amp;gt;ObservationCategoryChoices&amp;lt;/code&amp;gt; — see [[#category-values}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=code|type=JSONField|notes=Required. What is being observed: a &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to the &amp;lt;code&amp;gt;system-observation&amp;lt;/code&amp;gt; value set (LOINC) — see [[#coding-shape}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=permitted_data_type|type=CharField(100)|notes=Required. &amp;lt;code&amp;gt;QuestionType&amp;lt;/code&amp;gt; enum (questionnaire data types) — see [[#permitted-data-type-values}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=body_site|type=JSONField|notes=Nullable. &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to the &amp;lt;code&amp;gt;system-body-site-observation&amp;lt;/code&amp;gt; value set (SNOMED CT)}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=method|type=JSONField|notes=Nullable. &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to the &amp;lt;code&amp;gt;system-collection-method&amp;lt;/code&amp;gt; value set (SNOMED CT)}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Coding &amp;amp;amp; measurement|name=permitted_unit|type=JSONField|notes=Nullable. &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to the &amp;lt;code&amp;gt;system-ucum-units&amp;lt;/code&amp;gt; value set (UCUM). Care does not convert between units when displaying data}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Components &amp;amp;amp; ranges ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Components &amp;amp;amp; ranges|name=component|type=JSONField|notes=Nullable. &amp;lt;code&amp;gt;list[ObservationDefinitionComponentSpec] | None&amp;lt;/code&amp;gt;. Several measured values under one definition (systolic + diastolic, for example), each with its own &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_data_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;qualified_ranges&amp;lt;/code&amp;gt; — see [[#observationdefinitioncomponentspec}}&lt;br /&gt;
{{Field|model=ObservationDefinition|section=Components &amp;amp;amp; ranges|name=qualified_ranges|type=JSONField|notes=Model default &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;. &amp;#039;&amp;#039;&amp;#039;Required&amp;#039;&amp;#039;&amp;#039; in the API as &amp;lt;code&amp;gt;list[QualifiedRangeSpec]&amp;lt;/code&amp;gt;, though it may be empty. Condition-dependent reference ranges / interpretations — see [[#qualifiedrangespec}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
=== Status values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ObservationStatusChoices&amp;lt;/code&amp;gt; — bound to the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Category values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ObservationCategoryChoices&amp;lt;/code&amp;gt; — bound to the &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; field.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;social_history&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;vital_signs&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;imaging&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;laboratory&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;procedure&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;survey&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;exam&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;therapy&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;activity&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Permitted data type values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;QuestionType&amp;lt;/code&amp;gt; (from &amp;lt;code&amp;gt;questionnaire/spec.py&amp;lt;/code&amp;gt;) — bound to &amp;lt;code&amp;gt;permitted_data_type&amp;lt;/code&amp;gt; on both the definition and each component. &amp;lt;code&amp;gt;validate_question_type&amp;lt;/code&amp;gt; rejects &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;display&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt; with &amp;amp;quot;Cannot create a definition with this type&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Allowed for a definition&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;&lt;br /&gt;
| No (rejected)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;decimal&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integer&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;display&amp;lt;/code&amp;gt;&lt;br /&gt;
| No (rejected)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dateTime&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;choice&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt;&lt;br /&gt;
| No (rejected)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;quantity&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;structured&amp;lt;/code&amp;gt;&lt;br /&gt;
| Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== JSON field shapes (nested specs) ==&lt;br /&gt;
&lt;br /&gt;
=== Coding shape ===&lt;br /&gt;
&lt;br /&gt;
The coded fields (&amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;method&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt;) store a &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object. The spec binds each to a value set via &amp;lt;code&amp;gt;ValueSetBoundCoding[&amp;amp;lt;slug&amp;amp;gt;]&amp;lt;/code&amp;gt;, so the submitted &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; is validated against that value set on write.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;Coding {&lt;br /&gt;
  system:  str | null&lt;br /&gt;
  version: str | null&lt;br /&gt;
  code:    str            # required&lt;br /&gt;
  display: str | null&lt;br /&gt;
}                          # extra=&amp;quot;forbid&amp;quot; — unknown keys rejected&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Bound value set (slug)&lt;br /&gt;
! Code system&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;system-observation&amp;lt;/code&amp;gt;&lt;br /&gt;
| LOINC (&amp;lt;code&amp;gt;http://loinc.org&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;system-body-site-observation&amp;lt;/code&amp;gt;&lt;br /&gt;
| SNOMED CT (&amp;lt;code&amp;gt;http://snomed.info/sct&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;method&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;system-collection-method&amp;lt;/code&amp;gt;&lt;br /&gt;
| SNOMED CT&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;system-ucum-units&amp;lt;/code&amp;gt;&lt;br /&gt;
| UCUM (&amp;lt;code&amp;gt;http://unitsofmeasure.org&amp;lt;/code&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== ObservationDefinitionComponentSpec ===&lt;br /&gt;
&lt;br /&gt;
Element of the &amp;lt;code&amp;gt;component&amp;lt;/code&amp;gt; list — one per measured value when a definition carries several.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;ObservationDefinitionComponentSpec {&lt;br /&gt;
  code:                ValueSetBoundCoding[system-observation]   # required&lt;br /&gt;
  permitted_data_type: QuestionType                              # required; group/display/url rejected&lt;br /&gt;
  permitted_unit:      ValueSetBoundCoding[system-ucum-units] | null = null&lt;br /&gt;
  qualified_ranges:    list[QualifiedRangeSpec]                  # required&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== QualifiedRangeSpec ===&lt;br /&gt;
&lt;br /&gt;
Element of &amp;lt;code&amp;gt;qualified_ranges&amp;lt;/code&amp;gt; (on the definition and on each component). A qualified range is either &amp;#039;&amp;#039;&amp;#039;numeric&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;ranges&amp;lt;/code&amp;gt;) or &amp;#039;&amp;#039;&amp;#039;categorical&amp;#039;&amp;#039;&amp;#039; (coded value sets) — never both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;QualifiedRangeSpec {&lt;br /&gt;
  title:                    str | null = null&lt;br /&gt;
  conditions:               list[EvaluatorConditionSpec] = []&lt;br /&gt;
  ranges:                   list[NumericRangeSpec] = []&lt;br /&gt;
  default_interpretation:   InterpretationSpec | null = null&lt;br /&gt;
  normal_coded_value_set:   str | null = &amp;quot;&amp;quot;&lt;br /&gt;
  critical_coded_value_set: str | null = &amp;quot;&amp;quot;&lt;br /&gt;
  abnormal_coded_value_set: str | null = &amp;quot;&amp;quot;&lt;br /&gt;
  valueset_interpretation:  list[ValueSetInterpretationSpec] = []&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;validate_categorical_or_numeric&amp;lt;/code&amp;gt; enforces:&lt;br /&gt;
&lt;br /&gt;
* Either &amp;lt;code&amp;gt;ranges&amp;lt;/code&amp;gt; (numeric) &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; at least one coded value set / &amp;lt;code&amp;gt;valueset_interpretation&amp;lt;/code&amp;gt; (categorical) — one is required.&lt;br /&gt;
* Numeric &amp;lt;code&amp;gt;ranges&amp;lt;/code&amp;gt; and coded value sets cannot both appear.&lt;br /&gt;
* Numeric &amp;lt;code&amp;gt;ranges&amp;lt;/code&amp;gt; must not overlap (sorted by &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, treating missing &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt; as -∞/+∞).&lt;br /&gt;
* Coded value-set slugs (&amp;lt;code&amp;gt;normal_coded_value_set&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;critical_coded_value_set&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;abnormal_coded_value_set&amp;lt;/code&amp;gt;, and each &amp;lt;code&amp;gt;valueset_interpretation.valuset&amp;lt;/code&amp;gt;) must be unique — duplicates are rejected.&lt;br /&gt;
&lt;br /&gt;
=== NumericRangeSpec ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;NumericRangeSpec {&lt;br /&gt;
  interpretation: InterpretationSpec          # required&lt;br /&gt;
  min: Decimal(max_digits=20, decimal_places=6) | null = null&lt;br /&gt;
  max: Decimal(max_digits=20, decimal_places=6) | null = null&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
At least one of &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt; must be provided (&amp;lt;code&amp;gt;validate_range&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== InterpretationSpec ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;InterpretationSpec {&lt;br /&gt;
  display:   str             # required&lt;br /&gt;
  icon:      str | null = &amp;quot;&amp;quot;&lt;br /&gt;
  color:     str | null = &amp;quot;&amp;quot;&lt;br /&gt;
  highlight: bool | null = false&lt;br /&gt;
  code:      Coding | null = {}&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== ValueSetInterpretationSpec ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;ValueSetInterpretationSpec {&lt;br /&gt;
  interpretation: InterpretationSpec   # required&lt;br /&gt;
  valuset:        str                  # value-set slug (note: spelling &amp;quot;valuset&amp;quot;)&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== EvaluatorConditionSpec ===&lt;br /&gt;
&lt;br /&gt;
Element of &amp;lt;code&amp;gt;QualifiedRangeSpec.conditions&amp;lt;/code&amp;gt;. Validated against &amp;lt;code&amp;gt;EvaluatorMetricsRegistry&amp;lt;/code&amp;gt;: an unknown &amp;lt;code&amp;gt;metric&amp;lt;/code&amp;gt; raises, and the registered evaluator validates &amp;lt;code&amp;gt;operation&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;EvaluatorConditionSpec {&lt;br /&gt;
  metric:    str          # must resolve in EvaluatorMetricsRegistry&lt;br /&gt;
  operation: str&lt;br /&gt;
  value:     dict | str&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
All specs subclass &amp;lt;code&amp;gt;BaseObservationDefinitionSpec&amp;lt;/code&amp;gt; (itself a subclass of &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt;, with &amp;lt;code&amp;gt;__model__ = ObservationDefinition&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; provides &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; plus the &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; hooks.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec class&lt;br /&gt;
! Role&lt;br /&gt;
! Notable fields / behaviour&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;BaseObservationDefinitionSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| Shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_data_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;component&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;method&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;derived_from_uri&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;qualified_ranges&amp;lt;/code&amp;gt;. Runs &amp;lt;code&amp;gt;validate_data_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;validate_qualified_ranges_consistency&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ObservationDefinitionCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| Write · create&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;facility: UUID4 | null&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;slug_value: SlugType&amp;lt;/code&amp;gt;. Validates the facility exists; &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the facility and sets &amp;lt;code&amp;gt;obj.slug = slug_value&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ObservationDefinitionUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| Write · update&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;slug_value: SlugType&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;obj.slug = slug_value&amp;lt;/code&amp;gt;. The facility is not re-bound on update&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ObservationDefinitionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| Read · list &amp;amp;amp; detail&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;version: int | null&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility: dict | null&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug_config: dict&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug: str&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt;, serializes &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;FacilityBareMinimumSpec&amp;lt;/code&amp;gt;, and sets &amp;lt;code&amp;gt;slug_config = parse_slug(slug)&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Value-set bindings&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;method&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt; (and component equivalents) are &amp;lt;code&amp;gt;ValueSetBoundCoding[...]&amp;lt;/code&amp;gt;; the submitted coding is validated against the bound value set (&amp;lt;code&amp;gt;system-observation&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;system-body-site-observation&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;system-collection-method&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;system-ucum-units&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Data-type guard&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;permitted_data_type&amp;lt;/code&amp;gt; (definition and component) rejects &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;display&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Range consistency&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;validate_qualified_ranges_consistency&amp;lt;/code&amp;gt; requires every &amp;lt;code&amp;gt;qualified_ranges&amp;lt;/code&amp;gt; entry on a definition to be the same kind: all numeric &amp;lt;code&amp;gt;ranges&amp;lt;/code&amp;gt; or all coded value sets. Mixing raises.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt;: 5–50 chars, URL-safe (&amp;lt;code&amp;gt;[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]&amp;lt;/code&amp;gt;), starting and ending alphanumeric. Stored namespaced as &amp;lt;code&amp;gt;obj.slug&amp;lt;/code&amp;gt; (see below).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;No metadata store&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;__store_metadata__&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;, so spec fields map directly to model columns rather than into &amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ObservationDefinition&amp;lt;/code&amp;gt; overrides nothing of its own. Slug handling comes from &amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;, and the create/update side effects live in the API specs.&lt;br /&gt;
&lt;br /&gt;
=== Slug behaviour ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;FACILITY_SCOPED = True&amp;lt;/code&amp;gt;, so the stored &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; is namespaced:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility-scoped: f-&amp;lt;facility.external_id&amp;gt;-&amp;lt;slug_value&amp;gt;&lt;br /&gt;
instance-scoped: i-&amp;lt;slug_value&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;calculate_slug()&amp;lt;/code&amp;gt; returns the &amp;lt;code&amp;gt;f-…&amp;lt;/code&amp;gt; form when &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; is set, otherwise the &amp;lt;code&amp;gt;i-…&amp;lt;/code&amp;gt; form.&lt;br /&gt;
* &amp;lt;code&amp;gt;parse_slug(slug)&amp;lt;/code&amp;gt; validates the prefix and returns a dict: &amp;lt;code&amp;gt;{&amp;amp;quot;facility&amp;amp;quot;: &amp;amp;lt;uuid&amp;amp;gt;, &amp;amp;quot;slug_value&amp;amp;quot;: &amp;amp;lt;bare slug&amp;amp;gt;}&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;f-&amp;lt;/code&amp;gt; slugs, or &amp;lt;code&amp;gt;{&amp;amp;quot;slug_value&amp;amp;quot;: &amp;amp;lt;bare slug&amp;amp;gt;}&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;i-&amp;lt;/code&amp;gt; slugs. &amp;lt;code&amp;gt;ObservationDefinitionReadSpec&amp;lt;/code&amp;gt; exposes this as &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The create/update specs receive the bare &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; and store it on &amp;lt;code&amp;gt;obj.slug&amp;lt;/code&amp;gt;; the model&amp;#039;s slug helpers apply the namespacing.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* The facility binding is write-once: the create spec resolves the &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; UUID to an FK; the update spec only re-sets &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; and never re-binds the facility.&lt;br /&gt;
* Retire definitions via &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;) instead of deleting. The inherited &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; flag gives you ORM-level soft-delete if you need it.&lt;br /&gt;
* &amp;lt;code&amp;gt;permitted_unit&amp;lt;/code&amp;gt; codings follow UCUM, but Care never converts between units at display time — store data in the unit you intend to read.&lt;br /&gt;
* &amp;lt;code&amp;gt;convert_od_to_observation&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;observation.py&amp;lt;/code&amp;gt;) builds an [[References/Observation|&amp;lt;code&amp;gt;Observation&amp;lt;/code&amp;gt;]] from a definition for a given encounter, carrying over &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; and defaulting &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;final&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>