Building a Virtual Ward Simulation: From Clinical Case to Scored Scenario

How to turn a deteriorating-patient case into a browser or VR simulation that clinical educators trust: objectives, a patient state model, actions and timing, NEWS2-style scoring, xAPI action logs for debriefing, and authoring that faculty can maintain.

Gigantic WorkEngineering team • • Updated • Markdown version

Recognising a deteriorating patient and escalating early is one of the most important things a new doctor or nurse learns — and one of the hardest to practise. Real deteriorating patients are not scheduled, and in a manikin session only a few students get to lead.

A virtual ward lets every student manage the same case, as many times as they need, with their actions and timings recorded for the debrief. This guide shows how we build one, from the clinical case to the code.

The demo

The gamified Babylon.js demo below applies the same principles to an operating theatre: move 3D surgical tools and operate live OR equipment (anaesthesia machine, IV fluids, electrosurgical diathermy, suction wand, surgical lamps, and table tilt) with physiological and visual feedback on the manikin. Actions, vitals stability, and checklist verifications are checked step by step, timed, and scored for the OSCE debrief — exactly the state-and-telemetry model this guide describes.

Operating theatre
Loading Babylon.js surgical engine…
Built with Babylon.js + WebXR · Manikin & organs: BodyParts3D, © DBCLS (CC BY 4.0) · Theatre & lighting by Gigantic Work.

On a ward the same design pays off in the details. Giving oxygen, for example, raises the NEWS2 score by two points even as saturation improves, because NEWS2 counts supplemental oxygen as a risk factor; and a patient who improves but stays in the medium band should teach “keep reassessing”, not “problem solved”. Details like these are what make clinicians trust a scenario.

Step 1: Start from observable objectives

Write two to four objectives that you could tick off by watching a student:

  • Recognises deterioration from the observations within 3 minutes.
  • Calculates the early-warning score correctly and identifies the response level.
  • Escalates to a senior using SBAR (Situation, Background, Assessment, Recommendation).
  • Starts the local sepsis bundle within the target time.

Each objective becomes a measurable event in the scenario: an action, a time stamp, or an answer.

Step 2: Model the patient as states, not a script

A linear script (“click A, then B, then C”) breaks as soon as a student does something unexpected. Instead, model the patient as a small set of physiological states with vital signs, and let actions and time move the patient between them.

State RR SpO₂ BP HR Temp Moves to…
Deteriorating (start) 24 92% air 96/58 118 38.6 Worse after 20 min without treatment
Oxygen on 20 95% on O₂ 96/58 118 38.6 Stabilising after fluids
Stabilising 20 95% on O₂ 108/64 104 38.6 Improving after antibiotics + time
Worse 30 88% air 84/50 132 39.2 Needs emergency response

All values here are fictional and for illustration. Your clinical owner sets the real numbers.

In code, a case is just data. Keeping it as data (JSON, YAML or even a spreadsheet) is what later lets faculty write new cases without a developer:

export const case01 = {
  id: 'post-op-sepsis',
  start: 'deteriorating',
  states: {
    deteriorating: { rr: 24, spo2: 92, o2: false, sbp: 96, dbp: 58, hr: 118, alert: true, temp: 38.6 },
    worse:         { rr: 30, spo2: 88, o2: false, sbp: 84, dbp: 50, hr: 132, alert: false, temp: 39.2 },
    // ...
  },
  transitions: [
    { from: 'deteriorating', after: { minutes: 20 }, unless: ['oxygen', 'fluids'], to: 'worse' },
    { from: 'deteriorating', on: 'oxygen', to: 'oxygenOn' },
    { from: 'oxygenOn', on: 'fluids', to: 'stabilising' },
  ],
};

Step 3: Give actions a cost in time

Real clinical work takes time, and the order matters. Give each action a simulated duration — taking blood cultures takes minutes; a fluid bolus takes longer — and let the clock drive deterioration. This creates honest time pressure without a game-style countdown.

Also decide what happens with unhelpful or harmful actions. For formative use, avoid “game over”: let the consequence unfold (for example, a fluid-overload state in a heart-failure case) and discuss it in the debrief.

Step 4: Score from rules your clinicians already use

Use the scoring system your hospitals use, implemented as a pure function that clinicians can check line by line. Here is NEWS2 (Royal College of Physicians, 2017, SpO₂ scale 1), as used in the demo:

