Build Medical Software From Evidence to Software Lesson 3 of 5 intermediate 8 min read

Make the Clinical Logic Visible Before You Code

Translate a clinical protocol into explicit inputs, branches, thresholds, exceptions, and failure states before choosing a programming language.

In This Lesson

Read with a defined objective.

View the complete course

Learning objectives

  • Build a logic sheet that another clinician can audit without reading code.
  • Translate clinical rules into plain language and pseudocode.
  • Apply the boundary triplet to numerical thresholds.

Prerequisites

  • A protocol map from Lesson 2.

Build Medical Software From Evidence to Software

Listen to this post

Make the Clinical Logic Visible Before You Code

0:00 / 0:00
A clinical guideline unfolding into an inspectable decision tree with thresholds, branches, and exception paths
On this page6 sections

An SMFM delivery-timing table can fit on one page. The logic inside it does not fit into one sentence.

Gestational age matters. Doppler findings matter. Associated conditions matter. Missing information matters. The edge between two recommendations matters most because that is where an innocent comparison operator can change care.

Before code, there must be an inspectable model of the clinical reasoning.

The Logic Sheet

Use a logic sheet to turn prose into executable structure. It has five parts:

  1. Inputs.
  2. Normalized values and units.
  3. Decision rules.
  4. Outputs.
  5. Exceptions and failure states.

This is the bridge between medicine and software. It is also the first artifact another clinician can review without reading code.

Inputs Are Clinical Claims

An input field is not merely a box on a screen. It asserts that a specific patient fact is necessary, available, and sufficiently reliable to influence the output.

Name the type and unit. Define allowed values. State whether the field is required. Decide what missing means.

gestationalAge = 32 is ambiguous. Thirty-two weeks is not the same as 32 days, 32 weeks and 0 days, or a string a browser cannot parse. Clinical software should not infer the unit from context when the consequence of inference is a recommendation.

Branches Need Plain Language First

Write every rule as a clinical sentence before writing pseudocode.

For example:

If the patient belongs to the intended population, all required information is present, and the threshold condition is met, return the associated recommendation and its source.

Then make the structure visible:

IF population_is_eligible is false
  RETURN outside_protocol

IF required_data_is_missing is true
  RETURN insufficient_information

IF threshold_condition is true
  RETURN recommendation_with_source

RETURN alternate_recommendation_with_source

The early exits matter. A tool that cannot say “outside protocol” or “insufficient information” will eventually produce an answer where it should produce a boundary.

Test the Edges on Paper

The typical case proves very little. Most defective clinical calculators work for the example copied from the guideline.

Test the point just below a threshold, the threshold itself, and the point just above it. Test a missing value. Test an impossible value. Test a patient excluded by the source protocol. Test two conditions that lead to competing branches.

I call this the boundary triplet: below, at, and above. It is the smallest useful test of whether a threshold has been translated faithfully.

This extends the three-check standard: test the ordinary behavior, the boundary, and the failure state.

Keep Exceptions Visible

Exceptions should not disappear into a final else block.

Name them. Give them their own output. Explain why the ordinary recommendation does not apply. If physician review is required, state what needs review rather than using a generic warning banner.

Explainability begins before the interface. The logic itself must be explainable.

Your Exercise

Take one section of the protocol map from the previous lesson. Create a logic sheet.

List the inputs and units. Write each decision rule in plain clinical language. Convert the rules into pseudocode. Add the boundary triplet for every numerical threshold. Finish with at least two explicit non-answer states.

If another physician cannot audit the logic sheet, a programmer should not compile it.

Share this article

Share X / Twitter Bluesky LinkedIn

Related articles

A precise clinical protocol grid bending around a complex patient silhouette without enclosing it
Clinical Software

A Protocol Is a Memory System, Not a Patient

Clinical protocols reduce avoidable variation, but software must preserve their population boundaries, exceptions, provenance, and judgment points.

· 7 min read
clinical protocolsclinical decision supportevidence-based medicine
Clinical research papers narrowing toward a bedside monitor while uncertainty remains visible around the patient
Clinical Software

Evidence Is Not Yet a Clinical Instruction

Clinical evidence describes populations. Physician-developers must preserve its limits before translating it into protocol logic or software.

· 7 min read
evidence-based medicineclinical protocolsclinical software
A simple seven-day tracking sheet on a clinician's desk beside a closed laptop, end of week reflection setting
AI in Medicine

The One-Week Ambient Challenge

A seven-day self-audit for physicians using an approved ambient documentation system, built around three questions that matter more than words per minute.

· 7 min read
ambient aiclinical documentationai in medicine
Chukwuma Onyeije, MD, FACOG

Chukwuma Onyeije, MD, FACOG

Maternal-Fetal Medicine Specialist

MFM specialist at Atlanta Perinatal Associates. Founder of CodeCraftMD and OpenMFM.org. I write about building physician-owned AI tools, clinical software, and the case for doctors who code.