<?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%2FToken</id>
	<title>References/Token - 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%2FToken"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Token&amp;action=history"/>
	<updated>2026-07-06T05:20:06Z</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/Token&amp;diff=461&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/Token&amp;diff=461&amp;oldid=prev"/>
		<updated>2026-07-06T04:20:21Z</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:50, 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 314:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 314:&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;TokenCategory.metadata&amp;lt;/code&amp;gt; is an open JSON bag for deployment-specific config; &amp;lt;code&amp;gt;shorthand&amp;lt;/code&amp;gt; is capped at 5 characters by the spec.&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;TokenCategory.metadata&amp;lt;/code&amp;gt; is an open JSON bag for deployment-specific config; &amp;lt;code&amp;gt;shorthand&amp;lt;/code&amp;gt; is capped at 5 characters by the spec.&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;booking&amp;lt;/code&amp;gt; links a token back to a [[References/Booking|&amp;lt;code&amp;gt;TokenBooking&amp;lt;/code&amp;gt;]]; on retrieve it expands to the booking and its associated [[References/Encounter|encounter]].&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;booking&amp;lt;/code&amp;gt; links a token back to a [[References/Booking|&amp;lt;code&amp;gt;TokenBooking&amp;lt;/code&amp;gt;]]; on retrieve it expands to the booking and its associated [[References/Encounter|encounter]].&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 scheduling}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Token&amp;diff=176&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/Token&amp;diff=176&amp;oldid=prev"/>
		<updated>2026-07-04T22:45:43Z</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=scheduling&lt;br /&gt;
