Coverage for src/lumen/fhir/resource_types.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-08-31 18:46 +0000

1""" 

2This module defines the set of all concrete FHIR R4B resource types. 

3It loads and caches the valid names from the official schema to support resource type validation. 

4""" 

5 

6from __future__ import annotations 

7 

8import json 

9from functools import lru_cache 

10from pathlib import Path 

11 

12_SCHEMA_PATH = Path(__file__).parent / "data" / "r4b" / "fhir.schema.json" 

13 

14 

15@lru_cache(maxsize=1) 

16def known_resource_types() -> frozenset[str]: 

17 """Return the set of concrete R4B resource type names (e.g. ``Patient``).""" 

18 schema = json.loads(_SCHEMA_PATH.read_text()) 

19 mapping = schema["discriminator"]["mapping"] 

20 return frozenset(mapping.keys())