001package org.hl7.fhir.r4.utils.validation;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009    
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030 */
031
032import java.io.IOException;
033import java.io.InputStream;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat;
038import org.hl7.fhir.r4.model.StructureDefinition;
039import org.hl7.fhir.r4.utils.ValidationProfileSet;
040import org.hl7.fhir.r4.utils.validation.constants.BestPracticeWarningLevel;
041import org.hl7.fhir.r4.utils.validation.constants.CheckDisplayOption;
042import org.hl7.fhir.r4.utils.validation.constants.IdStatus;
043import org.hl7.fhir.utilities.validation.ValidationMessage;
044
045import com.google.gson.JsonObject;
046
047/**
048 * Interface to the instance validator. This takes a resource, in one of many
049 * forms, and checks whether it is valid
050 * 
051 * @author Grahame Grieve
052 *
053 */
054public interface IResourceValidator {
055
056  /**
057   * how much to check displays for coded elements
058   */
059  CheckDisplayOption getCheckDisplay();
060
061  void setCheckDisplay(CheckDisplayOption checkDisplay);
062
063  /**
064   * whether the resource must have an id or not (depends on context)
065   */
066  IdStatus getResourceIdRule();
067
068  void setResourceIdRule(IdStatus resourceIdRule);
069
070  /**
071   * whether the validator should enforce best practice guidelines as defined by
072   * various HL7 committees
073   */
074  BestPracticeWarningLevel getBestPracticeWarningLevel();
075
076  IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
077
078  IValidatorResourceFetcher getFetcher();
079
080  IResourceValidator setFetcher(IValidatorResourceFetcher value);
081
082  IValidationPolicyAdvisor getPolicyAdvisor();
083
084  IResourceValidator setPolicyAdvisor(IValidationPolicyAdvisor advisor);
085
086  boolean isNoBindingMsgSuppressed();
087
088  IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
089
090  boolean isNoInvariantChecks();
091
092  IResourceValidator setNoInvariantChecks(boolean value);
093
094  boolean isNoTerminologyChecks();
095
096  IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
097
098  boolean isNoExtensibleWarnings();
099
100  IResourceValidator setNoExtensibleWarnings(boolean noExtensibleWarnings);
101
102  /**
103   * Whether being unable to resolve a profile in found in Resource.meta.profile
104   * or ElementDefinition.type.profile or targetProfile is an error or just a
105   * warning
106   */
107  boolean isErrorForUnknownProfiles();
108
109  void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
110
111  String getValidationLanguage();
112
113  void setValidationLanguage(String value);
114
115  /**
116   * Validate suite
117   * 
118   * you can validate one of the following representations of resources:
119   * 
120   * stream - provide a format - this is the preferred choice
121   * 
122   * Use one of these two if the content is known to be valid XML/JSON, and
123   * already parsed - a DOM element or Document - a Json Object
124   * 
125   * In order to use these, the content must already be parsed - e.g. it must
126   * syntactically valid - a native resource - a elementmodel resource
127   * 
128   * in addition, you can pass one or more profiles ti validate beyond the base
129   * standard - as structure definitions or canonical URLs
130   * 
131   * @throws IOException
132   */
133  void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.r4.elementmodel.Element element)
134      throws FHIRException;
135
136  void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.r4.elementmodel.Element element,
137      ValidationProfileSet profiles) throws FHIRException;
138
139  void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.r4.elementmodel.Element element,
140      String profile) throws FHIRException;
141
142  void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.r4.elementmodel.Element element,
143      StructureDefinition profile) throws FHIRException;
144
145  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream,
146      FhirFormat format) throws FHIRException;
147
148  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream,
149      FhirFormat format, ValidationProfileSet profiles) throws FHIRException;
150
151  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream,
152      FhirFormat format, String profile) throws FHIRException;
153
154  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream,
155      FhirFormat format, StructureDefinition profile) throws FHIRException;
156
157  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
158      org.hl7.fhir.r4.model.Resource resource) throws FHIRException;
159
160  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
161      org.hl7.fhir.r4.model.Resource resource, ValidationProfileSet profiles) throws FHIRException;
162
163  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
164      org.hl7.fhir.r4.model.Resource resource, String profile) throws FHIRException;
165
166  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
167      org.hl7.fhir.r4.model.Resource resource, StructureDefinition profile) throws FHIRException;
168
169  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
170      org.w3c.dom.Element element) throws FHIRException;
171
172  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
173      org.w3c.dom.Element element, ValidationProfileSet profiles) throws FHIRException;
174
175  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
176      org.w3c.dom.Element element, String profile) throws FHIRException;
177
178  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
179      org.w3c.dom.Element element, StructureDefinition profile) throws FHIRException;
180
181  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
182      org.w3c.dom.Document document) throws FHIRException;
183
184  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
185      org.w3c.dom.Document document, ValidationProfileSet profiles) throws FHIRException;
186
187  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
188      org.w3c.dom.Document document, String profile) throws FHIRException;
189
190  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors,
191      org.w3c.dom.Document document, StructureDefinition profile) throws FHIRException;
192
193  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object)
194      throws FHIRException;
195
196  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object,
197      ValidationProfileSet profiles) throws FHIRException;
198
199  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object,
200      String profile) throws FHIRException;
201
202  org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object,
203      StructureDefinition profile) throws FHIRException;
204
205}