<?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%2FSpecimen_Definition</id>
	<title>References/Specimen 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%2FSpecimen_Definition"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Specimen_Definition&amp;action=history"/>
	<updated>2026-07-06T08:43:52Z</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/Specimen_Definition&amp;diff=409&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/Specimen_Definition&amp;diff=409&amp;oldid=prev"/>
		<updated>2026-07-06T04:03:23Z</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 277:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 277:&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;* &#039;&#039;&#039;Read payload&#039;&#039;&#039; (&amp;lt;code&amp;gt;SpecimenDefinitionReadSpec&amp;lt;/code&amp;gt;): adds &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; (= &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, the qualified &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;slug_config&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;* &#039;&#039;&#039;Read payload&#039;&#039;&#039; (&amp;lt;code&amp;gt;SpecimenDefinitionReadSpec&amp;lt;/code&amp;gt;): adds &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; (= &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, the qualified &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt;.&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 model maps to the FHIR &amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; resource. Care&#039;s spec is intentionally minimal: one container per definition, and behaviour changes bump &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt; rather than mutate published records.&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 model maps to the FHIR &amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; resource. Care&#039;s spec is intentionally minimal: one container per definition, and behaviour changes bump &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt; rather than mutate published records.&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;!-- diff cache key mediawiki:diff:1.41:old-154:rev-409:wikidiff2=table:1.14.2:bc2a06be --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Specimen_Definition&amp;diff=154&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/Specimen_Definition&amp;diff=154&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:53Z</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=Specimen Definition&lt;br /&gt;
