Skip to main content

Multi Organ Intervention State Space Code — a domain-specific language for clinical decision support and biotech workflow automation.

Project description

MOISSCode
Multi Organ Intervention State Space Code
Tests Python 3.10+ BSL 1.1 v3.0.1

A domain-specific language for clinical decision support and biotech workflow automation.

Install · Quick Start · Library · CLI · Full Manual

⚠️ RESEARCH USE ONLY
MOISSCode is a research prototype. It is NOT approved by FDA, CDSCO, or any regulatory body for clinical decision-making. Do not use MOISSCode output to make real patient care decisions. Aethryva Deeptech accepts no liability for clinical outcomes.


What is MOISSCode?

MOISSCode is a domain-specific language designed for medical professionals and biotech engineers. Write clinical protocols in English-like syntax and let the engine handle scoring, drug classification, billing, lab interpretation, FHIR interoperability, and more.

protocol SepsisScreen {
    input: Patient p;

    let score = med.scores.qsofa(p);
    track p.lactate using KAE;

    if score >= 2 {
        administer Norepinephrine dose: 0.1 mcg/kg/min;
        alert "Sepsis detected!" severity: critical;
    }

    assess p for sepsis;
}

Installation

Requires: Python 3.10+

git clone https://github.com/aethryva/MOISSCode.git
cd MOISSCode

Windows (PowerShell):

py -m pip install -e .

macOS / Linux:

pip install -e .

Quick Start

Run a protocol file

moiss run examples/sepsis_workup.moiss -v

Validate syntax without executing

moiss validate examples/sepsis_workup.moiss

Interactive REPL

moiss repl

Embed in Python

from moisscode import MOISSCodeLexer, MOISSCodeParser, MOISSCodeInterpreter, Patient

code = """
protocol QuickCheck {
    input: Patient p;
    let score = med.scores.qsofa(p);
    if score >= 2 {
        alert "High risk" severity: critical;
    }
}
"""

lexer = MOISSCodeLexer()
tokens = lexer.tokenize(code)
parser = MOISSCodeParser(tokens)
program = parser.parse_program()

interp = MOISSCodeInterpreter()
interp.scope['p'] = {
    'type': 'Patient',
    'value': Patient(bp=85, hr=110, rr=24, temp=38.5, spo2=94,
                     weight=70, age=55, gcs=14, lactate=3.2, sex='M')
}

events = interp.execute(program)
for e in events:
    print(e)

Library Reference

MOISSCode ships with 20 built-in modules, all accessible via the med. prefix:

Module Description
med.scores 12 validated clinical scores (qSOFA, SOFA, NEWS2, MELD-Na, CHA2DS2-VASc, HEART, Framingham, Child-Pugh, CURB-65, Wells PE, Glasgow-Blatchford, KDIGO AKI)
med.pk Pharmacokinetic engine (100+ drugs, dosing, interactions, TDM, renal/hepatic adjustment)
med.lab Lab panels (80+ tests, 15 panels, reference ranges, eGFR via CKD-EPI 2021)
med.micro Microbiology (30 organisms, MIC breakpoints, 15 empiric therapy protocols)
med.genomics Pharmacogenomics (8 CYP450 genes, 20 CPIC/DPWG guidelines)
med.biochem Enzyme kinetics (25 enzymes), 8 metabolic pathways
med.epi Epidemiology (SIR/SEIR models, R0, herd immunity)
med.nutrition Clinical nutrition (BMI, BEE, TPN, IV fluids)
med.fhir FHIR R4 bridge (Patient, Bundle, MedicationRequest)
med.db SQLite persistence (patients, audit trail, alerts)
med.io Device management (infusion pumps, monitors, ventilators, waveforms, alarms)
med.finance CPT billing (38 codes) and cost tracking
med.research De-identification, consent, randomization, sample size, stratification
med.glucose Diabetes management (HbA1c, CGM analytics, insulin dosing, DKA, hypoglycemia)
med.chem Medicinal chemistry (40 compounds, Lipinski, BCS, ADMET, toxicity screening)
med.signal Biosignal processing (ECG peaks, HRV, SpO2, rhythm classification)
med.icd Medical coding (94 ICD-10-CM codes, 25 DRG groups, SNOMED CT mapping)
med.papers Scientific paper generation (LaTeX/PDF in IEEE, medRxiv, bioRxiv, JAMA, Nature, Lancet, PLOS)
med.kae Kalman-Autoencoder state estimator for real-time vital sign tracking
med.moiss MOISS intervention timing classifier (prophylactic to too-late)

