Tutorial

Offline Hepatology Cirrhosis & Portal Hypertension Risk Predictor

Difficulty: Advanced Time: 25 min read

Introduction

Chronic liver disease and cirrhosis management requires continuous tracking of liver stiffness, portal hypertension decompensation risks, and serial MELD-Na (Model for End-Stage Liver Disease) scores to predict esophageal variceal bleeding and hepatic encephalopathy. In this cookbook, we introduce HepatoTrack-GNN-v1, an offline graph neural network that processes liver transient elastography (FibroScan) measurements, abdominal Doppler ultrasound waveforms, and hepatic panel serology to forecast 6-month cirrhosis decompensation trajectories on edge clinic hardware.

Prerequisites

  • Python 3.9+
  • PyTorch & pandas
  • openphr-cli
  • Local transient elastography (kPa), Doppler velocity metrics, and liver panel serology (bilirubin, INR, creatinine, sodium)

Step 1: Ingest Local Elastography & Hepatic Serology

Load structured liver stiffness measurements along with portal vein velocity metrics and serial MELD-Na laboratory parameters.

import json
import torch

# Load local elastography & liver panel lab telemetry
with open('hepatology_panel.json', 'r') as f:
    hep_data = json.load(f)

# Compute MELD-Na score baseline
# MELD-Na = MELD + 1.32 * (137 - Na) - [0.033 * MELD * (137 - Na)]
bilirubin = hep_data['bilirubin'] # mg/dL
inr = hep_data['inr']
creatinine = hep_data['creatinine']
sodium = hep_data['sodium'] # mEq/L

features = torch.tensor([hep_data['liver_stiffness_kpa'], bilirubin, inr, creatinine, sodium], dtype=torch.float32).unsqueeze(0)
print("Hepatology feature vector initialized:", features.shape)

Step 2: Execute Local Cirrhosis Trajectory Pipeline

Run the openphr-cli pipeline to evaluate 6-month decompensation probabilities and portal hypertension progression risks:

openphr-cli run hepatotrack-gnn-v1 \
    --input-elastography ./hepatology_panel.json \
    --doppler ./doppler_ultrasound.json \
    --output-decompensation-risk ./cirrhosis_trajectory.json

Expected Outcome

A structured 6-month risk assessment of portal hypertension progression, variceal screening recommendations, and decompensation forecasting computed locally with complete patient data privacy.