001package ca.uhn.fhir.context.support; 002 003/*- 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 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 023import org.apache.commons.lang3.Validate; 024 025/** 026 * Options for ValueSet expansion 027 * 028 * @see IValidationSupport 029 */ 030public class ValueSetExpansionOptions { 031 032 private boolean myFailOnMissingCodeSystem = true; 033 private int myCount = 1000; 034 private int myOffset = 0; 035 private boolean myIncludeHierarchy; 036 private String myFilter; 037 038 public String getFilter() { 039 return myFilter; 040 } 041 042 public ValueSetExpansionOptions setFilter(String theFilter) { 043 myFilter = theFilter; 044 return this; 045 } 046 047 /** 048 * The number of codes to return. 049 * <p> 050 * Default is 1000 051 * </p> 052 */ 053 public int getCount() { 054 return myCount; 055 } 056 057 /** 058 * The number of codes to return. 059 * <p> 060 * Default is 1000 061 * </p> 062 */ 063 public ValueSetExpansionOptions setCount(int theCount) { 064 Validate.isTrue(theCount >= 0, "theCount must be >= 0"); 065 myCount = theCount; 066 return this; 067 } 068 069 /** 070 * The code index to start at (i.e the individual code index, not the page number) 071 */ 072 public int getOffset() { 073 return myOffset; 074 } 075 076 /** 077 * The code index to start at (i.e the individual code index, not the page number) 078 */ 079 public ValueSetExpansionOptions setOffset(int theOffset) { 080 Validate.isTrue(theOffset >= 0, "theOffset must be >= 0"); 081 myOffset = theOffset; 082 return this; 083 } 084 085 /** 086 * Should the expansion fail if a codesystem is referenced by the valueset, but 087 * it can not be found? 088 * <p> 089 * Default is <code>true</code> 090 * </p> 091 */ 092 public boolean isFailOnMissingCodeSystem() { 093 return myFailOnMissingCodeSystem; 094 } 095 096 /** 097 * Should the expansion fail if a codesystem is referenced by the valueset, but 098 * it can not be found? 099 * <p> 100 * Default is <code>true</code> 101 * </p> 102 */ 103 public ValueSetExpansionOptions setFailOnMissingCodeSystem(boolean theFailOnMissingCodeSystem) { 104 myFailOnMissingCodeSystem = theFailOnMissingCodeSystem; 105 return this; 106 } 107 108 public boolean isIncludeHierarchy() { 109 return myIncludeHierarchy; 110 } 111 112 public void setIncludeHierarchy(boolean theIncludeHierarchy) { 113 myIncludeHierarchy = theIncludeHierarchy; 114 } 115 116 public static ValueSetExpansionOptions forOffsetAndCount(int theOffset, int theCount) { 117 return new ValueSetExpansionOptions() 118 .setOffset(theOffset) 119 .setCount(theCount); 120 } 121}