Linkr
Home Resources Tools Documentation Blog Demo
FR
  • What is Linkr?
  • Deployment modes
  • Quick start
  • Local install
  • With Docker
  • Manual install
  • Client-only
  • Your first project
  • Linkr in a clinical data warehouse
  • Workspaces and projects
  • The data pipeline
  • Entities and sharing
  • Versioning and collaboration
  • Overview
  • Projects
  • Wiki
  • Plugins
  • Members and roles
  • Settings
  • Schemas
  • Getting and exploring
  • Mapping
  • Databases
  • Derived sub-databases
  • Data quality
  • Data catalog
  • Build and publish
  • Anonymize
  • SQL script collections
  • ETL pipelines
  • Building and running
  • Generating the scripts
  • Overview
  • Mapping projects
  • Global view
  • Target concepts
  • Mapping editor
  • Suggestions
  • AI agent
  • Evaluation
  • Export
  • Overview
  • Databases
  • Concepts
  • Cohorts
  • Building
  • Results, SQL and report
  • Patient data
  • Pipeline
  • Datasets
  • IDE
  • Web apps
  • Versioning
  • Overview
  • Tabs and widgets
  • Built-in widgets
  • Analysis widgets
  • Control charts (SPC)
  • Surveys and eCRF
  • R and Python code
  • Filters, settings and export
  • Overview
  • Presentation mode
  • Exporting a report
  • Agents
  • MCP server
  • Skills
  • Import and export
  • Git versioning
  • Community catalog
  • Publishing content
  • Production install
  • Configuration
  • Authentication and permissions
  • Files on the server
  • Backup and restore
  • Contributing code
  • Glossary
  • Keyboard shortcuts
  • Release notes
Documentation Project Results, SQL and report

Results, SQL and report

Running a cohort and reading its results — count, attrition as bars or a flowchart, patients, filtered tables, SQL output —, editing its SQL query in portable form or on the source tables, and producing the cohort report as HTML, PDF or Word.

In short

Once the criteria are set, Run query fills the results panel: the count, the rows, the attrition as bars or a flowchart, the patients and the filtered tables. The SQL tab shows the query — portable or written on the source tables — and can be edited by hand. Report turns it into an HTML, PDF or Word summary, with small counts suppressed.

Client Available in client-only mode — runs entirely in the browser, no backend. Backend Available with the FastAPI backend.

Running

Run query executes the query on the cohort’s database. While it computes, the button becomes Stop: an over-broad query can be interrupted without waiting.

The header of the results panel then gives the count — the number of rows at the chosen level —, how long it took, and a CSV button that downloads the rows shown.

Displayed results are capped at 10,000 rows

The count stays exact: only the display is limited, and a banner says so. To work with a larger cohort, freeze it, or take its SQL into an SQL collection.

When a run fails, the panel says so and gives the database’s message. The most frequent case — No query could be built from these criteria — points to a Concept criterion with no concept selected, or a database mapping that does not declare the table for the chosen level.

The result tabs

The right-hand panel has up to six tabs.

demo.linkr.interhop.org

412

results

184ms
All records
2,000
88 excluded
Age >= 18
1,91295.6 %
1,426 excluded
Severe infection
48624.3 %
74 excluded
NOT Deceased
41220.6 %
The results panel: count and CSV at the top, then six tabs. Click each one; in Attrition, switch between Bars and Flowchart.
  • Results — the cohort’s rows: the id at the chosen level, age at admission, start and end dates.
  • Attrition — the count after each criterion, detailed below.
  • Patients — reviewing the members, chart by chart.
  • Tables — every table of the database, filtered on the cohort.
  • SQL output — the raw rows of a hand-written query.
  • Schema — the database explorer, unfiltered, to find a table or column name while writing SQL.

Patients, Tables and SQL output

The Patients tab opens a board of the cohort’s own: the same tabs and widgets as the Patient data page, listing the patients of the last run — there is no need to materialize the cohort. On first opening the board is empty: Add widget lays it out, and it stays attached to the cohort.

The Tables tab lists every table of the database, filtered on the finest id it carries — the cohort’s unit stays, its hospital stays or its patients —, as a derivation would filter it. Clicking a table counts it and shows its first rows; Count all counts them all. A table without an id, such as a care-unit reference, stays Not filtered. It is the quickest way to see what the cohort brings with it: how many measurements, how many prescriptions.

The SQL output tab shows what a query written in the SQL tab returns, whether or not it lists the cohort’s members — SELECT * FROM measurement LIMIT 10 to glance at a table. When a query does not return the expected id column, Linkr opens this tab directly rather than showing only an error.

Tabs that depend on the schema

The Patients and Tables tabs assume the database’s schema is mapped — with a patient table for the former. Without it, they do not appear.

Reading attrition

The Attrition tab gives what every publication asks for: how many patients remain after each criterion, applied in the tree’s order. Each top-level criterion is a step; a group counts as a single step, under its name — hence the value of naming your groups.

Two presentations, chosen at the top right:

Bars

A horizontal funnel.

One bar per step, then the list of counts with, in brackets, what each step removed. The quickest way to spot an over-selective criterion.

Flowchart

The CONSORT layout.

The steps down the middle, from All records to the final cohort, with their share of the starting count; to the side, how many were excluded at each step. The form a paper expects.

It is the most instructive reading on the page. A criterion that drops the count from 4,000 to 40 is almost always a badly written criterion — a concept absent from this database, an unexpected unit of measure — rather than a genuinely rare population.

The order changes the steps, never the result

Moving a criterion changes the intermediate counts and how many each step excludes, not the final count. Order the criteria as you want to present them: most often, inclusion criteria first, exclusions after.

The cohort’s SQL

