<?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%2FResource_Request</id>
	<title>References/Resource Request - 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%2FResource_Request"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Resource_Request&amp;action=history"/>
	<updated>2026-07-06T05:17:24Z</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/Resource_Request&amp;diff=472&amp;oldid=prev</id>
		<title>Admin: Add Navbox platform (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Resource_Request&amp;diff=472&amp;oldid=prev"/>
		<updated>2026-07-06T04:24:18Z</updated>

		<summary type="html">&lt;p&gt;Add Navbox platform (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:54, 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 230:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 230:&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;* Send &amp;lt;code&amp;gt;referring_facility_contact_number&amp;lt;/code&amp;gt; in a format &amp;lt;code&amp;gt;mobile_or_landline_number_validator&amp;lt;/code&amp;gt; accepts.&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;* Send &amp;lt;code&amp;gt;referring_facility_contact_number&amp;lt;/code&amp;gt; in a format &amp;lt;code&amp;gt;mobile_or_landline_number_validator&amp;lt;/code&amp;gt; accepts.&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;related_patient&amp;lt;/code&amp;gt; cascades on patient deletion. &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;-ed, so it can&#039;t be deleted while requests reference it or changed once the request exists.&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;related_patient&amp;lt;/code&amp;gt; cascades on patient deletion. &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;-ed, so it can&#039;t be deleted while requests reference it or changed once the request exists.&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 platform}}&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/Resource_Request&amp;diff=172&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/Resource_Request&amp;diff=172&amp;oldid=prev"/>
		<updated>2026-07-04T22:45:36Z</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=platform&lt;br /&gt;
|title=Resource Request&lt;br /&gt;
|order=4&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=ResourceRequest&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;ResourceRequest&amp;lt;/code&amp;gt; represents an inter-facility request for a resource (transfer, supply, or assistance) and tracks it from the originating facility through approval and assignment. You touch it whenever a facility needs something another facility can provide.&lt;br /&gt;
&lt;br /&gt;
The Django model is only storage: &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;priority&amp;lt;/code&amp;gt; are open &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;IntegerField&amp;lt;/code&amp;gt; columns with no model-level choices. The Pydantic resource specs give the fields their shape — pinning them to enums, running validation, resolving foreign keys, and splitting the read and write schemas.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sources:&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/resource_request.py &amp;lt;code&amp;gt;care/emr/models/resource_request.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/resource_request/spec.py &amp;lt;code&amp;gt;care/emr/resources/resource_request/spec.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;ResourceRequest&amp;lt;/code&amp;gt;&lt;br /&gt;
| An inter-facility request for a resource (transfer, supply, or assistance), tracked from origin through approval and assignment&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestComment&amp;lt;/code&amp;gt;&lt;br /&gt;
| A free-text comment thread entry attached to a &amp;lt;code&amp;gt;ResourceRequest&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Both 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 adds &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 semantics.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;ResourceRequest&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Facilities ===&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=ResourceRequest|section=Facilities|name=origin_facility|type=FK → Facility (PROTECT)|notes=Required. The facility raising the request. Set once on create (when &amp;lt;code&amp;gt;is_update&amp;lt;/code&amp;gt; is false) and never reassigned. &amp;lt;code&amp;gt;related_name=&amp;amp;quot;resource_requesting_facilities&amp;amp;quot;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Facilities|name=approving_facility|type=FK → Facility (SET_NULL)|notes=Nullable. The facility responsible for approving. &amp;lt;code&amp;gt;related_name=&amp;amp;quot;resource_approving_facilities&amp;amp;quot;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Facilities|name=assigned_facility|type=FK → Facility (SET_NULL)|notes=Nullable. The facility the request is assigned to or fulfilled by. Required when &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; is set. &amp;lt;code&amp;gt;related_name=&amp;amp;quot;resource_assigned_facilities&amp;amp;quot;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Request details ===&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;
! Default&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=emergency|type=bool (BooleanField)|notes=Yes (spec)}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=title|type=str (CharField(255))|notes=Yes}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=reason|type=str (TextField)|notes=Yes (spec)}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=status|type=StatusChoices enum (CharField(100))|notes=Yes}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=category|type=CategoryChoices enum (CharField(100))|notes=Yes}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Request details|name=priority|type=int (IntegerField)|notes=Yes (spec)}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Referring contact ===&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;
! Default&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ResourceRequest|section=Referring contact|name=referring_facility_contact_name|type=str (TextField)|notes=Yes (spec)}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Referring contact|name=referring_facility_contact_number|type=str (CharField(14))|notes=Yes (spec)}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Assignment &amp;amp;amp; patient ===&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=ResourceRequest|section=Assignment &amp;amp;amp; patient|name=is_assigned_to_user|type=bool (BooleanField)|notes=Defaults to &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;; signals that a user-level assignment exists. The spec classes never expose it.}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Assignment &amp;amp;amp; patient|name=assigned_to|type=FK → User (SET_NULL)|notes=Nullable. The user the request is assigned to. Requires &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, and the user must belong to that facility (see [[#validation}}&lt;br /&gt;
{{Field|model=ResourceRequest|section=Assignment &amp;amp;amp; patient|name=related_patient|type=FK → Patient (CASCADE)|notes=Nullable, defaults to &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;. Links the request to a patient where one applies. Set only on create.}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
The spec layer pins &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; to string enums defined in &amp;lt;code&amp;gt;spec.py&amp;lt;/code&amp;gt;. The Django columns are plain &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt;s, so these values hold only through the API — anything written directly to the database bypasses them.&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;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pending&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;approved&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;rejected&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;cancelled&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;transportation_to_be_arranged&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;transfer_in_progress&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;completed&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;CategoryChoices&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;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;patient_care&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;comfort_devices&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;medicines&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;financial&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;supplies&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;other&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 builds on &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; ([&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;]), which supplies &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; (DB object → pydantic, the read path) and &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; (pydantic → DB object, the write path), 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;lt;/code&amp;gt; names the fields the base (de)serializer skips, leaving them to be handled by hand — FK resolution, for instance.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ResourceRequest&amp;lt;/code&amp;gt; specs ===&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;
! Fields beyond base&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestBaseSpec&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;emergency&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;reason&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;referring_facility_contact_name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;referring_facility_contact_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;, &amp;lt;code&amp;gt;priority&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__exclude__&amp;lt;/code&amp;gt;s the five FK fields (&amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;approving_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create &amp;amp;amp; update&lt;br /&gt;
| Adds the FKs as &amp;lt;code&amp;gt;UUID4&amp;lt;/code&amp;gt; external ids: &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; (required), &amp;lt;code&amp;gt;approving_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; (all optional). Resolves each external id to a DB object 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;ResourceRequestListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| &amp;lt;code&amp;gt;origin_facility: dict&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_facility: dict | None&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;. Inlines &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;FacilityReadSpec&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Everything in List plus &amp;lt;code&amp;gt;approving_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt; (via &amp;lt;code&amp;gt;PatientListSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; (via &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;, cache-backed), &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;
There is no separate &amp;lt;code&amp;gt;UpdateSpec&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;ResourceRequestCreateSpec&amp;lt;/code&amp;gt; covers both create and update, branching on the &amp;lt;code&amp;gt;is_update&amp;lt;/code&amp;gt; flag.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;validate_assigned_to_user&amp;lt;/code&amp;gt; (model validator, &amp;lt;code&amp;gt;mode=&amp;amp;quot;after&amp;amp;quot;&amp;lt;/code&amp;gt;): once &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; is set, &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt; becomes &amp;#039;&amp;#039;&amp;#039;required&amp;#039;&amp;#039;&amp;#039;, and the assigned user must be a member of that facility (checked via &amp;lt;code&amp;gt;FacilityOrganizationUser&amp;lt;/code&amp;gt;). Either gap raises &amp;lt;code&amp;gt;ValueError&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Server-side behaviour (&amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; external id → &amp;lt;code&amp;gt;Facility&amp;lt;/code&amp;gt; object, &amp;#039;&amp;#039;&amp;#039;only on create&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;is_update&amp;lt;/code&amp;gt; false). It is never reassigned on update.&lt;br /&gt;
* &amp;lt;code&amp;gt;approving_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; external ids → their DB objects whenever present, on create or update.&lt;br /&gt;
* &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt; external id → &amp;lt;code&amp;gt;Patient&amp;lt;/code&amp;gt; object, &amp;#039;&amp;#039;&amp;#039;only on create&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* Every lookup uses &amp;lt;code&amp;gt;get_object_or_404&amp;lt;/code&amp;gt; on &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, so an unknown id returns 404.&lt;br /&gt;
&lt;br /&gt;
==== Read serialization (&amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; is emitted as the string &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; (and &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;approving_facility&amp;lt;/code&amp;gt; where present) are inlined via &amp;lt;code&amp;gt;FacilityReadSpec&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;PatientListSpec&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;assigned_to&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;, resolved from cache (&amp;lt;code&amp;gt;model_from_cache&amp;lt;/code&amp;gt; keyed on &amp;lt;code&amp;gt;assigned_to_id&amp;lt;/code&amp;gt;).&lt;br /&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; come from &amp;lt;code&amp;gt;serialize_audit_users&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ResourceRequestComment&amp;lt;/code&amp;gt; specs ===&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;
! Fields beyond base&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestCommentBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;comment: str&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__exclude__&amp;lt;/code&amp;gt;s &amp;lt;code&amp;gt;request&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestCommentCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| No extra fields — the parent &amp;lt;code&amp;gt;ResourceRequest&amp;lt;/code&amp;gt; is bound from the URL, not the body.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ResourceRequestCommentListSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt;; populates &amp;lt;code&amp;gt;created_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;
| &amp;lt;code&amp;gt;ResourceRequestCommentRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Subclasses &amp;lt;code&amp;gt;ResourceRequestCommentListSpec&amp;lt;/code&amp;gt; with no changes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;ResourceRequestComment&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
A comment entry on a resource request. The FK uses &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;, so deleting a comment leaves the request untouched.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;request → FK ResourceRequest (PROTECT, required)&lt;br /&gt;
comment → TextField (default &amp;quot;&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
* Read path: &amp;lt;code&amp;gt;&amp;amp;lt;Spec&amp;amp;gt;.serialize(obj)&amp;lt;/code&amp;gt; copies model fields, runs &amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt; (FK inlining, audit users, &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; as string), and builds the pydantic instance without re-validation (&amp;lt;code&amp;gt;model_construct&amp;lt;/code&amp;gt;).&lt;br /&gt;
* Write path: &amp;lt;code&amp;gt;&amp;amp;lt;Spec&amp;amp;gt;.de_serialize()&amp;lt;/code&amp;gt; writes scalar fields onto the model (&amp;lt;code&amp;gt;model_dump(exclude_defaults=True)&amp;lt;/code&amp;gt;), then &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves FK external ids and enforces the create-only constraints on &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; keep no &amp;lt;code&amp;gt;status_history&amp;lt;/code&amp;gt; here; a transition overwrites the column directly.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ResourceRequest&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ResourceRequestComment&amp;lt;/code&amp;gt; are served through Care&amp;#039;s REST API. Write bodies use the &amp;lt;code&amp;gt;CreateSpec&amp;lt;/code&amp;gt; schema; reads use &amp;lt;code&amp;gt;ListSpec&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;RetrieveSpec&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Foreign keys travel as &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt; UUIDs in write payloads and come back as nested objects (&amp;lt;code&amp;gt;FacilityReadSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PatientListSpec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;) in read payloads.&lt;br /&gt;
* Only &amp;lt;code&amp;gt;StatusChoices&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;CategoryChoices&amp;lt;/code&amp;gt; values clear validation for &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;priority&amp;lt;/code&amp;gt; must be an integer — even though all three columns are looser in the database.&lt;br /&gt;
* Assigning to a user requires &amp;lt;code&amp;gt;assigned_facility&amp;lt;/code&amp;gt;, with the user a member of that facility.&lt;br /&gt;
* Send &amp;lt;code&amp;gt;referring_facility_contact_number&amp;lt;/code&amp;gt; in a format &amp;lt;code&amp;gt;mobile_or_landline_number_validator&amp;lt;/code&amp;gt; accepts.&lt;br /&gt;
* &amp;lt;code&amp;gt;related_patient&amp;lt;/code&amp;gt; cascades on patient deletion. &amp;lt;code&amp;gt;origin_facility&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;PROTECT&amp;lt;/code&amp;gt;-ed, so it can&amp;#039;t be deleted while requests reference it or changed once the request exists.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>