A Converter which converts Fhir (http://fhir.furore.com/forge) profiles to Hapi Fhir Resources
String xmlFile = "SomeStructureDefinition.xml";
String packageTargetName = "com.systematic.healthcare.fhir.generator.generated";
StructureDefinitionProvider provider = new FileStructureDefinitionProvider(
packageTargetName,
new File(directory, xmlFile));
JavaClassSource javaClass = Generator.generate(provider);
new File(directory, "generated/"+packageTargetName.replace("\\.", "/")).mkdirs();
Files.write(new File(new File(directory, "generated"), javaClass.getName()+".java"
This project contains a samle gradle module (gradle-plugin-example) which if enabled will convert all files in a specified folder to hapi fhir dstu2 java.
//Enable the structure definition to java plugin
apply plugin: 'sdToJava'
// Arguments for the converter.
sdToJavaArg {
//The build folder where the generated files should be placed
outDirectory = "$buildDir/generated-resources/main/java"
//The files to convert from structure definition to dstu2 java.
files = project.fileTree("testdata").include("*.xml")
//The package name for the generated files
packageName = "com.systematic.healthcare.fhir.generator.generated"
}
build.dependsOn sdToJavaTask
To get the StructureDefinition to DSTU2 converter use the following gradle dependency
compile 'com.systematic.healthcare.fhir.generator:dstu2:1.0'
To use the gradle plugin to convert files from gradle, add the following to the buildscript classpath
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.systematic.healthcare.fhir.generator:gradle-plugin:1.0'
}
}
apply plugin: 'sdToJava'
sdToJavaArg {
outDirectory = "$buildDir/generated-resources/main/java"
files = project.fileTree("testdata").include("*.xml")
packageName = "com.systematic.healthcare.fhir.generator.generated"
}
build.dependsOn sdToJavaTask
- Tests needs to be written and added..
- Add support for writing @Override when overriding super methods..
- Slicing is still under development. Waiting for HAPI FHIR support for slicing annotation.