Backend: The claims App

Views

class claims.views.AddNoteView(**kwargs)[source]

Handles POST requests to add a new note to a claim. Returns an HTML partial of the updated notes section.

class claims.views.ClaimDetailView(**kwargs)[source]

Handles fetching and displaying the details for a single claim. This view is designed to be rendered within the main list view via an HTMX request, to avoid a full page reload.

get_context_data(**kwargs: Any) Dict[str, Any][source]

Adds the claim’s notes to the context, ordered by most recent first.

model

alias of Claim

class claims.views.ClaimListView(**kwargs)[source]

Displays a list of all claims in the Claims Dashboard.

This view supports: - Searching by insurer name and patient name. - Filtering by claim status and flagged status. - Sorting on multiple fields. - HTMX-powered partial updates for filtering, sorting, and infinite scroll.

get_context_data(**kwargs: Any) Dict[str, Any][source]

Adds filter and sorting values to the context for use in the template.

get_queryset() QuerySet[source]

Overrides the default queryset to implement search, filter, and sorting logic.

get_template_names() list[str][source]

If the request is from HTMX, return the appropriate partial template. - For infinite scroll, return just the table rows. - For sorting/filtering, return the entire table body.

model

alias of Claim

class claims.views.FlagButtonView(**kwargs)[source]

Returns the current flag button partial for a claim without mutating state. Used to refresh the flag icon in the list row when the flag is toggled elsewhere.

class claims.views.RegisterView(**kwargs)[source]

Allow users to create an account and then log in.

form_class

alias of RegistrationForm

form_valid(form) HttpResponse[source]

If the form is valid, redirect to the supplied URL.

class claims.views.ToggleFlagView(**kwargs)[source]

Handles POST requests to toggle the ‘is_flagged’ status of a claim. This view returns an HTML partial of the updated flag button and triggers an HTMX event to refresh the claim detail view if it’s open.

Models

class claims.models.Claim(*args, **kwargs)[source]

Represents a single insurance claim.

class ClaimStatus(*values)[source]

Defines the possible statuses for a claim.

exception DoesNotExist
exception MultipleObjectsReturned
property underpayment: Decimal

Calculates the difference between the billed and paid amounts and get the underpayment value.

class claims.models.ClaimDetail(*args, **kwargs)[source]

Provides specific, detailed information related to a single claim, such as medical codes or denial reasons.

exception DoesNotExist
exception MultipleObjectsReturned
class claims.models.Note(*args, **kwargs)[source]

Stores user-generated annotations or notes for a specific claim.

exception DoesNotExist
exception MultipleObjectsReturned

Services

class claims.services.ClaimDataIngestor(claims_csv_path: Path | str, details_csv_path: Path | str, delimiter: str = ',', mode: str = 'append')[source]

A service class to handle the ingestion of claim data from CSV files. This class encapsulates the logic for parsing, validating, and saving claim and claim detail data to the database.

run() Tuple[Dict[str, int], List[str]][source]

Executes the full data loading process within a single database transaction. If any part of the process fails, the transaction is rolled back.

Returns:

A tuple containing a summary dictionary of the load results and a list of any errors encountered.

Management Commands

class claims.management.commands.load_claim_data.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]
add_arguments(parser: CommandParser) None[source]

Add the command line arguments for the CSV file paths.

handle(*args, **options) None[source]

The main execution logic for the command.

Template Tags

claims.templatetags.claim_tags.sort_indicator(context, field_name: str) str[source]

Returns an HTML SVG arrow to indicate the current sort field and direction.

Args:

context: The template context, which must contain the request object. field_name: The name of the model field for the indicator.

Returns:

An HTML string for an SVG arrow if the field is being sorted, otherwise an empty string.

claims.templatetags.claim_tags.sort_url(context, field_name: str) str[source]

Generates a URL for a table header to handle sorting.

It preserves all existing filter/search query parameters and toggles the sort direction for the given field.

Args:

context: The template context, which must contain the request object. field_name: The name of the model field to sort by.

Returns:

A URL-encoded string for the href attribute of a link. e.g., “?search=acme&status=PAID&sort=-billed_amount”

claims.templatetags.claim_tags.split(value: str, key: str = ' ') list[str][source]

A simple template filter that splits a string into a list of strings.

Usage: {{ some_string|split:”,” }}