CLI

moiss run <file.moiss> [-v]    Execute a protocol
moiss validate <file.moiss>    Parse-only validation
moiss repl                     Interactive shell
moiss version                  Print version

Language Features

  • Protocols - protocol Name { ... }
  • Patient input - input: Patient p;
  • Variables - let x = expression;
  • Conditionals - if condition { ... } else { ... }
  • Loops - while condition { ... } and for item in list { ... }
  • Custom types - type Bacteria { name: str; mic: float; }
  • Functions - function calc(a, b) { return a + b; }
  • Lists - let drugs = ["A", "B", "C"];
  • Alerts - alert "message" severity: critical;
  • Assessments - assess p for sepsis;
  • Drug admin - administer Drug dose: 0.1 mcg/kg/min;
  • Tracking - track p.lactate using KAE;

Project Structure

moisscode/
├── __init__.py       # Public API
├── cli.py            # CLI tool
├── lexer.py          # Tokenizer
├── parser.py         # AST parser
├── ast_nodes.py      # AST definitions
├── interpreter.py    # Runtime engine
├── typesystem.py     # Type checking + Patient
├── stdlib.py         # 20-module library
└── modules/          # Domain modules (med.*)

API Server

MOISSCode includes a REST API service for remote protocol execution.

Windows (PowerShell):

py -m pip install -e ".[api]"
py -m uvicorn moisscode.api.server:app --reload

macOS / Linux:

pip install -e ".[api]"
uvicorn moisscode.api.server:app --reload

See the moisscode/api/ directory for full API documentation and configuration.

Citation

If you use MOISSCode in research, please cite:

MOISS Framework:

Kunche, N. (2026). Multi-Organ Intervention State Space (MOISS): A Collision Geometry Framework for Quantifying Therapeutic Windows Across 10 Organ Systems in 301,470 ICU Patients. medRxiv. https://www.medrxiv.org/content/10.64898/2026.02.08.26345873v1

KAE Algorithm:

Kunche, N. (2025). The Kunche Adaptive Estimator: A Reliability-Adaptive Kalman Filtering Framework for Autonomous Multi-Biomarker State Estimation in Critical Care Monitoring. Authorea. https://doi.org/10.22541/au.176313985.55971071/v1

Contact

License

BSL 1.1 - See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moisscode-3.0.1.tar.gz (128.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moisscode-3.0.1-py3-none-any.whl (123.2 kB view details)

Uploaded Python 3

File details

Details for the file moisscode-3.0.1.tar.gz.

File metadata

  • Download URL: moisscode-3.0.1.tar.gz
  • Upload date:
  • Size: 128.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for moisscode-3.0.1.tar.gz
Algorithm Hash digest
SHA256 6a8f6d02ce6985408ba26cc2394bbd7103244ee2302a55b1e0d8ea368d1abd7d
MD5 e79858c76bb5a84822c438b739444705
BLAKE2b-256 c04a57ea233887b16cbacba59db26713b5ec0830e108df86d4748e1e7c823a6f

See more details on using hashes here.

File details

Details for the file moisscode-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: moisscode-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 123.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for moisscode-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 500e0690938280481b1907e709f31a50936839d87623a5edec2796990f09fda0
MD5 401ac63059a0a70f6694a5c8a8232e90
BLAKE2b-256 277ae957efb7a7cf325c85289b48718f28c1b6649fb3ba56f53c221900077bfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page