export function news2(v: Vitals) {
  const rr   = v.rr <= 8 ? 3 : v.rr <= 11 ? 1 : v.rr <= 20 ? 0 : v.rr <= 24 ? 2 : 3;
  const spo2 = v.spo2 <= 91 ? 3 : v.spo2 <= 93 ? 2 : v.spo2 <= 95 ? 1 : 0;
  const air  = v.o2 ? 2 : 0;
  const sbp  = v.sbp <= 90 ? 3 : v.sbp <= 100 ? 2 : v.sbp <= 110 ? 1 : v.sbp <= 219 ? 0 : 3;
  const hr   = v.hr <= 40 ? 3 : v.hr <= 50 ? 1 : v.hr <= 90 ? 0 : v.hr <= 110 ? 1 : v.hr <= 130 ? 2 : 3;
  const cns  = v.alert ? 0 : 3;
  const temp = v.temp <= 35 ? 3 : v.temp <= 36 ? 1 : v.temp <= 38 ? 0 : v.temp <= 39 ? 1 : 2;
  return rr + spo2 + air + sbp + hr + cns + temp; // 5–6 medium, ≥7 high; any single 3 needs urgent review
}

Many hospitals use their own early-warning chart, so make thresholds configuration, not code, and write unit tests for every boundary value (20 vs 21 breaths, 90 vs 91 mmHg). A scoring bug in a clinical scenario costs credibility fast.

Beyond the score, measure what the objectives asked for: time to first escalation, which bundle steps were done and when, and any step done in an unsafe order.

Step 5: Log actions for the debrief with xAPI

Record each meaningful event as an xAPI statement — actor, verb, object, result, time — and send it to a Learning Record Store (LRS). Because xAPI is a standard, the same log can feed your LMS reports, a debrief timeline and your evaluation study.

{
  "actor": { "account": { "homePage": "https://lms.example.edu", "name": "student-8231" } },
  "verb": { "id": "http://adlnet.gov/expapi/verbs/completed", "display": { "en": "completed" } },
  "object": { "id": "https://sim.example.edu/cases/post-op-sepsis/actions/escalate-sbar" },
  "result": { "extensions": { "https://sim.example.edu/xapi/scenario-minute": 3, "https://sim.example.edu/xapi/news2": 9 } },
  "timestamp": "2026-11-22T09:14:05Z"
}

Use pseudonymous IDs where you can, log decisions rather than raw head or hand movement, and agree retention with your data-protection officer.

Step 6: Design the debrief around the log

The debrief is where the learning happens. A structured model such as PEARLS (reactions, description, analysis, summary) works well, and the action log makes the description and analysis phases concrete: “You escalated at minute 14 — what were you waiting for?”

Show the facilitator a simple timeline per student or group: actions, the score at each point, and missed steps. Keep it on one screen.

Step 7: Validate with clinicians before students see it

  1. Walk-through: the clinical owner plays the case and reads every line of feedback.
  2. Think-aloud: two or three junior clinicians play it and say what they are thinking. You will find wording and realism problems quickly.
  3. Boundary tests: automated tests for every score threshold and transition.
  4. Pilot: one real session with debriefing, then revise.

Step 8: Let faculty write the next cases

Most of a scenario’s long-term value comes from new cases, so plan for authoring from the start:

  • Cases live in data files or a simple form, with validation (no impossible vital signs, every state reachable).
  • A preview mode that jumps to any state, so reviewers do not replay ten minutes to check one line.
  • Version history, so you know which case version a cohort used when you analyse results.

Browser, desktop or VR?

Build the scenario engine once and present it in more than one way. A browser version reaches every student for self-study before placements. A VR version adds presence for a facilitated session in the simulation centre. A multi-user version (usually Unity) supports team training — powerful, but plan it as a second phase. Our Unity or WebXR guide covers the trade-offs.

Mistakes we see most often

  • Graphics first, case logic later. Clinicians forgive simple visuals; they do not forgive wrong physiology.
  • Hard-coded protocol values. They change, and then nobody can update them.
  • Scores without debriefs. A number on its own teaches little.
  • No owner after the grant. Name who maintains cases and fixes bugs — see keeping grant-funded software alive.

Planning a ward, emergency or virtual-patient scenario? Read VR for medical and nursing schools for the bigger picture, or tell us about your case and we’ll sketch the states, scoring and a budget.

WORK WITH US

Planning a project like this?

Gigantic Work builds AI tools and agents, web platforms, research portals, cloud infrastructure and 3D/VR experiences for universities, grant-funded projects, NGOs and SMEs — and hands over everything at the end.