<?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%2FCharge_Item_Definition</id>
	<title>References/Charge Item Definition - 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%2FCharge_Item_Definition"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Charge_Item_Definition&amp;action=history"/>
	<updated>2026-07-06T05:20:19Z</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/Charge_Item_Definition&amp;diff=416&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/Charge_Item_Definition&amp;diff=416&amp;oldid=prev"/>
		<updated>2026-07-06T04:04:20Z</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:34, 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 283:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 283:&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;* The spec enum-gates &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;); only &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt; definitions should drive new charge items.&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;* The spec enum-gates &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;); only &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt; definitions should drive new charge items.&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;can_edit_charge_item&amp;lt;/code&amp;gt; controls whether a &#039;&#039;derived&#039;&#039; charge item is mutable, not the definition itself.&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;can_edit_charge_item&amp;lt;/code&amp;gt; controls whether a &#039;&#039;derived&#039;&#039; charge item is mutable, not the definition itself.&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 definitions}}&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/Charge_Item_Definition&amp;diff=149&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/Charge_Item_Definition&amp;diff=149&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:37Z</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=definitions&lt;br /&gt;
|title=Charge Item Definition&lt;br /&gt;
|order=7&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=ChargeItemDefinition&lt;br /&gt;
|reference=References/Base models &amp;amp;amp; conventions&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A charge item definition is a facility&amp;#039;s pricing template for a billable resource: it answers &amp;amp;quot;how much does resource X cost&amp;amp;quot;. It binds the resource to a set of price components — base rate, surcharges, discounts, and taxes — that get evaluated when a [[References/Charge Item|charge item]] is generated during data entry. You touch it when defining or revising the prices a facility charges.&lt;br /&gt;
&lt;br /&gt;
The resource spans two layers. The Django model (&amp;lt;code&amp;gt;care/emr/models/charge_item_definition.py&amp;lt;/code&amp;gt;) is storage: &amp;lt;code&amp;gt;price_components&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s with no structure of their own. The Pydantic specs (&amp;lt;code&amp;gt;care/emr/resources/charge_item_definition/&amp;lt;/code&amp;gt;) are the API: they define the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; enum, give those JSON fields a real shape via &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt;, enforce validation, and split the read and write schemas. See [[#resource-specs-api-schema|Resource specs (API schema)]].&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/charge_item_definition.py &amp;lt;code&amp;gt;care/emr/models/charge_item_definition.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Resource spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/charge_item_definition/spec.py &amp;lt;code&amp;gt;care/emr/resources/charge_item_definition/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Shared spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/common/monetary_component.py &amp;lt;code&amp;gt;care/emr/resources/common/monetary_component.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;ChargeItemDefinition&amp;lt;/code&amp;gt;&lt;br /&gt;
| Facility-scoped pricing template defining the price components applied to a billable resource&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ChargeItemDefinition&amp;lt;/code&amp;gt; extends [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt;]], the slug-aware Care EMR base, which itself extends &amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;. From that chain it inherits &amp;lt;code&amp;gt;external_id&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;, 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 the &amp;lt;code&amp;gt;history&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt; JSON fields, then adds facility-scoped slug helpers (see [[#methods--save-behaviour|Methods &amp;amp;amp; save behaviour]]).&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;ChargeItemDefinition&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Identity &amp;amp;amp; versioning ===&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=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=facility|type=FK → facility.Facility|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=version|type=IntegerField|notes=—}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=status|type=CharField(255)|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=title|type=CharField(255)|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=slug|type=CharField(255)|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Identity &amp;amp;amp; versioning|name=derived_from_uri|type=TextField|notes=no}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Descriptive ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Required&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Descriptive|name=description|type=TextField|notes=no}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Descriptive|name=purpose|type=TextField|notes=no}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Pricing &amp;amp;amp; rules ===&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=ChargeItemDefinition|section=Pricing &amp;amp;amp; rules|name=price_components|type=JSONField|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Pricing &amp;amp;amp; rules|name=discount_configuration|type=JSONField|notes=no}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Pricing &amp;amp;amp; rules|name=can_edit_charge_item|type=BooleanField|notes=yes}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Pricing &amp;amp;amp; rules|name=category|type=FK → emr.ResourceCategory|notes=no}}&lt;br /&gt;
{{Field|model=ChargeItemDefinition|section=Pricing &amp;amp;amp; rules|name=tags|type=ArrayField[int]|notes=—}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enum values ==&lt;br /&gt;
&lt;br /&gt;
=== Status values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ChargeItemDefinitionStatusOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;spec.py&amp;lt;/code&amp;gt;) constrains &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;. The model &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt; is unconstrained at the DB level, so the spec is the source of truth.&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;draft&amp;lt;/code&amp;gt;&lt;br /&gt;
| Not yet active; excluded from live billing&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;&lt;br /&gt;
| In use; only these should drive new charge items&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;&lt;br /&gt;
| Withdrawn; excluded from live billing&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Monetary component type values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;MonetaryComponentType&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;common/monetary_component.py&amp;lt;/code&amp;gt;) sets the &amp;lt;code&amp;gt;monetary_component_type&amp;lt;/code&amp;gt; of each price component.&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;base&amp;lt;/code&amp;gt;&lt;br /&gt;
| The base rate. Exactly one allowed; must carry an &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;; may not have &amp;lt;code&amp;gt;conditions&amp;lt;/code&amp;gt; or a &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;surcharge&amp;lt;/code&amp;gt;&lt;br /&gt;
| An additive charge layered on the base&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;discount&amp;lt;/code&amp;gt;&lt;br /&gt;
| A reduction layered on the base&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tax&amp;lt;/code&amp;gt;&lt;br /&gt;
| A tax component&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;informational&amp;lt;/code&amp;gt;&lt;br /&gt;
| Non-priced informational component&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Discount applicability values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;DiscountApplicability&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;common/monetary_component.py&amp;lt;/code&amp;gt;) sets &amp;lt;code&amp;gt;discount_configuration.applicability_order&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;total_asc&amp;lt;/code&amp;gt;&lt;br /&gt;
| Apply discounts in ascending order of total&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;total_desc&amp;lt;/code&amp;gt;&lt;br /&gt;
| Apply discounts in descending order of total&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== JSON field shapes ==&lt;br /&gt;
&lt;br /&gt;
=== Price components shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;price_components&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;list[MonetaryComponent]&amp;lt;/code&amp;gt;. Each entry (&amp;lt;code&amp;gt;common/monetary_component.py&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;MonetaryComponent {&lt;br /&gt;
  monetary_component_type : MonetaryComponentType   # required; see enum above&lt;br /&gt;
  code                    : Coding | null           # billing code (system/version/code/display); code required if present&lt;br /&gt;
  factor                  : Decimal | null          # max_digits=20, decimal_places=6&lt;br /&gt;
  amount                  : Decimal | null          # max_digits=20, decimal_places=6&lt;br /&gt;
  tax_included_amount     : Decimal | null          # max_digits=20, decimal_places=6; base-only&lt;br /&gt;
  global_component        : bool                     # default false&lt;br /&gt;
  conditions              : list[EvaluatorConditionSpec]   # default []&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;common/coding.py&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;extra=&amp;amp;quot;forbid&amp;amp;quot;&amp;lt;/code&amp;gt;): &amp;lt;code&amp;gt;{ system: str|null, version: str|null, code: str (required), display: str|null }&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;EvaluatorConditionSpec&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;common/condition_evaluator.py&amp;lt;/code&amp;gt;): &amp;lt;code&amp;gt;{ metric: str, operation: str, value: dict|str }&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;metric&amp;lt;/code&amp;gt; is validated against &amp;lt;code&amp;gt;EvaluatorMetricsRegistry&amp;lt;/code&amp;gt;, and that metric&amp;#039;s evaluator validates &amp;lt;code&amp;gt;operation&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Each &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; is checked against these rules:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Rule&lt;br /&gt;
! Detail&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tax_included_amount&amp;lt;/code&amp;gt; base-only&lt;br /&gt;
| Allowed only when &amp;lt;code&amp;gt;monetary_component_type == base&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| base no conditions&lt;br /&gt;
| A &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; component must have no &amp;lt;code&amp;gt;conditions&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| base requires amount&lt;br /&gt;
| A &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; component must have an &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| amount xor factor&lt;br /&gt;
| &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; cannot both be present&lt;br /&gt;
|-&lt;br /&gt;
| amount or factor required&lt;br /&gt;
| One of &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; must be present — except when &amp;lt;code&amp;gt;global_component&amp;lt;/code&amp;gt; is true and a &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; is set&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Discount configuration shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;DiscountConfiguration | null&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;common/monetary_component.py&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;DiscountConfiguration {&lt;br /&gt;
  max_applicable      : int                     # required; &amp;gt;= 0&lt;br /&gt;
  applicability_order : DiscountApplicability   # required; total_asc | total_desc&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
The API never serializes the Django model directly. It routes through Pydantic specs built on &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/base.py&amp;lt;/code&amp;gt;), which provide &amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; (DB → API) and &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt; (API → DB).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec class&lt;br /&gt;
! Role&lt;br /&gt;
! Exposes / behaviour&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemDefinitionSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;derived_from_uri&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;purpose&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;can_edit_charge_item&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;__exclude__ = []&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemDefinitionWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create + update&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;slug_value: SlugType&amp;lt;/code&amp;gt; and `category: ExtendedSlugType&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemDefinitionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list + detail&lt;br /&gt;
| Adds read-only &amp;lt;code&amp;gt;version&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category: dict&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug_config: dict&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tags: list[dict]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;slug: str&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;created_date&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;updated_date&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These specs reuse several nested specs: &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; (price component), &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt; (discount rules), &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; (component code), and &amp;lt;code&amp;gt;EvaluatorConditionSpec&amp;lt;/code&amp;gt; (component conditions).&lt;br /&gt;
&lt;br /&gt;
=== Write-spec validation &amp;amp;amp; side effects ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Duplicate (code, type) check&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;check_components_with_duplicate_codes&amp;lt;/code&amp;gt; field validator): no two &amp;lt;code&amp;gt;price_components&amp;lt;/code&amp;gt; may share the same &amp;lt;code&amp;gt;(code.code, monetary_component_type)&amp;lt;/code&amp;gt; pair. Only components that carry a &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; are checked.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;ChargeItemDefinitionWriteSpec&amp;lt;/code&amp;gt;):&lt;br /&gt;
** When &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; (slug) is supplied, resolves it via &amp;lt;code&amp;gt;ResourceCategory.objects.get(slug=category)&amp;lt;/code&amp;gt; and sets &amp;lt;code&amp;gt;obj.category&amp;lt;/code&amp;gt;.&lt;br /&gt;
** Sets &amp;lt;code&amp;gt;obj.slug = self.slug_value&amp;lt;/code&amp;gt; (the unprefixed value; the model&amp;#039;s slug helpers prefix it — see below).&lt;br /&gt;
&lt;br /&gt;
=== Read-spec serialization ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;perform_extra_serialization&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;ChargeItemDefinitionReadSpec&amp;lt;/code&amp;gt;):&lt;br /&gt;
** &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; ← &amp;lt;code&amp;gt;obj.external_id&amp;lt;/code&amp;gt;.&lt;br /&gt;
** &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; ← &amp;lt;code&amp;gt;ResourceCategoryReadSpec.serialize(obj.category)&amp;lt;/code&amp;gt; when set.&lt;br /&gt;
** &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt; ← &amp;lt;code&amp;gt;obj.parse_slug(obj.slug)&amp;lt;/code&amp;gt; (decomposes the stored slug into &amp;lt;code&amp;gt;{facility, slug_value}&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;{slug_value}&amp;lt;/code&amp;gt;).&lt;br /&gt;
** &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt; ← &amp;lt;code&amp;gt;SingleFacilityTagManager().render_tags(obj)&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; ← serialized via &amp;lt;code&amp;gt;serialize_audit_users&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Slug type constraints ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type&lt;br /&gt;
! Constraints&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SlugType&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;min_length=5&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max_length=50&amp;lt;/code&amp;gt;; pattern &amp;lt;code&amp;gt;^[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]$&amp;lt;/code&amp;gt; (URL-safe; alphanumeric start/end)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ExtendedSlugType&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;)&lt;br /&gt;
| &amp;lt;code&amp;gt;min_length=7&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max_length=88&amp;lt;/code&amp;gt;; same pattern, and must start with &amp;lt;code&amp;gt;f-&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;i-&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;ChargeItemDefinition&amp;lt;/code&amp;gt; references two other models by foreign key:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;facility  → FK facility.Facility (PROTECT)&lt;br /&gt;
category  → FK emr.ResourceCategory (CASCADE, nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; is protected: a facility cannot be deleted while definitions reference it.&lt;br /&gt;
* &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; cascades: deleting the [[References/Resource Category|resource category]] removes the link.&lt;br /&gt;
&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ChargeItemDefinition&amp;lt;/code&amp;gt; overrides nothing of its own; slug behaviour comes from &amp;lt;code&amp;gt;SlugBaseModel&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;FACILITY_SCOPED = True&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Method&lt;br /&gt;
! Behaviour&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;calculate_slug()&amp;lt;/code&amp;gt;&lt;br /&gt;
| Returns &amp;lt;code&amp;gt;f-{facility.external_id}-{slug}&amp;lt;/code&amp;gt; when facility-scoped with a facility, otherwise &amp;lt;code&amp;gt;i-{slug}&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;calculate_slug_from_facility(facility_external_id, slug)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Classmethod — builds a facility-scoped slug string&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;calculate_slug_from_instance(slug)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Classmethod — builds an instance-scoped slug string&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;parse_slug(slug)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Splits a stored slug back into &amp;lt;code&amp;gt;{facility, slug_value}&amp;lt;/code&amp;gt; (facility-scoped, &amp;lt;code&amp;gt;f-&amp;lt;/code&amp;gt; prefix) or &amp;lt;code&amp;gt;{slug_value}&amp;lt;/code&amp;gt; (instance-scoped, &amp;lt;code&amp;gt;i-&amp;lt;/code&amp;gt; prefix); validates the embedded facility UUID; raises on length &amp;lt;code&amp;gt;&amp;amp;lt;= 2&amp;lt;/code&amp;gt; or an unknown prefix&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Because slugs are namespaced by the owning facility&amp;#039;s &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, the same &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt; (for example &amp;lt;code&amp;gt;consultation-fee&amp;lt;/code&amp;gt;) can coexist across facilities without colliding.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* The structure is FHIR-aligned (&amp;lt;code&amp;gt;ChargeItemDefinition&amp;lt;/code&amp;gt;), and &amp;lt;code&amp;gt;price_components&amp;lt;/code&amp;gt; mirror the FHIR &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; shape.&lt;br /&gt;
* Field names diverge between write and read: the client sends &amp;lt;code&amp;gt;slug_value&amp;lt;/code&amp;gt;, not &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt; is a slug string on write but an object on read. &amp;lt;code&amp;gt;slug_config&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;category&amp;lt;/code&amp;gt;, and audit users are computed server-side and appear only on read.&lt;br /&gt;
* The spec enum-gates &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;retired&amp;lt;/code&amp;gt;); only &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt; definitions should drive new charge items.&lt;br /&gt;
* &amp;lt;code&amp;gt;can_edit_charge_item&amp;lt;/code&amp;gt; controls whether a &amp;#039;&amp;#039;derived&amp;#039;&amp;#039; charge item is mutable, not the definition itself.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>