# Business rules — glob-1 (Global Welness Centre)

Evidence date: 2026-10-13.

Source: `git@bitbucket.org:overdrive/glob-1.git`, `main` at `f26707a`.

Rules are taken from code. Each rule is marked **Documented** only when a comment or config string states it. **Inferred** means the behaviour is visible in code and the business intent is the reading of that code, not a signed rule. No rule below was invented to fill a gap.

There is no business-rules document in the source repository.

## Identity

### BR-001 — Tenant code

**Inferred.** The site setup code for this product is `GLOB-1`. Login accepts a user whose `customerCode` equals that code (`Core.master.cs`). `Test.aspx.cs` assigns `GLOB-1` to a new user.

The same forks also run when the code is `GLOB-2` or `MEDI-1`, except where a rule below says otherwise. Those codes are not given their own site folder in this repository (`GLOB-3` is a different tree).

### BR-002 — Practice name

**Documented** in config: `website` and email `subject` use "Global Welness Centre (GLOB-1)". Comments say GWC.

**Inferred** that statements and the public title do not automatically use that string. `Core.master` title is "Palette". A second `website` appSetting is "Evolution Software Framework".

## Access

### BR-003 — Who may sign in

**Implemented.**

1. Email plus reversibly encrypted password must match a `pal_` user.
2. `customerCode` must equal the setup code, or `customerCode` must be `EVOL-1` and `userType` must be greater than Power User (2). Super User (3), Admin User (4), and Custom User (5) all satisfy "greater than 2".
3. **Documented** by comment: on GLOB-1 and MEDI-1, a Website User who is not active must not sign in, because they still need to be verified. GLOB-2 is not in this condition.

### BR-004 — Session length

**Implemented.** Session timeout is 60 minutes. Anonymous identification is enabled. Remember-me cookie assignment is commented out and does not run.

### BR-005 — Registration mail recipient

**Documented** by comment and **Implemented** in code.

For a finished surface save by a Website User when the code is GLOB-1, GLOB-2, or MEDI-1, send the patient-registration notification.

For GLOB-1 and MEDI-1 the subject is `New Patient Registration: {first name} {surname}`. The To address is the first Power User whose name equals the patient site and whose surname is `Admin`. If that user has no email, To falls back to the `admin` appSetting. If appSetting `registration` exists, it is the CC. It is not in the committed GLOB-1 config.

**Inferred defect:** the other registration sender (`Core.master.cs`) tries to skip a template named "Patient Registration Notification" but compares a lowercased name to a mixed-case literal, so the skip does not work. **Requires Confirmation.**

## Patients

### BR-006 — Welgemoed numbers start at 50001

**Documented** by the region name "Welgemoed check". **Implemented.**

When the setup code is `GLOB-1` and the site string is `Welgemoed`, the next controlled patient number is 50001 if that site has no patient rows, otherwise one greater than the current maximum `PatientInformation_PatientDetails_PatientNumber` for that site. The shared counter on the surface field is not updated in this branch.

Other sites increment `oSurfaceField.controlledValue`.

GLOB-2 and MEDI-1 are not included.

### BR-007 — New patient receives the ideal x-ray set

**Documented** by the method summary on `GLOB1_InsertIdealXrays`. **Implemented** for GLOB-1, GLOB-2, and MEDI-1 when the surface application name is `PatientProfile`.

The copy source is the `XRays` item with `ParentSurfaceItemId` 0. Image fields are copied. Other field types are skipped except the parent id and date fields (dates are stored as `DateTime.MinValue`).

### BR-008 — Master x-rays are not editable

**Documented** by comment (2017-10-24): if the x-ray folder is not for the current item, it is the master, and edit is disabled.

**Implemented** when the image value does not start with the current surface item id, on PatientProfile, for GLOB-1, GLOB-2, and MEDI-1. The edit link's `Enabled` flag is set from that check.

### BR-009 — Copy patient details onto the account holder

