Package org.fhirfrog.frog.shorthand


package org.fhirfrog.frog.shorthand
TestScript Shorthand (TSH) - A concise syntax for authoring FHIR TestScripts.

Overview

This package provides a FHIR Shorthand-inspired domain-specific language for authoring FHIR TestScripts with reduced verbosity (70-80% fewer lines than JSON/XML).

Architecture

The TSH processor uses ANTLR4 for parsing and HAPI FHIR for TestScript generation:

TSH Architecture

Example TSH Syntax


 TestScript: PatientReadTest
 Title: "Patient Read Test"
 Description: "Test reading a patient resource"
 Status: #draft
 Url: "http://example.org/TestScript/patient-read"
 
 Setup:
   * operation create Patient from "patient.json" as createResponse
   * assert responseCode = 201
   * variable patientId = Patient.id from createResponse
 
 Test: "Read the created patient"
   * operation read Patient/123 as readResponse
   * assert responseCode = 200
   * assert resource = Patient
 
 Teardown:
   * operation delete Patient/123
 

Usage

Parse TSH files and compile to FHIR TestScript resources:


 TSHProcessor processor = new TSHProcessor();
 TestScript testScript = processor.parse(Path.of("test.tsh"));
 String json = processor.toJson(testScript);
 

Integration

TSH files are automatically recognized by all FHIR Frog deployment modes:

  • CLI: java -jar fhir-frog-cli.jar test.tsh
  • Maven: <testScript>test.tsh</testScript>
  • Ant: <fhirtest testScript="test.tsh" />

Grammar

The TSH grammar is defined in ANTLR4 format:

  • TSH.g4 - Parser grammar
  • TSHLexer.g4 - Lexer grammar
See Also: