<?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%2FDevice</id>
	<title>References/Device - 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%2FDevice"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Device&amp;action=history"/>
	<updated>2026-07-06T05:19:21Z</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/Device&amp;diff=423&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/Device&amp;diff=423&amp;oldid=prev"/>
		<updated>2026-07-06T04:05:58Z</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:35, 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 341:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 341:&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;metadata&amp;lt;/code&amp;gt; (the model column) is plugin-owned; clients read deployment-specific data back through the &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; virtual field, not &amp;lt;code&amp;gt;metadata&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;metadata&amp;lt;/code&amp;gt; (the model column) is plugin-owned; clients read deployment-specific data back through the &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; virtual field, not &amp;lt;code&amp;gt;metadata&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;* &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt; is platform-maintained — don&#039;t set it directly. The list endpoint scopes results to devices whose cache overlaps the requesting user&#039;s facility-organization memberships, or, when &amp;lt;code&amp;gt;?location=&amp;lt;/code&amp;gt; is supplied, by location permission / &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;?include_children=&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;facility_organization_cache&amp;lt;/code&amp;gt; is platform-maintained — don&#039;t set it directly. The list endpoint scopes results to devices whose cache overlaps the requesting user&#039;s facility-organization memberships, or, when &amp;lt;code&amp;gt;?location=&amp;lt;/code&amp;gt; is supplied, by location permission / &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;?include_children=&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 facility}}&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;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;Wiki: ohcnwiki.tellmey.fyi&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/Device&amp;diff=156&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/Device&amp;diff=156&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:56Z</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=facility&lt;br /&gt;
