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

io.github.linuxforhealth.hl7.expression.specification.SimpleSpecification 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.hl7.expression.specification;

import java.util.HashMap;
import java.util.Map;
import io.github.linuxforhealth.api.EvaluationResult;
import io.github.linuxforhealth.api.InputDataExtractor;
import io.github.linuxforhealth.api.Specification;
import io.github.linuxforhealth.core.Constants;
import io.github.linuxforhealth.core.expression.EvaluationResultFactory;


/**
 * Represents HL7 data specification. It defines segment, field, component and subcomponent
 * names/identifiers that can be used for extracting data.
 * 
 *
 * @author pbhallam
 */

public class SimpleSpecification implements Specification {

  private String variableName;
  private boolean isExtractMultiple;
  private boolean useGroup;
  private InputDataExtractor primaryDataSource = new ContextMapData();
  
  public SimpleSpecification(String variableName,
      boolean isMultiple, boolean useGroup) {
    this.variableName = variableName;
    this.isExtractMultiple = isMultiple;
    this.useGroup = useGroup;

  }



  public boolean isExtractMultiple() {
    return isExtractMultiple;
  }



  public String getVariable() {
    return variableName;
  }



  public Class getSourceInputDataClass() {
    return this.primaryDataSource.getClass();
  }

  @Override
  public EvaluationResult extractValueForSpec(InputDataExtractor dataSource,
      Map contextValues) {
    Map localContextValues = new HashMap<>(contextValues);
    localContextValues.put(Constants.USE_GROUP,
        EvaluationResultFactory.getEvaluationResult(useGroup));
    return primaryDataSource.extractValueForSpec(this, localContextValues);
  }


  @Override
  public EvaluationResult extractMultipleValuesForSpec(InputDataExtractor dataSource,
      Map contextValues) {
    Map localContextValues = new HashMap<>(contextValues);
    localContextValues.put(Constants.USE_GROUP,
        EvaluationResultFactory.getEvaluationResult(useGroup));
    return primaryDataSource.extractMultipleValuesForSpec(this, localContextValues);
  }



  public boolean isUseGroup() {
    return useGroup;
  }



  public void setUseGroup(boolean useGroup) {
    this.useGroup = useGroup;
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy