001package org.hl7.fhir.dstu3.terminologies; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu3 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024import java.io.FileNotFoundException; 025import java.io.IOException; 026 027import org.hl7.fhir.dstu3.model.ExpansionProfile; 028import org.hl7.fhir.dstu3.model.ValueSet; 029 030public interface ValueSetExpander { 031 public enum TerminologyServiceErrorClass { 032 UNKNOWN, NOSERVICE, SERVER_ERROR, VALUESET_UNSUPPORTED; 033 034 public boolean isInfrastructure() { 035 return this == NOSERVICE || this == SERVER_ERROR || this == VALUESET_UNSUPPORTED; 036 } 037 } 038 039 public class ETooCostly extends Exception { 040 041 public ETooCostly(String msg) { 042 super(msg); 043 } 044 045 } 046 047 /** 048 * Some value sets are just too big to expand. Instead of an expanded value set, 049 * you get back an interface that can test membership - usually on a server somewhere 050 * 051 * @author Grahame 052 */ 053 public class ValueSetExpansionOutcome { 054 private ValueSet valueset; 055 private ValueSetChecker service; 056 private String error; 057 private TerminologyServiceErrorClass errorClass; 058 059 public ValueSetExpansionOutcome(ValueSet valueset) { 060 super(); 061 this.valueset = valueset; 062 this.service = null; 063 this.error = null; 064 } 065 public ValueSetExpansionOutcome(ValueSet valueset, String error, TerminologyServiceErrorClass errorClass) { 066 super(); 067 this.valueset = valueset; 068 this.service = null; 069 this.error = error; 070 this.errorClass = errorClass; 071 } 072 public ValueSetExpansionOutcome(ValueSetChecker service, String error, TerminologyServiceErrorClass errorClass) { 073 super(); 074 this.valueset = null; 075 this.service = service; 076 this.error = error; 077 this.errorClass = errorClass; 078 } 079 public ValueSetExpansionOutcome(String error, TerminologyServiceErrorClass errorClass) { 080 this.valueset = null; 081 this.service = null; 082 this.error = error; 083 this.errorClass = errorClass; 084 } 085 public ValueSet getValueset() { 086 return valueset; 087 } 088 public ValueSetChecker getService() { 089 return service; 090 } 091 public String getError() { 092 return error; 093 } 094 public TerminologyServiceErrorClass getErrorClass() { 095 return errorClass; 096 } 097 098 099 } 100/** 101 * 102 * @param source the value set definition to expand 103 * @param profile a profile affecting the outcome. If you don't supply a profile, the default internal expansion profile will be used. 104 * 105 * @return 106 * @throws ETooCostly 107 * @throws FileNotFoundException 108 * @throws IOException 109 */ 110 public ValueSetExpansionOutcome expand(ValueSet source, ExpansionProfile profile) throws ETooCostly, FileNotFoundException, IOException; 111}