FHIR & HL7 Validator
Healthcare data format validation skill for AI agents. Validates FHIR R5 resources, HL7 v2 messages, and CDA clinical documents. Ensures healthcare data interchange compliance with HL7 standards and identifies schema violations, missing required fields, and interoperability issues.
Capabilities
- FHIR Validation - Validate FHIR R5 resources against official schemas
- HL7 Message Parsing - Parse and validate HL7 v2.x messages (ADT, ORU, OBX, RXO)
- CDA Document Validation - Validate Clinical Document Architecture (CDA) R2 documents
- Schema Compliance - Check resources against FHIR specification and UK Core
- Data Type Validation - Verify FHIR data types (Identifier, CodeableConcept, Reference, etc.)
- Reference Resolution - Validate internal and external references
- Cardinality Checking - Ensure required vs. optional field compliance
- Terminology Validation - Check value sets and coding systems (SNOMED CT, LOINC, ICD-10)
- Interoperability Analysis - Identify implementation guide adherence
- Error Reporting - Generate detailed validation error reports with remediation
Usage
/fhir-hl7-validator [command] [target] [options]
Commands
validate-fhir <file> - Validate FHIR JSON/XML resource
validate-hl7 <file> - Validate HL7 v2 message
validate-cda <file> - Validate CDA clinical document
parse-fhir <file> - Parse and display FHIR resource structure
parse-hl7 <file> - Parse and display HL7 segments
check-references <file> - Validate all resource references
check-terminology <file> - Validate coding systems and value sets
bulk-validate <directory> - Validate multiple files
report <output-format> - Generate validation report (JSON, markdown, HTML)
Options
--version <ver> - FHIR version (default: R5; also 4.0, 3.0)
--variant <name> - Implementation guide (e.g., uk-core, us-core)
--strict - Enforce must-support constraints
--terminology-check - Validate coding systems (enables online lookup)
--output <file> - Write report to file
--format <type> - Output format: json, markdown, html, xml
Workflow
Follow this workflow when invoked:
Step 1: Identify Healthcare Data Type
Ask user to specify:
- Data format (FHIR, HL7 v2, CDA)
- FHIR version or HL7 dialect
- Implementation guide/profile (if applicable)
- Data source (EHR, lab system, imaging system)
Step 2: Validate Structure
Check:
- JSON/XML well-formedness
- Required elements present
- Data type conformance
- Cardinality compliance (min/max occurrences)
- Pattern and regex validation
Step 3: Semantic Validation
Verify:
- Code system membership (SNOMED CT, LOINC, ICD-10, etc.)
- Reference consistency (local vs. external)
- Identifier uniqueness and format
- Date/time format accuracy (ISO 8601)
- Quantity unit validity
Step 4: Interoperability Check
Ensure compliance with:
- FHIR implementation guides
- US Core or UK Core profiles
- HL7 message specifications
- Clinical data interchange standards
Step 5: Generate Report
Provide:
- List of validation errors with line numbers
- Severity level (error, warning, info)
- Remediation guidance
- Reference to relevant standards
FHIR Resource Examples
Patient Resource
{
"resourceType": "Patient",
"id": "example",
"identifier": [
{
"system": "http://example.org/medical-record",
"value": "12345"
}
],
"name": [
{
"use": "official",
"given": ["Jane"],
"family": "Doe"
}
],
"birthDate": "1990-01-15",
"address": [
{
"use": "home",
"line": ["123 Main St"],
"city": "Springfield",
"state": "IL",
"postalCode": "62701"
}
]
}
Observation Resource
{
"resourceType": "Observation",
"id": "example",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "39156-5",
"display": "BMI"
}
]
},
"subject": {
"reference": "Patient/example"
},
"valueQuantity": {
"value": 24.5,
"unit": "kg/m2",
"system": "http://unitsofmeasure.org",
"code": "kg/m2"
}
}
HL7 v2 Segment Examples
ADT Message (Patient Admission)
MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|202502071350||ADT^A01|123456|P|2.5
PID^^^12345||JaneDoe||19900115|F|||123 Main St^^Springfield^IL^62701|||||||S
PV1||I|ICU^FL2^BED01|||||||||||||||||||||||||||
Common Validation Errors
| Error |
Cause |
Solution |
| Missing required element |
Element marked cardinality: 1..1 not present |
Add the required element |
| Invalid data type |
Value doesn't match specified type |
Convert to correct type (e.g., date to YYYY-MM-DD) |
| Unknown code system |
Code not in specified value set |
Use code from official code system (SNOMED CT, LOINC) |
| Broken reference |
Reference target doesn't exist |
Verify reference path and ID |
| Invalid identifier format |
ID format doesn't match pattern |
Follow system-specific identifier format |
Standards & Implementation Guides
References
- Fast Healthcare Interoperability Resources (FHIR) - R5 Specification
- HL7 Version 2.5.1 - Standard for Healthcare Data Exchange
- Clinical Document Architecture R2 - CDA Specification
- NIST SP 800-66 Rev. 2 - HIPAA Security Implementation Guidance
- HL7 FHIR Implementation Guides
1---2name: fhir-hl7-validator3description: This skill should be used when the user asks to "validate FHIR resources", "check HL7 messages", "validate healthcare data format", "parse FHIR", "HL7 v2 messages", "FHIR R5 validation", "CDA documents", "healthcare data interchange", "FHIR resource schema", "HL7 specifications", or mentions FHIR validation, HL7 message parsing, CDA validation, healthcare data format compliance, or Fast Healthcare Interoperability Resources standards.4license: MIT5---6
7# FHIR & HL7 Validator
8
9Healthcare data format validation skill for AI agents. Validates FHIR R5 resources, HL7 v2 messages, and CDA clinical documents. Ensures healthcare data interchange compliance with HL7 standards and identifies schema violations, missing required fields, and interoperability issues.
10
11## Capabilities
12
131. **FHIR Validation** - Validate FHIR R5 resources against official schemas
142. **HL7 Message Parsing** - Parse and validate HL7 v2.x messages (ADT, ORU, OBX, RXO)
153. **CDA Document Validation** - Validate Clinical Document Architecture (CDA) R2 documents
164. **Schema Compliance** - Check resources against FHIR specification and UK Core
175. **Data Type Validation** - Verify FHIR data types (Identifier, CodeableConcept, Reference, etc.)
186. **Reference Resolution** - Validate internal and external references
197. **Cardinality Checking** - Ensure required vs. optional field compliance
208. **Terminology Validation** - Check value sets and coding systems (SNOMED CT, LOINC, ICD-10)
219. **Interoperability Analysis** - Identify implementation guide adherence
2210. **Error Reporting** - Generate detailed validation error reports with remediation
23
24## Usage
25
26```
27/fhir-hl7-validator [command] [target] [options]
28```
29
30### Commands
31
32- `validate-fhir <file>` - Validate FHIR JSON/XML resource
33- `validate-hl7 <file>` - Validate HL7 v2 message
34- `validate-cda <file>` - Validate CDA clinical document
35- `parse-fhir <file>` - Parse and display FHIR resource structure
36- `parse-hl7 <file>` - Parse and display HL7 segments
37- `check-references <file>` - Validate all resource references
38- `check-terminology <file>` - Validate coding systems and value sets
39- `bulk-validate <directory>` - Validate multiple files
40- `report <output-format>` - Generate validation report (JSON, markdown, HTML)
41
42### Options
43
44- `--version <ver>` - FHIR version (default: R5; also 4.0, 3.0)
45- `--variant <name>` - Implementation guide (e.g., uk-core, us-core)
46- `--strict` - Enforce must-support constraints
47- `--terminology-check` - Validate coding systems (enables online lookup)
48- `--output <file>` - Write report to file
49- `--format <type>` - Output format: json, markdown, html, xml
50
51## Workflow
52
53Follow this workflow when invoked:
54
55### Step 1: Identify Healthcare Data Type
56
57Ask user to specify:
58- Data format (FHIR, HL7 v2, CDA)
59- FHIR version or HL7 dialect
60- Implementation guide/profile (if applicable)
61- Data source (EHR, lab system, imaging system)
62
63### Step 2: Validate Structure
64
65Check:
66- JSON/XML well-formedness
67- Required elements present
68- Data type conformance
69- Cardinality compliance (min/max occurrences)
70- Pattern and regex validation
71
72### Step 3: Semantic Validation
73
74Verify:
75- Code system membership (SNOMED CT, LOINC, ICD-10, etc.)
76- Reference consistency (local vs. external)
77- Identifier uniqueness and format
78- Date/time format accuracy (ISO 8601)
79- Quantity unit validity
80
81### Step 4: Interoperability Check
82
83Ensure compliance with:
84- FHIR implementation guides
85- US Core or UK Core profiles
86- HL7 message specifications
87- Clinical data interchange standards
88
89### Step 5: Generate Report
90
91Provide:
92- List of validation errors with line numbers
93- Severity level (error, warning, info)
94- Remediation guidance
95- Reference to relevant standards
96
97## FHIR Resource Examples
98
99### Patient Resource
100
101```json
102{
103 "resourceType": "Patient",
104 "id": "example",
105 "identifier": [
106 {
107 "system": "http://example.org/medical-record",
108 "value": "12345"
109 }
110 ],
111 "name": [
112 {
113 "use": "official",
114 "given": ["Jane"],
115 "family": "Doe"
116 }
117 ],
118 "birthDate": "1990-01-15",
119 "address": [
120 {
121 "use": "home",
122 "line": ["123 Main St"],
123 "city": "Springfield",
124 "state": "IL",
125 "postalCode": "62701"
126 }
127 ]
128}
129```
130
131### Observation Resource
132
133```json
134{
135 "resourceType": "Observation",
136 "id": "example",
137 "status": "final",
138 "code": {
139 "coding": [
140 {
141 "system": "http://loinc.org",
142 "code": "39156-5",
143 "display": "BMI"
144 }
145 ]
146 },
147 "subject": {
148 "reference": "Patient/example"
149 },
150 "valueQuantity": {
151 "value": 24.5,
152 "unit": "kg/m2",
153 "system": "http://unitsofmeasure.org",
154 "code": "kg/m2"
155 }
156}
157```
158
159## HL7 v2 Segment Examples
160
161### ADT Message (Patient Admission)
162
163```
164MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|202502071350||ADT^A01|123456|P|2.5
165PID^^^12345||JaneDoe||19900115|F|||123 Main St^^Springfield^IL^62701|||||||S
166PV1||I|ICU^FL2^BED01|||||||||||||||||||||||||||
167```
168
169## Common Validation Errors
170
171| Error | Cause | Solution |
172|-------|-------|----------|
173| Missing required element | Element marked `cardinality: 1..1` not present | Add the required element |
174| Invalid data type | Value doesn't match specified type | Convert to correct type (e.g., date to YYYY-MM-DD) |
175| Unknown code system | Code not in specified value set | Use code from official code system (SNOMED CT, LOINC) |
176| Broken reference | Reference target doesn't exist | Verify reference path and ID |
177| Invalid identifier format | ID format doesn't match pattern | Follow system-specific identifier format |
178
179## Standards & Implementation Guides
180
181- **FHIR R5** (http://hl7.org/fhir/R5/)
182- **HL7 v2.5.1** (http://www.hl7.org/)
183- **CDA R2** (https://www.hl7.org/implement/standards/cdar2/)
184- **US Core** (http://www.hl7.org/fhir/us/core/)
185- **UK Core** (https://digital.nhs.uk/developer/api-catalogue/fhir-uk-core)
186- **SNOMED CT** (https://www.snomed.org/)
187- **LOINC** (https://loinc.org/)
188- **ICD-10** (https://www.cdc.gov/nchs/icd/icd10cm.htm)
189
190## References
191
192- **Fast Healthcare Interoperability Resources (FHIR)** - R5 Specification
193- **HL7 Version 2.5.1** - Standard for Healthcare Data Exchange
194- **Clinical Document Architecture R2** - CDA Specification
195- **NIST SP 800-66 Rev. 2** - HIPAA Security Implementation Guidance
196- **HL7 FHIR Implementation Guides**
197