Learn R Programming

⚠️There's a newer version (1.0.2) of this package.Take me there.

LabTNS CPSS Package

This R package implements a pipeline to process clinical episode data, identify chronic pathologies, and calculate frailty and comorbidity scores based on patient diagnosis codes.


Overview

The pipeline performs the following steps:

  1. Setup environment
    Load and install required R packages and source supporting scripts.

  2. Data Preparation
    Clean and format input episode data based on user-specified column mappings.

  3. Chronic Pathologies Identification
    Apply algorithms to detect and propagate chronic conditions within episodes.

  4. Frailty Calculation
    Calculate frailty indices from updated episode data.

  5. Comorbidity and Frailty Summary
    Combine frailty and comorbidity measures into final result tables.


Usage

Installation

You can either clone the repository or download the ZIP file.

git clone https://github.com/bayaniazadeh/LabTNSCPSSPackage.git
cd LabTNSCPSSPackage

Running the pipeline

Running the pipeline

  1. Place your input CSV in LABTNSCPSS_Data/, e.g., LABTNSCPSS_Data/testpackage.csv

  2. Go to your directory that the LabTNSCPSSPackage folder exists and run the file LabTNSCPSSPackage.Rproj,

then open Frailty_Comorbidity_Pipeline.R in your open R studio.

In the Frailty_Comorbidity_Pipeline.R code edit these information:

  • The input dataset should be a CSV file with episode-level patient data.
  • Required columns (default mapping):
    • Patient_id — patient ID
    • ICD — ICD coding system diagnosis codes
    • start_date — episode start date
    • end_date — episode end date
    • episode_id — unique episode identifier

You can customize these column names by modifying the col_mapping list in the pipeline.

  1. Run the pipeline from your R session line by line:
source("./LABTNSCPSS_Code/setup_package.R")      # Load/install packages
source("./LABTNSCPSS_Code/source_scripts.R")     # Load pipeline functions

coding_system <- get_coding_system()

Here you should select the ICD vesion of according to your data: ICD-10-CA, ICD-10-CM, ICD-11, write it in the console part and press enter.

  1. Run the rest of the code line by line.

  2. Finally you can find the generated files at LABTNSCPSS_Data/

Important resources

In the folder data/ you can find all the mapping files and categorizations in ".rda"" format. To be able to explore the mappings in your R studio browser use this code, and replace "file_name" with your desired data file :

df <- as.data.frame(file_name)
View(df)

Copy Link

Version

Install

install.packages('LABTNSCPSS')

Monthly Downloads

204

Version

1.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Azadeh Bayani

Last Published

February 20th, 2026

Functions in LABTNSCPSS (1.0)

australia10

Australian mortality data, 2010
run_pipeline

Run the LABTNSCPSS comorbidity + frailty pipeline
score

Compute (weighted) comorbidity scores
ICD11_categorisation

ICD11_categorisation
LABTNSCPSS-package

LABTNSCPSS: Calculation of Comorbidity and Frailty Scores
icd10_2011

ICD-10 Diagnostic Codes, 2011 Version
nhds2010

Adult same-day discharges, 2010
Frailty_ICD10CM

Frailty_ICD10CM
get_coding_system

Choose a coding system
LABTNSCPSS

LABTNSCPSS: Tools for comorbidity and frailty scoring
comorbidity

Comorbidity mapping
Code_Categories

Code_Categories
icd10_2009

ICD-10 Diagnostic Codes, 2009 Version
ICD10CA_categorisation

ICD10CA_categorisation
ICD10CM_categorisation

ICD10CM_categorisation
ICD11_Basal_Codes

ICD11_Basal_Codes
Frailty_Comorbidity_Mapping

Frailty_Comorbidity_Mapping
icd10cm_2017

ICD-10-CM Diagnostic Codes, 2017 Version
icd10cm_2018

ICD-10-CM Diagnostic Codes, 2018 Version
Frailty_mapping

Frailty_mapping
icd10cm_2022

ICD-10-CM Diagnostic Codes, 2022 Version
Basal_Codes

Basal_Codes
Frailty_ICD11

Frailty_ICD11
icd9_2015

ICD-9 Diagnostic Codes, 2015 Version (v32)
ICD10CM_Basal_Codes

ICD10CM_Basal_Codes