> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emtelligent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emtelligent.com/_mcp/server.

# Sleep Apnea

## Synopsis

This query searches mentions of Sleep Apnea in patient records by querying for a set of related SNOMED concepts.

## Processing Requirements

This query assumes that at least the following `emtellipro-db-client` processing options were enabled:

* `--feature snomed-ontology`
* `--store-sections-and-sentences`

For this query, Clinical notes were processed with the following document type:

* `--category Clinical`
* `--subcategory generic` (or more specific report types such as Discharge Summary, SOAP Note, CCD as applicable)

## Clinical Context

Sleep apnea is a disorder characterized by intermittent periods of apnea (arrest of respiration) during sleep. However, in day-to-day clinical practice, this condition can be referred to by multiple different terms such as `obstructive sleep apnea`, `sleep apnea`, or it may be written that the patient has `PND` or `paroxysmal nocturnal dyspnea`, or there may be no mention of `sleep apnea` and it may just be written that the patient uses a continuous positive airway pressure (CPAP) machine at night. Thus, we must look for multiple concepts related to the same (or similar) clinical entities.

* `78275009|Obstructive sleep apnea syndrome (disorder)|`
* `73430006|Sleep apnea (disorder)|`
* `55442000|Paroxysmal nocturnal dyspnea (finding)|`
* `62744007|Orthopnea (finding)|`
* `47545007|Continuous positive airway pressure ventilation treatment (regime/therapy)|`

This type of query can easily be modified to retrieve occurrences of other clinical entities by identifying a subset of associated concepts to use in place of the list of SNOMED concept IDs used in this sample query.

## SQL query

#### SQL

```sql
-- Multi-concept query for sleep apnea without experiencer relation
SELECT c.concept_id  As concept_id,
    c.description AS concept_description,
    fe.section_name,
    fe.text      AS annotated_text,
    sl.text       AS sentence
    FROM entity e
            JOIN foundentity fe ON fe.id = e.entity_id AND e.type_ = 'found' -- IMPORTANT: e.type_ = 'found' is required
            JOIN foundentityconcept fec ON fe.id = fec.found_entity_id
            JOIN concept c ON c.concept_id = fec.concept_id AND c.ontology = fec.concept_ontology
            JOIN foundentitylocation fel ON fe.id = fel.found_entity_id
            JOIN location l
                ON fel.location_id = l.id AND l.type_ = 'sentence' -- IMPORTANT: check that location type is 'sentence'
            JOIN sentencelocation sl ON sl.id = l.location_id
    WHERE c.ontology = 'snomed'
    AND c.concept_id IN ('78275009', '73430006', '55442000', '62744007', '47545007') -- REPLACE: with target concepts
    AND fe.polarity = 'asserted'
    AND fe.uncertainty = 'certain';
```

#### Snowflake

```sql
-- Multi-concept query for sleep apnea without experiencer relation
WITH distinct_concepts AS (SELECT DISTINCT * FROM concept )
SELECT c.concept_id  As concept_id,
c.description AS concept_description,
fe.section_name,
fe.text      AS annotated_text,
sl.text       AS sentence
FROM entity e
        JOIN foundentity fe ON fe.id = e.entity_id AND e.type_ = 'found' -- IMPORTANT: e.type_ = 'found' is required
        JOIN foundentityconcept fec ON fe.id = fec.found_entity_id
        JOIN distinct_concepts c ON c.concept_id = fec.concept_id AND c.ontology = fec.concept_ontology
        JOIN foundentitylocation fel ON fe.id = fel.found_entity_id
        JOIN location l
                ON fel.location_id = l.id AND l.type_ = 'sentence' -- IMPORTANT: check that location type is 'sentence'
        JOIN sentencelocation sl ON sl.id = l.location_id
WHERE c.ontology = 'snomed'
AND c.concept_id IN ('78275009', '73430006', '55442000', '62744007', '47545007') -- REPLACE: with target concepts
AND fe.polarity = 'asserted'
AND fe.uncertainty = 'certain';
```

| concept_id | concept_description                                                        | section_name         | annotated_text | sentence                                                                                                                                                                                   |
| ---------- | -------------------------------------------------------------------------- | -------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | SUBJECTIVE           | CPAP           | As noted, the patient is not snoring on CPAP.                                                                                                                                              |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | ASSESSMENT           | CPAP           | I recommend he continues CPAP indefinitely.                                                                                                                                                |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | ASSESSMENT           | CPAP           | If this continues, we can consider a new sleep study to determine whether he still needs CPAP.                                                                                             |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | SUBJECTIVE           | CPAP           | Mr. Sidney is a 50-year-old man who returns to discuss his still moderate-to- sleep apnea, and to review his response to CPAP.                                                             |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | SUBJECTIVE           | CPAP           | He was found to have moderate-to-severe sleep apnea, and was treated with nasal CPAP for the past few months.                                                                              |
| 47545007   | Continuous positive airway pressure ventilation treatment (regime/therapy) | SUBJECTIVE           | CPAP           | He estimates that he uses the CPAP approximately 4-6 nights per week, and on occasion takes it off and does not replace the mask when he awakens spontaneously in the middle of the night. |
| 73430006   | Sleep apnea (disorder)                                                     | SUBJECTIVE           | sleep apnea    | Mr. Sidney is a 50-year-old man who returns to discuss his still moderate-to- sleep apnea, and to review his response to CPAP.                                                             |
| 73430006   | Sleep apnea (disorder)                                                     | SUBJECTIVE           | sleep apnea    | He was found to have moderate-to-severe sleep apnea, and was treated with nasal CPAP for the past few months.                                                                              |
| 73430006   | Sleep apnea (disorder)                                                     | ASSESSMENT           | sleep apnea    | Moderate-to-severe sleep apnea.                                                                                                                                                            |
| 78275009   | Obstructive sleep apnea syndrome (disorder)                                | PAST MEDICAL HISTORY | OSA            | OSA                                                                                                                                                                                        |

## Next steps

The list of sleep apnea and related mentions can be further filtered to return only those that pertain to the patient. See [Sleep Apnea Experienced by Patients](/nlp/database/cookbook/concept-queries/multi-concept/sleep-apnea-experiencer).

## Related links

* [Entity-level Tables](/nlp/database/schema/core/entity-tables)