Implementation Guide
1.2.0 - CI Build Implementation Guide - Local Development build (v1.2.0). See the Directory of published versions

Build ETL with TOS

This section describes how to build an ETL-process and fill the Blaze Store with Talend Open Studio for Data Integration and Hapi FHIR Api. This instructions were originally writen and tested by Marko Wegehaupt from Wuerzburg in november 2019.

Step-by-step instructions:

  1. A new routine must be created in Talend Open Studio for Data Integration. In this manual it is called FHIR_API_Wrapper. click on „Edit libraries of the Routines“ and import the following libraries from hapi-fhir-4.0.0-standard-distribution to solve imports. TOS import external libs

  2. Use JavaRow to create a FHIR_API_Wrapper Object in TOS and run methodes on it to produce FHIR Resources.
  3. In a final step upload the generated Bundles to the Blaze Store.

In details:

Create a new wrapper-object in a Java_Row componente and store it in the globalMap:

Boolean returnCode;
FHIR_API_Wrapper temp;
globalMap.put("FHIR", temp=new FHIR_API_Wrapper());

You can use the object in other Java-Row components to run methodes:

returnCode = ((FHIR_API_Wrapper) globalMap.get("FHIR")).doPatient(toJava1.cPatId, toJava1.cBirthDate, toJava1.cDeceased, toJava1.cGender, toJava1.sourceFlag, toJava1.lastRowFlag);
returnCode = ((FHIR_API_Wrapper) globalMap.get("FHIR")).addEncounterToPatient(patFall.cPatId, patFall.FallNr, patFall.RecId,patFall.anfang, patFall.ende, "p70");

Create a new Bundle in the TOS Routine:

bundle = new Bundle();
bdlMap.put(String.valueOf(bundleCounter), bundle);

Create patient and placing the patient in the bundle:

Patient patient = new Patient();
IdDt patRand=IdDt.newRandomUuid();
patient.setId(cPatId); // argument from method call

Meta m= new Meta();

switch (geschlecht){
case "male": patient.setGender(AdministrativeGender.MALE); break;
case "female": patient.setGender(AdministrativeGender.FEMALE); break;
default: patient.setGender(AdministrativeGender.UNKNOWN);



  patient.setDeceased(new DateTimeType(sterbeDatum));

System.err.println("size after addition: "+patientMap.size());


patientToBundle.put(patient.getId(), bundle.getId());

Create and assign the diagnosis ressources:

Condition condition = new Condition();
  condition.setEncounter(new Reference("Encounter/fn"+obEncId));
  condition.setOnset(new DateTimeType(onset));
  condition.setAbatement(new DateTimeType(abatement));

condition.setSubject(new Reference("Patient/"+patientMap.get(obPatId).getId()));

Bundle lookedUpBundle=bdlMap.get(patientToBundle.get(obPatId));


System.err.println("condition added.");

Upload bundles:

FhirContext ctx = FhirContext.forR4();

// Create a client and PUT the transaction to the server
IGenericClient client = ctx.newRestfulGenericClient("http://FHIRSERVER:8080/fhir");

// Create an HTTP basic auth interceptor
String username = "admin";
String password = "psw";
IClientInterceptor authInterceptor = new BasicAuthInterceptor(username, password);

System.err.println("number of bundles: "+bdlMap.size());
for (Bundle bdlIt : bdlMap.values()) {
  Bundle resp = client.transaction().withBundle(bdlIt).execute();

TOS Flow1

TOS Flow2


@ResourceDef(name="Specimen", profile="")

public class GBASpecimen extends Specimen {

private static final long serialVersionUID = 1L;

* Each extension is defined in a field. Any valid HAPI Data Type
* can be used for the field type. Note that the [name=""] attribute
* in the @Child annotation needs to match the name for the bean accessor
* and mutator methods.
@Extension(url="", definedLocally=true, isModifier=false)
@Description(shortDefinition="The temperature")
private CodeableConcept myTemperatureCC;
@Extension(url="", definedLocally=true, isModifier=false)
@Description(shortDefinition="The custodian")
private Reference myOrgaRef;
@Extension(url="", definedLocally=true, isModifier=false)
private CodeableConcept mySampleDiagnosisCC;
@Extension(url="", definedLocally=true, isModifier=false)
private CodeableConcept myTypeIBDWCC;

* It is important to override the isEmpty() method, adding a check for any
* newly added fields.
public boolean isEmpty() {
   return super.isEmpty()
   && ElementUtil.isEmpty(myTemperatureCC)
   && ElementUtil.isEmpty(myOrgaRef)
   && ElementUtil.isEmpty(mySampleDiagnosisCC)
   && ElementUtil.isEmpty(myTypeIBDWCC);

* Accessors and mutators follow
* Each extension is required to have an getter/accessor and a setter/mutator.
* You are highly recommended to create getters which create instances if they
* do not already exist, since this is how the rest of the HAPI FHIR API works.

/** Getter for CC */
public CodeableConcept getTemperatureCC() {
if (myTemperatureCC == null) {
  myTemperatureCC = new CodeableConcept();
return this.myTemperatureCC;

public CodeableConcept getSampleDiagnosisCC() {
if (mySampleDiagnosisCC == null) {
  mySampleDiagnosisCC = new CodeableConcept();
return this.mySampleDiagnosisCC;

public CodeableConcept getTypeIBDWCC() {
if (myTypeIBDWCC == null) {
  myTypeIBDWCC = new CodeableConcept();
return this.myTypeIBDWCC;

public Reference getOrgaRef() {
if (myOrgaRef == null) {
  myOrgaRef = new Reference();
return this.myOrgaRef;

public ResourceType getResourceType(){
return ResourceType.Specimen;


public FhirVersionEnum getStructureFhirVersionEnum() {
return FhirVersionEnum.R4;