Skip to main content

MOISSCode Language Guide

Protocols

Every MOISSCode program contains one or more protocols - named blocks of clinical logic.

protocol SepsisScreen {
input: Patient p;
// statements go here
}

Patient Input

Protocols declare patient inputs. The engine provides a default patient or accepts one via the API.

input: Patient p;

Core Fields (Always Available)

FieldTypeDefaultDescription
namestr"Unknown"Patient name
ageint0Age in years
weightfloat0.0Weight (kg)
heightfloat170.0Height (cm)
sexstr"U""M", "F", or "U"
bpfloat120.0Systolic BP (mmHg)
diastolic_bpfloat80.0Diastolic BP (mmHg)
hrfloat80.0Heart rate (bpm)
rrfloat16.0Respiratory rate
tempfloat37.0Temperature (°C)
spo2float98.0O₂ saturation (%)
gcsint15Glasgow Coma Scale
lactatefloat1.0Lactate (mmol/L)

Computed Properties

  • p.map - Mean Arterial Pressure (auto-calculated from bp and diastolic_bp)
  • p.bmi - Body Mass Index (auto-calculated from weight and height)

Extensible Fields

The Patient type supports any additional field via the Python SDK:

from moisscode.typesystem import Patient

p = Patient(
name="Jane", age=62, bp=90,
creatinine=2.4, # Extended field
platelets=85, # Extended field
pao2_fio2=180, # Extended field
on_vasopressors=True # Extended field
)

print(p.creatinine) # 2.4 - accessed like any core field
tip

Extended fields are used by advanced scoring systems (e.g., SOFA score uses platelets, bilirubin, creatinine, pao2_fio2). You can add any clinical data you need.

Variables

let score = med.scores.qsofa(p);
let drugs = ["Vancomycin", "Meropenem"];
let threshold = 2.0;

Conditionals

if score >= 2 {
alert "High risk" severity: critical;
} else {
alert "Stable" severity: info;
}

Operators: >, <, >=, <=, ==, !=, and, or, not

Loops

While Loop

let counter = 0;
while counter < 5 {
let counter = counter + 1;
}

For-Each Loop

let drugs = ["A", "B", "C"];
for drug in drugs {
alert drug severity: info;
}

Safety limit: 1000 iterations maximum.

Drug Administration

administer Norepinephrine dose: 0.1 mcg/kg/min;

The MOISS classifier automatically categorizes timing (PROPHYLACTIC, ON_TIME, PARTIAL, MARGINAL, FUTILE, TOO_LATE).

Tracking with KAE

Track a patient value using the Kalman-Autoencoder estimator:

track p.lactate using KAE;

Alerts

alert "Sepsis protocol activated" severity: critical;
alert "Monitoring" severity: info;

Severity levels: critical 🚨, warning ⚠️, info ℹ️

Clinical Assessment

assess p for sepsis;

Automatically calculates qSOFA and assigns risk level (HIGH / MODERATE / LOW).

Custom Types

Define domain-specific data structures:

type Bacteria {
name: str;
mic: float;
resistant: bool;
}

type MDRBacteria extends Bacteria {
resistance_genes: str;
}

Create instances:

let ecoli = Bacteria { name: "E.coli", mic: 0.5, resistant: false };

Functions

function is_resistant(mic, breakpoint) {
if mic > breakpoint {
return true;
}
return false;
}

let result = is_resistant(2.0, 1.0);

Lists

let panel = ["Vancomycin", "Meropenem", "Ceftriaxone"];
let first = panel[0];

Library Calls

All 20 modules are accessed via the med. prefix:

let score = med.scores.qsofa(p);
med.io.infuse("Pump_01", "Norepinephrine", 0.1);
med.finance.bill("99291", "Critical Care");

Comments

// This is a single-line comment

Imports

import med.biochem;
import med.lab;