|
| 1 | +# FML Execution Validation Test Suite |
| 2 | + |
| 3 | +A comprehensive FHIR Implementation Guide defining a test suite for validating FHIR Mapping Language (FML) execution using real-world test cases. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This test suite provides a standardized way to validate FML implementations using: |
| 8 | +- Real-world test cases from the ahdis/matchbox project |
| 9 | +- Official FHIR test cases from FHIR/fhir-test-cases repository |
| 10 | +- FHIR TestPlan resources for structured test execution |
| 11 | +- Comprehensive licensing compliance for all imported content |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | + |
| 17 | +- [SUSHI](https://fshschool.org/docs/sushi/) (FHIR Shorthand IG generator) |
| 18 | +- [FHIR IG Publisher](https://confluence.hl7.org/display/FHIR/IG+Publisher+Documentation) |
| 19 | +- Node.js (for test data import scripts) |
| 20 | + |
| 21 | +### Building the Implementation Guide |
| 22 | + |
| 23 | +1. **Clone the repository** |
| 24 | + ```bash |
| 25 | + git clone https://github.com/litlfred/fmlrunner.git |
| 26 | + cd fmlrunner |
| 27 | + ``` |
| 28 | + |
| 29 | +2. **Generate the IG** |
| 30 | + ```bash |
| 31 | + # Compile FSH files |
| 32 | + sushi |
| 33 | + |
| 34 | + # Generate the full IG |
| 35 | + _genonce.sh # or .bat on Windows |
| 36 | + ``` |
| 37 | + |
| 38 | +3. **Import additional test data** (optional) |
| 39 | + ```bash |
| 40 | + node scripts/test-data-import/import-all.js |
| 41 | + ``` |
| 42 | + |
| 43 | +## Directory Structure |
| 44 | + |
| 45 | +``` |
| 46 | +input/ |
| 47 | +├── fsh/ |
| 48 | +│ └── tests/ |
| 49 | +│ └── FMLExecutionValidationTestPlan.fsh |
| 50 | +├── testdata/ |
| 51 | +│ ├── matchbox/ |
| 52 | +│ │ ├── qr2patgender/ |
| 53 | +│ │ │ ├── qr2patgender.map |
| 54 | +│ │ │ ├── qr-input.json |
| 55 | +│ │ │ └── patient-output.json |
| 56 | +│ │ └── test-cases-metadata.json |
| 57 | +│ └── fhir-test-cases/ |
| 58 | +│ ├── tutorial-step1/ |
| 59 | +│ │ ├── tutorial-step1.map |
| 60 | +│ │ └── tutorial-input.json |
| 61 | +│ └── test-cases-metadata.json |
| 62 | +└── pagecontent/ |
| 63 | + ├── index.md |
| 64 | + ├── test-suite.md |
| 65 | + ├── test-data.md |
| 66 | + └── license-compliance.md |
| 67 | +``` |
| 68 | + |
| 69 | +## Test Data Import |
| 70 | + |
| 71 | +The test suite includes scripts to import test data from external repositories: |
| 72 | + |
| 73 | +### Import from ahdis/matchbox |
| 74 | +```bash |
| 75 | +node scripts/test-data-import/import-matchbox.js |
| 76 | +``` |
| 77 | + |
| 78 | +### Import from FHIR/fhir-test-cases |
| 79 | +```bash |
| 80 | +node scripts/test-data-import/import-fhir-test-cases.js |
| 81 | +``` |
| 82 | + |
| 83 | +### Import all sources |
| 84 | +```bash |
| 85 | +node scripts/test-data-import/import-all.js |
| 86 | +``` |
| 87 | + |
| 88 | +## Using the Test Suite |
| 89 | + |
| 90 | +### For FML Engine Implementers |
| 91 | + |
| 92 | +1. **Load the TestPlan**: Import the `FMLExecutionValidationTestPlan` resource |
| 93 | +2. **Execute Test Cases**: Run each test case against your FML engine |
| 94 | +3. **Validate Results**: Compare outputs against expected results |
| 95 | +4. **Check Assertions**: Evaluate FHIRPath assertions for pass/fail status |
| 96 | + |
| 97 | +### For Test Suite Maintainers |
| 98 | + |
| 99 | +1. **Add Test Data**: Place new test files in appropriate directories |
| 100 | +2. **Update Metadata**: Modify metadata JSON files to include new test cases |
| 101 | +3. **Regenerate TestPlan**: Run import scripts to update the FSH TestPlan |
| 102 | +4. **Rebuild IG**: Use SUSHI and IG Publisher to generate updated documentation |
| 103 | + |
| 104 | +## Test Case Structure |
| 105 | + |
| 106 | +Each test case includes: |
| 107 | + |
| 108 | +- **Map File**: FML mapping specification (`.map` or `.fml`) |
| 109 | +- **Input File**: Source FHIR resource (JSON or XML) |
| 110 | +- **Output File**: Expected transformation result (when available) |
| 111 | +- **Assertions**: FHIRPath expressions for validation |
| 112 | + |
| 113 | +### Example Test Case |
| 114 | + |
| 115 | +``` |
| 116 | +input/testdata/matchbox/qr2patgender/ |
| 117 | +├── qr2patgender.map # FML mapping |
| 118 | +├── qr-input.json # Input QuestionnaireResponse |
| 119 | +└── patient-output.json # Expected Patient output |
| 120 | +``` |
| 121 | + |
| 122 | +## License Compliance |
| 123 | + |
| 124 | +The test suite incorporates content from multiple sources: |
| 125 | + |
| 126 | +- **ahdis/matchbox**: Apache License 2.0 |
| 127 | +- **FHIR/fhir-test-cases**: HL7 FHIR License |
| 128 | + |
| 129 | +All imported files include proper attribution headers. See [License Compliance](input/pagecontent/license-compliance.md) for details. |
| 130 | + |
| 131 | +## Contributing |
| 132 | + |
| 133 | +To contribute to the test suite: |
| 134 | + |
| 135 | +1. **Add Test Cases**: Include proper licensing headers |
| 136 | +2. **Update Documentation**: Describe new test scenarios |
| 137 | +3. **Maintain Attribution**: Preserve all license information |
| 138 | +4. **Test Changes**: Verify IG builds successfully |
| 139 | + |
| 140 | +## File Naming Conventions |
| 141 | + |
| 142 | +Test files follow these patterns: |
| 143 | +- Map files: `*.map`, `*.fml`, `*-map.txt` |
| 144 | +- Input files: `*-input.json`, `*-input.xml`, `*source*` |
| 145 | +- Output files: `*-output.json`, `*-output.xml`, `*-expected.*` |
| 146 | + |
| 147 | +## Building and Testing |
| 148 | + |
| 149 | +### Build the IG |
| 150 | +```bash |
| 151 | +# Quick build |
| 152 | +sushi |
| 153 | + |
| 154 | +# Full build with publisher |
| 155 | +./_genonce.sh |
| 156 | +``` |
| 157 | + |
| 158 | +### Validate FSH |
| 159 | +```bash |
| 160 | +sushi -s |
| 161 | +``` |
| 162 | + |
| 163 | +### Update test data |
| 164 | +```bash |
| 165 | +node scripts/test-data-import/import-all.js |
| 166 | +sushi |
| 167 | +``` |
| 168 | + |
| 169 | +## Support |
| 170 | + |
| 171 | +For questions or issues: |
| 172 | +- Review the [Implementation Guide](https://litlfred.github.io/fmlrunner/) documentation |
| 173 | +- Check existing [GitHub Issues](https://github.com/litlfred/fmlrunner/issues) |
| 174 | +- Create a new issue for bugs or feature requests |
| 175 | + |
| 176 | +## License |
| 177 | + |
| 178 | +This project is licensed under the MIT License. See [LICENSE](LICENSE) for details. |
| 179 | + |
| 180 | +Individual test cases are licensed under their original terms (Apache 2.0 or HL7 FHIR License) as documented in each file. |
0 commit comments