io.github.linuxforhealth.hl7.data.Hl7DataHandlerUtil 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.hl7.data;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ca.uhn.hl7v2.model.Composite;
import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.Primitive;
import ca.uhn.hl7v2.model.Type;
import ca.uhn.hl7v2.model.Variable;
import ca.uhn.hl7v2.model.primitive.ID;
import ca.uhn.hl7v2.model.primitive.IS;
public class Hl7DataHandlerUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(Hl7DataHandlerUtil.class);
private Hl7DataHandlerUtil() {}
public static String getStringValue(Object obj) {
return getStringValue(obj, false);
}
public static String getStringValue(Object obj, boolean allComponents) {
if (obj == null) {
return null;
}
LOGGER.debug("Extracting string value for {} type {}", obj, obj.getClass());
Object local = obj;
String returnValue;
if (local instanceof Collection) {
List