<?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</id>
	<title>References/Charge Item - 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"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Charge_Item&amp;action=history"/>
	<updated>2026-07-06T07:12:21Z</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&amp;diff=437&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&amp;diff=437&amp;oldid=prev"/>
		<updated>2026-07-06T04:11:26Z</updated>

		<summary type="html">&lt;p&gt;Automated edit (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:41, 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 343:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 343:&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;* Create and update enforce that &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; (and, when applying definitions, the actor) belongs to the facility&#039;s organization.&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;* Create and update enforce that &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; (and, when applying definitions, the actor) belongs to the facility&#039;s organization.&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;discount_configuration&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt; are structured but deployment-tunable: &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; follows &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt;, and tags resolve through the single-facility tag manager.&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;discount_configuration&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt; are structured but deployment-tunable: &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; follows &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt;, and tags resolve through the single-facility tag manager.&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 billing}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Wiki: ohcnwiki.tellmey.fyi&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;!-- diff cache key mediawiki:diff:1.41:old-134:rev-437:wikidiff2=table:1.14.2:bc2a06be --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Charge_Item&amp;diff=134&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&amp;diff=134&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:07Z</updated>

		<summary type="html">&lt;p&gt;OHC identity seed&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Doc header&lt;br /&gt;
|type=reference&lt;br /&gt;
|domain=billing&lt;br /&gt;
|title=Charge Item&lt;br /&gt;
|order=2&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=ChargeItem&lt;br /&gt;
|reference=References/Base models &amp;amp;amp; conventions&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;ChargeItem&amp;lt;/code&amp;gt; is a single billable line for a service or product supplied to a patient — what was charged, the quantity, the unit and total price components, and any discounts or override reasons. You create one against a patient (and optionally an encounter); it always settles onto an [[References/Account|&amp;lt;code&amp;gt;Account&amp;lt;/code&amp;gt;]].&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.py &amp;lt;code&amp;gt;care/emr/models/charge_item.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Resource specs: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/tree/develop/care/emr/resources/charge_item &amp;lt;code&amp;gt;care/emr/resources/charge_item/&amp;lt;/code&amp;gt;] ([&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/charge_item/spec.py &amp;lt;code&amp;gt;spec.py&amp;lt;/code&amp;gt;], [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/charge_item/sync_charge_item_costs.py &amp;lt;code&amp;gt;sync_charge_item_costs.py&amp;lt;/code&amp;gt;], [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/charge_item/apply_charge_item_definition.py &amp;lt;code&amp;gt;apply_charge_item_definition.py&amp;lt;/code&amp;gt;], [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/charge_item/handle_charge_item_cancel.py &amp;lt;code&amp;gt;handle_charge_item_cancel.py&amp;lt;/code&amp;gt;])&lt;br /&gt;
* Viewset: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/api/viewsets/charge_item.py &amp;lt;code&amp;gt;care/emr/api/viewsets/charge_item.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The Django model is only the storage layer. Several fields are opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt;s whose structure lives in the Pydantic resource specs under &amp;lt;code&amp;gt;care/emr/resources/charge_item/&amp;lt;/code&amp;gt;, which also define the enums, validation, read/write API schemas, server-side cost calculation, and status side effects. The field tables below tell you what&amp;#039;s stored; the spec and behaviour sections tell you what happens on write.&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;ChargeItem&amp;lt;/code&amp;gt;&lt;br /&gt;
| A single billable line item for a service or product rendered to a patient&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ChargeItem&amp;lt;/code&amp;gt; extends &amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt; (shared Care EMR base with &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 — see [[References/Base models &amp;amp;amp; conventions|Base model]]).&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;ChargeItem&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
=== Context &amp;amp;amp; relationships ===&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=ChargeItem|section=Context &amp;amp;amp; relationships|name=facility|type=FK → facility.Facility (PROTECT)|notes=Set server-side from the URL; a body value is ignored}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Context &amp;amp;amp; relationships|name=patient|type=FK → emr.Patient (CASCADE)|notes=When you supply an &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt;, the patient is taken from it rather than the request}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Context &amp;amp;amp; relationships|name=encounter|type=FK → emr.Encounter (CASCADE)|notes=Nullable; the encounter the charge relates to}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Context &amp;amp;amp; relationships|name=charge_item_definition|type=FK → emr.ChargeItemDefinition (CASCADE)|notes=Nullable; the template the charge was applied from. Not writable via create/update — set only by &amp;lt;code&amp;gt;apply_charge_item_defs&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Context &amp;amp;amp; relationships|name=account|type=FK → emr.Account (CASCADE)|notes=The account this charge lands on. Falls back to the patient&amp;#039;s default account when omitted}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Description &amp;amp;amp; status ===&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=ChargeItem|section=Description &amp;amp;amp; status|name=title|type=CharField(255)|notes=Required; display title for the charge}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Description &amp;amp;amp; status|name=description|type=TextField|notes=Nullable; longer description}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Description &amp;amp;amp; status|name=status|type=CharField(255)|notes=Required; lifecycle status, constrained to &amp;lt;code&amp;gt;ChargeItemStatusOptions&amp;lt;/code&amp;gt; — see [[#status-values}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Description &amp;amp;amp; status|name=code|type=JSONField|notes=Nullable; a &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt; that identifies the charge (e.g. a billing code), shape &amp;lt;code&amp;gt;Coding { system?, version?, code, display? }&amp;lt;/code&amp;gt; — see [[#coding-shape}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Description &amp;amp;amp; status|name=note|type=TextField|notes=Nullable; free-text (markdown) comments}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Pricing ===&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=ChargeItem|section=Pricing|name=quantity|type=DecimalField(20, 6)|notes=Required on write; the quantity serviced. Multiplies the base/per-unit components during cost sync}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Pricing|name=unit_price_components|type=JSONField|notes=Required on write; list of &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; — see [[#monetarycomponent-shape}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Pricing|name=total_price_components|type=JSONField|notes=Nullable; server-computed list of &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt; (as dicts) — the resolved breakdown after base × quantity, surcharges, discounts, and taxes. Not client-writable}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Pricing|name=total_price|type=DecimalField(20, 6)|notes=Nullable; server-computed total. Must be ≥ 0 unless the charge is a reversal}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Pricing|name=override_reason|type=JSONField|notes=Nullable; &amp;lt;code&amp;gt;ChargeItemOverrideReason { text: str, code?: Coding }&amp;lt;/code&amp;gt; explaining a list-price/factor override. No bound value set}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Pricing|name=discount_configuration|type=JSONField|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); &amp;lt;code&amp;gt;DiscountConfiguration { max_applicable: int (≥0), applicability_order: total_asc | total_desc }&amp;lt;/code&amp;gt;. Populated from the definition/facility config when applied from a definition}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Service source ===&lt;br /&gt;
&lt;br /&gt;
These fields trace the charge back to the resource that produced it.&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=ChargeItem|section=Service source|name=service_resource|type=CharField(255)|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); resource type, constrained to &amp;lt;code&amp;gt;ChargeItemResourceOptions&amp;lt;/code&amp;gt; — see [[#service-resource-types}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Service source|name=service_resource_id|type=CharField(255)|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); external id of the originating resource. Required once &amp;lt;code&amp;gt;service_resource&amp;lt;/code&amp;gt; is set}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Service source|name=performer_actor|type=FK → users.User (CASCADE)|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); the user who performed the service. Must belong to the facility&amp;#039;s organization}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Invoicing &amp;amp;amp; tags ===&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=ChargeItem|section=Invoicing &amp;amp;amp; tags|name=paid_invoice|type=FK → emr.Invoice (CASCADE)|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); denormalized link to the settling invoice. Platform-maintained; cleared on cancel}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Invoicing &amp;amp;amp; tags|name=paid_on|type=DateTimeField|notes=Nullable (default &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt;); when the charge was paid. Platform-maintained; cleared on cancel}}&lt;br /&gt;
{{Field|model=ChargeItem|section=Invoicing &amp;amp;amp; tags|name=tags|type=ArrayField[int]|notes=Tag IDs, default &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;. Managed through the tag mixin (&amp;lt;code&amp;gt;SingleFacilityTagManager&amp;lt;/code&amp;gt;), serialized as objects on read}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enums ==&lt;br /&gt;
&lt;br /&gt;
=== Status values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; is a plain &amp;lt;code&amp;gt;CharField&amp;lt;/code&amp;gt; in storage, but every write passes through &amp;lt;code&amp;gt;ChargeItemStatusOptions&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/charge_item/spec.py&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;billable&amp;lt;/code&amp;gt;&lt;br /&gt;
| Ready to be invoiced&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;not_billable&amp;lt;/code&amp;gt;&lt;br /&gt;
| Will not be billed&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;aborted&amp;lt;/code&amp;gt;&lt;br /&gt;
| Charge was cancelled before billing&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;billed&amp;lt;/code&amp;gt;&lt;br /&gt;
| Included on an invoice&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;paid&amp;lt;/code&amp;gt;&lt;br /&gt;
| Settled (links to &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;paid_on&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;&lt;br /&gt;
| Recorded in error&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(&amp;lt;code&amp;gt;planned&amp;lt;/code&amp;gt; exists in the source as a commented-out option and is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; currently selectable.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;not_billable&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;aborted&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt; form the cancelled set (&amp;lt;code&amp;gt;CHARGE_ITEM_CANCELLED_STATUS&amp;lt;/code&amp;gt;). Moving into this set on update triggers the cancel side effect (see [[#methods--save-behaviour|Methods &amp;amp;amp; save behaviour]]). &amp;lt;code&amp;gt;billed&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;paid&amp;lt;/code&amp;gt; cannot be set by hand — the viewset rejects manual transitions into them.&lt;br /&gt;
&lt;br /&gt;
=== Service resource types ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;service_resource&amp;lt;/code&amp;gt; is constrained by &amp;lt;code&amp;gt;ChargeItemResourceOptions&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;service_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;medication_dispense&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;appointment&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bed_association&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On create, the viewset validates the referenced resource: &amp;lt;code&amp;gt;service_request&amp;lt;/code&amp;gt; must exist (and not be completed) for the patient/encounter, and &amp;lt;code&amp;gt;bed_association&amp;lt;/code&amp;gt; must reference a &amp;lt;code&amp;gt;FacilityLocationEncounter&amp;lt;/code&amp;gt; on a non-completed encounter in the facility.&lt;br /&gt;
&lt;br /&gt;
=== MonetaryComponentType values ===&lt;br /&gt;
&lt;br /&gt;
Used by every entry in &amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/common/monetary_component.py&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;
! Role in cost sync&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt;&lt;br /&gt;
| Per-unit base price. Exactly one allowed; must carry &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; (not &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt;); no &amp;lt;code&amp;gt;conditions&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;base.amount × quantity&amp;lt;/code&amp;gt; seeds the running total&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;surcharge&amp;lt;/code&amp;gt;&lt;br /&gt;
| Added on top of base; &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; (% of base)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;discount&amp;lt;/code&amp;gt;&lt;br /&gt;
| Subtracted from the net price; &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; (% of net). Filtered/limited by &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;tax&amp;lt;/code&amp;gt;&lt;br /&gt;
| Added on the post-discount taxable price; &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; (% of taxable)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;informational&amp;lt;/code&amp;gt;&lt;br /&gt;
| Carried through without affecting the computed total&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DiscountApplicability values ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;discount_configuration.applicability_order&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/common/monetary_component.py&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;
! Effect&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;total_asc&amp;lt;/code&amp;gt;&lt;br /&gt;
| Sort candidate discounts by amount ascending before applying &amp;lt;code&amp;gt;max_applicable&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;total_desc&amp;lt;/code&amp;gt;&lt;br /&gt;
| Sort by amount descending before applying &amp;lt;code&amp;gt;max_applicable&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;max_applicable = 0&amp;lt;/code&amp;gt; drops all discounts.&lt;br /&gt;
&lt;br /&gt;
== JSON field shapes ==&lt;br /&gt;
&lt;br /&gt;
=== Coding shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, plus the &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; field inside components and &amp;lt;code&amp;gt;override_reason&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/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;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;Coding {&lt;br /&gt;
  system?:  str&lt;br /&gt;
  version?: str&lt;br /&gt;
  code:     str        # required&lt;br /&gt;
  display?: str&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== MonetaryComponent shape ===&lt;br /&gt;
&lt;br /&gt;
Each entry of &amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/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: base | surcharge | discount | tax | informational   # required&lt;br /&gt;
  code?:                Coding&lt;br /&gt;
  factor?:              Decimal(20,6)      # percentage; mutually exclusive with amount&lt;br /&gt;
  amount?:              Decimal(20,6)      # absolute; mutually exclusive with factor&lt;br /&gt;
  tax_included_amount?: Decimal(20,6)      # base component only&lt;br /&gt;
  global_component:     bool = False       # resolved against facility monetary config&lt;br /&gt;
  conditions:           [EvaluatorConditionSpec] = []   # not allowed on base&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Validation: exactly one of &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt; (unless &amp;lt;code&amp;gt;global_component&amp;lt;/code&amp;gt; with a &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;); &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; must have &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;factor&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;conditions&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;tax_included_amount&amp;lt;/code&amp;gt; only on &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt;; duplicate component &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;s are rejected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;EvaluatorConditionSpec { metric: str, operation: str, value: dict | str }&amp;lt;/code&amp;gt; — conditions are evaluated against patient/facility/encounter context when a definition is applied; a component whose conditions fail is dropped.&lt;br /&gt;
&lt;br /&gt;
=== ChargeItemOverrideReason shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;override_reason&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/charge_item/spec.py&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;ChargeItemOverrideReason {&lt;br /&gt;
  text: str            # required&lt;br /&gt;
  code?: Coding        # no bound value set&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== DiscountConfiguration shape ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;care/emr/resources/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 (&amp;gt;= 0)               # 0 drops all discounts&lt;br /&gt;
  applicability_order: 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;
Charge items are exposed through &amp;lt;code&amp;gt;ChargeItemViewSet&amp;lt;/code&amp;gt; (create / retrieve / update / upsert / list / tag actions, plus the &amp;lt;code&amp;gt;apply_charge_item_defs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;change_account&amp;lt;/code&amp;gt; custom actions). The Pydantic specs in &amp;lt;code&amp;gt;care/emr/resources/charge_item/spec.py&amp;lt;/code&amp;gt; build on &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;serialize&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;de_serialize&amp;lt;/code&amp;gt;, with &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).&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;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared base&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = ChargeItem&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;__exclude__ = [&amp;amp;quot;encounter&amp;amp;quot;, &amp;amp;quot;account&amp;amp;quot;]&amp;lt;/code&amp;gt;. Fields: &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;quantity&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;note&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;override_reason&amp;lt;/code&amp;gt;. Validators: no duplicate component codes, ≤1 &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; component&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemWriteSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| Extends base with &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;account&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;service_resource&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;service_resource_id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; (all &amp;lt;code&amp;gt;UUID4&amp;lt;/code&amp;gt;/enum, optional). Requires &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;; requires &amp;lt;code&amp;gt;service_resource_id&amp;lt;/code&amp;gt; when &amp;lt;code&amp;gt;service_resource&amp;lt;/code&amp;gt; set&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| Base fields + &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt;. Does not re-bind patient/encounter/account&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list &amp;amp;amp; detail&lt;br /&gt;
| Base fields + server-side: &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;total_price&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;charge_item_definition&amp;lt;/code&amp;gt; (nested), &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt; (nested), &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt; (objects), &amp;lt;code&amp;gt;service_resource(_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;, &amp;lt;code&amp;gt;paid_on&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;performer_actor&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;discount_configuration&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notable validation and binding:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;override_reason.code&amp;lt;/code&amp;gt;, and component &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;s are FHIR-aligned &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt;s with &amp;#039;&amp;#039;&amp;#039;no bound value set&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;lt;code&amp;gt;ChargeItemWriteSpec.perform_extra_deserialization&amp;lt;/code&amp;gt; resolves &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;account&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; from external ids; supplying &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; overrides &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt; with the encounter&amp;#039;s patient, and &amp;lt;code&amp;gt;account&amp;lt;/code&amp;gt; is looked up scoped to that patient.&lt;br /&gt;
* &amp;lt;code&amp;gt;ChargeItemReadSpec.perform_extra_serialization&amp;lt;/code&amp;gt; nests the full &amp;lt;code&amp;gt;ChargeItemDefinitionReadSpec&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;InvoiceReadSpec&amp;lt;/code&amp;gt;, renders tags, and resolves &amp;lt;code&amp;gt;performer_actor&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; from the user cache.&lt;br /&gt;
&lt;br /&gt;
=== Nested / related specs ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec&lt;br /&gt;
! Used by&lt;br /&gt;
! Shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Coding&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt;, component &amp;amp;amp; override codes&lt;br /&gt;
| see [[#coding-shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;MonetaryComponent&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt;&lt;br /&gt;
| see [[#monetarycomponent-shape&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemOverrideReason&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;override_reason&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;{ text, code? }&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;{ max_applicable, applicability_order }&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ChargeItemDefinitionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;charge_item_definition&amp;lt;/code&amp;gt; (read)&lt;br /&gt;
| full nested definition — see [[References/Charge Item Definition]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;InvoiceReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt; (read)&lt;br /&gt;
| full nested invoice — see [[References/Invoice]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt;, audit users (read)&lt;br /&gt;
| see [[References/User &amp;amp;amp; Skills&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Related models ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ChargeItem&amp;lt;/code&amp;gt; is a leaf model — it holds foreign keys rather than owning child rows:&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;
patient                → FK emr.Patient (CASCADE)&lt;br /&gt;
encounter              → FK emr.Encounter (CASCADE, nullable)&lt;br /&gt;
charge_item_definition → FK emr.ChargeItemDefinition (CASCADE, nullable)&lt;br /&gt;
account                → FK emr.Account (CASCADE)&lt;br /&gt;
paid_invoice           → FK emr.Invoice (CASCADE, nullable)&lt;br /&gt;
performer_actor        → FK users.User (CASCADE, nullable)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Methods &amp;amp;amp; save behaviour ==&lt;br /&gt;
&lt;br /&gt;
Cost resolution and status side effects live in the spec helpers and the viewset, not in the model&amp;#039;s &amp;lt;code&amp;gt;save()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cost sync (&amp;lt;code&amp;gt;sync_charge_item_costs&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — runs on every create and on update (unless suppressed). It walks &amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt;: multiplies the &amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt; amount by &amp;lt;code&amp;gt;quantity&amp;lt;/code&amp;gt; to seed &amp;lt;code&amp;gt;total_price&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;base&amp;lt;/code&amp;gt;, adds &amp;lt;code&amp;gt;surcharge&amp;lt;/code&amp;gt;s, applies &amp;lt;code&amp;gt;discount&amp;lt;/code&amp;gt;s (filtered by &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;apply_discount_configuration&amp;lt;/code&amp;gt;), then adds &amp;lt;code&amp;gt;tax&amp;lt;/code&amp;gt;es on the taxable price. It writes the resolved breakdown to &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt; and the sum to &amp;lt;code&amp;gt;total_price&amp;lt;/code&amp;gt;, and raises &amp;lt;code&amp;gt;ValidationError&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;total_price &amp;amp;lt; 0&amp;lt;/code&amp;gt; on a non-reversal charge.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Apply from definition (&amp;lt;code&amp;gt;apply_charge_item_definition&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;POST apply_charge_item_defs&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — builds a &amp;lt;code&amp;gt;ChargeItem&amp;lt;/code&amp;gt; from a &amp;lt;code&amp;gt;ChargeItemDefinition&amp;lt;/code&amp;gt;: copies &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, merges category + global components, evaluates each component&amp;#039;s &amp;lt;code&amp;gt;conditions&amp;lt;/code&amp;gt; against patient/facility/encounter context (dropping unmet ones), sets &amp;lt;code&amp;gt;status = billable&amp;lt;/code&amp;gt;, resolves &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt;, defaults the account to the patient&amp;#039;s default account, and runs cost sync. &amp;lt;code&amp;gt;reverse&amp;lt;/code&amp;gt; negates component amounts to produce a credit.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cancel (&amp;lt;code&amp;gt;handle_charge_item_cancel&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — fires on update when &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; moves into &amp;lt;code&amp;gt;CHARGE_ITEM_CANCELLED_STATUS&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;not_billable&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;aborted&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;). If the charge sits on a &amp;#039;&amp;#039;&amp;#039;draft&amp;#039;&amp;#039;&amp;#039; invoice, it is removed from the invoice, the invoice is rebalanced and saved, and &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;paid_on&amp;lt;/code&amp;gt; are cleared. Cancelling a charge on a non-draft invoice raises &amp;lt;code&amp;gt;ValidationError&amp;lt;/code&amp;gt;. Cost sync is skipped for cancellations.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Update guards (&amp;lt;code&amp;gt;validate_data&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;perform_update&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — a charge in a cancelled status can&amp;#039;t be updated; updates are blocked when the linked invoice is &amp;lt;code&amp;gt;balanced&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;issued&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; can&amp;#039;t be moved by hand into &amp;lt;code&amp;gt;billed&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;paid&amp;lt;/code&amp;gt;; and if the source definition has &amp;lt;code&amp;gt;can_edit_charge_item = False&amp;lt;/code&amp;gt;, the pricing fields (&amp;lt;code&amp;gt;unit_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;total_price&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;quantity&amp;lt;/code&amp;gt;) are reset from the previous object and cost sync is skipped. After update, a draft &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt; is re-synced.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cancel authorization (&amp;lt;code&amp;gt;authorize_cancel&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — cancellation is free within &amp;lt;code&amp;gt;CHARGE_ITEM_FREE_CANCEL_PERIOD_MINUTES&amp;lt;/code&amp;gt; of creation; after that it needs the &amp;lt;code&amp;gt;can_cancel_charge_item_in_facility&amp;lt;/code&amp;gt; permission.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Change account (&amp;lt;code&amp;gt;POST change_account&amp;lt;/code&amp;gt;)&amp;#039;&amp;#039;&amp;#039; — bulk-moves up to 100 &amp;lt;code&amp;gt;billable&amp;lt;/code&amp;gt; charge items to a target account, then queues &amp;lt;code&amp;gt;rebalance_account_task&amp;lt;/code&amp;gt; for every affected account.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* The viewset sets &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; from the URL and ignores any body value; &amp;lt;code&amp;gt;patient&amp;lt;/code&amp;gt; is derived from &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; when one is supplied.&lt;br /&gt;
* A charge item must resolve to an &amp;lt;code&amp;gt;account&amp;lt;/code&amp;gt; — with none supplied, the patient&amp;#039;s default account is used. &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;charge_item_definition&amp;lt;/code&amp;gt; are optional.&lt;br /&gt;
* &amp;lt;code&amp;gt;total_price&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;total_price_components&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;paid_invoice&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;paid_on&amp;lt;/code&amp;gt; are server-maintained; don&amp;#039;t set them from clients.&lt;br /&gt;
* Create and update enforce that &amp;lt;code&amp;gt;performer_actor&amp;lt;/code&amp;gt; (and, when applying definitions, the actor) belongs to the facility&amp;#039;s organization.&lt;br /&gt;
* &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tags&amp;lt;/code&amp;gt; are structured but deployment-tunable: &amp;lt;code&amp;gt;discount_configuration&amp;lt;/code&amp;gt; follows &amp;lt;code&amp;gt;DiscountConfiguration&amp;lt;/code&amp;gt;, and tags resolve through the single-facility tag manager.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>