<?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%2FLocation</id>
	<title>References/Location - 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%2FLocation"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Location&amp;action=history"/>
	<updated>2026-07-06T05:18:45Z</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/Location&amp;diff=419&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/Location&amp;diff=419&amp;oldid=prev"/>
		<updated>2026-07-06T04:05:00Z</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 395:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 395:&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;parent&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt; are settable only at creation (&amp;lt;code&amp;gt;FacilityLocationWriteSpec&amp;lt;/code&amp;gt;). Updates go through &amp;lt;code&amp;gt;FacilityLocationUpdateSpec&amp;lt;/code&amp;gt;, which omits all three.&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;parent&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt; are settable only at creation (&amp;lt;code&amp;gt;FacilityLocationWriteSpec&amp;lt;/code&amp;gt;). Updates go through &amp;lt;code&amp;gt;FacilityLocationUpdateSpec&amp;lt;/code&amp;gt;, which omits all three.&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;* For fields you can&#039;t write, see [[#server-maintained-behaviour|Server-maintained behaviour]].&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;* For fields you can&#039;t write, see [[#server-maintained-behaviour|Server-maintained behaviour]].&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/Location&amp;diff=161&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/Location&amp;diff=161&amp;oldid=prev"/>
		<updated>2026-07-04T22:45:10Z</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=Location&lt;br /&gt;
