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