**Implemented.** The button `PatientInformation_PersonResponsibleforAccountPayment_CopyFromPatient` copies title, first names, surname, ID or passport, date of birth, mobile, home phone, work phone, email, six postal lines, and physical address lines from the patient-detail fields.

**Inferred** that this exists so staff do not retype the patient when the patient is the person who pays. The code does not say that.

### BR-010 — Visit status

**Documented** by comment "GWC Status Button". **Implemented.**

`Status: Pending` signs out any open `oMedicalPatientVisitLog` rows for the patient, inserts a new row with `signInDate` now, and shows `Status: In Progress`. Any other label signs out all rows for the patient and returns the label to `Status: Pending`.

## Billing and tax

### BR-011 — Zero VAT from 1 April 2026

**Documented** in `InvoiceVatPolicy`: "tax invoices (sales TI + medical TI) persist 0% VAT from 2026-04-01 (server-local calendar date)."

**Implemented.**

- Medical lines: `vatRate` becomes 0 when `dateOfService` is on or after that date; otherwise the practice VAT rate is stored (`enquiry.ascx.cs`).
- Sales tax invoices (`itemType` `TI`): line `vatRate` is set to 0 and the exclusive/VAT split is not shown. Quotes (`QT`) are excluded.
- The split is also hidden when the company is not VAT registered or the practice rate is not greater than 0, regardless of date.
- MediSwitch uses the rate already stored on the account.

**Inferred.** Invoices dated before 1 April 2026 keep a non-zero practice rate if the practice is VAT registered. The code does not restate historical rates.

### BR-012 — Private tariff is the default

**Documented** by comment "Default selected tariff to Private for GWC" (2017-11-16). **Implemented** for GLOB-1, GLOB-2, and MEDI-1 by selecting dropdown value `PRIV` when present. Other codes use the medical scheme's `planCode`.

### BR-013 — Patient invoice email must not be sent to medical aid

**Documented** by the default body (2018-07-16) for GLOB-1 and GLOB-2:

"Herewith please find attached your invoice. DO NOT submit this to your Medical Aid for re-imbursement. Invoices needed to be submitted can be requested from our front desk. It will be printed and stamped \"PAID BY PATIENT\"."

**Implemented** as the initial value of the email body field. MEDI-1 is not included. A user can change the text before send; the code does not show a lock.

### BR-014 — Statements show the site

**Documented** by comment "Change POS (Place of Service) to show Site for GWC" (2018-01-24). **Implemented** for GLOB-1 and GLOB-2. The cell is `PatientType_PatientTypeandPracticeLocation_Site`. MEDI-1 is not included. Other codes print `placeOfService`.

### BR-015 — Main member name comes from the surface, not the account row

**Documented** by comment (2018-07-13): the main member is not saved on `pal_Account` for GWC, so statements and invoices replace `{PatientInformation_MedicalAidifapplicable_MainMembersName}` from surface field data.

**Implemented** for GLOB-1 and GLOB-2, both on the statement header and on each invoice body.

### BR-016 — Account holder is the person responsible for payment

**Implemented** for GLOB-1, GLOB-2, and MEDI-1. Title, first names, surname, initials, ID, postal address, and email on the account are taken from `PatientInformation_PersonResponsibleforAccountPayment_*`. Patient name fields are taken from `PatientInformation_PatientDetails_*`. Birth date is parsed from the patient date of birth (comment 2018-01-02 says an earlier version never saved it).

**Documented** as GWC-30 (2018-05-15): dependant code is `PatientInformation_MedicalAidifapplicable_DependentCode`. The non-GLOB builder uses `DependantCode` (different spelling).

Injury-on-duty fields are commented out inside this block. **Requires Confirmation** whether GWC still records injury on duty.

### BR-017 — Billing lines sort newest first

**Documented** as GWC-71 (2019-06-18), "Patient Billing (Sort Order of Invoices/Receipts)". **Implemented** on the GLOB-1 enquiry fork as `dateOfService DESC, sequence` for visible account lines. The previous ascending sort is commented out. The sort is not guarded by setup code inside this file.

