|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +AMRIT MMU (Mobile Medical Unit) UI — an Angular 16 healthcare application for the PSMRI AMRIT platform. Supports nurse, doctor, lab technician, pharmacist, radiologist, and oncologist workflows including patient registration, vitals capture, clinical examination, diagnosis, prescriptions, lab tests, drug dispensing, and offline data sync for van operations. |
| 8 | + |
| 9 | +## Build & Development Commands |
| 10 | + |
| 11 | +| Command | Purpose | |
| 12 | +|---------|---------| |
| 13 | +| `npm start` | Dev server on **port 4202** (`ng serve`) | |
| 14 | +| `npm run build` | Production build | |
| 15 | +| `npm run build-dev` | AOT dev build (increased heap) | |
| 16 | +| `npm run build-prod` | AOT production build (increased heap) | |
| 17 | +| `npm run build-ci` | CI build (generates `environment.ci.ts` from template + env vars) | |
| 18 | +| `npm test` | Run tests (Karma + Jasmine) | |
| 19 | +| `npm run lint` | ESLint | |
| 20 | +| `npm run lint:fix` | ESLint with auto-fix | |
| 21 | +| `npm run commit` | Commitizen conventional commit prompt | |
| 22 | + |
| 23 | +## Git Submodule: Common-UI |
| 24 | + |
| 25 | +`Common-UI/` is a git submodule from `https://github.com/PSMRI/Common-UI`. It provides: |
| 26 | +- `registrar` module (patient registration + `SessionStorageService`) |
| 27 | +- `feedback` module |
| 28 | +- `tracking` module (Matomo analytics) |
| 29 | + |
| 30 | +Initialize with: |
| 31 | +```bash |
| 32 | +cd Common-UI && git submodule update --init --recursive && git checkout develop |
| 33 | +``` |
| 34 | + |
| 35 | +Import paths use `Common-UI/src/...` (e.g., `Common-UI/src/registrar/registration.module`). |
| 36 | + |
| 37 | +## Architecture |
| 38 | + |
| 39 | +### Module Structure |
| 40 | +- **AppModule** — root module with hash-based routing (`useHash: true`) |
| 41 | +- **CoreModule** — singleton services, guards, shared components, directives. Uses `CoreModule.forRoot()` pattern |
| 42 | +- **Feature modules** (lazy-loaded): `nurse-doctor`, `lab`, `pharmacist`, `data-sync`, `registrar` (from Common-UI), `feedback` (from Common-UI) |
| 43 | +- **MaterialModule** — re-exports all Angular Material modules |
| 44 | + |
| 45 | +### State Management |
| 46 | +No NgRx — uses Angular services with `BehaviorSubject`/`Subject` for reactive state. Key examples: |
| 47 | +- `NurseService` — cross-component clinical state (RBS, NCD, IDRS, assessment) |
| 48 | +- `HttpServiceService` — language/i18n state via `currentLangugae$` BehaviorSubject |
| 49 | +- `SessionStorageService` (Common-UI) — encrypted sessionStorage via `ng-cryptostore`, key from `environment.encKey` |
| 50 | + |
| 51 | +### HTTP / Auth |
| 52 | +- `HttpInterceptorService` — attaches auth tokens (`Authorization`, `ServerAuthorization`), manages spinner, handles 27-minute session timeout with warning dialog, auto-logout on 401/5002 |
| 53 | +- Auth tokens stored in sessionStorage as `authenticationToken` and `isAuthenticated` |
| 54 | +- `AuthGuard` protects clinical routes; `CanDeactivateGuardService` prevents navigation with unsaved changes |
| 55 | + |
| 56 | +### Key Services (core) |
| 57 | +- `ConfirmationService` — alert/confirm/remarks dialogs via `CommonDialogComponent` + `MatDialog` |
| 58 | +- `IotService` — Bluetooth device integration at `http://localhost:8085/ezdx-hub-connect-srv` |
| 59 | +- `SpinnerService` — global loading indicator |
| 60 | + |
| 61 | +### Routing |
| 62 | +Root routes: `login`, `service`, `servicePoint`, `registrar`, `nurse-doctor`, `lab`, `pharmacist`, `datasync` |
| 63 | +Nurse-doctor sub-routes: role-specific worklists, patient workarea (`attendant/:attendant/patient/:beneficiaryRegID`), case sheet print, reports |
| 64 | + |
| 65 | +## Code Conventions |
| 66 | + |
| 67 | +- **License header**: All source files begin with the AMRIT GPL-3.0 license block |
| 68 | +- **Component prefix**: `app` (kebab-case for components, camelCase for directives) |
| 69 | +- **Commit convention**: Conventional Commits enforced via commitlint. Types: `feat`, `fix`, `build`, `chore`, `ci`, `docs`, `perf`, `refactor`, `revert`, `style`, `test` |
| 70 | +- **Pre-commit hook**: `lint-staged` runs ESLint `--fix` on `src/**/*.ts` |
| 71 | +- **Formatting**: Prettier — 2-space tabs, single quotes, semicolons, 80 char width, ES5 trailing commas |
| 72 | +- **TypeScript**: strict mode, ES5 target, strict templates enabled |
| 73 | + |
| 74 | +## Environment Configuration |
| 75 | + |
| 76 | +Environment files in `src/environments/`. CI build uses EJS template (`environment.ci.ts.template`) with env vars for API endpoints, encryption keys, captcha config, and tracking config. Key environment properties: |
| 77 | +- API base URLs: `commonAPI`, `mmuAPI`, `tmAPI`, `schedulerAPI`, etc. |
| 78 | +- `encKey` — sessionStorage encryption key |
| 79 | +- `siteKey` / `captchaChallengeUrl` — captcha configuration |
| 80 | +- `tracking` — Matomo analytics config (siteId, trackerUrl, enabled) |
| 81 | +- `isMMUOfflineSync` — enables offline data sync feature |
| 82 | + |
| 83 | +## Key Dependencies |
| 84 | + |
| 85 | +- Angular 16.2 + Angular Material 16.2 |
| 86 | +- Bootstrap 5.3 (layout) + Font Awesome 4.7 (icons) |
| 87 | +- RxJS 7.8, Moment.js 2.30 |
| 88 | +- `ng-cryptostore` — encrypted sessionStorage |
| 89 | +- `exceljs` + `file-saver` — Excel report generation |
| 90 | +- `ngx-webcam` — webcam capture |
| 91 | +- `ng2-charts` / `chart.js` — charts |
| 92 | +- `recordrtc` — audio recording |
0 commit comments