What makes a medical case “complex” for AI research?
Complex cases are common in medical communication, but must be made concrete in machine learning datasets. For image classification, the difficulty may be small lesions, vague signs, or the coexistence of multiple diseases; for diagnostic reasoning, the difficulty may be multiple differential diagnoses, disease course evolution, and inconsistent testing; for treatment path prediction, the difficulty may be comorbidities, interdisciplinary care, or differences in treatment response. Long hospital stay, multiple diagnoses, and multiple consultations are only proxy indicators and cannot replace the definition of clinical difficulty of the task itself.
If the target tasks are not defined first, sampling based on "complexity" can easily create conceptual confusion: some cases are complex due to serious illness, some are complex due to a large number of documents, and some are simply information systems with high integrity. Models trained may learn to predict hospital workflow, document length, or transfer patterns rather than target disease phenotypes. The first step should be to form a case complexity framework that lists the target tasks, clinical decision points, available inputs, output labels, applicable populations, and failure scenarios that are expected to be covered.
The attachment proposes to construct high-difficulty files using fields such as diagnosis revision, number of consultation departments, length of stay, ICU/CCU, historical visits, number of discharge diagnoses, critical illness notification, and non-cure outcome, and prefers surgical cases in which preoperative diagnosis and postoperative pathology are inconsistent. These indicators are suitable as calculable sampling clues and have the advantage of being auditable and traceable; however, they are only screening agents in the project specifications and are not a recognized disease severity scale, nor can it be inferred that the selected cases represent "all complex cases in the real world."
Therefore, “complex cases” can be broken down into several dimensions: clinical uncertainty, disease duration, comorbidity burden, multidisciplinary involvement, treatment intensity, differences in imaging or pathological interpretation, data completeness, and outcome changes. Each dimension is recorded separately, allowing patients to be high on some dimensions and low on others. Comprehensive stratification can aid sampling but should not overwrite the original indicators. Model studies can also report results by dimension to avoid an overall score masking the heterogeneity of complex cases.
Define filtering indicators as reviewable variables
Each screening variable requires operational definition. Number of diagnosis revisions: Count the revisions or supplementary diagnoses in which document types, count by patient or visit, and how to remove duplicates from repeated issuances. Number of consultation departments: Based on formal consultation application, consultation record or document author department, whether transferred departments are counted twice. Length of hospitalization: use natural days, hours or difference in admission and discharge dates, and how to handle cross-hospital transfers. Number of historical medical visits: Limit the time window and the range of past systems that can be associated to avoid misjudgment that no historical data means no previous medical visits.
ICU/CCU admission needs to clearly define the actual bed record, transfer-in and transfer-out time, and short-term observation; the notice of serious or critical illness must distinguish between formal notification documents and disease course descriptions; the discharge diagnosis number must indicate whether it includes symptoms, complications, and repeated coding; the discharge outcome of "not cured" needs to clarify the original enumeration and mapping rules. Variable values should be linked to source or HIS fields and record extraction time, rule version, verifiers, and exception handling. This way, independent reviewers can recalculate the screening results.
For each threshold, it is recommended to save three or multiple states: satisfied, not satisfied, and unable to determine; and also record the reasons for missing, unavailable data sources, incomplete time windows, or failed document recognition."No ICU records found" cannot be equated with "patient had no ICU experience" unless the data source coverage is complete. For cases near the threshold, manual review can avoid misclassification due to date accuracy, duplicate paperwork, or coding errors. The threshold itself needs to be frozen before sampling; if adjusted midway, the version and the impact of each rule change on the number of queues will be retained.
From difficult sampling to representative cohorts: two goals cannot be confused
Enriching hard examples has clear value: improving model training coverage when facing edge cases, discovering errors not seen in regular datasets, and assessing robustness to rare subpopulations or cross-modal contradictions. However, high-difficulty cohorts and target deployment populations often have different case spectrums. If the test set has too many ICU, multi-morbidity, or complex surgical cases, the overall performance may not be representative of ordinary clinical use; if the training set is over-enriched, the model probabilities and thresholds may not be suitable for the true prevalence.
At least three queues should be distinguished. The first is the representative queue, which is used to estimate the overall performance of the target scenario; the second is the challenge queue, which specifically covers complex, rare, or high-risk situations; and the third is the development queue, which is used for training or algorithm parameter tuning. They may share some definitions but differ in purpose, sampling ratios, and reporting methods. Passing results on challenge sets cannot replace representative validation; representative average metrics cannot mask failures in difficult subgroups.
To estimate the overall performance of the deployed population from enriched samples, it is necessary to understand the sampling probability, the target population distribution, and consider weighting or recalibration; but this relies on a reasonable sampling mechanism and sufficient target population information. We cannot simply use “20% for high difficulty level and 80% for normal level” to infer the natural occurrence rate. If the 200/800 stratification in the attachment is only a procurement ratio, it is a delivery component requirement, not a clinical epidemiological estimate. Research reports should clearly distinguish the sample design from the target population.
For the model, the representativeness of difficult samples is not only reflected in the condition indicators, but also in the site, equipment, age, gender, language, referral method, document quality and available modalities. If complex cases come from only a few large hospitals, a certain department, or a specific facility, the model may treat institutional characteristics as difficulty. Stratified sampling by center and department, followed by distribution inspection for each dimension, can help detect such biases.
Pathology and preoperative diagnosis are inconsistent: retaining differences is more valuable than forcing unification
The difference between preoperative working diagnosis and postoperative pathological diagnosis is important information in the clinical diagnosis process. It may result from atypical imaging findings, limited sampling range, lesion heterogeneity, intraoperative findings, pathological review, or changes in diagnostic standard versions. The difference does not automatically mean that preoperative judgment was wrong, nor does it automatically mean that pathology must be the perfect gold standard. For training data, directly covering preoperative diagnosis with pathological conclusions will cause the model to be incorrectly asked to answer the "final known answer", while the actual task may be to perform risk estimation based on limited evidence before surgery.
In the data model, the source and time of diagnosis should be retained: preoperative imaging impression, clinical working diagnosis, intraoperative findings, initial pathology, immunohistochemistry supplement, expert review, final diagnosis and their respective evidence. Differential type labels can be established, such as changes in diagnostic categories, stage changes, changes in benign and malignant judgments, mismatched lesion locations, insufficient sampling or uncertainty; labels are confirmed by a qualified medical review process and retain consistency and dispute status. The label of the model depends on the target problem and one final result should not be used for all tasks.
When the sample uses “preoperative and postoperative inconsistency” as the priority screening condition, it is necessary to check whether this condition increases selection bias. People who undergo surgery and receive pathological results are often different from those who do not have surgery; the location of the lesion, patient risk, hospital capacity, and physician decision-making all influence whether to operate. If the research target is preoperative imaging models, studying cases with surgical pathology alone may result in validation bias. Such samples can be used as a specialized challenge subset, and a separate validation set closer to the target user population can be created, indicating that the pathology label only covers a specific patient group.
How label uncertainty and expert review enter data design
Case complexity often means the labels themselves are more uncertain. Different doctors may have different opinions on the stage of disease, lesion boundaries, severity, or diagnostic category; a pathological conclusion may also be modified after additional staining. A single label file hides this uncertainty. For key targets, it is recommended to retain the initial annotations, review annotations, verdict conclusions, reasons and corresponding evidence. If necessary, retain the independent judgment and confidence of multiple annotators instead of only saving one final value.
The quality control of medical annotation can use stratified sampling: basic cases are used to monitor routine consistency; complex cases increase the proportion of independent annotation by two people; divergent cases are handed over to senior experts for adjudication; random blind testing is used to evaluate repeatability and potential drift. The indicator should not only be the overall agreement rate, but also analyze the category imbalance, boundary categories and different departments separately. Statistics such as Cohen’s kappa and Krippendorff’s alpha can be supplemented, but consistent statistics do not prove clinical validity; they need to be reviewed in conjunction with clinical definitions and source evidence.
Audit roles must also be distinguished. Annotators are responsible for extracting or interpreting according to specifications; reviewers check definition applications and source evidence; adjudicators resolve disputes; and data governance leaders confirm permissions and usage boundaries. Each role should have qualifications, scope of tasks, and a record of changes. For free text tags, the mapping between original text fragments and structured tags should be saved; for image or pathology annotations, the annotation tools, coordinates, versions, fields of view or slice identifiers should be retained for review.
How to evaluate complex case models without being misled by a single AUROC
Complex queue evaluation cannot report only one AUROC. If positive cases are rare, AUPRC, sensitivity under fixed clinical thresholds, and positive predictive value may be more direct; if the model outputs risk probability, it is necessary to look at the calibration intercept, calibration slope, group calibration, and performance near the clinical threshold; if it is a multi-class or multi-label task, category-level indicators and confusion matrices should also be reported. Results need to be given confidence intervals and explain how patient-level clustering or duplicate examinations are handled.
Overall average performance should be presented simultaneously with the tiered results. It can be analyzed by complexity dimension, department, site, modal completeness, age range, gender, data year and device type. Report sample size, number of positives, missingness rate, and uncertainty for each subgroup to avoid drawing strong conclusions from very small samples. External validation should also evaluate differences in labeling processes and data collection processes; when performance degrades, distinguish between case spectrum changes, data drift, label definition changes, and insufficient model generalization.
model explanation should not rely solely on attention heat maps or importance rankings. For challenge samples, error case backtracking should be done: Did the model use diagnoses after the prediction time point? Treat hospital or device text as a shortcut? Is the image focused on task-relevant areas? Is evidence regarding the course of the disease cited that contradicts the conclusion? These issues need to be reviewed by clinical experts and engineers, and the failure types are converted into the next round of data and evaluation improvement items.
Turn procurement specifications into a scientifically defined cohort plan
can be made into an "auditable complexity portrait table": patient identification, scope of consultation, original values of each indicator, calculation basis, whether the threshold is met, reasons for failure to determine, location of evidence, and final stratification. During the acceptance check, the indicator table and the original text of the medical record are randomly checked to not only verify whether the statistics meet the conditions, but also to verify whether the original text supports the results, whether the statistical windows are consistent, and whether there are repeated calculations. The department and modality distribution of cases should be compared with the target application scenarios at the same time.
A more stable design sequence is: first define clinical tasks and target populations; then determine complexity dimensions and operational variables; freeze the rules and verify them on a small sample; evaluate the selected sites, departments, modalities, and population distribution; separate representative cohorts and challenge cohorts; then perform patient-level training/validation/test segmentation; and finally conduct independent external evaluation and report by tiers. Each step should leave a reproducible version. Threshold selection should not only consider data availability, but also ensure that it is consistent with the scientific question.
Langhui can assist in establishing medical data field mapping, screening rules, medical labeling specifications, blind testing and review processes, data cards and model evaluation frameworks within the scope of project authorization. The specific scale, disease types, institutions, expert allocation and acceptance indicators are subject to the contract and implementation plan confirmed by both parties. The real value of complex cases is not to write "difficulty" as a marketing label, but to make it observable, reviewable, and improveable for which groups and under which information conditions the model is reliable or unreliable.
The case cohort also examines the difference between “visible cases” and “target population”. Single-center medical records often only record events that occurred in the hospital, and diagnoses, past medications, and out-of-hospital outcomes may not be visible; difficult patients are more likely to be transferred to higher-level hospitals. If the research goal is to assist decision-making in a certain type of hospital, the target population should be limited to that scenario; if it is to be claimed to be applicable to a wider population, it needs to cover across centers and explain the referral mechanism. The scope of data sources determines the questions that the model can answer. The completeness of records cannot be mistaken for the completeness of patient health facts.
Complexity metrics may be highly correlated with each other. Severity, length of stay, consultation and discharge diagnoses may all be driven by the same illness process or hospital process, and adding them directly will result in double weighting. The marginal distribution, correlation and co-occurrence pattern of each indicator can be reported first, and then a stratified strategy can be formed based on clinical expert opinions and statistical analysis. Threshold sensitivity analysis is also important: does the cohort composition change significantly after slightly adjusting the length-of-stay threshold? If the change is large, it means that stratification depends on the threshold, and this should be prompted when reporting.
In order to reduce selection bias, it is recommended to retain the denominator before screening, the number of exclusions at each step, and the reasons. The screening flow chart should illustrate how many cases were lost at each stage from the source data pool to rule-compliant, linkable, label-complete, and final sampling. If only patients with complete information end up in the queue, the model may be more suitable for patients with standardized records in the information system, rather than in a more chaotic real-world environment. You can create a separate "data incomplete challenge set" to test the model's behavior when some fields or modes are missing, and clarify which missing inputs will trigger rejection or manual review.
When screening complex cases, research teams can pre-register cohort designs and major subgroups, especially when stratification rules may affect test results. Pre-fixing difficult definitions, thresholds, and endpoints reduces the risk of adjusting "hard cases" after seeing the model results. If rules must be iterated, they should be explored using development data and then frozen in definitions in independent validation data. Changes in indicator thresholds and labeling rules must be written into the plan version, and the sample structure before and after the change should be reported. For procurement-based data projects, this also helps to separate acceptance compliance from scientific research conclusions: meeting the contract ratio means that the delivery meets the agreement, but does not mean that clinical performance has been proven.
Hierarchical evaluation can be used when modeling to identify whether the model is only effective on easy subsets. For example, observe the groups of clear and controversial labels, single-modality and multi-modality complete, initial diagnosis and follow-up diagnosis, routine department and interdisciplinary consultation, consistent and inconsistent pathology, etc. Differences between groups cannot only be explained by model bias, but may also arise from differences in sample size, disease spectrum, and label quality; therefore, original sample size, feature distribution, and confidence intervals need to be reported in conjunction with clinical review. If there are too few data for a certain subgroup, it should be marked as insufficient evidence rather than packaging the unstable point estimate as a conclusion.
method boundaries and data sources
This article summarizes the key points of data engineering and cohort design based on the medical data fields and repurchase requirement documents provided by users, and discusses it in conjunction with public peer-reviewed research, technical standards, and regulatory/reporting guidelines. The fields, filter thresholds, and quantities in the attachment are examples of requirement specifications and do not prove that the data has been procured, delivered, or has passed model validation. The algorithms and processes in this article are used for scientific research and engineering design discussions and do not constitute medical diagnosis or treatment recommendations. Specific projects are subject to authorizations, data cards, contracts, and ethics/compliance reviews.
References and Technical Standards
- TRIPOD+AI statement: updated guidance for reporting clinical prediction models that use regression or machine learning methods, BMJ (2024)
- DECIDE-AI: reporting guideline for early-stage clinical evaluation of AI decision support systems, Nature Medicine (2022)
- External validation of clinical prediction models, BMJ (2024)
- Good Machine Learning Practice for Medical Device Development, FDA / IMDRF
