001package org.hl7.fhir.instance.utils;
002
003import java.util.List;
004
005import org.hl7.fhir.instance.model.StructureDefinition;
006import org.hl7.fhir.utilities.validation.ValidationMessage;
007import org.w3c.dom.Document;
008import org.w3c.dom.Element;
009
010import com.google.gson.JsonObject;
011
012public interface IResourceValidator {
013
014  /**
015   * whether the validator should enforce best practice guidelines
016   * as defined by various HL7 committees 
017   *  
018   *  
019   * @author Grahame Grieve
020   *
021   */
022  public enum BestPracticeWarningLevel {
023    Ignore,
024    Hint,
025    Warning,
026    Error
027  }
028
029  public enum CheckDisplayOption {
030    Ignore,
031    Check,
032    CheckCaseAndSpace,
033    CheckCase,
034    CheckSpace
035  }
036
037  /**
038   * how much to check displays for coded elements 
039   * @return
040   */
041  CheckDisplayOption getCheckDisplay();
042
043  /**
044   * how much to check displays for coded elements 
045   * @return
046   */
047  void setCheckDisplay(CheckDisplayOption checkDisplay);
048
049        enum IdStatus {
050                OPTIONAL, REQUIRED, PROHIBITED
051        }
052        
053  /**
054   * whether the resource must have an id or not (depends on context)
055   * 
056   * @return
057   */
058
059        IdStatus getResourceIdRule();
060        void setResourceIdRule(IdStatus resourceIdRule);
061  
062  BestPracticeWarningLevel getBasePracticeWarningLevel();
063  void setBestPracticeWarningLevel(BestPracticeWarningLevel value);
064  
065  
066  /**
067   * Given a DOM element, return a list of errors in the resource
068   * 
069   * @param errors
070   * @param elem
071   * @- if the underlying infrastructure fails (not if the resource is invalid)
072   */
073  void validate(List<ValidationMessage> errors, Element element) throws Exception;
074
075  /**
076   * Given a JSON Object, return a list of errors in the resource
077   * 
078   * @param errors
079   * @param elem
080   * @- if the underlying infrastructure fails (not if the resource is invalid)
081   */
082  void validate(List<ValidationMessage> errors, JsonObject object) throws Exception;
083
084  /**
085   * Given a DOM element, return a list of errors in the resource
086   * 
087   * @param errors
088   * @param elem
089   * @- if the underlying infrastructure fails (not if the resource is invalid)
090   */
091  List<ValidationMessage> validate(Element element) throws Exception;
092
093  /**
094   * Given a DOM element, return a list of errors in the resource
095   * 
096   * @param errors
097   * @param elem
098   * @- if the underlying infrastructure fails (not if the resource is invalid)
099   */
100  List<ValidationMessage> validate(JsonObject object) throws Exception;
101
102  /**
103   * Given a DOM element, return a list of errors in the resource 
104   * with regard to the specified profile (by logical identifier)
105   *  
106   * @param errors
107   * @param element
108   * @param profile
109   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
110   */
111  void validate(List<ValidationMessage> errors, Element element, String profile) throws Exception;
112
113  /**
114   * Given a DOM element, return a list of errors in the resource 
115   * with regard to the specified profile (by logical identifier)
116   *  
117   * @param errors
118   * @param element
119   * @param profile
120   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
121   */
122        List<ValidationMessage> validate(Element element, String profile) throws Exception;
123
124  /**
125   * Given a DOM element, return a list of errors in the resource 
126   * with regard to the specified profile (by logical identifier)
127   *  
128   * @param errors
129   * @param element
130   * @param profile
131   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
132   */
133  List<ValidationMessage> validate(JsonObject object, StructureDefinition profile) throws Exception;
134
135  /**
136   * Given a DOM element, return a list of errors in the resource 
137   * with regard to the specified profile (by logical identifier)
138   *  
139   * @param errors
140   * @param element
141   * @param profile
142   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
143   */
144  List<ValidationMessage> validate(JsonObject object, String profile) throws Exception;
145
146  /**
147   * Given a DOM element, return a list of errors in the resource 
148   * with regard to the specified profile 
149   *  
150   * @param errors
151   * @param element
152   * @param profile
153   * @- if the underlying infrastructure fails (not if the resource is invalid)
154   */
155  void validate(List<ValidationMessage> errors, Element element, StructureDefinition profile) throws Exception;
156
157  /**
158   * Given a DOM element, return a list of errors in the resource 
159   * with regard to the specified profile 
160   *  
161   * @param errors
162   * @param element
163   * @param profile
164   * @- if the underlying infrastructure fails (not if the resource is invalid)
165   */
166  void validate(List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws Exception;
167
168  /**
169   * Given a DOM element, return a list of errors in the resource 
170   * with regard to the specified profile 
171   *  
172   * @param errors
173   * @param element
174   * @param profile
175   * @- if the underlying infrastructure fails (not if the resource is invalid)
176   */
177  void validate(List<ValidationMessage> errors, JsonObject object, String profile) throws Exception;
178
179  /**
180   * Given a DOM element, return a list of errors in the resource 
181   * with regard to the specified profile
182   *  
183   * @param errors
184   * @param element
185   * @param profile
186   * @- if the underlying infrastructure fails (not if the resource is invalid)
187   */
188  List<ValidationMessage> validate(Element element, StructureDefinition profile) throws Exception;
189
190
191  /**
192   * Given a DOM document, return a list of errors in the resource
193   * 
194   * @param errors
195   * @param elem
196   * @- if the underlying infrastructure fails (not if the resource is invalid)
197   */
198  void validate(List<ValidationMessage> errors, Document document) throws Exception;
199
200  /**
201   * Given a DOM document, return a list of errors in the resource
202   * 
203   * @param errors
204   * @param elem
205   * @- if the underlying infrastructure fails (not if the resource is invalid)
206   */
207  List<ValidationMessage> validate(Document document) throws Exception;
208
209  /**
210   * Given a DOM document, return a list of errors in the resource 
211   * with regard to the specified profile (by logical identifier)
212   *  
213   * @param errors
214   * @param element
215   * @param profile
216   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
217   */
218  void validate(List<ValidationMessage> errors, Document document, String profile) throws Exception;
219
220  /**
221   * Given a DOM document, return a list of errors in the resource 
222   * with regard to the specified profile (by logical identifier)
223   *  
224   * @param errors
225   * @param element
226   * @param profile
227   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
228   */
229        List<ValidationMessage> validate(Document document, String profile) throws Exception;
230
231  /**
232   * Given a DOM document, return a list of errors in the resource 
233   * with regard to the specified profile 
234   *  
235   * @param errors
236   * @param element
237   * @param profile
238   * @- if the underlying infrastructure fails (not if the resource is invalid)
239   */
240  void validate(List<ValidationMessage> errors, Document document, StructureDefinition profile) throws Exception;
241
242  /**
243   * Given a DOM document, return a list of errors in the resource 
244   * with regard to the specified profile
245   *  
246   * @param errors
247   * @param element
248   * @param profile
249   * @- if the underlying infrastructure fails (not if the resource is invalid)
250   */
251  List<ValidationMessage> validate(Document document, StructureDefinition profile) throws Exception;
252
253}