The Criteria / SQL toggle in the toolbar shows the query your criteria produce. Its first use is to understand, and to check. It can also be edited.

demo.linkr.interhop.org
One row per

The query must return a patient_id column — one row per patient.

Written on the source tables of MIMIC-IV: it runs only on databases of this schema.

1-- One row per patient: its patient_id
2SELECT DISTINCT
3 p.subject_id AS patient_id
4FROM hosp.patients p
5JOIN hosp.admissions a ON a.subject_id = p.subject_id
6WHERE p.anchor_age >= 18
7 AND EXISTS (
8 SELECT 1 FROM hosp.diagnoses_icd d
9 WHERE d.subject_id = p.subject_id
10 AND d.icd_code IN ('A419', 'R6521'))
11 AND p.dod IS NULL
Edit the query below to try it.
The SQL tab. Switch format while nothing is edited; type in the query: the orange dot flags the edit, Report and Materialize grey out. Save sets the Modified badge, Reset goes back to the generated SQL.

The line at the top recalls the query’s contract: it must return a patient_id column — one row per patient (visit_id at hospitalization level, visit_detail_id at unit-stay level).

Portable or on the source tables

The format menu offers two writings of the same query:

Source tables

Written on this database’s tables.

The default, named after the schema — MIMIC-IV (source tables). Readable by anyone who knows the database, but it runs only on databases of that schema.

Linkr (portable)

Written on the linkr_* relations.

linkr_patient, linkr_visit… are the same on every database whose schema is mapped: the query re-runs on another database, in another model.

When the criteria cannot be written on the database’s own tables, only the portable format is offered.

Editing, saving, resetting

Typing in the editor creates an unsaved edit, flagged by an orange dot — in the editor’s bar and on the SQL tab. Save (or Cmd+S) keeps it; Cancel goes back to the last saved text. A saved query carries the Modified badge, and an amber dot on the SQL tab recalls it even while you are on the criteria. Reset goes back to the SQL the criteria generate, Copy puts the query on the clipboard.

A saved query is shown as it was written: the format can no longer be switched until you reset it.

Run query always runs what the editor shows, saved or not. A result obtained from an unsaved edit carries the Unsaved SQL badge: saving keeps that definition, cancelling drops the result. Report and Materialize, for their part, read the saved definition — they stay greyed out while an edit is pending, and hovering says why.

Touching the criteria overwrites edited SQL

Criteria and a hand-written query do not coexist. Changing a criterion after editing the SQL opens Overwrite custom SQL?: confirming regenerates the query from the criteria, and your edits are lost.

Custom SQL reduces attrition to one step

Linkr computes attrition by unrolling the criteria one at a time. With a hand-written query there are no criteria to unroll: the attrition goes straight from the total to the query, and the report writes “Selected by the custom SQL query”. That is the price of SQL’s freedom, to weigh against the chart you will need in order to publish.

The cohort report

Report produces a self-contained summary of the cohort, computed fresh from the database: counts, inclusion flowchart, criteria applied, concepts used and their coverage, characteristics — age at index date, sex, month of inclusion —, data available per event table, stays per care unit, methodology and data source. The dialog’s preview is the exported file itself: what you read is what is sent.

demo.linkr.interhop.org

Cohort report

A self-contained summary of this cohort: counts, flowchart, criteria, characteristics and methodology, computed fresh from the database.

Format
Small-cell threshold

Cohort report

Adult sepsis — alive at discharge

Generated on 2026-09-28 at 10:42

412

Patients

468

Stays

Patients by sex

Male
243 59 %
Female
160 39 %
Unknown
<11

Age distribution (at index date)

18–29
14 3 %
30–44
38 9 %
45–59
97 24 %
60–74
161 39 %
75–89
94 23 %
90+
<11

Methodology

Small-cell rule: any count between 1 and 11 is replaced by <11, and no percentage is given for such counts, so that no small group of patients can be singled out.

-- One row per patient: its patient_id
SELECT DISTINCT
linkr_patient.patient_id
FROM linkr_patient…
The Report dialog. Lower the threshold from 11 to 5, then Recompute: counts under the threshold show again. Click the format to go from HTML to PDF then Word.

Three settings, in the left-hand column:

  • Format — HTML: a single file that opens in any browser; PDF: goes through the browser’s print dialog, where you choose “Save as PDF”; Word: a .docx to rework.
  • Small-cell threshold — any count between 1 and this threshold shows as <N, with no percentage and no bar, so that no small group of patients can be singled out. 11 is the default, the usual rule for health data. A new threshold re-runs the report’s thirty-odd queries: it applies with Recompute, or Enter.
  • Include the SQL query in the methodology — the exact query, so a reviewer can re-run it.

Export downloads the file in the chosen format.

What a report needs

The database must be connected and its schema mapped — without a mapping, the report cannot find the patients. An unsaved SQL edit disables the button: the report describes the saved definition.

The threshold does not replace dissemination rules

Suppressing small counts makes a report shareable with colleagues; it is not anonymization in the regulatory sense. Before any release outside the team, check your institution’s rules.

Going further

  • Building a cohort — the level, the criteria and how they combine.
  • Cohorts — what a cohort is, and what it feeds.
  • Patient data — reviewing the members’ charts, and laying out a board.
  • Schemas — the mapping the portable SQL relies on.
  • Derived sub-databases — drawing a new database from a cohort’s members.
PreviousBuildingNextPatient data

Product

  • Home
  • Demo

Resources

  • Documentation
  • Resources
  • Tools
  • Blog

Community

  • Framagit source code
  • Github source code

About

  • InterHop.org
  • Contact

2021–2026 InterHop — CC BY-NC-SA 4.0 (site) · GPLv3 (software)