# Variable naming guidelines

How to name a new concept (variable) in the `corr_v1` taxonomy. Propose the name when
you suggest the concept in a
[GitHub issue](https://github.com/CUB-CORR/corr_vars/issues) (see
{doc}`../contributing_variables`), and use it when the concept is created in the
Concepts API.

## General rules

1. **Follow existing names**: orient the name on variables that already exist
   (`corr concepts search`, see {doc}`../cli`).
2. **snake_case**: all variable names are in snake_case.
3. **Lowercase only**: no capitals (`dx_hypertension`, not `Dx_Hypertension`).
4. **Descriptive and concise**: balance clarity and brevity (`dx_hypertension`, not
   `dx_high_blood_pressure_diagnosis`).
5. **Avoid redundancy**: leave out unnecessary or overlapping words (`blood_potassium`, not
   `blood_potassium_level`).
6. **Structure**: `<location/group>_<entity>_<source>_<timeframe>_<aggregation>`

## Prefixes for grouping variables

1. Lab measurements are named by specimen (e.g. `blood_potassium`, `blood_glucose`):
   1. `blood_[component]` → central/poc
   2. `blood_[component]_[central/poc]_arterial/venous`
   3. `urine_[component]`
2. `dx_`: diagnoses (e.g. `dx_hypertension`, `dx_heart_failure`).
   1. Structure: `dx_[diagnosis_name]_[recency/certainty]`
3. `hx_`: diagnoses prior to the index stay (e.g. `hx_kidney_txa`).
4. `med_`: medications (e.g. `med_antibiotics_any`, `med_insulin_adm`).
5. `vent_`: ventilation variables (e.g. `vent_crs_static`).
6. `score_`: medical scores (e.g. `score_apache2`).

## Suffixes for context and scope

Often used project-specific.

1. `_any`: any occurrence. Example: `dx_hypertension_any` (any instance of hypertension).
2. `_adm` / `_disc`: documented specifically at admission or discharge. Examples:
   `smoking_status_adm` (smoking status documented at admission), `blood_potassium_adm`
   (potassium level at admission).
3. `_iv` / `_po`: route of medication administration.
4. `_txa`: transplant procedures.
5. `_first` / `_last` / `_closest`
6. `_Xprior` / `_Xpost` / `_XpostOp` / `_XpostICUdisc` / `_XpostHospdisc`, where X can be
   min, h or d.
7. `_id`: unique identification variables.
8. `_min` / `_max` / `_p50` / `_mean`
