# ethermorphcorp-cloud/arich_clinic architecture

> Architecture diagram of the GitHub repository ethermorphcorp-cloud/arich_clinic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ethermorphcorp-cloud/arich_clinic
- Repository: https://github.com/ethermorphcorp-cloud/arich_clinic

## Overview

ARICH CLINIC is a Google Apps Script clinic-management web app. Staff prepare dispensing records, create patient/OPD details, queue patients for a doctor, record treatment, and collect payment; the backend manages stock effects and persists clinic data. Admin capabilities include inventory and purchasing, pricing and commissions, reports/dashboard, settings, and audit. The README documents client/server calls and page roles; sampled backend excerpts confirm selected auth, stock, dashboard, receipt, and Drive behavior, but most implementation detail is unsampled.

Main entry points: [`gas/index.html`](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/index.html) (Clinic SPA), [`gas/Code.js`](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js) (OPD treatment), [`gas/Line.html`](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Line.html) (Daily LINE summary), [`gas/StockView.html`](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/StockView.html) (Mobile stock view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Clinic interface"]
  node_spa["Clinic SPA<br/>[index.html]"]
  node_stockview["Mobile stock view<br/>[StockView.html]"]
end

subgraph group_care["Patient care"]
  node_dispensing["Dispensing queue<br/>[Code.js]"]
  node_patient["Patient records<br/>[Code.js]"]
  node_visit["OPD treatment<br/>[Code.js]"]
  node_queue["Visit queue<br/>[Code.js]"]
  node_payment["Payment and receipts<br/>[Code.js]"]
  node_opdform["OPD print form<br/>[OpdSheet.html]"]
  node_receiptview["Receipt page<br/>[Receipt.html]"]
end

subgraph group_admin["Clinic administration"]
  node_inventory["Inventory management<br/>[Code.js]"]
  node_purchasing["Purchasing and expenses<br/>[Code.js]"]
  node_pricing["Group pricing<br/>[Code.js]"]
  node_commissions["Commission reports<br/>[Code.js]"]
  node_dashboard["Dashboard and reports<br/>[Code.js]"]
  node_settings["Clinic settings<br/>[Code.js]"]
end

subgraph group_backend["Backend and storage"]
  node_auth["Authentication and roles<br/>[Code.js]"]
  node_audit["Audit log<br/>[Code.js]"]
  node_logo["Default clinic logo<br/>[Logo.js]"]
end

subgraph group_integrations["Documents and integrations"]
  node_sheets[("Google Sheets")]
  node_drive[("Google Drive")]
  node_line["LINE messaging"]
  node_line_template["Daily LINE summary<br/>[Line.html]"]
end

node_staff(("Clinic staff"))

node_staff -->|"uses"| node_spa
node_staff -->|"views stock"| node_stockview
node_spa -->|"authenticates"| node_auth
node_spa -->|"calls server"| node_dispensing
node_dispensing -->|"adds patient"| node_patient
node_dispensing -->|"creates OPD"| node_visit
node_visit -->|"queues visit"| node_queue
node_queue -->|"records treatment"| node_visit
node_visit -->|"awaits payment"| node_payment
node_visit -->|"prints OPD"| node_opdform
node_payment -->|"issues receipt"| node_receiptview
node_spa -->|"calls server"| node_inventory
node_spa -->|"calls server"| node_purchasing
node_spa -->|"calls server"| node_pricing
node_dashboard -->|"reports commissions"| node_commissions
node_spa -->|"loads data"| node_dashboard
node_settings -->|"uses fallback"| node_logo
node_spa -->|"calls server"| node_settings
node_auth -.->|"reads users"| node_sheets
node_dispensing -.->|"updates records"| node_sheets
node_visit -.->|"stores treatment"| node_sheets
node_payment -.->|"stores payment"| node_sheets
node_inventory -.->|"updates stock"| node_sheets
node_purchasing -.->|"stores orders"| node_sheets
node_dashboard -->|"aggregates data"| node_sheets
node_visit -->|"uploads photos"| node_drive
node_line_template -->|"formats summary"| node_line
node_spa -.->|"sends summary"| node_line

click node_spa "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/index.html"
click node_stockview "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/StockView.html"
click node_dispensing "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_patient "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_visit "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_queue "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_payment "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_opdform "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/OpdSheet.html"
click node_receiptview "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Receipt.html"
click node_inventory "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_purchasing "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_pricing "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_commissions "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_dashboard "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_settings "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_auth "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_audit "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js"
click node_logo "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Logo.js"
click node_line_template "https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Line.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spa,node_stockview toneBlue
class node_dispensing,node_patient,node_visit,node_queue,node_payment,node_opdform,node_receiptview toneAmber
class node_inventory,node_purchasing,node_pricing,node_commissions,node_dashboard,node_settings toneMint
class node_auth,node_audit,node_logo toneRose
class node_sheets,node_drive,node_line,node_line_template,node_staff toneIndigo
```

## Components

### Clinic interface

- [Clinic SPA](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/index.html): `gas/index.html`
- [Mobile stock view](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/StockView.html): `gas/StockView.html`

### Patient care

- [Dispensing queue](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Patient records](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [OPD treatment](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Visit queue](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Payment and receipts](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [OPD print form](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/OpdSheet.html): `gas/OpdSheet.html`
- [Receipt page](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Receipt.html): `gas/Receipt.html`

### Clinic administration

- [Inventory management](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Purchasing and expenses](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Group pricing](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Commission reports](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Dashboard and reports](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Clinic settings](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`

### Backend and storage

- [Authentication and roles](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Audit log](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Code.js): `gas/Code.js`
- [Default clinic logo](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Logo.js): `gas/Logo.js`

### Documents and integrations

- **Google Sheets**
- **Google Drive**
- **LINE messaging**
- [Daily LINE summary](https://github.com/ethermorphcorp-cloud/arich_clinic/blob/main/gas/Line.html): `gas/Line.html`

### Other components

- **Clinic staff**

## Connections

- Clinic staff → Clinic SPA: uses (evidence: `README.md`)
- Clinic staff → Mobile stock view: views stock (evidence: `README.md`)
- Clinic SPA → Authentication and roles: authenticates (evidence: `README.md`)
- Clinic SPA → Dispensing queue: calls server (evidence: `README.md`)
- Dispensing queue → Patient records: adds patient (evidence: `README.md`)
- Dispensing queue → OPD treatment: creates OPD (evidence: `README.md`)
- OPD treatment → Visit queue: queues visit (evidence: `README.md`)
- Visit queue → OPD treatment: records treatment (evidence: `README.md`)
- OPD treatment → Payment and receipts: awaits payment (evidence: `README.md`)
- OPD treatment → OPD print form: prints OPD (evidence: `README.md`)
- Payment and receipts → Receipt page: issues receipt (evidence: `gas/Code.js`)
- Clinic SPA → Inventory management: calls server (evidence: `README.md`)
- Clinic SPA → Purchasing and expenses: calls server (evidence: `README.md`)
- Clinic SPA → Group pricing: calls server (evidence: `README.md`)
- Dashboard and reports → Commission reports: reports commissions (evidence: `README.md`)
- Clinic SPA → Dashboard and reports: loads data (evidence: `README.md`)
- Clinic settings → Default clinic logo: uses fallback (evidence: `README.md`)
- Clinic SPA → Clinic settings: calls server (evidence: `README.md`)
- Authentication and roles → Google Sheets: reads users
- Dispensing queue → Google Sheets: updates records
- OPD treatment → Google Sheets: stores treatment
- Payment and receipts → Google Sheets: stores payment
- Inventory management → Google Sheets: updates stock
- Purchasing and expenses → Google Sheets: stores orders
- Dashboard and reports → Google Sheets: aggregates data (evidence: `gas/Code.js`)
- OPD treatment → Google Drive: uploads photos (evidence: `gas/Code.js`)
- Daily LINE summary → LINE messaging: formats summary (evidence: `README.md`)
- Clinic SPA → LINE messaging: sends summary