|order=5&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=Location&lt;br /&gt;
|reference=References/Base models &amp;amp;amp; conventions&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt; is a node in a facility&amp;#039;s building/ward/room/bed tree — where resources sit and where care happens. You work with it when you place an encounter somewhere, scope organization access to part of a facility, or model a site&amp;#039;s physical layout.&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/location.py &amp;lt;code&amp;gt;care/emr/models/location.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/location/spec.py &amp;lt;code&amp;gt;care/emr/resources/location/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Base resource: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/base.py &amp;lt;code&amp;gt;care/emr/resources/base.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Coding type: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/common/coding.py &amp;lt;code&amp;gt;care/emr/resources/common/coding.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Nodes nest without limit: every node may have a parent and children, so one tree can run from a campus down to a single bed. Encounters and organizations attach to nodes, and access granted at a node cascades to its descendants asynchronously rather than resolving on each request. The model maps to the [&amp;lt;nowiki/&amp;gt;https://build.fhir.org/location.html FHIR Location] resource.&lt;br /&gt;
&lt;br /&gt;
The Django model is only the storage layer. &amp;lt;code&amp;gt;location_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;cached_parent_json&amp;lt;/code&amp;gt; are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s; their real shape lives in the Pydantic resource specs (&amp;lt;code&amp;gt;care/emr/resources/location/spec.py&amp;lt;/code&amp;gt;), which also define every enum and the read/write schema split. See [[#resource-specs-api-schema|Resource specs (API schema)]].&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;FacilityLocation&amp;lt;/code&amp;gt;&lt;br /&gt;
| A node in a facility&amp;#039;s location tree (building, ward, room, bed, …)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationOrganization&amp;lt;/code&amp;gt;&lt;br /&gt;
| Grants a &amp;lt;code&amp;gt;FacilityOrganization&amp;lt;/code&amp;gt; access to a location&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounter&amp;lt;/code&amp;gt;&lt;br /&gt;
| Records how/when an encounter occupied a location (e.g. a bed)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All three extend [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]], which supplies &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;FacilityLocation&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Descriptive ===&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 values / shape&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=name|type=CharField(255)|notes=&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt;, required}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=description|type=CharField(255)|notes=&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt;, required}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=status|type=CharField(255)|notes=&amp;lt;code&amp;gt;StatusChoices&amp;lt;/code&amp;gt; enum}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=operational_status|type=CharField(255)|notes=&amp;lt;code&amp;gt;FacilityLocationOperationalStatusChoices&amp;lt;/code&amp;gt; enum}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=system_availability_status|type=CharField(255)|notes=&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; (read-only)}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=mode|type=CharField(255)|notes=&amp;lt;code&amp;gt;FacilityLocationModeChoices&amp;lt;/code&amp;gt; enum}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=location_type|type=JSONField (default=dict, nullable)|notes=&amp;lt;code&amp;gt;Coding | None&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
{{Field|model=Location|section=Descriptive|name=form|type=CharField(255)|notes=&amp;lt;code&amp;gt;FacilityLocationFormChoices&amp;lt;/code&amp;gt; enum}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Hierarchy &amp;amp;amp; tree caches ===&lt;br /&gt;
&lt;br /&gt;
These fields denormalize the tree so descendants are queryable without recursive joins. &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt; and the cascade task own them; never set them from a client.&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=Location|section=Hierarchy &amp;amp;amp; tree caches|name=parent|type=FK → FacilityLocation|notes=&amp;lt;code&amp;gt;SET_NULL&amp;lt;/code&amp;gt;, nullable. Immediate parent. Accepted on write as a UUID (&amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt;); on read it&amp;#039;s dropped in favour of the serialized parent JSON}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=root_location|type=FK → self|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;related_name=&amp;amp;quot;root&amp;amp;quot;&amp;lt;/code&amp;gt;, nullable. Top of this node&amp;#039;s tree. Excluded from specs}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=has_children|type=BooleanField|notes=&amp;lt;code&amp;gt;default=False&amp;lt;/code&amp;gt;. Set &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; on the parent when a child is created. Read-only in list/retrieve specs}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=level_cache|type=IntegerField|notes=&amp;lt;code&amp;gt;default=0&amp;lt;/code&amp;gt;. Depth in the tree (&amp;lt;code&amp;gt;parent.level_cache + 1&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=parent_cache|type=ArrayField[int]|notes=Ordered ancestor IDs (&amp;lt;code&amp;gt;parent.parent_cache + [parent.id]&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=cached_parent_json|type=JSONField (default=dict)|notes=Serialized parent chain (&amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;) plus a &amp;lt;code&amp;gt;cache_expiry&amp;lt;/code&amp;gt; ISO timestamp. Rebuilt lazily by &amp;lt;code&amp;gt;get_parent_json()&amp;lt;/code&amp;gt;, invalidated by the cascade task. &amp;lt;code&amp;gt;cache_expiry_days = 15&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Location|section=Hierarchy &amp;amp;amp; tree caches|name=sort_index|type=IntegerField|notes=&amp;lt;code&amp;gt;default=0&amp;lt;/code&amp;gt;. In specs &amp;lt;code&amp;gt;int | None&amp;lt;/code&amp;gt;, default &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, constrained &amp;lt;code&amp;gt;0 ≤ sort_index ≤ 10000&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;MIN_SORT_INDEX&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;MAX_SORT_INDEX&amp;lt;/code&amp;gt;). Auto-assigned as &amp;lt;code&amp;gt;max(sibling sort_index) + 1&amp;lt;/code&amp;gt; when left unset}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Access &amp;amp;amp; encounter ===&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=Location|section=Access &amp;amp;amp; encounter|name=facility|type=FK → facility.Facility|notes=&amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;. Owning facility. Excluded from specs — resolved from route/context}}&lt;br /&gt;
{{Field|model=Location|section=Access &amp;amp;amp; encounter|name=facility_organization_cache|type=ArrayField[int]|notes=&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;. Org IDs that can reach this location; rebuilt by &amp;lt;code&amp;gt;sync_organization_cache()&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Location|section=Access &amp;amp;amp; encounter|name=current_encounter|type=FK → Encounter|notes=&amp;lt;code&amp;gt;SET_NULL&amp;lt;/code&amp;gt;, nullable, &amp;lt;code&amp;gt;default=None&amp;lt;/code&amp;gt;. Populated from &amp;lt;code&amp;gt;FacilityLocationEncounter&amp;lt;/code&amp;gt;. Excluded from the base spec; surfaced as serialized JSON in list/retrieve specs}}&lt;br /&gt;
{{Field|model=Location|section=Access &amp;amp;amp; encounter|name=metadata|type=JSONField|notes=&amp;lt;code&amp;gt;default=dict&amp;lt;/code&amp;gt;. Open extension bag for deployment-specific data}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
Every enum is a &amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;Enum&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;care/emr/resources/location/spec.py&amp;lt;/code&amp;gt;. Values below are character-for-character from source.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;StatusChoices&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;active&amp;lt;/code&amp;gt;&lt;br /&gt;
| Location is active&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inactive&amp;lt;/code&amp;gt;&lt;br /&gt;
| Location is inactive&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;&lt;br /&gt;
| Status unknown&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FacilityLocationOperationalStatusChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
FHIR HL7 v2 bed/location operational status codes.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;&lt;br /&gt;
| Closed&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;H&amp;lt;/code&amp;gt;&lt;br /&gt;
| Housekeeping&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;O&amp;lt;/code&amp;gt;&lt;br /&gt;
| Occupied&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;&lt;br /&gt;
| Unoccupied&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;&lt;br /&gt;
| Contaminated&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;&lt;br /&gt;
| Isolated&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FacilityLocationModeChoices&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;instance&amp;lt;/code&amp;gt;&lt;br /&gt;
| A single, concrete location (e.g. Bed 1). Instances cannot have children&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt;&lt;br /&gt;
| A class/type of location (e.g. a ward or building)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FacilityLocationFormChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
FHIR &amp;lt;code&amp;gt;location-physical-type&amp;lt;/code&amp;gt; codes.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Code&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;si&amp;lt;/code&amp;gt;&lt;br /&gt;
| Site&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bu&amp;lt;/code&amp;gt;&lt;br /&gt;
| Building&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;wi&amp;lt;/code&amp;gt;&lt;br /&gt;
| Wing&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;wa&amp;lt;/code&amp;gt;&lt;br /&gt;
| Ward&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lvl&amp;lt;/code&amp;gt;&lt;br /&gt;
| Level&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;co&amp;lt;/code&amp;gt;&lt;br /&gt;
| Corridor&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ro&amp;lt;/code&amp;gt;&lt;br /&gt;
| Room&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bd&amp;lt;/code&amp;gt;&lt;br /&gt;
| Bed&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ve&amp;lt;/code&amp;gt;&lt;br /&gt;
| Vehicle&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ho&amp;lt;/code&amp;gt;&lt;br /&gt;
| House&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ca&amp;lt;/code&amp;gt;&lt;br /&gt;
| Cabinet&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rd&amp;lt;/code&amp;gt;&lt;br /&gt;
| Road&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;area&amp;lt;/code&amp;gt;&lt;br /&gt;
| Area&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;jdn&amp;lt;/code&amp;gt;&lt;br /&gt;
| Jurisdiction&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;vi&amp;lt;/code&amp;gt;&lt;br /&gt;
| Virtual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;LocationEncounterAvailabilityStatusChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
Used by &amp;lt;code&amp;gt;FacilityLocationEncounter.status&amp;lt;/code&amp;gt; — how an encounter occupies a location.&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;planned&amp;lt;/code&amp;gt;&lt;br /&gt;
| Occupancy planned&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
| Currently occupied&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;reserved&amp;lt;/code&amp;gt;&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;completed&amp;lt;/code&amp;gt;&lt;br /&gt;
| Occupancy ended&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;LocationAvailabilityStatusChoices&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
The server-derived values that &amp;lt;code&amp;gt;system_availability_status&amp;lt;/code&amp;gt; resolves to.&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;available&amp;lt;/code&amp;gt;&lt;br /&gt;
| Not actively tied to an encounter&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;reserved&amp;lt;/code&amp;gt;&lt;br /&gt;
| Tied to an encounter&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;location_type&amp;lt;/code&amp;gt; is a single &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object (&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;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;Coding {&lt;br /&gt;
  system:  str | None = None&lt;br /&gt;
  version: str | None = None&lt;br /&gt;
  code:    str            # required&lt;br /&gt;
  display: str | None = None&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FacilityLocationOrganization&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Links an organization to a location. Users under that organization inherit access to the location and its encounters through whatever role they hold on the organization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;location     → FK FacilityLocation (CASCADE)&lt;br /&gt;
organization → FK FacilityOrganization (CASCADE)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Saving one of these rows calls &amp;lt;code&amp;gt;location.save()&amp;lt;/code&amp;gt; (rebuilding &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt;), then &amp;lt;code&amp;gt;location.cascade_changes()&amp;lt;/code&amp;gt; to propagate the grant down to descendants asynchronously. On write, the organization set comes from &amp;lt;code&amp;gt;FacilityLocationWriteSpec.organizations&amp;lt;/code&amp;gt;, a list of UUIDs.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FacilityLocationEncounter&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
A bed assignment, in effect: it records how an encounter occupied a location over a time window.&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&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=Location|section=FacilityLocationEncounter|name=status|type=CharField(25)|notes=&amp;lt;code&amp;gt;LocationEncounterAvailabilityStatusChoices&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=Location|section=FacilityLocationEncounter|name=location|type=FK → FacilityLocation|notes=excluded / nested}}&lt;br /&gt;
{{Field|model=Location|section=FacilityLocationEncounter|name=encounter|type=FK → Encounter|notes=UUID on write, JSON on read}}&lt;br /&gt;
{{Field|model=Location|section=FacilityLocationEncounter|name=start_datetime|type=DateTimeField|notes=&amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; (required)}}&lt;br /&gt;
{{Field|model=Location|section=FacilityLocationEncounter|name=end_datetime|type=DateTimeField (nullable)|notes=&amp;lt;code&amp;gt;datetime | None&amp;lt;/code&amp;gt;}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FacilityLocation.current_encounter&amp;lt;/code&amp;gt; is populated from these rows.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt; side effects ===&lt;br /&gt;
&lt;br /&gt;
On insert (no &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; yet):&lt;br /&gt;
&lt;br /&gt;
# If &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt; is set, &amp;lt;code&amp;gt;level_cache&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;root_location&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt; are derived from the parent, and the parent&amp;#039;s &amp;lt;code&amp;gt;has_children&amp;lt;/code&amp;gt; is flipped to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if needed.&lt;br /&gt;
# If &amp;lt;code&amp;gt;sort_index&amp;lt;/code&amp;gt; is unset, it&amp;#039;s assigned &amp;lt;code&amp;gt;max(sibling sort_index) + 1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
On update, &amp;lt;code&amp;gt;cached_parent_json&amp;lt;/code&amp;gt; is cleared so it rebuilds lazily. After every &amp;lt;code&amp;gt;super().save()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sync_organization_cache()&amp;lt;/code&amp;gt; runs and persists &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt; through a second &amp;lt;code&amp;gt;save(update_fields=[...])&amp;lt;/code&amp;gt;, so each write touches the row twice.&lt;br /&gt;
&lt;br /&gt;
=== Caches &amp;amp;amp; cascade ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;sync_organization_cache()&amp;lt;/code&amp;gt; — unions the parent&amp;#039;s org cache, the org chains of every linked &amp;lt;code&amp;gt;FacilityLocationOrganization&amp;lt;/code&amp;gt;, and the facility&amp;#039;s &amp;lt;code&amp;gt;default_internal_organization_id&amp;lt;/code&amp;gt;, then writes &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;get_parent_json()&amp;lt;/code&amp;gt; — returns the cached parent chain, refreshing &amp;lt;code&amp;gt;cached_parent_json&amp;lt;/code&amp;gt; (via &amp;lt;code&amp;gt;FacilityLocationListSpec.serialize(parent)&amp;lt;/code&amp;gt;) once it expires (&amp;lt;code&amp;gt;cache_expiry_days = 15&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;lt;code&amp;gt;cascade_changes()&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;handle_cascade(base_location)&amp;lt;/code&amp;gt; — a Celery task that walks every descendant and re-saves it to invalidate each node&amp;#039;s &amp;lt;code&amp;gt;cached_parent_json&amp;lt;/code&amp;gt;. It fires when a location&amp;#039;s organizations change, so propagation is eventually consistent, not immediate.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;validate_uniqueness()&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Classmethod that enforces &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; uniqueness among siblings at the same &amp;lt;code&amp;gt;level_cache&amp;lt;/code&amp;gt; within the same &amp;lt;code&amp;gt;root_location&amp;lt;/code&amp;gt; — or among root-level locations when there&amp;#039;s no root. For a new instance with a &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;level_cache&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;root_location&amp;lt;/code&amp;gt; are computed from that parent before the check runs.&lt;br /&gt;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
The Pydantic specs in &amp;lt;code&amp;gt;care/emr/resources/location/spec.py&amp;lt;/code&amp;gt; define the request/response shapes. All extend &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt;, which provides &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; plus the &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; hooks (see [[References/Base models &amp;amp;amp; conventions|base model]] and [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/base.py &amp;lt;code&amp;gt;base.py&amp;lt;/code&amp;gt;]).&lt;br /&gt;
&lt;br /&gt;
=== Location 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;
! Exposes / notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = FacilityLocation&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;id: UUID4 | None&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__exclude__ = [parent, facility, organizations, root_location, current_encounter]&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared fields&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;operational_status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;location_type&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;Coding | None&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;form&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sort_index&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;0..10000&amp;lt;/code&amp;gt;, default &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;parent: UUID4 | None&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;organizations: list[UUID4]&amp;lt;/code&amp;gt; (required), &amp;lt;code&amp;gt;mode: FacilityLocationModeChoices&amp;lt;/code&amp;gt;. Validator: a set &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt; must exist and must not be &amp;lt;code&amp;gt;mode = instance&amp;lt;/code&amp;gt; (&amp;amp;quot;Instances cannot have children&amp;amp;quot;). &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt; UUID to an FK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| Same fields as &amp;lt;code&amp;gt;FacilityLocationSpec&amp;lt;/code&amp;gt;. Drops &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;organizations&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt; — hierarchy and mode are fixed after creation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationMinimalListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · minimal&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;parent: dict&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;mode: str&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_children: bool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;system_availability_status: str&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;parent = obj.get_parent_json()&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Extends minimal; adds &amp;lt;code&amp;gt;current_encounter: dict | None&amp;lt;/code&amp;gt;, serialized via &amp;lt;code&amp;gt;EncounterListSpec&amp;lt;/code&amp;gt; when present&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Extends list; adds &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt; (via &amp;lt;code&amp;gt;serialize_audit_users&amp;lt;/code&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Encounter-association 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;
! Exposes / notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = FacilityLocationEncounter&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;id: UUID4 | None&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__exclude__ = [encounter, location]&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;LocationEncounterAvailabilityStatusChoices&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;encounter: UUID4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;start_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end_datetime: datetime | None&amp;lt;/code&amp;gt;. Validator: encounter must exist. &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; UUID to an FK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;start_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end_datetime&amp;lt;/code&amp;gt;. Encounter is not re-assignable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;encounter: UUID4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;start_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status: str&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;id = external_id&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterListSpecWithLocation&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Extends list; adds &amp;lt;code&amp;gt;location: dict&amp;lt;/code&amp;gt; (serialized via &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FacilityLocationEncounterReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| &amp;lt;code&amp;gt;encounter: dict&amp;lt;/code&amp;gt; (serialized via &amp;lt;code&amp;gt;EncounterRetrieveSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;start_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end_datetime&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&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;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Server-maintained behaviour ===&lt;br /&gt;
&lt;br /&gt;
* These are platform-maintained — don&amp;#039;t write them from a client: &amp;lt;code&amp;gt;system_availability_status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_children&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;level_cache&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;parent_cache&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cached_parent_json&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility_organization_cache&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;current_encounter&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;sort_index&amp;lt;/code&amp;gt; (when left unset).&lt;br /&gt;
* On read, &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt; comes back as the serialized parent chain (&amp;lt;code&amp;gt;get_parent_json()&amp;lt;/code&amp;gt;), never the raw FK.&lt;br /&gt;
* Access granted through &amp;lt;code&amp;gt;organizations&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;FacilityLocationOrganization&amp;lt;/code&amp;gt; lands asynchronously; the org cache and descendant caches settle only after the cascade task runs.&lt;br /&gt;
* &amp;lt;code&amp;gt;location_type&amp;lt;/code&amp;gt; takes a free &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; (no value-set slug) and &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt; is an open bag, so both add coded or extension data without a schema migration.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* The API is modelled on the FHIR &amp;lt;code&amp;gt;Location&amp;lt;/code&amp;gt; resource, so payload field names may differ from these Django names.&lt;br /&gt;
* &amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt; separates &amp;lt;code&amp;gt;kind&amp;lt;/code&amp;gt; (a location type) from &amp;lt;code&amp;gt;instance&amp;lt;/code&amp;gt; (a concrete location such as a bed). Beds are &amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt; instances, not a separate model, and &amp;lt;code&amp;gt;instance&amp;lt;/code&amp;gt; locations cannot have children.&lt;br /&gt;
* &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt; are settable only at creation (&amp;lt;code&amp;gt;FacilityLocationWriteSpec&amp;lt;/code&amp;gt;). Updates go through &amp;lt;code&amp;gt;FacilityLocationUpdateSpec&amp;lt;/code&amp;gt;, which omits all three.&lt;br /&gt;
* For fields you can&amp;#039;t write, see [[#server-maintained-behaviour|Server-maintained behaviour]].&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>