<?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%2FHealthcare_Service</id>
	<title>References/Healthcare Service - 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%2FHealthcare_Service"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Healthcare_Service&amp;action=history"/>
	<updated>2026-07-06T05:19:49Z</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/Healthcare_Service&amp;diff=421&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/Healthcare_Service&amp;diff=421&amp;oldid=prev"/>
		<updated>2026-07-06T04:05:26Z</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 250:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 250:&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;* On write, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; are &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;s (UUIDs); detail responses embed the full objects. Nothing at the DB level confirms the referenced locations belong to the same &amp;lt;code&amp;gt;facility&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;* On write, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; are &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;s (UUIDs); detail responses embed the full objects. Nothing at the DB level confirms the referenced locations belong to the same &amp;lt;code&amp;gt;facility&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&amp;lt;/code&amp;gt; is never accepted in the request body — it&#039;s set from the URL context.&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&amp;lt;/code&amp;gt; is never accepted in the request body — it&#039;s set from the URL context.&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/Healthcare_Service&amp;diff=160&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/Healthcare_Service&amp;diff=160&amp;oldid=prev"/>
		<updated>2026-07-04T22:45:07Z</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=Healthcare Service&lt;br /&gt;
|order=6&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=HealthcareService&lt;br /&gt;
|reference=References/Base models &amp;amp;amp; conventions&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;HealthcareService&amp;lt;/code&amp;gt; is a service a facility offers — cardiology, lab, radiology, pharmacy — scoped to one or more locations and to the facility organization that manages it. You touch it when modeling what a facility provides and where.&lt;br /&gt;
&lt;br /&gt;
The Django model is thin storage: &amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;styling_metadata&amp;lt;/code&amp;gt; are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s. Their real structure lives in the Pydantic resource specs, which also define the bound value set, the &amp;lt;code&amp;gt;internal_type&amp;lt;/code&amp;gt; enum, and the separate read and write API schemas.&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/healthcare_service.py &amp;lt;code&amp;gt;care/emr/models/healthcare_service.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/healthcare_service/spec.py &amp;lt;code&amp;gt;care/emr/resources/healthcare_service/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Value set: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/healthcare_service/valueset.py &amp;lt;code&amp;gt;care/emr/resources/healthcare_service/valueset.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;HealthcareService&amp;lt;/code&amp;gt;&lt;br /&gt;
| A service a facility offers (e.g. cardiology, lab, radiology), scoped to locations and a managing organization&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;HealthcareService&amp;lt;/code&amp;gt; extends [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]], the shared Care EMR base that provides &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, audit fields, soft-delete via &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;history&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt; JSON.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;HealthcareService&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Identity &amp;amp;amp; classification ===&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=HealthcareService|section=Identity &amp;amp;amp; classification|name=name|type=CharField(1024)|notes=Display name. Required on write; no default}}&lt;br /&gt;
{{Field|model=HealthcareService|section=Identity &amp;amp;amp; classification|name=service_type|type=JSONField → Coding|notes=Holds one FHIR-style &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object, not a string. Defaults to &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt;. In the API it is a &amp;lt;code&amp;gt;ValueSetBoundCoding&amp;lt;/code&amp;gt; bound to the &amp;#039;&amp;#039;&amp;#039;Healthcare Service Type Code&amp;#039;&amp;#039;&amp;#039; value set (below). Optional (&amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;)}}&lt;br /&gt;
{{Field|model=HealthcareService|section=Identity &amp;amp;amp; classification|name=internal_type|type=CharField(255)|notes=Nullable, default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;. The API constrains it to the &amp;lt;code&amp;gt;HealthcareServiceInternalType&amp;lt;/code&amp;gt; enum (&amp;lt;code&amp;gt;pharmacy&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;lab&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scheduling&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;store&amp;lt;/code&amp;gt;); the column does not}}&lt;br /&gt;
{{Field|model=HealthcareService|section=Identity &amp;amp;amp; classification|name=extra_details|type=TextField|notes=Free text. Not nullable and no DB default, so write specs require a value — an empty string counts}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scope &amp;amp;amp; placement ===&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=HealthcareService|section=Scope &amp;amp;amp; placement|name=facility|type=FK → facility.Facility|notes=&amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;; nullable (&amp;lt;code&amp;gt;default=None&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;blank=True&amp;lt;/code&amp;gt;). Excluded from every spec (&amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt;) and set server-side from the URL context — never from the request body}}&lt;br /&gt;
{{Field|model=HealthcareService|section=Scope &amp;amp;amp; placement|name=locations|type=ArrayField[int]|notes=Defaults to &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;. Holds &amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt; &amp;#039;&amp;#039;&amp;#039;primary-key integers&amp;#039;&amp;#039;&amp;#039;, not FK rows. Write specs take location &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;s (UUIDs); retrieve specs return serialized location objects}}&lt;br /&gt;
{{Field|model=HealthcareService|section=Scope &amp;amp;amp; placement|name=managing_organization|type=FK → emr.FacilityOrganization|notes=&amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;; nullable. The facility-scoped org (department/team) responsible for the service. Write specs take its &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; (UUID), resolved server-side}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Presentation ===&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=HealthcareService|section=Presentation|name=styling_metadata|type=JSONField → dict|notes=Nullable in the DB; defaults to &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt; in the specs. An open JSON bag of UI hints (colors, icons) with no backend semantics}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Coded field shapes (JSON fields) ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt; stores a single &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object. In the API it is a &amp;lt;code&amp;gt;ValueSetBoundCoding&amp;lt;/code&amp;gt; whose &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; is checked against the &amp;#039;&amp;#039;&amp;#039;Healthcare Service Type Code&amp;#039;&amp;#039;&amp;#039; value set during de-serialization. Optional (&amp;lt;code&amp;gt;None&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        # e.g. &amp;quot;http://terminology.hl7.org/CodeSystem/service-type&amp;quot;&lt;br /&gt;
  version: str | None&lt;br /&gt;
  code:    str               # required; validated against the bound value set&lt;br /&gt;
  display: str | None&lt;br /&gt;
}&lt;br /&gt;
# extra=&amp;quot;forbid&amp;quot; — unknown keys rejected&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Bound value set — Healthcare Service Type Code ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Property&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| Name&lt;br /&gt;
| &amp;lt;code&amp;gt;Healthcare Service Type Code&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Slug&lt;br /&gt;
| &amp;lt;code&amp;gt;healthcare-service-type-code&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Status&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Compose / include system&lt;br /&gt;
| &amp;lt;code&amp;gt;http://terminology.hl7.org/CodeSystem/service-type&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| System version&lt;br /&gt;
| &amp;lt;code&amp;gt;2.0.0&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Registered via &amp;lt;code&amp;gt;register_valueset(...)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;register_as_system()&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;service_type.code&amp;lt;/code&amp;gt; on create or update must resolve within this value set.&lt;br /&gt;
&lt;br /&gt;
== Enums ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;HealthcareServiceInternalType&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
Constrains &amp;lt;code&amp;gt;internal_type&amp;lt;/code&amp;gt; in the specs (&amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; enum). The model column is a plain &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt;, so legacy or other values may already exist in storage.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pharmacy&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lab&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scheduling&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;store&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;facility.Facility&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility → FK Facility (PROTECT, nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The facility offering the service. &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt; blocks deleting a facility that still has healthcare services. Excluded from specs and set from the request context. See [[References/Facility]].&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;emr.FacilityOrganization&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;managing_organization → FK FacilityOrganization (PROTECT, nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The facility-scoped organization (department/team) that owns the service. Write specs take its &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; (UUID); the retrieve spec embeds it, serialized via &amp;lt;code&amp;gt;FacilityOrganizationReadSpec&amp;lt;/code&amp;gt;. See [[References/Organization]].&lt;br /&gt;
&lt;br /&gt;
=== Locations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; is an &amp;lt;code&amp;gt;ArrayField&amp;lt;/code&amp;gt; of integer PKs, not a relational join — each entry references a &amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt; row by primary key, with resolution and validation handled in application code rather than by a database foreign key. Write specs take location &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;s (UUIDs); the retrieve spec embeds each location, serialized via &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;. See [[References/Location]].&lt;br /&gt;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
Every spec extends &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/base.py&amp;lt;/code&amp;gt;), which provides &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; (DB object → spec) and &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; (spec → DB object), 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. &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 every payload.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec class&lt;br /&gt;
! Role&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;BaseHealthcareServiceSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| Fields: &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;internal_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;styling_metadata&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;extra_details&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__model__ = HealthcareService&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;facility&amp;amp;quot;]&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HealthcareServiceWriteSpec&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;locations: list[UUID4]&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;managing_organization: UUID4 | None&amp;lt;/code&amp;gt;. Resolves &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; from its &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HealthcareServiceReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Base fields. &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; sets &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;obj.external_id&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;HealthcareServiceRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Extends &amp;lt;code&amp;gt;ReadSpec&amp;lt;/code&amp;gt;; overrides &amp;lt;code&amp;gt;locations: list[dict]&amp;lt;/code&amp;gt; (each location serialized via &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;managing_organization: dict | None&amp;lt;/code&amp;gt; (serialized via &amp;lt;code&amp;gt;FacilityOrganizationReadSpec&amp;lt;/code&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Field exposure by spec ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Base&lt;br /&gt;
! Write&lt;br /&gt;
! Read (list)&lt;br /&gt;
! Retrieve (detail)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; (UUID4)&lt;br /&gt;
| ✓ (read-only)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓ (= &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;)&lt;br /&gt;
| ✓ (= &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; (str, required)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt; (bound &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt;, optional)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;internal_type&amp;lt;/code&amp;gt; (enum, optional)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;styling_metadata&amp;lt;/code&amp;gt; (dict, default &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt;)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;extra_details&amp;lt;/code&amp;gt; (str, required)&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
| ✓&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;&lt;br /&gt;
| —&lt;br /&gt;
| &amp;lt;code&amp;gt;list[UUID4]&amp;lt;/code&amp;gt; (write)&lt;br /&gt;
| —&lt;br /&gt;
| &amp;lt;code&amp;gt;list[dict]&amp;lt;/code&amp;gt; (embedded)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt;&lt;br /&gt;
| —&lt;br /&gt;
| &amp;lt;code&amp;gt;UUID4 | None&amp;lt;/code&amp;gt; (write)&lt;br /&gt;
| —&lt;br /&gt;
| &amp;lt;code&amp;gt;dict | None&amp;lt;/code&amp;gt; (embedded)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Validation &amp;amp;amp; server-side behaviour ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; — a &amp;lt;code&amp;gt;ValueSetBoundCoding&amp;lt;/code&amp;gt;. De-serialization runs &amp;lt;code&amp;gt;validate_valueset&amp;lt;/code&amp;gt; on &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; against the &amp;lt;code&amp;gt;healthcare-service-type-code&amp;lt;/code&amp;gt; value set, and &amp;lt;code&amp;gt;extra=&amp;amp;quot;forbid&amp;amp;quot;&amp;lt;/code&amp;gt; on the underlying &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; rejects unknown keys.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (write) — &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the UUID via &amp;lt;code&amp;gt;get_object_or_404(FacilityOrganization, external_id=...)&amp;lt;/code&amp;gt; and assigns the FK; a falsy value sets &amp;lt;code&amp;gt;managing_organization = None&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (write) — submitted as UUIDs. The retrieve spec resolves each PK back to a &amp;lt;code&amp;gt;FacilityLocation&amp;lt;/code&amp;gt; and serializes it, silently skipping any that fail to load (&amp;lt;code&amp;gt;try/except … pass&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; — never written from the body. &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; skips both; &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; populate &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;obj.external_id&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; — excluded from all specs and assigned server-side, so it can&amp;#039;t be set or changed through the API body.&lt;br /&gt;
* No &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field, and therefore no server-maintained &amp;lt;code&amp;gt;status_history&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
* Inherits &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt;, soft-delete (&amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;), audit fields (&amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&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;, and &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; from [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]].&lt;br /&gt;
* &amp;lt;code&amp;gt;EMRResource.serialize&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; drive read/write conversion; the extra (de)serialization hooks above handle FK resolution and embedded serialization.&lt;br /&gt;
* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; use &amp;lt;code&amp;gt;on_delete=PROTECT&amp;lt;/code&amp;gt;, so deleting either while a service references it is blocked at the DB level.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
The API surface is built from the spec classes, not the raw model. Three things commonly trip up integrators:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;service_type&amp;lt;/code&amp;gt; takes a &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; object whose &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; is in the bound value set, not a bare string.&lt;br /&gt;
* On write, &amp;lt;code&amp;gt;locations&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;managing_organization&amp;lt;/code&amp;gt; are &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;s (UUIDs); detail responses embed the full objects. Nothing at the DB level confirms the referenced locations belong to the same &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; is never accepted in the request body — it&amp;#039;s set from the URL context.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>