<?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%2FActivity_Definition</id>
	<title>References/Activity 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%2FActivity_Definition"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Activity_Definition&amp;action=history"/>
	<updated>2026-07-06T05:18:53Z</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/Activity_Definition&amp;diff=411&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/Activity_Definition&amp;diff=411&amp;oldid=prev"/>
		<updated>2026-07-06T04:03: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:33, 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 291:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 291:&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;* Apply instantiates the target &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt; (only &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt; today) by merging stored defaults with the encounter, and instantiates any linked &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt; in the same pass.&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;* Apply instantiates the target &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt; (only &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt; today) by merging stored defaults with the encounter, and instantiates any linked &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt; in the same pass.&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;* The requirement and linkage fields are plain integer ID arrays. Retrieve serialization resolves them to nested objects and skips any ID that no longer resolves, so a response can omit a requirement you stored.&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;* The requirement and linkage fields are plain integer ID arrays. Retrieve serialization resolves them to nested objects and skips any ID that no longer resolves, so a response can omit a requirement you stored.&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/Activity_Definition&amp;diff=148&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/Activity_Definition&amp;diff=148&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:36Z</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=Activity Definition&lt;br /&gt;
|order=6&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=ActivityDefinition&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;ActivityDefinition&amp;lt;/code&amp;gt; is a FHIR-aligned, facility-scoped template for a clinical activity. It stores the defaults needed to spin up a downstream resource — currently a [[References/Service Request]] — and you &amp;amp;quot;apply&amp;amp;quot; it against an encounter, which merges those defaults with the encounter context to produce the live resource.&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/activity_definition.py &amp;lt;code&amp;gt;care/emr/models/activity_definition.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Resource specs: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/activity_definition/spec.py &amp;lt;code&amp;gt;spec.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/activity_definition/valueset.py &amp;lt;code&amp;gt;valueset.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/activity_definition/service_request.py &amp;lt;code&amp;gt;service_request.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The Django model is just storage. Several fields are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s or integer &amp;lt;code&amp;gt;ArrayField&amp;lt;/code&amp;gt;s whose real structure lives in the Pydantic resource specs — the API layer that defines the enums, JSON shapes, validation rules, and the split between read and write schemas. Neither layer is complete on its own; read them together.&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;ActivityDefinition&amp;lt;/code&amp;gt;&lt;br /&gt;
| Versioned, facility-scoped template describing a clinical activity and the defaults used to create the resources it produces&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ActivityDefinition&amp;lt;/code&amp;gt; extends &amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;, which adds a facility-scoped &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; 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. See [[References/Base models &amp;amp;amp; conventions|Base model]].&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;ActivityDefinition&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
Each field lists its storage type (Django model) and, where the spec constrains it, the API shape or values the Pydantic specs enforce.&lt;br /&gt;
&lt;br /&gt;
=== Identity &amp;amp;amp; versioning ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Storage type&lt;br /&gt;
! API shape / notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;FK → facility.Facility&amp;lt;/code&amp;gt; (PROTECT)&lt;br /&gt;
| Owning facility. Spec-&amp;lt;code&amp;gt;__exclude__&amp;lt;/code&amp;gt;d — set server-side and never accepted in the payload.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;CharField(255)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Facility-scoped identifier. On write you supply it as &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt;); &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; assigns it to &amp;lt;code&amp;gt;obj.slug&amp;lt;/code&amp;gt;. On read it comes back as &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; plus a parsed &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt; dict.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;IntegerField&amp;lt;/code&amp;gt;&lt;br /&gt;
| Default &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;. Read-only in specs (&amp;lt;code&amp;gt;version: int | None&amp;lt;/code&amp;gt;), serialized on list and retrieve. Drives the append-only version chain.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;latest&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;BooleanField&amp;lt;/code&amp;gt;&lt;br /&gt;
| Default &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;. Marks the current version within a slug&amp;#039;s chain. Server-maintained, not exposed in the specs.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;derived_from_uri&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;TextField&amp;lt;/code&amp;gt;&lt;br /&gt;
| Nullable. URI this definition was derived from. Optional in specs (&amp;lt;code&amp;gt;str | None = None&amp;lt;/code&amp;gt;).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Descriptive metadata ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Storage type&lt;br /&gt;
! API shape / notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;CharField(1024)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Required (&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt;). Human-friendly name.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;CharField(255)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Required enum — &amp;lt;code&amp;gt;ActivityDefinitionStatusOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;classification&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;CharField(100)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Required enum — &amp;lt;code&amp;gt;ActivityDefinitionCategoryOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;laboratory&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;imaging&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;counselling&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;surgical_procedure&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;education&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;CharField(100)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Required enum — &amp;lt;code&amp;gt;ActivityDefinitionKindOptions&amp;lt;/code&amp;gt; (only &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt;). Determines the resource produced on apply.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;TextField&amp;lt;/code&amp;gt;&lt;br /&gt;
| Optional in specs; default &amp;lt;code&amp;gt;&amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;usage&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;TextField&amp;lt;/code&amp;gt;&lt;br /&gt;
| Optional in specs; default &amp;lt;code&amp;gt;&amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Coded clinical attributes (JSON) ===&lt;br /&gt;
&lt;br /&gt;
These are &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s. 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;, which validates the submitted code against that value set. Every coding is shaped &amp;lt;code&amp;gt;{ system?: str, version?: str, code: str (required), display?: str }&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;extra=&amp;amp;quot;forbid&amp;amp;quot;&amp;lt;/code&amp;gt;, so unknown keys are rejected.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Storage type&lt;br /&gt;
! API shape / notes&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;JSONField&amp;lt;/code&amp;gt; (nullable)&lt;br /&gt;
| Required &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to value set &amp;lt;code&amp;gt;activity-definition-procedure-code&amp;lt;/code&amp;gt; (SNOMED CT, &amp;lt;code&amp;gt;concept is-a 71388002&amp;lt;/code&amp;gt; &amp;amp;quot;Procedure&amp;amp;quot;). Nullable in the DB but rejected on write if absent.&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;JSONField&amp;lt;/code&amp;gt; (nullable)&lt;br /&gt;
| Optional &amp;lt;code&amp;gt;Coding | None = None&amp;lt;/code&amp;gt; bound to value set &amp;lt;code&amp;gt;system-body-site-observation&amp;lt;/code&amp;gt; (SNOMED CT body sites).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;diagnostic_report_codes&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; (nullable)&lt;br /&gt;
| &amp;lt;code&amp;gt;list[Coding]&amp;lt;/code&amp;gt;, default &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;. Each &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to value set &amp;lt;code&amp;gt;system-observation&amp;lt;/code&amp;gt; (LOINC).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Requirement &amp;amp;amp; linkage arrays ===&lt;br /&gt;
&lt;br /&gt;
These store integer primary keys, not Django FK relations — &amp;lt;code&amp;gt;ArrayField(IntegerField, default=list)&amp;lt;/code&amp;gt;. The specs never expose those raw PKs: writes reference targets by external slug or UUID, and retrieves expand them back into serialized objects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Storage type&lt;br /&gt;
! Write shape&lt;br /&gt;
! Read (retrieve) shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;specimen_requirements&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;ArrayField[int]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[ExtendedSlugType]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; — serialized [[References/Specimen Definition&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;observation_result_requirements&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;ArrayField[int]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[ExtendedSlugType]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; — serialized [[References/Observation Definition&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;ArrayField[int]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[UUID4]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; — serialized [[References/Location&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;ArrayField[int]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[ExtendedSlugType]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; — serialized [[References/Charge Item Definition&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;ArrayField[int]&amp;lt;/code&amp;gt;&lt;br /&gt;
| not written via spec&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; — rendered via &amp;lt;code&amp;gt;SingleFacilityTagManager().render_tags(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;ExtendedSlugType&amp;lt;/code&amp;gt;: 7–88 chars, URL-safe, must start with &amp;lt;code&amp;gt;f-&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;i-&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt; (used for &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;): 5–50 chars, URL-safe. The stored integer arrays carry no referential integrity — nothing stops you storing an ID whose target is later deleted, and retrieve serialization silently skips any ID that no longer resolves.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
=== Service relationships ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Storage type&lt;br /&gt;
! API shape / notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;FK → emr.HealthcareService&amp;lt;/code&amp;gt; (PROTECT)&lt;br /&gt;
| Nullable; default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;. Write: &amp;lt;code&amp;gt;UUID4 | None&amp;lt;/code&amp;gt;, resolved by &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt;. Retrieve: serialized via &amp;lt;code&amp;gt;HealthcareServiceReadSpec&amp;lt;/code&amp;gt;. See [[References/Healthcare Service]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;FK → emr.ResourceCategory&amp;lt;/code&amp;gt; (CASCADE)&lt;br /&gt;
| Nullable. Write: &amp;lt;code&amp;gt;ExtendedSlugType | None&amp;lt;/code&amp;gt;, resolved by &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;. Read: serialized via &amp;lt;code&amp;gt;ResourceCategoryReadSpec&amp;lt;/code&amp;gt;. Deleting the [[References/Resource Category]] cascades to the definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ActivityDefinitionStatusOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;) ===&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;
=== &amp;lt;code&amp;gt;ActivityDefinitionKindOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt;&lt;br /&gt;
| Only supported kind; applying the definition produces a [[References/Service Request]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ActivityDefinitionCategoryOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;classification&amp;lt;/code&amp;gt;) ===&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;laboratory&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;counselling&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;surgical_procedure&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;education&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bound value sets ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Value set slug&lt;br /&gt;
! Source system / filter&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;activity-definition-procedure-code&amp;lt;/code&amp;gt;&lt;br /&gt;
| SNOMED CT, &amp;lt;code&amp;gt;concept is-a 71388002&amp;lt;/code&amp;gt; (Procedure)&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 body-site concepts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;diagnostic_report_codes[]&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;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
All specs extend &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (see [[References/Base models &amp;amp;amp; conventions|Base model]]), which provides &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; (DB → Pydantic) and &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; (Pydantic → DB) 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. Here &amp;lt;code&amp;gt;__model__ = ActivityDefinition&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt;.&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;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;BaseActivityDefinitionSpec&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;derived_from_uri&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;usage&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;classification&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt;, &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;diagnostic_report_codes&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ActivityDefinitionWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create + update&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;list[UUID4]&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;specimen_requirements&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;observation_result_requirements&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;list[ExtendedSlugType]&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UUID4 | None&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;ExtendedSlugType | None&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ActivityDefinitionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Base fields plus &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (serialized dict), &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ActivityDefinitionRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Extends &amp;lt;code&amp;gt;ReadSpec&amp;lt;/code&amp;gt;; expands &amp;lt;code&amp;gt;specimen_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;observation_result_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt; from ID arrays into fully serialized nested objects.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Server-side behaviour ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;ActivityDefinitionWriteSpec.perform_extra_deserialization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (write path):&lt;br /&gt;
** Resolves &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, or clears it to &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt; when absent.&lt;br /&gt;
** Resolves &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, only when provided.&lt;br /&gt;
** Assigns &amp;lt;code&amp;gt;obj.slug = self.slug_value&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;ActivityDefinitionReadSpec.perform_extra_serialization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (read path): sets &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt;, renders &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt;, serializes &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (when present) via &amp;lt;code&amp;gt;ResourceCategoryReadSpec&amp;lt;/code&amp;gt;, and parses &amp;lt;code&amp;gt;slug_config = obj.parse_slug(obj.slug)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;ActivityDefinitionRetrieveSpec.perform_extra_serialization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;: calls the parent, then resolves each ID array (&amp;lt;code&amp;gt;specimen_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;observation_result_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt;) against its model — dropping IDs that no longer exist — and serializes &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The base &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; writes only model-mapped fields with &amp;lt;code&amp;gt;exclude_defaults=True&amp;lt;/code&amp;gt;, so any unset optional field falls back to its model default.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Apply → Service Request&amp;#039;&amp;#039;&amp;#039; ([&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/activity_definition/service_request.py &amp;lt;code&amp;gt;service_request.py&amp;lt;/code&amp;gt;]): &amp;lt;code&amp;gt;convert_ad_to_sr(activity_definition, encounter)&amp;lt;/code&amp;gt; builds a draft [[References/Service Request|&amp;lt;code&amp;gt;ServiceRequest&amp;lt;/code&amp;gt;]]. It carries over &amp;lt;code&amp;gt;title&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;body_site&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;, and binds &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; from the encounter. The new request starts at &amp;lt;code&amp;gt;status=draft&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;intent=proposal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;priority=routine&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;do_not_perform=False&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Charge items on apply&amp;#039;&amp;#039;&amp;#039;: &amp;lt;code&amp;gt;apply_ad_charge_definitions(activity_definition, encounter, service_request)&amp;lt;/code&amp;gt; loads every linked [[References/Charge Item Definition]] and, for each, instantiates a Charge Item (via &amp;lt;code&amp;gt;apply_charge_item_definition&amp;lt;/code&amp;gt;), tags it to the service request (&amp;lt;code&amp;gt;service_resource = service_request&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;service_resource_id = external_id&amp;lt;/code&amp;gt;), copies the creator, and sets &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; to the request&amp;#039;s &amp;lt;code&amp;gt;requester&amp;lt;/code&amp;gt; when one is set.&lt;br /&gt;
* &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;latest&amp;lt;/code&amp;gt; form an append-only chain per &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;: query &amp;lt;code&amp;gt;latest=True&amp;lt;/code&amp;gt; for the current definition; superseded versions stay readable so existing references don&amp;#039;t break.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* Payload field names follow the Pydantic specs, not the Django model. Send &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;. Reference &amp;lt;code&amp;gt;specimen_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;observation_result_requirements&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; by external slug (&amp;lt;code&amp;gt;ExtendedSlugType&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;f-&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;i-&amp;lt;/code&amp;gt; prefixed); reference &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt; by UUID.&lt;br /&gt;
* &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; is required and must validate against the &amp;lt;code&amp;gt;activity-definition-procedure-code&amp;lt;/code&amp;gt; value set. &amp;lt;code&amp;gt;body_site&amp;lt;/code&amp;gt; and each entry of &amp;lt;code&amp;gt;diagnostic_report_codes&amp;lt;/code&amp;gt; validate against their bound value sets.&lt;br /&gt;
* Apply instantiates the target &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt; (only &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt; today) by merging stored defaults with the encounter, and instantiates any linked &amp;lt;code&amp;gt;charge_item_definitions&amp;lt;/code&amp;gt; in the same pass.&lt;br /&gt;
* The requirement and linkage fields are plain integer ID arrays. Retrieve serialization resolves them to nested objects and skips any ID that no longer resolves, so a response can omit a requirement you stored.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>