All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.linuxforhealth.fhir.FHIRContext Maven / Gradle / Ivy

Go to download

FHIR converter is a Java based library that enables converting Hl7v2 messages to FHIR resources

There is a newer version: 1.0.19
Show newest version
/*
 * (C) Copyright IBM Corp. 2020
 *
 * SPDX-License-Identifier: Apache-2.0
 */
package io.github.linuxforhealth.fhir;

import org.hl7.fhir.r4.model.Bundle;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import io.github.linuxforhealth.core.Constants;

public class FHIRContext {
  private static final FhirContext CTX = FhirContext.forR4();
  private IParser parser;

  /**
   * Constructor for FHIRContext
   */
  public FHIRContext(boolean isPrettyPrint) {
    parser = CTX.newJsonParser();
    parser.setPrettyPrint(isPrettyPrint);
  }

  public FHIRContext() {
    this(Constants.DEFAULT_PRETTY_PRINT);
  }

  public IParser getParser() {
    return parser;
  }

  public FhirContext getCtx() {
    return CTX;
  }


  public String encodeResourceToString(Bundle bundle) {
    return this.parser.encodeResourceToString(bundle);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy