io.github.linuxforhealth.fhir.FHIRContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hl7v2-fhir-converter Show documentation
Show all versions of hl7v2-fhir-converter Show documentation
FHIR converter is a Java based library that enables converting Hl7v2 messages to FHIR resources
/*
* (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);
}
}