Skip to main content

medOS Foundation

Scope: Base and master-data models — organizational entities, master catalogs, inventory & stock, QR codes, reporting, and cross-service utilities. Internal scope ever-api-foundation.

medOS Foundation is the shared substrate the rest of the platform builds on. It owns the master data (companies, manufacturers, vendors, units, product categories, document types) and the reference utilities (data dictionary, keywords, QR codes, report templates, queue sequencing) that nearly every other service reads from. It also hosts the inventory / stock domain — stock items, balances, batches, locations, transactions, and pharmacy purchasing — plus staff scheduling and leave management. Like all medOS backend services it is a NestJS + Moleculer service communicating over NATS; its scope name is ever-api-foundation and it runs as an internal service (no public port).

64+
Modules
ever-api-foundation
Moleculer scope
NATS
Transport
MongoDB
Primary store

Responsibilities

  • Master data — companies, company types, manufacturers, vendors, units (and unit categories), product categories, item types, document types.
  • Inventory & stock — stock items, balances, batches, transactions and logs, returns, requests, store rooms / shelves, barcode and location records.
  • Pharmacy procurement — purchase requisitions (PR) and purchase orders (PO) with their audit logs.
  • Reference utilities — data dictionary, keywords, QR code generation, report templates and printing logs, queue sequencing.
  • Staff operations — staff schedule management, leave requests (and leave types / per-user records), work-time settings.
  • Cross-service plumbing — notifications, documents and folders, acknowledgement and co-sign requests, batch scripts, and external sync adapters.

Major modules

ModulePurpose
company / companyTypeOrganizational entities and their classification (master data).
manufacturer / vendorSupplier and manufacturer master records.
unit / unitCategory / productCategory / itemTypeCatalog dimensions for products and inventory.
stockItem / stockBalance / stockBatchCore inventory: items, on-hand balances, and lot/batch tracking.
stockTransaction / stockTransactionLogs / stockReturn / stockRequestStock movements, audit logs, returns, and requests.
store / storeRoom / storeShelf / stockLocation / inventoryLocationPhysical storage hierarchy and location records.
stockBarcodeDepartment / stockBarcodeOpenBarcode issuance and lookup for stock items.
pharmacyPR / pharmacyPRLogPharmacy purchase requisitions and their change log.
pharmacyPO / pharmacyPOLogPharmacy purchase orders and their change log.
qrcode / imageQrCodeServer-rendered QR codes keyed by feature discriminator (see below).
dataDictionary / keywordShared reference data and keyword lookup.
reportTemplate / reportTemplateSize / reportTemplateRelease / reportPrintingLogReport template management, versioning, and print audit.
queueSystem / queueSystemSequenceQueue definitions and sequence generation.
staffScheduleManagement / listStaffSchedules / workTimeSettingStaff scheduling and work-time configuration.
leaveRequest / leaveRequestType / leaveRequestUserLeave request lifecycle and policy.
document / documentType / documentFolder / albumDocument and media organization.
notification / notificationReadCross-service notifications and read tracking.
acknowledgementRequest / coSignRequestAcknowledgement and clinical co-sign request records.
conferenceConference / multidisciplinary meeting records.
nhsoToken / nhsoDataNHSO token and reference data for Thai claims integration.
externalSpecimenDoc / webFormCentralizedExternal specimen documents and centralized web-form intake.
batchScript / batchScriptLogScheduled batch jobs and their execution logs.

QR code generation

The qrcode module is one of two QR "centrals" in the platform. It persists a Qrcode record keyed by a QrcodeFeatures discriminator and server-renders the QR image (a data-URL), encoding a reader URL plus the responsible staff member. This is distinct from the client-side, HMAC-token scan/v1 system used for ephemeral wristband / specimen / inventory scans. See the QR architecture notes referenced from the main repository docs for the convergence design.

caller ── POST qrcodes ──▶ foundation/qrcode.service
│ resolve feature → build reader URL
│ render image (data-URL)

Qrcode record (Mongo) ──▶ qrcodeImage returned to caller

Integration notes

  • Transport: all actions are exposed over the Moleculer service mesh on NATS under the ever-api-foundation scope; callers reach them via the API Gateway.
  • External sync: several modules ship an Odoo sync companion (*OdooSync.service.ts for stockItem, stockBalance, store, unit, inventoryLocation, etc.) for ERP inventory mirroring.
  • Read models: inventory and stock changes feed the Supabase realtime read-model cache used by frontend dashboards; Foundation remains the system of write-record in MongoDB.
  • CP-5 — Data Dictionary
  • CP-10 — Staff Schedule Management
  • CP-12 — SMS & Email / Report Templates
  • CL-6, CL-7 — Queue Management
  • RX-7 — Pharmacy PO / PR