001package org.hl7.fhir.r4.terminologies;
002
003import java.io.FileNotFoundException;
004import java.io.IOException;
005
006import org.hl7.fhir.r4.model.Parameters;
007import org.hl7.fhir.r4.model.ValueSet;
008
009public interface ValueSetExpander {
010  public enum TerminologyServiceErrorClass {
011    UNKNOWN, NOSERVICE, SERVER_ERROR, VALUESET_UNSUPPORTED;
012
013    public boolean isInfrastructure() {
014      return this == NOSERVICE || this == SERVER_ERROR || this == VALUESET_UNSUPPORTED;
015    }
016  }
017  
018  public class ETooCostly extends Exception {
019
020    public ETooCostly(String msg) {
021      super(msg);
022    }
023
024  }
025
026  /**
027   * Some value sets are just too big to expand. Instead of an expanded value set, 
028   * you get back an interface that can test membership - usually on a server somewhere
029   * 
030   * @author Grahame
031   */
032  public class ValueSetExpansionOutcome {
033    private ValueSet valueset;
034    private String error;
035    private TerminologyServiceErrorClass errorClass;
036    private String txLink;
037    
038    public ValueSetExpansionOutcome(ValueSet valueset) {
039      super();
040      this.valueset = valueset;
041      this.error = null;
042    }
043    public ValueSetExpansionOutcome(ValueSet valueset, String error, TerminologyServiceErrorClass errorClass) {
044      super();
045      this.valueset = valueset;
046      this.error = error;
047      this.errorClass = errorClass;
048    }
049    public ValueSetExpansionOutcome(ValueSetChecker service, String error, TerminologyServiceErrorClass errorClass) {
050      super();
051      this.valueset = null;
052      this.error = error;
053      this.errorClass = errorClass;
054    }
055    public ValueSetExpansionOutcome(String error, TerminologyServiceErrorClass errorClass) {
056      this.valueset = null;
057      this.error = error;
058      this.errorClass = errorClass;
059    }
060    public ValueSet getValueset() {
061      return valueset;
062    }
063    public String getError() {
064      return error;
065    }
066    public TerminologyServiceErrorClass getErrorClass() {
067      return errorClass;
068    }
069    public String getTxLink() {
070      return txLink;
071    }
072    public ValueSetExpansionOutcome setTxLink(String txLink) {
073      this.txLink = txLink;
074      return this;
075    }
076
077
078  }
079/**
080 * 
081 * @param source the value set definition to expand
082 * @param profile a profile affecting the outcome. If you don't supply a profile, the default internal expansion profile will be used.
083 *  
084 * @return
085 * @throws ETooCostly
086 * @throws FileNotFoundException
087 * @throws IOException
088 */
089  public ValueSetExpansionOutcome expand(ValueSet source, Parameters parameters) throws ETooCostly, FileNotFoundException, IOException;
090}