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        private String myDisplayLanguage;
039
040        public String getFilter() {
041                return myFilter;
042        }
043
044        public ValueSetExpansionOptions setFilter(String theFilter) {
045                myFilter = theFilter;
046                return this;
047        }
048
049        /**
050         * The number of codes to return.
051         * <p>
052         * Default is 1000
053         * </p>
054         */
055        public int getCount() {
056                return myCount;
057        }
058
059        /**
060         * The number of codes to return.
061         * <p>
062         * Default is 1000
063         * </p>
064         */
065        public ValueSetExpansionOptions setCount(int theCount) {
066                Validate.isTrue(theCount >= 0, "theCount must be >= 0");
067                myCount = theCount;
068                return this;
069        }
070
071        /**
072         * The code index to start at (i.e the individual code index, not the page number)
073         */
074        public int getOffset() {
075                return myOffset;
076        }
077
078        /**
079         * The code index to start at (i.e the individual code index, not the page number)
080         */
081        public ValueSetExpansionOptions setOffset(int theOffset) {
082                Validate.isTrue(theOffset >= 0, "theOffset must be >= 0");
083                myOffset = theOffset;
084                return this;
085        }
086
087        /**
088         * Should the expansion fail if a codesystem is referenced by the valueset, but
089         * it can not be found?
090         * <p>
091         * Default is <code>true</code>
092         * </p>
093         */
094        public boolean isFailOnMissingCodeSystem() {
095                return myFailOnMissingCodeSystem;
096        }
097
098        /**
099         * Should the expansion fail if a codesystem is referenced by the valueset, but
100         * it can not be found?
101         * <p>
102         * Default is <code>true</code>
103         * </p>
104         */
105        public ValueSetExpansionOptions setFailOnMissingCodeSystem(boolean theFailOnMissingCodeSystem) {
106                myFailOnMissingCodeSystem = theFailOnMissingCodeSystem;
107                return this;
108        }
109
110        public boolean isIncludeHierarchy() {
111                return myIncludeHierarchy;
112        }
113
114        public void setIncludeHierarchy(boolean theIncludeHierarchy) {
115                myIncludeHierarchy = theIncludeHierarchy;
116        }
117
118        public static ValueSetExpansionOptions forOffsetAndCount(int theOffset, int theCount) {
119                return new ValueSetExpansionOptions()
120                        .setOffset(theOffset)
121                        .setCount(theCount);
122        }
123
124        public String getTheDisplayLanguage() {
125                return myDisplayLanguage;
126        }
127
128        public ValueSetExpansionOptions setTheDisplayLanguage(String theDisplayLanguage) {
129                myDisplayLanguage = theDisplayLanguage;
130                return this;
131        }
132}