|order=5&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=SpecimenDefinition&lt;br /&gt;
|reference=References/Value Set&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; is a reusable, facility-scoped template for a &amp;#039;&amp;#039;kind&amp;#039;&amp;#039; of specimen: what material to collect, how to prepare the patient, how to collect it, and how it&amp;#039;s held in a container for testing. A lab maintains a repository of these, and an [[References/Activity Definition]] or [[References/Service Request]] references one so the same container and handling rules apply every time. When a concrete [[References/Specimen]] is instantiated from a definition, the link is kept and the specimen copies the definition&amp;#039;s data for history and integrity.&lt;br /&gt;
&lt;br /&gt;
The Django model is only the storage layer: &amp;lt;code&amp;gt;type_collected&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient_preparation&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt; are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s. Their real structure — the enums, value-set bindings, and read/write API schemas — lives in the Pydantic resource specs documented below.&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/specimen_definition.py &amp;lt;code&amp;gt;care/emr/models/specimen_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/specimen_definition/spec.py &amp;lt;code&amp;gt;care/emr/resources/specimen_definition/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Value sets: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/specimen_definition/valueset.py &amp;lt;code&amp;gt;care/emr/resources/specimen_definition/valueset.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Conversion helper: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/specimen_definition/specimen.py &amp;lt;code&amp;gt;care/emr/resources/specimen_definition/specimen.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* ViewSet: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/specimen_definition.py &amp;lt;code&amp;gt;care/emr/api/viewsets/specimen_definition.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;SpecimenDefinition&amp;lt;/code&amp;gt;&lt;br /&gt;
| Reusable definition of a kind of specimen: what to collect, how to prepare the patient, how to collect it, and how it is contained and tested&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; extends [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;]]: the Care EMR base with &amp;lt;code&amp;gt;FACILITY_SCOPED = True&amp;lt;/code&amp;gt;, a facility-scoped &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;history&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt; JSON, audit fields, and soft-delete semantics.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Identity &amp;amp;amp; status ===&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;
! Required&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=facility|type=FK → facility.Facility (PROTECT)|notes=model: optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=version|type=IntegerField|notes=default &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=slug|type=CharField(255)|notes=yes (server-built)}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=title|type=CharField(1024)|notes=yes}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=derived_from_uri|type=TextField|notes=optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=status|type=CharField(255)|notes=yes}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=Identity &amp;amp;amp; status|name=description|type=TextField|notes=yes}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Collection &amp;amp;amp; testing detail (JSON fields) ===&lt;br /&gt;
&lt;br /&gt;
The model stores these as raw JSON; the spec defines their true shape and value-set bindings.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Model type&lt;br /&gt;
! Spec type&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;type_collected&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;null=True&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to &amp;#039;&amp;#039;&amp;#039;Specimen Type Code&amp;#039;&amp;#039;&amp;#039; value set&lt;br /&gt;
| Required on write. The kind of material collected. See [[#bound-value-sets&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;patient_preparation&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;list[Coding]&amp;lt;/code&amp;gt; bound to &amp;#039;&amp;#039;&amp;#039;Prepare Patient Prior Specimen Code&amp;#039;&amp;#039;&amp;#039; value set&lt;br /&gt;
| Defaults to &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;. Steps the patient follows before collection&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;null=True&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; bound to &amp;#039;&amp;#039;&amp;#039;Specimen Collection Code&amp;#039;&amp;#039;&amp;#039; value set, optional&lt;br /&gt;
| The specimen collection procedure&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;default=dict&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;TypeTestedSpec&amp;lt;/code&amp;gt; (nested), optional&lt;br /&gt;
| Container, handling, and testing detail. See [[#typetestedspec&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Each bound coded field accepts a &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object (&amp;lt;code&amp;gt;{ system, version?, code, display? }&amp;lt;/code&amp;gt;); &amp;lt;code&amp;gt;ValueSetBoundCoding&amp;lt;/code&amp;gt; validates the &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; against the bound value set at de-serialization time.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type&lt;br /&gt;
! Where&lt;br /&gt;
! Shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt;&lt;br /&gt;
| [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/common/coding.py &amp;lt;code&amp;gt;resources/common/coding.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
| &amp;lt;code&amp;gt;{ system: str?, version: str?, code: str (required), display: str? }&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;extra=&amp;amp;quot;forbid&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuantitySpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ value: Decimal (max_digits=20, decimal_places=0), unit: Coding }&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;decimal_places=0&amp;lt;/code&amp;gt;, so integer-valued&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;MinimumVolumeSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ quantity: QuantitySpec?, string: str? }&amp;lt;/code&amp;gt;; a validator forbids supplying both&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ContainerSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ description: str?, capacity: QuantitySpec?, minimum_volume: MinimumVolumeSpec?, cap: Coding? (bound to Container Cap), preparation: str? }&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DurationSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ value: Decimal (max_digits=20, decimal_places=0), unit: Coding }&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;unit&amp;lt;/code&amp;gt; not yet restricted to datetime units&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;RangeSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ low: QuantitySpec?, high: QuantitySpec? }&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HandlingSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| &amp;lt;code&amp;gt;{ temperature_qualifier: HandlingConditionOptions?, temperature_range: RangeSpec?, max_duration: DurationSpec?, instruction: str? }&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TypeTestedSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| spec.py&lt;br /&gt;
| see [[#typetestedspec&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;TypeTestedSpec&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
The structured shape of the &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt; JSON field. A definition holds a single container; for multiple containers per test, repeat the definition in the [[References/Activity Definition]] spec.&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;
! Required&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=is_derived|type=bool|notes=yes}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=preference|type=PreferenceOptions|notes=yes}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=container|type=ContainerSpec|notes=optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=requirement|type=str|notes=optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=retention_time|type=DurationSpec|notes=optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=single_use|type=bool|notes=optional}}&lt;br /&gt;
{{Field|model=SpecimenDefinition|section=TypeTestedSpec|name=handling|type=HandlingSpec|notes=optional}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enums ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;SpecimenDefinitionStatusOptions&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;&lt;br /&gt;
| Being authored, not yet in use&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
| In use&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;&lt;br /&gt;
| Withdrawn from use&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;PreferenceOptions&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;preferred&amp;lt;/code&amp;gt;&lt;br /&gt;
| Preferred specimen for the test&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;alternate&amp;lt;/code&amp;gt;&lt;br /&gt;
| Acceptable alternative specimen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;HandlingConditionOptions&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;room&amp;lt;/code&amp;gt;&lt;br /&gt;
| Room temperature&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;refrigerated&amp;lt;/code&amp;gt;&lt;br /&gt;
| Refrigerated&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;frozen&amp;lt;/code&amp;gt;&lt;br /&gt;
| Frozen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
All specs build on &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt;, &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;). &amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt; keeps &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; out of both directions. The ViewSet wires &amp;lt;code&amp;gt;pydantic_model = SpecimenDefinitionWriteSpec&amp;lt;/code&amp;gt; for create/update and &amp;lt;code&amp;gt;pydantic_read_model = SpecimenDefinitionReadSpec&amp;lt;/code&amp;gt; for list/retrieve.&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;
! Fields / behaviour&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;BaseSpecimenDefinitionSpec&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;type_collected&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient_preparation&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt;. Holds the coded-field value-set bindings and the nested &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt; shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SpecimenDefinitionWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create &amp;amp;amp; update&lt;br /&gt;
| Base fields &amp;#039;&amp;#039;&amp;#039;plus&amp;#039;&amp;#039;&amp;#039; &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; copies &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;obj.slug&amp;lt;/code&amp;gt; (the ViewSet then fully-qualifies it). &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, and the stored &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; are never client-supplied&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SpecimenDefinitionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list &amp;amp;amp; detail&lt;br /&gt;
| Base fields &amp;#039;&amp;#039;&amp;#039;plus&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;version: int?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug: str&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug_config: dict&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 = obj.external_id&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;slug_config = obj.parse_slug(obj.slug)&amp;lt;/code&amp;gt;, decomposing the qualified slug into &amp;lt;code&amp;gt;{ facility, slug_value }&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Nested specs used by the schemas: &amp;lt;code&amp;gt;TypeTestedSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ContainerSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;MinimumVolumeSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QuantitySpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DurationSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;RangeSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;HandlingSpec&amp;lt;/code&amp;gt; (see [[#related-models|Related models]]).&lt;br /&gt;
&lt;br /&gt;
=== Validation rules ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt;): string, length 5–50, matching &amp;lt;code&amp;gt;^[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]$&amp;lt;/code&amp;gt; (URL-safe; starts and ends alphanumeric).&lt;br /&gt;
* Coded fields &amp;lt;code&amp;gt;type_collected&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient_preparation[*]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;container.cap&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;ValueSetBoundCoding&amp;lt;/code&amp;gt; validates each &amp;lt;code&amp;gt;Coding.code&amp;lt;/code&amp;gt; against its bound value set during de-serialization and rejects unknown codes.&lt;br /&gt;
* &amp;lt;code&amp;gt;MinimumVolumeSpec&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;quantity&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; are mutually exclusive — supplying both raises &amp;lt;code&amp;gt;&amp;amp;quot;Only one of quantity or string should be provided&amp;amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;QuantitySpec&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;DurationSpec&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Decimal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max_digits=20&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;decimal_places=0&amp;lt;/code&amp;gt; (integer-valued).&lt;br /&gt;
* Slug uniqueness (ViewSet &amp;lt;code&amp;gt;validate_data&amp;lt;/code&amp;gt;): the fully-qualified &amp;lt;code&amp;gt;f-&amp;amp;lt;facility&amp;amp;gt;-&amp;amp;lt;slug_value&amp;amp;gt;&amp;lt;/code&amp;gt; must be unique within the facility (case-insensitive), else &amp;lt;code&amp;gt;&amp;amp;quot;Specimen Definition with this slug already exists.&amp;amp;quot;&amp;lt;/code&amp;gt; On update, the current record is excluded from the check.&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&lt;br /&gt;
! Slug&lt;br /&gt;
! Source system(s)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;type_collected&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specimen Type Code&lt;br /&gt;
| &amp;lt;code&amp;gt;system-specimen_type-code&amp;lt;/code&amp;gt;&lt;br /&gt;
| HL7 v2-0487 (unbounded include)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;patient_preparation[*]&amp;lt;/code&amp;gt;&lt;br /&gt;
| Prepare Patient Prior Specimen Code&lt;br /&gt;
| &amp;lt;code&amp;gt;system-prepare_patient_prior_specimen_code&amp;lt;/code&amp;gt;&lt;br /&gt;
| SNOMED CT, &amp;lt;code&amp;gt;is-a 703763000&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;&lt;br /&gt;
| Specimen Collection Code&lt;br /&gt;
| &amp;lt;code&amp;gt;system-specimen_collection_code&amp;lt;/code&amp;gt;&lt;br /&gt;
| SNOMED CT (curated list: aspiration, biopsy, puncture, excision, scraping, clean-catch/timed/catheterized urine, coughed sputum, finger-prick)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;container.cap&amp;lt;/code&amp;gt;&lt;br /&gt;
| Container Cap&lt;br /&gt;
| &amp;lt;code&amp;gt;system-container_cap-code&amp;lt;/code&amp;gt;&lt;br /&gt;
| HL7 &amp;lt;code&amp;gt;container-cap&amp;lt;/code&amp;gt; code system&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; overrides no &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;delete()&amp;lt;/code&amp;gt; and defines no custom methods. Slug helpers, audit fields, and soft-delete come from [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;]]. The side effects below live in the resource spec and the ViewSet, not the model:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Slug qualification (write).&amp;#039;&amp;#039;&amp;#039; Clients send a bare &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;SpecimenDefinitionWriteSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;obj.slug = slug_value&amp;lt;/code&amp;gt;; then the ViewSet&amp;#039;s &amp;lt;code&amp;gt;perform_create&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;perform_update&amp;lt;/code&amp;gt; rewrites it via &amp;lt;code&amp;gt;SpecimenDefinition.calculate_slug_from_facility(facility.external_id, slug)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f-&amp;amp;lt;facility_external_id&amp;amp;gt;-&amp;amp;lt;slug_value&amp;amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Facility binding (create).&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;perform_create&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;instance.facility&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;facility_external_id&amp;lt;/code&amp;gt; URL kwarg before saving.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Slug decomposition (read).&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;SpecimenDefinitionReadSpec.perform_extra_serialization&amp;lt;/code&amp;gt; exposes &amp;lt;code&amp;gt;slug_config = obj.parse_slug(obj.slug)&amp;lt;/code&amp;gt;, splitting the stored slug back into &amp;lt;code&amp;gt;{ facility, slug_value }&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Specimen instantiation.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;convert_sd_to_specimen&amp;lt;/code&amp;gt; ([&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/specimen_definition/specimen.py &amp;lt;code&amp;gt;specimen.py&amp;lt;/code&amp;gt;]) builds a [[References/Specimen|&amp;lt;code&amp;gt;Specimen&amp;lt;/code&amp;gt;]] from a definition with &amp;lt;code&amp;gt;status=&amp;amp;quot;available&amp;amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;specimen_type = definition.type_collected&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;specimen_definition = &amp;amp;lt;definition&amp;amp;gt;&amp;lt;/code&amp;gt;, preserving the link and a copy of the type.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Endpoints are facility-scoped.&amp;#039;&amp;#039;&amp;#039; The ViewSet supports create, retrieve, update, list, and upsert with &amp;lt;code&amp;gt;lookup_field = &amp;amp;quot;slug&amp;amp;quot;&amp;lt;/code&amp;gt;. Every operation requires &amp;lt;code&amp;gt;facility_external_id&amp;lt;/code&amp;gt; in the URL.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Authorization.&amp;#039;&amp;#039;&amp;#039; Writes require &amp;lt;code&amp;gt;can_write_facility_specimen_definition&amp;lt;/code&amp;gt;; list/retrieve require &amp;lt;code&amp;gt;can_list_facility_specimen_definition&amp;lt;/code&amp;gt; on the facility — otherwise &amp;lt;code&amp;gt;403 PermissionDenied&amp;lt;/code&amp;gt;. The queryset is filtered to the URL facility.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Filtering / ordering.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (iexact) and &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt; (icontains) filters; ordering by &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Write payload&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;SpecimenDefinitionWriteSpec&amp;lt;/code&amp;gt;): send &amp;lt;code&amp;gt;slug_value&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;, the coded fields (&amp;lt;code&amp;gt;type_collected&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient_preparation&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;collection&amp;lt;/code&amp;gt;) as &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; objects, and &amp;lt;code&amp;gt;type_tested&amp;lt;/code&amp;gt;. Don&amp;#039;t send &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, or the qualified &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; — they&amp;#039;re server-managed.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Read payload&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;SpecimenDefinitionReadSpec&amp;lt;/code&amp;gt;): adds &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; (= &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, the qualified &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The model maps to the FHIR &amp;lt;code&amp;gt;SpecimenDefinition&amp;lt;/code&amp;gt; resource. Care&amp;#039;s spec is intentionally minimal: one container per definition, and behaviour changes bump &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt; rather than mutate published records.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>