001package org.hl7.fhir.r5.context;
002
003import lombok.Getter;
004import org.fhir.ucum.UcumService;
005import org.hl7.fhir.exceptions.FHIRException;
006import org.hl7.fhir.exceptions.TerminologyServiceException;
007import org.hl7.fhir.r5.model.*;
008import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
009import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
010import org.hl7.fhir.r5.profilemodel.PEBuilder;
011import org.hl7.fhir.r5.profilemodel.PEBuilder.PEElementPropertiesPolicy;
012import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome;
013import org.hl7.fhir.r5.terminologies.utilities.CodingValidationRequest;
014import org.hl7.fhir.r5.terminologies.utilities.ValidationResult;
015import org.hl7.fhir.r5.utils.validation.IResourceValidator;
016import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
017import org.hl7.fhir.utilities.FhirPublication;
018import org.hl7.fhir.utilities.MarkedToMoveToAdjunctPackage;
019import org.hl7.fhir.utilities.TimeTracker;
020import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
021import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
022import org.hl7.fhir.utilities.npm.IPackageCacheManager;
023import org.hl7.fhir.utilities.npm.NpmPackage;
024import org.hl7.fhir.utilities.validation.ValidationOptions;
025
026import javax.annotation.Nonnull;
027import java.io.FileNotFoundException;
028import java.io.IOException;
029import java.util.List;
030import java.util.Locale;
031import java.util.Map;
032import java.util.Set;
033
034
035/**
036 * This is the standard interface used for access to underlying FHIR
037 * services through the tools and utilities provided by the reference
038 * implementation. 
039 *
040 * You need to provide an implementation of IWorkerContext in order to use
041 * the following features:
042 *
043 *  - FHIRPath Engine
044 *  - Rendering
045 *  - Terminology functions
046 *  - Validation
047 *  - Version Comparison
048 *
049 * The class SimpleWorkerContext provides a fully functional implementation
050 * that is thread safe and tied to the use of a local filesystem based
051 * package management context. The primary reason to not use the SimpleWorkerContext
052 * class is to store resources and packages somewhere other than the local filesystem
053 *
054 * If you provide your own implementation, you need to handle packages properly in
055 * order to get correct version resolution
056 *  
057 * @author Grahame
058 */
059
060@MarkedToMoveToAdjunctPackage
061public interface IWorkerContext {
062
063  //region General Properties
064
065  /**
066   * The version loaded *does not* have to be 5.0 (R5) - the context can load other versions, though the definitions
067   * need to be converted to R5 first
068   * 
069   * Note that more than one version might be loaded at once, but one version is always the default / master
070   * 
071   * @return the version of the base definitions loaded in context
072   */
073  public String getVersion();
074
075  /**
076   * @return The URL that points to the specification for the version loaded
077   */
078  public String getSpecUrl();
079
080  /**
081   * @return the locale used when creating messages and invoking the terminology server
082   */
083  Locale getLocale();
084
085  /**
086   * @return the logging service configured for the context
087   */
088  public ILoggingService getLogger();
089
090  /**
091   * @return Get the UCUM service that provides access to units of measure reasoning services (if available)
092   */
093  public UcumService getUcumService();
094
095  /**
096   * @return a handle to provide information about OIDs known to the context (if available)
097   */
098  public IOIDServices oidServices();
099
100  /**
101   * if this returns null, the context is frozen (usually for threading concerns on the server)
102   *
103   * If you're considering not providing this service, the context can't load stuff on the fly
104   * so you need to take care to load everything in advance. In particular, pay attention to
105   * cross-version packages
106   *
107   * Also, beware of the impact of lazy-loading on thread safety
108   *
109   * @return the manager that can be used to load / unload content from the context
110   */
111  public IWorkerContextManager getManager();
112
113  //endregion
114
115  //region Binary and Messaging Support
116
117  /**
118   * Access to the contexts internationalised error messages
119   *
120   * For rendering internationalization, see RenderingContext
121   *
122   * Use String.format() functionality
123   *
124   * @param theMessage
125   * @param theMessageArguments
126   * @return the formatted message
127   */
128  String formatMessage(String theMessage, Object... theMessageArguments);
129
130  /**
131   * Access to the contexts internationalised error messages for messages
132   * with a key plural property.
133   *
134   * There's no support for more than one plural property, so messages are designed accordingly
135   *
136   * For rendering internationalization, see RenderingContext
137   *
138   * Use String.format() functionality
139   *
140   * @param theMessage
141   * @param theMessageArguments
142   * @return the formatted message
143   */
144  String formatMessagePlural(Integer pluralNum, String theMessage, Object... theMessageArguments);
145
146
147  /**
148   * Returns a set of keys that can be used to get binaries from this context.
149   * In general, the binaries come from the loaded packages (mostly the pubpack)
150   *
151   * @return a set of binaries or null
152   */
153  public Set<String> getBinaryKeysAsSet();
154
155  /**
156   * Returns true if this worker context contains a binary for this key.
157   *
158   * @param binaryKey
159   * @return true if binary is available for this key
160   */
161  public boolean hasBinaryKey(String binaryKey);
162
163  /**
164   * Returns the binary for the key
165   * @param binaryKey
166   * @return
167   */
168  public byte[] getBinaryForKey(String binaryKey);
169
170  //endregion
171
172  //region Package Services
173
174  /**
175   * @return true if the nominated package has been loaded
176   */
177  public boolean hasPackage(String id, String ver);
178
179  /**
180   * @return true if the nominated package has been loaded (by id and version)
181   */
182  public boolean hasPackage(PackageInformation pack);
183
184  /**
185   * @return package information for nominated package
186   */
187  public PackageInformation getPackage(String id, String ver);
188
189  /**
190   * Note: take care with this method - there are multiple packages with the same
191   * canonical (different sub-packages, different versions)
192   *
193   * @param url - canonical URL
194   * @return - package information for the most recent package with the given canonical
195   */
196  public PackageInformation getPackageForUrl(String url);
197
198//endregion
199
200  //region Type Management Services
201
202  /**
203   * @return a list of the resource names defined for this version (sorted alphabetically)
204   */
205  public List<String> getResourceNames();
206
207  /**
208   * @return a set of the resource names defined for this version
209   */
210  public Set<String> getResourceNamesAsSet();
211
212  /**
213   * This is a short cut for fetchResource(StructureDefinition.class, ...)
214   * but it accepts a typename - that is, it resolves based on StructureDefinition.type
215   * or StructureDefinition.url. This only resolves to http://hl7.org/fhir/StructureDefinition/{typename}
216   *
217   * @param typeName
218   * @return type (or exception if there is multiple candidates
219   */
220  public StructureDefinition fetchTypeDefinition(String typeName);
221
222  /**
223   * This finds all the structure definitions that have the given typeName
224   *
225   * @param typeName
226   * @return
227   */
228  public List<StructureDefinition> fetchTypeDefinitions(String typeName);
229
230  /**
231   * return whether type is primitive type. This is called a lot, and needs a high performance implementation
232   * @param type
233   * @return
234   */
235  public boolean isPrimitiveType(String type);
236
237  /**
238   * return whether type is data type. This is called a lot, and needs a high performance implementation
239   * @param type
240   * @return
241   */
242  public boolean isDataType(String type);
243
244  //endregion
245
246  //region Canonical Resource Fetchers
247
248  /**
249   * This region provides access to CanonicalResources loaded into the context.
250   * For non-canonical resources, see the next region.
251   *
252   * In general, fetch a resource takes 4 properties:
253   *   - the class of resource wanted (a generics thing - Resource.class, or a particular class)
254   *   - the URL of the canonical resource
255   *   - the version of the resource
256   *   - the source of the reference
257   *
258   *  The URL may contain the version using the |version suffix. It's an error to provide both the suffix and a version.
259   *  version can be in either place for ease of use acros different scenarios; in practice, it's generally best to not
260   *  worry about it being in both places - it should not be and if it is, it's an error in the resource content, and
261   *  just let this routine return an error if it is
262   *
263   *  If no version is provided in either parameter, then the latest known resource will be returned using a general
264   *  heuristic based on the provided version algorithm etc.
265   *
266   *  The source of the reference gives a package context for the resolution, since the
267   *  package context drives the version determination. It should always be provided if the
268   *  reference being fetched come from another resource.
269   */
270
271  /**
272   * find whether a resource is available. the principal use of this method is to find whether
273   * a resource is known without actually loading it.
274   *
275   * @param class_ the type of resource
276   * @param uri the URL of the resource, optionally with a |version suffix
277   * @return if the resource is known
278   */
279  public <T extends Resource> boolean hasResource(Class<T> class_, String uri);
280
281  /**
282   * find whether a resource is available. the principal use of this method is to find whether
283   * a resource is known without actually loading it.
284   *
285   * @param class_ the type of resource
286   * @param uri the URL of the resource, optionally with a |version suffix
287   * @param version the version. Don't provide both a version and a |version suffix
288   * @param sourceOfReference where the reference was found (if the reference is in a resource)
289   * @return if the resource is known
290   */
291  public <T extends Resource> boolean hasResource(Class<T> class_, String uri, String version, Resource sourceOfReference);
292
293  /**
294   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
295   * standard conformance resources that are part of the standard - structure 
296   * definitions, value sets, concept maps, etc.
297   **
298   * The URI can have one of 3 formats:
299   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
300   *  - a relative URL e.g. ValueSet/[id]
301   *  - a logical id e.g. [id]
302   *  
303   * It's an error if the second form doesn't agree with class_. It's an 
304   * error if class_ is null for the last form
305   * 
306   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
307   *
308   * @param class_ the type of resource
309   * @param uri the URL of the resource, optionally with a |version suffix
310   * @return the resource if known (or null)
311   */
312  public <T extends Resource> T fetchResource(Class<T> class_, String uri);
313
314  /**
315   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
316   * standard conformance resources that are part of the standard - structure
317   * definitions, value sets, concept maps, etc.
318   **
319   * The URI can have one of 3 formats:
320   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
321   *  - a relative URL e.g. ValueSet/[id]
322   *  - a logical id e.g. [id]
323   *
324   * It's an error if the second form doesn't agree with class_. It's an
325   * error if class_ is null for the last form
326   *
327   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
328   *
329   * @param class_ the type of resource
330   * @param uri the URL of the resource, optionally with a |version suffix
331   * @param version the version. Don't provide both a version and a |version suffix
332   * @return if the resource is known
333   */
334 // public <T extends Resource> T fetchResource(Class<T> class_, String uri, String version);
335
336  /**
337   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
338   * standard conformance resources that are part of the standard - structure
339   * definitions, value sets, concept maps, etc.
340   **
341   * The URI can have one of 3 formats:
342   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
343   *  - a relative URL e.g. ValueSet/[id]
344   *  - a logical id e.g. [id]
345   *
346   * It's an error if the second form doesn't agree with class_. It's an
347   * error if class_ is null for the last form
348   *
349   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
350   *
351   * @param class_ the type of resource
352   * @param uri the URL of the resource, optionally with a |version suffix
353   * @param version the version. Don't provide both a version and a |version suffix
354   * @param sourceOfReference where the reference was found (if the reference is in a resource)
355   * @return if the resource is known
356   */
357  public <T extends Resource> T fetchResource(Class<T> class_, String uri, String version, Resource sourceOfReference);
358
359  /**
360   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
361   * standard conformance resources that are part of the standard - structure
362   * definitions, value sets, concept maps, etc.
363   **
364   * The URI can have one of 3 formats:
365   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
366   *  - a relative URL e.g. ValueSet/[id]
367   *  - a logical id e.g. [id]
368   *
369   * It's an error if the second form doesn't agree with class_. It's an
370   * error if class_ is null for the last form
371   *
372   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
373   *
374   * @param class_ the type of resource
375   * @param uri the URL of the resource, optionally with a |version suffix
376   * @return the resource if known (or an exception will be thrown)
377   */
378  public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri) throws FHIRException;
379
380  /**
381   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
382   * standard conformance resources that are part of the standard - structure
383   * definitions, value sets, concept maps, etc.
384   **
385   * The URI can have one of 3 formats:
386   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
387   *  - a relative URL e.g. ValueSet/[id]
388   *  - a logical id e.g. [id]
389   *
390   * It's an error if the second form doesn't agree with class_. It's an
391   * error if class_ is null for the last form
392   *
393   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
394   *
395   * @param class_ the type of resource
396   * @param uri the URL of the resource, optionally with a |version suffix
397   * @param version the version. Don't provide both a version and a |version suffix
398   * @param sourceOfReference where the reference was found (if the reference is in a resource)
399   * @return if the resource is known. Will throw an exception if the resource is not known
400   */
401  public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri, String version, Resource sourceOfReference) throws FHIRException;
402
403  /**
404   * Find an identified resource, but do not do any processing on it.
405   * The usual processing that happens is ensuring that the snapshot is
406   * generated before returning it; This routine is used in the snapshot
407   * generation routines to avoid circular dependency challenges generating
408   * snapshots.
409
410   * The URI can have one of 3 formats:
411   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
412   *  - a relative URL e.g. ValueSet/[id]
413   *  - a logical id e.g. [id]
414   *
415   * It's an error if the second form doesn't agree with class_. It's an
416   * error if class_ is null for the last form
417   *
418   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
419   *
420   * @param class_ the type of resource
421   * @param uri the URL of the resource, optionally with a |version suffix
422   * @return the resource if known (or an exception will be thrown)
423   */
424  public <T extends Resource> T fetchResourceRaw(Class<T> class_, String uri);
425
426  /**
427   * Fetch (load if necessary) an identified resource. The most common use of this is to access the
428   * standard conformance resources that are part of the standard - structure
429   * definitions, value sets, concept maps, etc.
430   *
431   * This is the non-generic version, but the functionality is otherwise the same
432   *
433   * The URI can have one of 3 formats:
434   *  - a full URL e.g. http://acme.org/fhir/ValueSet/[id]
435   *  - a relative URL e.g. ValueSet/[id]
436   *  - a logical id e.g. [id]
437   *
438   * It's an error if the second form doesn't agree with class_. It's an
439   * error if class_ is null for the last form
440   *
441   * class can be Resource, DomainResource or CanonicalResource, which means resource of all kinds
442   *
443   * @param type the type of resource
444   * @param uri the URL of the resource, optionally with a |version suffix
445   * @return the resource if known (or null)
446   */
447  public Resource fetchResourceById(String type, String uri);
448
449  /**
450   * Fetch all the resources of a particular type. if class == (null | Resource | DomainResource | CanonicalResource) return everything
451   *
452   * Note: this forces every resource to be loaded; this might take a very long time. Some implementations
453   * require some flag to be set elsewhere to allow this method to be called for some types to prevent the
454   * method from accidentally being called (ValueSets can take minutes to load, since there are so many in scope)
455   *
456   * @param class_ the type of resource to load
457   * @return all the resources
458   */
459  public <T extends Resource> List<T> fetchResourcesByType(Class<T> class_);
460
461  /**
462   * Fetch all the versions of a resource.
463   *
464   * @param class_ the type of resource to load
465   * @return all the resources
466   */
467  public <T extends Resource> List<T> fetchResourceVersions(Class<T> class_, String url);
468
469  //endregion
470
471  //region Terminology services
472
473  /**
474   * this first does a fetch resource, and if nothing is found, looks in the
475   * terminology eco-system for a matching definition for the resource
476   */
477  public <T extends Resource> T findTxResource(Class<T> class_, String canonical);
478  /**
479   * this first does a fetch resource, and if nothing is found, looks in the
480   * terminology eco-system for a matching definition for the resource
481   */
482  public <T extends Resource> T findTxResource(Class<T> class_, String canonical, String version, Resource sourceOfReference);
483
484  /**
485   * Get a copy of the expansion parameters to be passed through the terminology server when txServer calls are made
486   *
487   * You can change these - it's not setting the underlying expansion parameters (see IWorkerContextManager)
488   *
489   * Note that the Validation Options override these when they are specified on validateCode
490   */
491  public Parameters getExpansionParameters();
492
493  /**
494   * Find the code system definition for the nominated system uri. 
495   * return null if there isn't one (then the tool might try 
496   * supportsSystem)
497   * 
498   * This is a short cut for fetchResource(CodeSystem.class, system)
499   * 
500   * @param system
501   * @return
502   */
503  public CodeSystem fetchCodeSystem(String system);
504
505  /**
506   * Find the code system definition for the nominated system uri.
507   * return null if there isn't one (then the tool might try
508   * supportsSystem)
509   *
510   * This is a short cut for fetchResource(CodeSystem.class, system, version, sourceOfReference)
511   */
512  public CodeSystem fetchCodeSystem(String system, String version, Resource sourceOfReference);
513
514  /**
515   * Like fetchCodeSystem, except that the context will find any CodeSysetm supplements and merge them into the
516   * definition that's returned
517   */
518  public CodeSystem fetchSupplementedCodeSystem(String system);
519
520  /**
521   * Like fetchCodeSystem, except that the context will find any CodeSysetm supplements and merge them into the
522   * definition that's returned
523   */
524  public CodeSystem fetchSupplementedCodeSystem(String system, String version, Resource sourceOfReference);
525
526  /**
527   * ValueSet Expansion - see $expand
528   *
529   * Note that caching makes a real performance difference, so turn it off with care.
530   *
531   * @param source - the valueset to expand
532   * @param cacheOk - whether to look in the cache for an expansion
533   * @param heiarchical - whether to accept a heirarchical expansion
534   * @return the expansion, or information about how the expansion failed
535   */
536  @Deprecated
537  public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical);
538
539
540  /**
541   * ValueSet Expansion - see $expand
542   *
543   * Note that caching makes a real performance difference, so turn it off with care.
544   *
545   * @param options - controls the expansion process (overrides expansion parameters)
546   * @param source - the valueset to expand
547   * @return the expansion, or information about how the expansion failed
548   */
549  public ValueSetExpansionOutcome expandVS(ExpansionOptions options, ValueSet source);
550
551  /**
552   * ValueSet Expansion - see $expand
553   *
554   * Note that caching makes a real performance difference, so turn it off with care.
555   *
556   * @param source - the valueset to expand
557   * @param cacheOk - whether to look in the cache for an expansion
558   * @param heiarchical - whether to accept a heirarchical expansion
559   * @param count - maximum concepts to return
560   * @return the expansion, or information about how the expansion failed
561   */
562  @Deprecated
563  public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical, int count);
564
565  /**
566   * ValueSet Expansion - see $expand
567   *
568   * Note that caching makes a real performance difference, so turn it off with care.
569   *
570   * This isn't quite the same as findTxResource+expand because if the uri can't be
571   * resolved, it'll be passed to the terminology service directly, and some terminology
572   * servers will expand value sets that they won't return.
573   *
574   * @param options - controls the expansion process (overrides expansion parameters)
575   * @param uri - valueset uri.
576   * @return the expansion, or information about how the expansion failed
577   */
578  public ValueSetExpansionOutcome expandVS(ExpansionOptions options, String uri); // set to 0 to just check existence
579
580  /**
581   * ValueSet Expansion - see $expand, but resolves the binding first
582   *  
583   * @param src
584   * @return
585   * @throws FHIRException 
586   */
587  @Deprecated
588  public ValueSetExpansionOutcome expandVS(Resource src, ElementDefinitionBindingComponent binding, boolean cacheOk, boolean heiarchical) throws FHIRException;
589
590  /**
591   * Validation of a code - consult the terminology infrstructure and/or service
592   * to see whether it is known. If known, return a description of it
593   *
594   * note: always return a result, with either an error or a code description
595   *
596   * in this case, the system will be inferred from the value set. It's an error to call this one without the value set
597   *
598   * @param options - validation options (required)
599   * @param code The code to validate (required)
600   * @param vs the applicable valueset (required)
601   * @return
602   */
603  public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs);
604
605  /**
606   * Validation of a code - consult the terminology infrstructure and/or service
607   * to see whether it is known. If known, return a description of it
608   *
609   * corresponds to 2 terminology service calls: $validate-code and $lookup
610   *
611   * @param options - validation options (required)
612   * @param system - equals Coding.system (required)
613   * @param code - equals Coding.code (required)
614   * @param display - equals Coding.display (optional)
615   * @return
616   */
617  public ValidationResult validateCode(ValidationOptions options, String system, String version, String code, String display);
618
619  /**
620   * Validation of a code - consult the terminology infrstructure and/or service
621   * to see whether it is known. If known, return a description of it
622   *
623   * note: always return a result, with either an error or a code description
624   *
625   * @param options - validation options (required)
626   * @param system - equals Coding.system (required)
627   * @param code - equals Coding.code (required)
628   * @param display - equals Coding.display (optional)
629   * @param vs the applicable valueset (optional)
630   * @return
631   */
632  public ValidationResult validateCode(ValidationOptions options, String system, String version, String code, String display, ValueSet vs);
633
634  /**
635   * Validation of a code - consult the terminology infrstructure and/or service
636   * to see whether it is known. If known, return a description of it
637   *
638   * note: always return a result, with either an error or a code description
639   *
640   * Note that this doesn't validate binding strength (e.g. is just text allowed?)
641   *
642   * @param options - validation options (required)
643   * @param code - CodeableConcept to validate
644   * @param vs the applicable valueset (optional)
645   * @return
646   */
647  public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs);
648
649  /**
650   * Validation of a code - consult the terminology infrstructure and/or service
651   * to see whether it is known. If known, return a description of it
652   *
653   * note: always return a result, with either an error or a code description
654   *
655   * @param options - validation options (required)
656   * @param code - Coding to validate
657   * @param vs the applicable valueset (optional)
658   * @return
659   */
660  public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs);
661
662  /**
663   * See comments in ValidationContextCarrier. This is called when there might be additional value sets etc
664   * available in the context, but we don't want to pre-process them.
665   *
666   * @param options
667   * @param code
668   * @param vs
669   * @param ctxt
670   * @return
671   */
672  public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs, ValidationContextCarrier ctxt);
673
674  /**
675   * Batch validate code - reduce latency and do a bunch of codes in a single server call.
676   * Each is the same as a validateCode
677   *
678   * @param options
679   * @param codes
680   * @param vs
681   */
682  public void validateCodeBatch(ValidationOptions options, List<? extends CodingValidationRequest> codes, ValueSet vs, boolean passVS);
683
684  /**
685   * Validate the actual terminology resource itself on the appropriate terminology server
686   *
687   * (used for ECL validation)
688   *
689   * @param options
690   * @param resource
691   * @return
692   */
693  public OperationOutcome validateTxResource(ValidationOptions options, Resource resource);
694
695  /**
696   * ask the terminology system whether parent subsumes child.
697   *
698   * @return true if it does, false if it doesn't, and null if it's not know whether it does
699   */
700  public Boolean subsumes(ValidationOptions options, Coding parent, Coding child);
701
702  class SystemSupportInformation {
703    // whether the ssytem(/version) is supported
704    @Getter
705    private boolean supported;
706
707    // the server that supports the system(/version)
708    // may be null for some systems where we never consult any server
709    @Getter
710    private String server;
711
712    // if the server supports it, the set of test cases the server claims to pass (or null)
713    @Getter
714    private String testVersion;
715
716    public boolean isServerSide() { return server != null; }
717    public SystemSupportInformation(boolean supported, String server, String testVersion) {
718      this.supported = supported;
719      this.server = server;
720      this.testVersion = testVersion;
721    }
722
723    public SystemSupportInformation(boolean supported) {
724      this.supported = supported;
725    }
726  }
727  /**
728   * return the System Support Information for the server that serves the specified code system
729   * @param system
730   * @param version
731   * @return
732   */
733  public SystemSupportInformation getTxSupportInfo(String system, String version);
734
735  /**
736   * @return true if there is a terminology server supporting the context
737   */
738  public boolean isNoTerminologyServer();
739
740  /**
741   * @return a list of all the code systems used by the functions above
742   */
743  public Set<String> getCodeSystemsUsed();
744  //endregion
745
746
747  //region Deprecated
748
749  /**
750   * Get a validator that can check whether a resource is valid
751   *
752   * this is deprecated because there's lots of properties to set on the validator;
753   * the functions using this need to be changed to use the validator directly
754   *
755   * @return a prepared generator
756   * @throws FHIRException
757   * @
758   */
759  @Deprecated
760  public IResourceValidator newValidator() throws FHIRException;
761  @Deprecated
762  public PEBuilder getProfiledElementBuilder(PEElementPropertiesPolicy elementProps, boolean fixedProps);
763
764  /**
765   * @return time tracker for when the context is being loaded (0 = start of loading)
766   */
767  @Deprecated
768  public TimeTracker clock();
769
770  //endregion
771
772
773  // todo: figure these out
774  @Deprecated
775  public Map<String, NamingSystem> getNSUrlMap();
776
777  @Deprecated
778  public IWorkerContextManager.IPackageLoadingTracker getPackageTracker();
779  @Deprecated
780  public IWorkerContext setPackageTracker(IWorkerContextManager.IPackageLoadingTracker packageTracker);
781
782  @Deprecated
783  public int getClientRetryCount();
784  @Deprecated
785  public IWorkerContext setClientRetryCount(int value);
786
787
788  @Deprecated
789  public boolean isForPublication();
790  @Deprecated
791  public void setForPublication(boolean value);
792
793}