Lines with procedure type other than `PA` and `CA` go to the account list. Modifier `0008` or `0009`, or procedure type `PA` or `CA`, also go to the assisted list. That split is in the same method and is not GLOB-specific in the condition. **Inferred** as shared Palette billing, present because this fork contains it.

### BR-018 — Invoice VAT display uses the saved rate

**Documented** by comment (2018-03-23): use the saved VAT rate, not the current practice rate. **Implemented** in `xDebtors.cs` when splitting exclusive and VAT amounts: `excl = amount * 100 / (100 + vatRate)` and VAT is the remainder. After BR-011, a post-cut-over line has `vatRate` 0, so the exclusive amount equals the line amount and VAT is 0.

## Calendar and campaigns

### BR-019 — Calendar subject

**Documented** by comment (2017-11-30) for GLOB-1, GLOB-2, and MEDI-1. **Implemented.** Subject is the linked users (or the new contact), then the previous subject if any, then the event type. If the subject is already `users: type`, it is left as it is. CSS class `calendarEvent` is added.

### BR-020 — Calendar tooltip shows the patient number

**Implemented** for the same three codes when the calendar is linked to the Surface module. The tooltip appends patient number and "surname, name" from the surface row and the user. Further tooltip lines exist in the same method and were not all transcribed.

### BR-021 — Campaign name fields show their group

**Documented** by comment (2018-04-09): several fields share displays such as "First Name", so the group display is appended. **Implemented** for GLOB-1, GLOB-2, and MEDI-1 as `display (group)`.

### BR-022 — User-link label

**Implemented** for GLOB-1, GLOB-2, and MEDI-1. The linked item label is first names, surname, and patient number in parentheses.

## Scheduler timing

### BR-023 — When background work runs

**Implemented** in `tools/scheduler/Program.cs`.

- If the first argument contains `googlesheetimport`, only the Google sheet import runs, then logs older than 14 days for that import are deleted.
- Otherwise the Palette scheduler runs campaigns immediately (the hour gate is commented out), loyalty email only when the clock hour equals `loyaltyEmailHour` and the minute is less than 5, then transaction lock, MediSwitch queued responses, and surface data import.
- Scheduler logs older than 14 days are deleted.

The GLOB-1 site sets `loyaltyEmail` to `0` and `loyaltyEmailHour` to `20`. The scheduler's own `App.config` does not point at `Framework_GLOB-1`. **Requires Confirmation** which config is used in production. A flag value of `0` was not traced into `HandleLoyalty`; whether `0` means "off" is **Unknown**.

## Rules that are data, not code

**Unknown / Requires Confirmation** from git:

- Which modules a GWC user can open.
- Tariff amounts, scheme rules, and whether plan `PRIV` exists.
- Surface required fields and validation messages (they are surface metadata in the database).
- The practice VAT rate stored on the practice row for dates before 2026-04-01.
- Email template bodies.
- Whether website users are created already inactive so that BR-003's verification step always applies.

## Conflicts

| Topic | What the code does | What needs a person |
|---|---|---|
| Practice name | "Global Welness Centre" and "Evolution Software Framework" are both `website` keys. GLOB-3 says "Global Wellness Chiropractic" | Confirm the name patients should see |
| GLOB-2 | Many rules include GLOB-2. No GLOB-2 site is in the tree | Confirm GLOB-2 still exists |
| VAT | Policy class documents 0% from 2026-04-01. No separate business sign-off is in git | Confirm the date and that quotes staying on the old VAT display is correct |
| Patient registration template | Comment says skip "Patient Registration Notification". The comparison does not skip it | Confirm which template new patients receive |
| IOD | Set on the general account builder, commented out on the GLOB builder | Confirm whether injury-on-duty still applies to GWC |
| Task snapshot | 2026-09-28 onboarding notes described a Sonar wrapper. This tree is the Palette tenant | Confirm which tree is the product |
