Parent Keyword Validation
The Parent keyword validation ensures that Profile definitions reference valid base resources or profiles according to the FHIR Shorthand specification.
Implementation
Section titled “Implementation”Components
Section titled “Components”-
FHIR Resource Registry - Comprehensive lists of FHIR R4 and R5 base resources (~150 each)
- Canonical URL validation
- External IG profile detection (USCore, mCODE, etc.)
-
Profile Validation - Enhanced validation logic with appropriate severity levels
- Multi-tier validation logic
- Support for profile-to-profile inheritance
Validation Logic
Section titled “Validation Logic”The validation follows a layered approach:
1. Is it a FHIR base resource? (Patient, Observation, etc.) → ✅ Valid
2. Is it defined locally in the symbol table or resources list? → ✅ Valid
3. Is it a valid canonical URL? → ✅ Valid (if format is correct) → ❌ Error (if format is invalid)
4. Does it match a known external IG pattern? (USCore*, mcode-*) → ⚠️ Warning (cannot verify locally)
5. Otherwise → ⚠️ Warning (unknown, might be typo)
Supported Parent Formats
Section titled “Supported Parent Formats”1. FHIR Base Resources
Section titled “1. FHIR Base Resources”Profile: MyPatientProfileParent: Patient
2. Locally-Defined Profiles
Section titled “2. Locally-Defined Profiles”Profile: BaseProfileParent: Patient
Profile: DerivedProfileParent: BaseProfile // References profile defined above
3. Canonical URLs
Section titled “3. Canonical URLs”Profile: CustomProfileParent: http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient
4. External IG Profiles
Section titled “4. External IG Profiles”Profile: ExtendedUSCoreParent: USCorePatientProfile // Warning: cannot verify locally
Diagnostic Messages
Section titled “Diagnostic Messages”Valid Cases (No Diagnostic)
Section titled “Valid Cases (No Diagnostic)”- Parent is a FHIR R4/R5 base resource
- Parent is a locally-defined profile (by name or ID)
- Parent is a valid canonical URL
Warnings
Section titled “Warnings”-
Unknown Profile: Not a FHIR resource, local profile, or recognized external IG
Parent 'UnknownResourceType' is not a known FHIR resource, locally-defined profile, or recognized external profileHelp: Verify the spelling, ensure the parent profile is defined, or use a canonical URL -
External IG Profile: Appears to be from a known external implementation guide
Parent 'USCorePatientProfile' appears to be from an external implementation guide and cannot be verified locallyHelp: Consider using the canonical URL instead, or ensure this profile is defined in your dependencies
Errors
Section titled “Errors”-
Missing Parent: Profile lacks required Parent keyword
Profile 'MyProfile' must specify a Parent -
Invalid URL: Canonical URL format is incorrect
Invalid canonical URL format: URL is too short to be validHelp: Ensure the URL follows the pattern: http(s)://domain/StructureDefinition/profile-id
Known External IG Prefixes
Section titled “Known External IG Prefixes”The validator recognizes these common implementation guide patterns:
USCore*
- US Core profilesmcode-*
- mCODE (Minimal Common Oncology Data Elements)QICore*
- Quality Improvement CoreCARIN*
- CARIN Alliance profilesDaVinci*
- Da Vinci Project profilesPACIO*
- PACIO Project profilesIPA*
- International Patient AccessIHE*
- Integrating the Healthcare EnterpriseAU*
,UK*
,CA*
,CH*
- Regional profiles (Australia, UK, Canada, Switzerland)
FHIR Version Support
Section titled “FHIR Version Support”The registry supports both FHIR R4 and R5:
- R4: ~145 base resources
- R5: All R4 resources plus ~30 new resources (e.g.,
Transport
,Permission
,SubscriptionTopic
)
Version detection: Currently defaults to R4, with R5 support available via check_profile_assignments_with_version()
.
Testing
Section titled “Testing”Run validation on test examples:
fsh-lint lint examples/test-parent-validation.fsh
Future Enhancements
Section titled “Future Enhancements”Potential Improvements
Section titled “Potential Improvements”- FHIR Version Detection: Auto-detect FHIR version from project configuration
- External Profile Cache: Download and cache external IG definitions for verification
- Configuration Support: Allow users to specify known external profiles in
.fshlintrc
- Canonical URL Resolution: Resolve and verify canonical URLs against known registries
- Symbol Table Enhancement: Index profiles by both name and ID for faster lookup
Configuration Example (Future)
Section titled “Configuration Example (Future)”{ "validation": { "fhirVersion": "R4", "knownProfiles": [ "USCorePatientProfile", "USCoreCondition" ], "externalIGPaths": [ "./node_modules/fhir-us-core" ] }}
See Also
Section titled “See Also”- Configuration Rules - Configure rule behavior
- Custom Rules - Write your own validation rules
- CLI Commands - Command-line usage