|title=Device&lt;br /&gt;
|order=7&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=Device&lt;br /&gt;
|reference=References/Encounter&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;Device&amp;lt;/code&amp;gt; tracks a physical or logical piece of equipment within a facility — from its lifecycle status to where it&amp;#039;s placed and which encounter it&amp;#039;s attached to.&lt;br /&gt;
&lt;br /&gt;
The Django model is only the storage layer; it types fields loosely — &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt; for status enums, &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;contact&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;. The contract lives in the Pydantic resource specs under &amp;lt;code&amp;gt;care/emr/resources/device/&amp;lt;/code&amp;gt;, which constrain those &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt;s to enums, structure the JSON fields, and define validation, read/write schemas, and server-maintained side effects.&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/device.py &amp;lt;code&amp;gt;care/emr/models/device.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/device/spec.py &amp;lt;code&amp;gt;care/emr/resources/device/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* History spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/device/history_spec.py &amp;lt;code&amp;gt;care/emr/resources/device/history_spec.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/device.py &amp;lt;code&amp;gt;care/emr/api/viewsets/device.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Device-type registry: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/registries/device_type/device_registry.py &amp;lt;code&amp;gt;care/emr/registries/device_type/device_registry.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;Device&amp;lt;/code&amp;gt;&lt;br /&gt;
| A physical or logical device tracked within a facility&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceEncounterHistory&amp;lt;/code&amp;gt;&lt;br /&gt;
| Records each period a device was associated with an &amp;lt;code&amp;gt;Encounter&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceLocationHistory&amp;lt;/code&amp;gt;&lt;br /&gt;
| Records each period a device was placed at a &amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceServiceHistory&amp;lt;/code&amp;gt;&lt;br /&gt;
| Records servicing/maintenance events for a device&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All models extend [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]] (shared Care EMR base with &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, audit fields, and soft-delete semantics).&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;Device&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Device data ===&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;
! Spec constraint&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=Device|section=Device data|name=identifier|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=status|type=CharField(16)|notes=&amp;lt;code&amp;gt;DeviceStatusChoices&amp;lt;/code&amp;gt; (&amp;#039;&amp;#039;&amp;#039;required&amp;#039;&amp;#039;&amp;#039;)}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=availability_status|type=CharField(14)|notes=&amp;lt;code&amp;gt;DeviceAvailabilityStatusChoices&amp;lt;/code&amp;gt; (&amp;#039;&amp;#039;&amp;#039;required&amp;#039;&amp;#039;&amp;#039;)}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=manufacturer|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=manufacture_date|type=DateTimeField|notes=&amp;lt;code&amp;gt;datetime | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=expiration_date|type=DateTimeField|notes=&amp;lt;code&amp;gt;datetime | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=lot_number|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=serial_number|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=registered_name|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; (&amp;#039;&amp;#039;&amp;#039;required&amp;#039;&amp;#039;&amp;#039;)}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=user_friendly_name|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=model_number|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=part_number|type=CharField(1024)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=contact|type=JSONField (default {})|notes=&amp;lt;code&amp;gt;list[ContactPoint]&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=care_type|type=CharField(1024) (default None)|notes=&amp;lt;code&amp;gt;str | None&amp;lt;/code&amp;gt; (create only)}}&lt;br /&gt;
{{Field|model=Device|section=Device data|name=metadata|type=JSONField (default {})|notes=not exposed directly}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Virtual / spec-only field ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Spec type&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;dict&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt;)&lt;br /&gt;
| Not a DB column. On read it&amp;#039;s populated by the &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; plugin — &amp;lt;code&amp;gt;DeviceListSpec&amp;lt;/code&amp;gt; calls the plugin&amp;#039;s &amp;lt;code&amp;gt;list(obj)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DeviceRetrieveSpec&amp;lt;/code&amp;gt; calls &amp;lt;code&amp;gt;retrieve(obj)&amp;lt;/code&amp;gt;. On write it carries plugin-specific data for &amp;lt;code&amp;gt;handle_create&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;handle_update&amp;lt;/code&amp;gt;, which typically persist into the model&amp;#039;s &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt; column. Falls back to &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt; when there&amp;#039;s no &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; or the plugin lookup fails&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Relations ===&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=Device|section=Relations|name=facility|type=FK → Facility|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;; owning facility (required). Set server-side from the URL (&amp;lt;code&amp;gt;facility_external_id&amp;lt;/code&amp;gt;), never from the request body}}&lt;br /&gt;
{{Field|model=Device|section=Relations|name=managing_organization|type=FK → FacilityOrganization|notes=&amp;lt;code&amp;gt;SET_NULL&amp;lt;/code&amp;gt;, nullable; org responsible for the device. Excluded from the create/update body — managed via dedicated endpoints (see [[#api-integration-notes}}&lt;br /&gt;
{{Field|model=Device|section=Relations|name=current_location|type=FK → FacilityLocation|notes=&amp;lt;code&amp;gt;SET_NULL&amp;lt;/code&amp;gt;, nullable; where the device is currently placed. Excluded from the create/update body — managed via &amp;lt;code&amp;gt;associate_location&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Device|section=Relations|name=current_encounter|type=FK → Encounter|notes=&amp;lt;code&amp;gt;SET_NULL&amp;lt;/code&amp;gt;, nullable; encounter the device is currently attached to. Excluded from the create/update body — managed via &amp;lt;code&amp;gt;associate_encounter&amp;lt;/code&amp;gt;}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Access cache ===&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=Device|section=Access cache|name=facility_organization_cache|type=ArrayField[int]|notes=Denormalized cache of facility-organization IDs, rebuilt on every &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt;. Don&amp;#039;t set it directly. &amp;lt;code&amp;gt;get_queryset&amp;lt;/code&amp;gt; reads it to scope which devices a user may see}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceStatusChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field. Defined in &amp;lt;code&amp;gt;spec.py&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;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device is in service&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inactive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device is not currently in service&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;&lt;br /&gt;
| Record created in error&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceAvailabilityStatusChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;availability_status&amp;lt;/code&amp;gt; field. Defined in &amp;lt;code&amp;gt;spec.py&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;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lost&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device cannot be located&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;damaged&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device is damaged&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;destroyed&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device is destroyed&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;available&amp;lt;/code&amp;gt;&lt;br /&gt;
| Device is available for use&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ContactPoint&amp;lt;/code&amp;gt; shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;contact&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;list[ContactPoint]&amp;lt;/code&amp;gt;. Each item (from &amp;lt;code&amp;gt;care/emr/resources/common/contact_point.py&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;ContactPoint {&lt;br /&gt;
  system: ContactPointSystemChoices   # required&lt;br /&gt;
  value:  str                         # required&lt;br /&gt;
  use:    ContactPointUseChoices      # required&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;code&amp;gt;system&amp;lt;/code&amp;gt; values&lt;br /&gt;
! &amp;lt;code&amp;gt;use&amp;lt;/code&amp;gt; values&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;phone&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;fax&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pager&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sms&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;other&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;work&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;temp&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;old&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;mobile&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceEncounterHistory&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Audit trail of device-to-encounter associations. Attaching a device to an encounter creates a new row; detaching it stamps &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. Read-only via the API (&amp;lt;code&amp;gt;EMRModelReadOnlyViewSet&amp;lt;/code&amp;gt;), ordered by &amp;lt;code&amp;gt;-end&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;device    → FK Device (CASCADE)&lt;br /&gt;
encounter → FK Encounter (CASCADE)&lt;br /&gt;
start     → DateTimeField&lt;br /&gt;
end       → DateTimeField (nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceLocationHistory&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Audit trail of device placements. Moving a device to a location creates a new row; leaving it stamps &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. Read-only via the API, ordered by &amp;lt;code&amp;gt;-end&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;device   → FK Device (CASCADE)&lt;br /&gt;
location → FK FacilityLocation (CASCADE)&lt;br /&gt;
start    → DateTimeField&lt;br /&gt;
end      → DateTimeField (nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceServiceHistory&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Servicing/maintenance log for a device. Writable via the API (create + update + list + retrieve).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;device       → FK Device (PROTECT, required)&lt;br /&gt;
serviced_on  → DateTimeField (nullable, default None)&lt;br /&gt;
note         → TextField (default &amp;quot;&amp;quot;)&lt;br /&gt;
edit_history → JSONField (default [])&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;, so a &amp;lt;code&amp;gt;Device&amp;lt;/code&amp;gt; with service-history rows can&amp;#039;t be hard-deleted while those rows exist. &amp;lt;code&amp;gt;edit_history&amp;lt;/code&amp;gt; is an append-only audit list the server maintains on every update (see [[#deviceservicehistory-edit-history|Methods &amp;amp;amp; save behaviour]]).&lt;br /&gt;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
The viewset wires these specs as create = &amp;lt;code&amp;gt;DeviceCreateSpec&amp;lt;/code&amp;gt;, update = &amp;lt;code&amp;gt;DeviceUpdateSpec&amp;lt;/code&amp;gt;, list = &amp;lt;code&amp;gt;DeviceListSpec&amp;lt;/code&amp;gt;, retrieve = &amp;lt;code&amp;gt;DeviceRetrieveSpec&amp;lt;/code&amp;gt;. All extend &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;, with &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;
=== Device specs ===&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;
! Adds / overrides&lt;br /&gt;
! Excludes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceSpecBase&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, all device-data fields, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;availability_status&amp;lt;/code&amp;gt; enums, &amp;lt;code&amp;gt;contact: list[ContactPoint]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;registered_name&amp;lt;/code&amp;gt; required&lt;br /&gt;
| &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;current_location&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; (validated against &amp;lt;code&amp;gt;DeviceTypeRegistry&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;care_metadata: dict&amp;lt;/code&amp;gt;&lt;br /&gt;
| (inherits base excludes)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;care_metadata: dict&amp;lt;/code&amp;gt; — no &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt;, which makes &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; immutable after create&lt;br /&gt;
| (inherits base excludes)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; from plugin &amp;lt;code&amp;gt;list(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| (inherits)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| full nested objects: &amp;lt;code&amp;gt;current_location&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;EncounterListSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;FacilityOrganizationReadSpec&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; (audit users); &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; from plugin &amp;lt;code&amp;gt;retrieve(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| (inherits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Device history specs ===&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&lt;br /&gt;
! Excludes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceLocationHistoryListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt; (nested &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end?&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt; (raw FK)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceEncounterHistoryListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; (nested &amp;lt;code&amp;gt;EncounterListSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end?&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; (raw FK)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceServiceHistorySpecBase&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;edit_history&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceServiceHistoryWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write&lt;br /&gt;
| &amp;lt;code&amp;gt;serviced_on: datetime&amp;lt;/code&amp;gt; (required), &amp;lt;code&amp;gt;note: str&amp;lt;/code&amp;gt; (required)&lt;br /&gt;
| (inherits)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceServiceHistoryListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| adds &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt;&lt;br /&gt;
| (inherits)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DeviceServiceHistoryRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| adds &amp;lt;code&amp;gt;edit_history: list[dict]&amp;lt;/code&amp;gt; (each entry&amp;#039;s &amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt; hydrated to a &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt; from cache), &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;&lt;br /&gt;
| (inherits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Validation rules ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;availability_status&amp;lt;/code&amp;gt; must each match one of their enum values, or the request is rejected.&lt;br /&gt;
* &amp;lt;code&amp;gt;registered_name&amp;lt;/code&amp;gt; is required on every write.&lt;br /&gt;
* &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; (create only) must be a registered device-type key or &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;DeviceCreateSpec.validate_care_type&amp;lt;/code&amp;gt; calls &amp;lt;code&amp;gt;DeviceTypeRegistry.get_care_device_class(value)&amp;lt;/code&amp;gt;, which raises for unknown types.&lt;br /&gt;
* &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; can&amp;#039;t change on update — &amp;lt;code&amp;gt;DeviceUpdateSpec&amp;lt;/code&amp;gt; doesn&amp;#039;t expose it.&lt;br /&gt;
* &amp;lt;code&amp;gt;DeviceServiceHistory.serviced_on&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;note&amp;lt;/code&amp;gt; are required on write; updates are blocked once &amp;lt;code&amp;gt;edit_history&amp;lt;/code&amp;gt; reaches 50 entries (&amp;lt;code&amp;gt;&amp;amp;quot;Cannot Edit instance anymore&amp;amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;lt;code&amp;gt;ContactPoint.system&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;use&amp;lt;/code&amp;gt; are all required for each contact entry.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;Device.save()&amp;lt;/code&amp;gt; — organization cache ===&lt;br /&gt;
&lt;br /&gt;
Every save rebuilds &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
# Look up the &amp;lt;code&amp;gt;FacilityOrganization&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;org_type=&amp;amp;quot;root&amp;amp;quot;&amp;lt;/code&amp;gt; for the device&amp;#039;s &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;; its ID seeds the cache.&lt;br /&gt;
# If &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; is set, add its &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; and its &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt; (the full ancestor chain).&lt;br /&gt;
# Persist the resulting set as &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This lets the list endpoint filter by organization hierarchy without traversing joins. Treat the cache as platform-maintained; &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; are the writable inputs that drive it.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; plugin hooks ===&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;care_type&amp;lt;/code&amp;gt; is set, the matching &amp;lt;code&amp;gt;DeviceTypeBase&amp;lt;/code&amp;gt; subclass from &amp;lt;code&amp;gt;DeviceTypeRegistry&amp;lt;/code&amp;gt; runs inside the create/update/delete transaction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Stage&lt;br /&gt;
! Hook&lt;br /&gt;
! Effect&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| &amp;lt;code&amp;gt;handle_create(request_data, obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| May mutate &amp;lt;code&amp;gt;obj&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;obj.metadata&amp;lt;/code&amp;gt; and persist (e.g. the bundled &amp;lt;code&amp;gt;camera&amp;lt;/code&amp;gt; plugin stores &amp;lt;code&amp;gt;request_data[&amp;amp;quot;some_data&amp;amp;quot;]&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| &amp;lt;code&amp;gt;handle_update(request_data, obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same, on update&lt;br /&gt;
|-&lt;br /&gt;
| destroy&lt;br /&gt;
| &amp;lt;code&amp;gt;handle_delete(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Validation/cleanup before the device is soft-deleted (&amp;lt;code&amp;gt;deleted=True&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| list&lt;br /&gt;
| &amp;lt;code&amp;gt;list(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Supplies &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;DeviceListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| retrieve&lt;br /&gt;
| &amp;lt;code&amp;gt;retrieve(obj)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Supplies &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;DeviceRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;DeviceServiceHistory&amp;lt;/code&amp;gt; edit history ===&lt;br /&gt;
&lt;br /&gt;
On &amp;lt;code&amp;gt;perform_update&amp;lt;/code&amp;gt;, the viewset snapshots the current DB row and appends &amp;lt;code&amp;gt;{serviced_on, note, updated_by}&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;edit_history&amp;lt;/code&amp;gt; before writing the new values — a server-maintained, append-only trail of previous states. Updates are refused once it holds 50 entries.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; comes from the URL (&amp;lt;code&amp;gt;facility_external_id&amp;lt;/code&amp;gt;) on create, not from the body.&lt;br /&gt;
* &amp;lt;code&amp;gt;current_location&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; aren&amp;#039;t writable through the device create/update body. Dedicated detail actions mutate them, and each one closes the open history row (stamps &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;) before opening a new one:&lt;br /&gt;
** &amp;lt;code&amp;gt;POST associate_encounter&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;{ encounter: uuid | null }&amp;lt;/code&amp;gt;; closes the open &amp;lt;code&amp;gt;DeviceEncounterHistory&amp;lt;/code&amp;gt;, sets &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt;, and opens (and returns) a new history row. &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; detaches.&lt;br /&gt;
** &amp;lt;code&amp;gt;POST associate_location&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;{ location: uuid | null }&amp;lt;/code&amp;gt;; same pattern against &amp;lt;code&amp;gt;DeviceLocationHistory&amp;lt;/code&amp;gt;.&lt;br /&gt;
** &amp;lt;code&amp;gt;POST add_managing_organization&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;{ managing_organization: uuid }&amp;lt;/code&amp;gt;.&lt;br /&gt;
** &amp;lt;code&amp;gt;POST remove_managing_organization&amp;lt;/code&amp;gt; — clears &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt;.&lt;br /&gt;
* When an encounter reaches a completed status, &amp;lt;code&amp;gt;disassociate_device_from_encounter&amp;lt;/code&amp;gt; clears &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt; on all attached devices and stamps &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; on their open &amp;lt;code&amp;gt;DeviceEncounterHistory&amp;lt;/code&amp;gt; rows.&lt;br /&gt;
* &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt; (the model column) is plugin-owned; clients read deployment-specific data back through the &amp;lt;code&amp;gt;care_metadata&amp;lt;/code&amp;gt; virtual field, not &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt; is platform-maintained — don&amp;#039;t set it directly. The list endpoint scopes results to devices whose cache overlaps the requesting user&amp;#039;s facility-organization memberships, or, when &amp;lt;code&amp;gt;?location=&amp;lt;/code&amp;gt; is supplied, by location permission / &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;?include_children=&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>