|title=Token&lt;br /&gt;
|order=3&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=Token&lt;br /&gt;
|concept=Concepts/Patient&lt;br /&gt;
|reference=References/Encounter&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;Token&amp;lt;/code&amp;gt; is a numbered ticket a patient holds in a walk-in queue — use it when scheduling runs on first-come flow rather than fixed appointment slots. The patient gets a number against a [[References/Schedule &amp;amp;amp; Availability|schedulable resource]] (practitioner, location, or healthcare service), optionally routed to a sub-queue or room.&lt;br /&gt;
&lt;br /&gt;
The Django models store the data; the rules that make a token correct — status enums, the resource binding, queue progression — live in the Pydantic resource specs and the API viewsets. Both layers are covered here.&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/scheduling/token.py &amp;lt;code&amp;gt;care/emr/models/scheduling/token.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Specs: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/scheduling/token/spec.py &amp;lt;code&amp;gt;token/spec.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/scheduling/token_category/spec.py &amp;lt;code&amp;gt;token_category/spec.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/scheduling/token_queue/spec.py &amp;lt;code&amp;gt;token_queue/spec.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/scheduling/token_sub_queue/spec.py &amp;lt;code&amp;gt;token_sub_queue/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Viewsets: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/scheduling/token.py &amp;lt;code&amp;gt;api/viewsets/scheduling/token.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/scheduling/token_queue.py &amp;lt;code&amp;gt;token_queue.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/scheduling/token_sub_queue.py &amp;lt;code&amp;gt;token_sub_queue.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/scheduling/token_category.py &amp;lt;code&amp;gt;token_category.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Four models make up the subsystem.&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;TokenQueue&amp;lt;/code&amp;gt;&lt;br /&gt;
| A queue of tokens for one schedulable resource on one date&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenSubQueue&amp;lt;/code&amp;gt;&lt;br /&gt;
| A sub-queue splitting a resource&amp;#039;s tokens (e.g. multiple rooms)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenCategory&amp;lt;/code&amp;gt;&lt;br /&gt;
| Reusable token categories per facility / resource type&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Token&amp;lt;/code&amp;gt;&lt;br /&gt;
| A numbered token issued to a patient within a queue&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All four extend [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]], the shared Care EMR base that supplies &amp;lt;code&amp;gt;external_id&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;created_date&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;, and soft-delete via &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TokenSubQueue&amp;lt;/code&amp;gt; both carry a &amp;lt;code&amp;gt;resource&amp;lt;/code&amp;gt; FK to &amp;lt;code&amp;gt;emr.SchedulableResource&amp;lt;/code&amp;gt;, a polymorphic binding to a practitioner (&amp;lt;code&amp;gt;user&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;, distinguished by &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt;. See [[References/Schedule &amp;amp;amp; Availability|Schedule]].&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;Token&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Required&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=facility|type=FK → facility.Facility (CASCADE)|notes=yes (server)}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=patient|type=FK → emr.Patient (CASCADE)|notes=optional}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=queue|type=FK → TokenQueue (CASCADE)|notes=yes (server)}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=category|type=FK → TokenCategory (CASCADE)|notes=yes}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=sub_queue|type=FK → TokenSubQueue (CASCADE)|notes=optional}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=number|type=IntegerField|notes=yes (server)}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=status|type=CharField(255)|notes=yes (server)}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=is_next|type=BooleanField (default False)|notes=server}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=note|type=TextField|notes=optional}}&lt;br /&gt;
{{Field|model=Token|section=Token fields|name=booking|type=FK → emr.TokenBooking (CASCADE)|notes=optional}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; is unique per category within a queue, not across the whole queue — so one patient can hold several tokens in the same queue, and two categories can both have a token &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;TokenStatusOptions&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
Defined in &amp;lt;code&amp;gt;token/spec.py&amp;lt;/code&amp;gt;; bound on &amp;lt;code&amp;gt;Token.status&amp;lt;/code&amp;gt; through the read and update specs.&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;UNFULFILLED&amp;lt;/code&amp;gt;&lt;br /&gt;
| Token issued but not served&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CREATED&amp;lt;/code&amp;gt;&lt;br /&gt;
| Default state on creation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IN_PROGRESS&amp;lt;/code&amp;gt;&lt;br /&gt;
| Currently being served (set when made the sub-queue&amp;#039;s current token)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FULFILLED&amp;lt;/code&amp;gt;&lt;br /&gt;
| Service completed&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CANCELLED&amp;lt;/code&amp;gt;&lt;br /&gt;
| Cancelled&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ENTERED_IN_ERROR&amp;lt;/code&amp;gt;&lt;br /&gt;
| Set automatically on delete (soft-delete)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
One resource, one date, one queue of tokens.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility         → FK Facility (CASCADE)&lt;br /&gt;
resource         → FK SchedulableResource (CASCADE)&lt;br /&gt;
name             → CharField(255)&lt;br /&gt;
is_primary       → BooleanField (default True)&lt;br /&gt;
date             → DateField&lt;br /&gt;
system_generated → BooleanField (default False)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;is_primary&amp;lt;/code&amp;gt; is resolved server-side on create: the first queue for a &amp;lt;code&amp;gt;(resource, date)&amp;lt;/code&amp;gt; pair becomes primary, later ones do not. The &amp;lt;code&amp;gt;set_primary&amp;lt;/code&amp;gt; action re-points it.&lt;br /&gt;
* &amp;lt;code&amp;gt;generate_token&amp;lt;/code&amp;gt; creates &amp;lt;code&amp;gt;system_generated&amp;lt;/code&amp;gt; queues implicitly (name &amp;lt;code&amp;gt;&amp;amp;quot;System Generated&amp;amp;quot;&amp;lt;/code&amp;gt;) when no primary queue exists for the date.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;TokenSubQueue&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
A sub-queue routes one queue&amp;#039;s tokens to several physical points — multiple vaccination rooms, say, each pulling from its own sub-queue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility      → FK Facility (CASCADE)&lt;br /&gt;
resource      → FK SchedulableResource (CASCADE)&lt;br /&gt;
name          → CharField(255)&lt;br /&gt;
status        → CharField(255)          # TokenSubQueueStatusOptions&lt;br /&gt;
current_token → FK Token (CASCADE, nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The spec binds &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;TokenSubQueueStatusOptions&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inactive&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; is whichever token is being served at that point. The progression actions (&amp;lt;code&amp;gt;set_next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;set_next_token_to_subqueue&amp;lt;/code&amp;gt;) keep it current server-side.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;TokenCategory&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
A reusable category scoped to a facility and resource type — &amp;amp;quot;General&amp;amp;quot;, &amp;amp;quot;Priority&amp;amp;quot;, and so on.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility      → FK Facility (CASCADE)&lt;br /&gt;
resource_type → CharField(255)          # SchedulableResourceTypeOptions&lt;br /&gt;
name          → CharField(255)&lt;br /&gt;
shorthand     → CharField(255)          # spec limits to max_length 5&lt;br /&gt;
metadata      → JSONField (default dict)&lt;br /&gt;
default       → BooleanField (default False)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* The spec binds &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;practitioner&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;lt;code&amp;gt;shorthand&amp;lt;/code&amp;gt; is capped at &amp;lt;code&amp;gt;max_length=5&amp;lt;/code&amp;gt; by the spec even though the column allows 255.&lt;br /&gt;
* &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt; is an open JSON bag for deployment-specific category config, exposed as &amp;lt;code&amp;gt;dict | None&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; is writable only through the &amp;lt;code&amp;gt;set_default&amp;lt;/code&amp;gt; action, which clears &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; on every other category sharing the facility and resource type. It isn&amp;#039;t a field on the create spec.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt; values ===&lt;br /&gt;
&lt;br /&gt;
Defined in &amp;lt;code&amp;gt;scheduling/schedule/spec.py&amp;lt;/code&amp;gt;; used by &amp;lt;code&amp;gt;TokenCategory.resource_type&amp;lt;/code&amp;gt; and every &amp;lt;code&amp;gt;*WithQueue&amp;lt;/code&amp;gt; / create spec that binds to a resource.&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;practitioner&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;healthcare_service&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&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;): &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; builds the read payload from the model (plus &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt;), and &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; writes a model from the payload (plus &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; is always the model&amp;#039;s &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; (UUID).&lt;br /&gt;
&lt;br /&gt;
=== Token ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec&lt;br /&gt;
! Role&lt;br /&gt;
! Exposed fields&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenGenerateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create (nested under a queue)&lt;br /&gt;
| &amp;lt;code&amp;gt;patient?&amp;lt;/code&amp;gt; (UUID), &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (UUID, required), &amp;lt;code&amp;gt;note?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sub_queue?&amp;lt;/code&amp;gt; (UUID)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenGenerateWithQueueSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create (queue resolved/created)&lt;br /&gt;
| adds &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;resource_id&amp;lt;/code&amp;gt; (UUID), &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenUpdateSpec&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;TokenStatusOptions&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;note?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sub_queue&amp;lt;/code&amp;gt; (UUID, nullable)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenMinimalSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · embedded&lt;br /&gt;
| &amp;lt;code&amp;gt;note&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (serialized via &amp;lt;code&amp;gt;TokenCategoryReadSpec&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sub_queue&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;note&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;queue&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;TokenQueueReadSpec&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| extends &amp;lt;code&amp;gt;TokenReadSpec&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; (&amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;booking&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resource&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;encounter?&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
What happens on write, from &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; and the viewset:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;TokenGenerateSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;sub_queue&amp;lt;/code&amp;gt; UUIDs to model instances, returning 404 if any is missing.&lt;br /&gt;
* &amp;lt;code&amp;gt;TokenUpdateSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the &amp;lt;code&amp;gt;sub_queue&amp;lt;/code&amp;gt; UUID, or sets &amp;lt;code&amp;gt;sub_queue = None&amp;lt;/code&amp;gt; when it&amp;#039;s omitted — so an update can clear it.&lt;br /&gt;
* On create (&amp;lt;code&amp;gt;perform_create&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;queue&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; come from the URL queue, category-vs-queue and sub-queue-vs-queue facility/resource matching is enforced, &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; is computed under a per-queue lock, and &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; is forced to &amp;lt;code&amp;gt;CREATED&amp;lt;/code&amp;gt;.&lt;br /&gt;
* On update, changing the sub-queue clears the old sub-queue&amp;#039;s &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; if it pointed at this token. A sub-queue that already has a current token can&amp;#039;t be reassigned.&lt;br /&gt;
* On delete (&amp;lt;code&amp;gt;perform_destroy&amp;lt;/code&amp;gt;), the token is soft-deleted: &amp;lt;code&amp;gt;status = ENTERED_IN_ERROR&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted = True&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;TokenRetrieveSpec&amp;lt;/code&amp;gt; embeds the booking (via &amp;lt;code&amp;gt;TokenBookingMinimumReadSpec&amp;lt;/code&amp;gt;), the booking&amp;#039;s &amp;lt;code&amp;gt;associated_encounter&amp;lt;/code&amp;gt; ([[References/Encounter]]) when present, and the resolved &amp;lt;code&amp;gt;resource&amp;lt;/code&amp;gt; (practitioner &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;HealthcareServiceReadSpec&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;FacilityLocationListSpec&amp;lt;/code&amp;gt;) keyed by &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== TokenQueue ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec&lt;br /&gt;
! Role&lt;br /&gt;
! Exposed fields&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenQueueBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenQueueCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| adds &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;resource_id&amp;lt;/code&amp;gt; (UUID), &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenQueueUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; only&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenQueueReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| adds &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;is_primary&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;system_generated&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenQueueRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| 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;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;TokenQueueCreateSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; stashes &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;resource_id&amp;lt;/code&amp;gt; onto the instance. The viewset&amp;#039;s &amp;lt;code&amp;gt;perform_create&amp;lt;/code&amp;gt; then resolves or creates the &amp;lt;code&amp;gt;SchedulableResource&amp;lt;/code&amp;gt;, sets &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, and computes &amp;lt;code&amp;gt;is_primary&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== TokenSubQueue ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec&lt;br /&gt;
! Role&lt;br /&gt;
! Exposed fields&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenSubQueueBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared / write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;TokenSubQueueStatusOptions&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenSubQueueCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| adds &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;resource_id&amp;lt;/code&amp;gt; (UUID)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenSubQueueReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read&lt;br /&gt;
| adds &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;TokenMinimalSpec&amp;lt;/code&amp;gt;, nullable)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;TokenSubQueueCreateSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; stashes &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;resource_id&amp;lt;/code&amp;gt;. On create the viewset resolves or creates the resource and validates it. &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; is serialized only when set.&lt;br /&gt;
&lt;br /&gt;
=== TokenCategory ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec&lt;br /&gt;
! Role&lt;br /&gt;
! Exposed fields&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenCategoryBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resource_type&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;SchedulableResourceTypeOptions&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;shorthand&amp;lt;/code&amp;gt; (max 5), &amp;lt;code&amp;gt;metadata?&amp;lt;/code&amp;gt; (dict)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenCategoryCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| same as base&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenCategoryReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| adds &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TokenCategoryRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| 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;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; is set from the URL on create. &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; is read-only here and toggled through the &amp;lt;code&amp;gt;set_default&amp;lt;/code&amp;gt; action.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Number assignment&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;Token.number&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;count(tokens with same queue + category) + 1&amp;lt;/code&amp;gt;, computed inside a &amp;lt;code&amp;gt;Lock(&amp;amp;quot;booking:token:{queue.id}&amp;amp;quot;)&amp;lt;/code&amp;gt; and an atomic transaction so two tokens can&amp;#039;t claim the same number.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Status lifecycle&amp;#039;&amp;#039;&amp;#039; — create forces &amp;lt;code&amp;gt;CREATED&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;set_next&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;set_next_token_to_subqueue&amp;lt;/code&amp;gt; set &amp;lt;code&amp;gt;IN_PROGRESS&amp;lt;/code&amp;gt;; delete sets &amp;lt;code&amp;gt;ENTERED_IN_ERROR&amp;lt;/code&amp;gt;. Status is a single field, with no separate history table.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Queue progression&amp;#039;&amp;#039;&amp;#039; — custom actions maintain &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; (on &amp;lt;code&amp;gt;TokenSubQueue&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;is_next&amp;lt;/code&amp;gt;; clients never write them directly:&lt;br /&gt;
** &amp;lt;code&amp;gt;Token&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;set_next&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;POST .../{id}/set_next&amp;lt;/code&amp;gt;, body &amp;lt;code&amp;gt;{ sub_queue }&amp;lt;/code&amp;gt;) points the sub-queue&amp;#039;s &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt; at this token and marks it &amp;lt;code&amp;gt;IN_PROGRESS&amp;lt;/code&amp;gt;.&lt;br /&gt;
** &amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;set_next_token_to_subqueue&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;POST .../{queue}/set_next_token_to_subqueue&amp;lt;/code&amp;gt;, body &amp;lt;code&amp;gt;{ sub_queue, category? }&amp;lt;/code&amp;gt;) picks the oldest &amp;lt;code&amp;gt;CREATED&amp;lt;/code&amp;gt; token (optionally filtered by category), assigns it to the sub-queue as &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt;, and sets &amp;lt;code&amp;gt;IN_PROGRESS&amp;lt;/code&amp;gt;.&lt;br /&gt;
** &amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;set_primary&amp;lt;/code&amp;gt; makes one queue primary for its &amp;lt;code&amp;gt;(resource, date)&amp;lt;/code&amp;gt;, clearing the flag on siblings.&lt;br /&gt;
** &amp;lt;code&amp;gt;TokenCategory&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;set_default&amp;lt;/code&amp;gt; makes one category default per &amp;lt;code&amp;gt;(facility, resource_type)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Token generation shortcut&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;generate_token&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;POST .../generate_token&amp;lt;/code&amp;gt;, body = &amp;lt;code&amp;gt;TokenGenerateWithQueueSpec&amp;lt;/code&amp;gt;) finds or creates the primary (&amp;lt;code&amp;gt;system_generated&amp;lt;/code&amp;gt;) queue for &amp;lt;code&amp;gt;(resource, date)&amp;lt;/code&amp;gt; and issues a token in one call.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Queue summary&amp;#039;&amp;#039;&amp;#039; — &amp;lt;code&amp;gt;TokenQueue&amp;lt;/code&amp;gt; action &amp;lt;code&amp;gt;summary&amp;lt;/code&amp;gt; returns per-category, per-status token counts for a queue.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* Create tokens under a queue with &amp;lt;code&amp;gt;TokenGenerateSpec&amp;lt;/code&amp;gt; — &amp;lt;code&amp;gt;queue&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; are all server-set — or call the queue&amp;#039;s &amp;lt;code&amp;gt;generate_token&amp;lt;/code&amp;gt; action with &amp;lt;code&amp;gt;TokenGenerateWithQueueSpec&amp;lt;/code&amp;gt;, which also resolves or creates the queue.&lt;br /&gt;
* Send &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;sub_queue&amp;lt;/code&amp;gt; as UUIDs (&amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;); the server resolves them to FKs. Cross-facility and cross-resource mismatches return &amp;lt;code&amp;gt;400&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The update spec accepts only &amp;lt;code&amp;gt;TokenStatusOptions&amp;lt;/code&amp;gt; values for &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TokenSubQueue.status&amp;lt;/code&amp;gt; only &amp;lt;code&amp;gt;TokenSubQueueStatusOptions&amp;lt;/code&amp;gt;. Both columns are plain &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt;s, so the spec layer enforces this, not the database.&lt;br /&gt;
* Never set &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;is_next&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;current_token&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;is_primary&amp;lt;/code&amp;gt; directly — they&amp;#039;re queue-progression state owned by the viewset actions above.&lt;br /&gt;
* &amp;lt;code&amp;gt;TokenCategory.metadata&amp;lt;/code&amp;gt; is an open JSON bag for deployment-specific config; &amp;lt;code&amp;gt;shorthand&amp;lt;/code&amp;gt; is capped at 5 characters by the spec.&lt;br /&gt;
* &amp;lt;code&amp;gt;booking&amp;lt;/code&amp;gt; links a token back to a [[References/Booking|&amp;lt;code&amp;gt;TokenBooking&amp;lt;/code&amp;gt;]]; on retrieve it expands to the booking and its associated [[References/Encounter|encounter]].&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>