
001package org.hl7.fhir.dstu3.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 032 033import com.google.gson.JsonObject; 034import org.hl7.fhir.dstu3.elementmodel.Manager.FhirFormat; 035import org.hl7.fhir.dstu3.model.StructureDefinition; 036import org.hl7.fhir.dstu3.utils.ValidationProfileSet; 037import org.hl7.fhir.dstu3.utils.validation.constants.BestPracticeWarningLevel; 038import org.hl7.fhir.dstu3.utils.validation.constants.CheckDisplayOption; 039import org.hl7.fhir.dstu3.utils.validation.constants.IdStatus; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.utilities.validation.ValidationMessage; 042 043import java.io.IOException; 044import java.io.InputStream; 045import java.util.List; 046 047/** 048 * Interface to the instance validator. This takes a resource, in one of many forms, and 049 * 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 * @return 059 */ 060 CheckDisplayOption getCheckDisplay(); 061 void setCheckDisplay(CheckDisplayOption checkDisplay); 062 063 /** 064 * whether the resource must have an id or not (depends on context) 065 * 066 * @return 067 */ 068 069 IdStatus getResourceIdRule(); 070 void setResourceIdRule(IdStatus resourceIdRule); 071 072 /** 073 * whether the validator should enforce best practice guidelines 074 * as defined by various HL7 committees 075 * 076 */ 077 BestPracticeWarningLevel getBasePracticeWarningLevel(); 078 IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value); 079 080 IValidatorResourceFetcher getFetcher(); 081 IResourceValidator setFetcher(IValidatorResourceFetcher value); 082 083 IValidationPolicyAdvisor getPolicyAdvisor(); 084 IResourceValidator setPolicyAdvisor(IValidationPolicyAdvisor advisor); 085 086 boolean isNoBindingMsgSuppressed(); 087 IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed); 088 089 boolean isNoInvariantChecks(); 090 IResourceValidator setNoInvariantChecks(boolean value) ; 091 092 boolean isNoTerminologyChecks(); 093 IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks); 094 095 /** 096 * 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 097 * @return 098 */ 099 boolean isErrorForUnknownProfiles(); 100 void setErrorForUnknownProfiles(boolean errorForUnknownProfiles); 101 102 /** 103 * Validate suite 104 * 105 * you can validate one of the following representations of resources: 106 * 107 * stream - provide a format - this is the preferred choice 108 * 109 * Use one of these two if the content is known to be valid XML/JSON, and already parsed 110 * - a DOM element or Document 111 * - a Json Object 112 * 113 * In order to use these, the content must already be parsed - e.g. it must syntactically valid 114 * - a native resource 115 * - a elementmodel resource 116 * 117 * in addition, you can pass one or more profiles ti validate beyond the base standard - as structure definitions or canonical URLs 118 * @throws IOException 119 */ 120 void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.elementmodel.Element element) throws FHIRException, IOException; 121 void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.elementmodel.Element element, ValidationProfileSet profiles) throws FHIRException, IOException; 122 @Deprecated 123 void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.elementmodel.Element element, String profile) throws FHIRException, IOException; 124 @Deprecated 125 void validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.elementmodel.Element element, StructureDefinition profile) throws FHIRException, IOException; 126 127 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream, FhirFormat format) throws FHIRException, IOException; 128 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream, FhirFormat format, ValidationProfileSet profiles) throws FHIRException, IOException; 129 @Deprecated 130 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream, FhirFormat format, String profile) throws FHIRException, IOException; 131 @Deprecated 132 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, InputStream stream, FhirFormat format, StructureDefinition profile) throws FHIRException, IOException; 133 134 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException, IOException; 135 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.model.Resource resource, ValidationProfileSet profiles) throws FHIRException, IOException; 136 @Deprecated 137 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.model.Resource resource, String profile) throws FHIRException, IOException; 138 @Deprecated 139 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.hl7.fhir.dstu3.model.Resource resource, StructureDefinition profile) throws FHIRException, IOException; 140 141 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Element element) throws FHIRException, IOException; 142 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Element element, ValidationProfileSet profiles) throws FHIRException, IOException; 143 @Deprecated 144 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Element element, String profile) throws FHIRException, IOException; 145 @Deprecated 146 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Element element, StructureDefinition profile) throws FHIRException, IOException; 147 148 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Document document) throws FHIRException, IOException; 149 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Document document, ValidationProfileSet profiles) throws FHIRException, IOException; 150 @Deprecated 151 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Document document, String profile) throws FHIRException, IOException; 152 @Deprecated 153 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, org.w3c.dom.Document document, StructureDefinition profile) throws FHIRException, IOException; 154 155 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object) throws FHIRException, IOException; 156 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, ValidationProfileSet profiles) throws FHIRException, IOException; 157 @Deprecated 158 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, String profile) throws FHIRException, IOException; 159 @Deprecated 160 org.hl7.fhir.dstu3.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws FHIRException, IOException; 161 162 163}