001package org.hl7.fhir.r5.context; 002 003import java.io.FileNotFoundException; 004import java.io.IOException; 005import java.io.InputStream; 006 007/* 008 Copyright (c) 2011+, HL7, Inc. 009 All rights reserved. 010 011 Redistribution and use in source and binary forms, with or without modification, 012 are permitted provided that the following conditions are met: 013 014 * Redistributions of source code must retain the above copyright notice, this 015 list of conditions and the following disclaimer. 016 * Redistributions in binary form must reproduce the above copyright notice, 017 this list of conditions and the following disclaimer in the documentation 018 and/or other materials provided with the distribution. 019 * Neither the name of HL7 nor the names of its contributors may be used to 020 endorse or promote products derived from this software without specific 021 prior written permission. 022 023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 026 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 027 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 028 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 029 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 030 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 031 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 032 POSSIBILITY OF SUCH DAMAGE. 033 034 */ 035 036 037 038import java.util.List; 039import java.util.Locale; 040import java.util.Map; 041import java.util.Set; 042 043import org.fhir.ucum.UcumService; 044import org.hl7.fhir.exceptions.DefinitionException; 045import org.hl7.fhir.exceptions.FHIRException; 046import org.hl7.fhir.exceptions.TerminologyServiceException; 047import org.hl7.fhir.r5.context.TerminologyCache.CacheToken; 048import org.hl7.fhir.r5.elementmodel.Element; 049import org.hl7.fhir.r5.formats.IParser; 050import org.hl7.fhir.r5.formats.ParserType; 051import org.hl7.fhir.r5.model.Bundle; 052import org.hl7.fhir.r5.model.CanonicalResource; 053import org.hl7.fhir.r5.model.CodeSystem; 054import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; 055import org.hl7.fhir.r5.model.CodeableConcept; 056import org.hl7.fhir.r5.model.Coding; 057import org.hl7.fhir.r5.model.ConceptMap; 058import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent; 059import org.hl7.fhir.r5.model.Parameters; 060import org.hl7.fhir.r5.model.Resource; 061import org.hl7.fhir.r5.model.StructureDefinition; 062import org.hl7.fhir.r5.model.StructureMap; 063import org.hl7.fhir.r5.model.ValueSet; 064import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; 065import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; 066import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; 067import org.hl7.fhir.r5.utils.validation.IResourceValidator; 068import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; 069import org.hl7.fhir.utilities.TimeTracker; 070import org.hl7.fhir.utilities.TranslationServices; 071import org.hl7.fhir.utilities.npm.BasePackageCacheManager; 072import org.hl7.fhir.utilities.npm.NpmPackage; 073import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; 074import org.hl7.fhir.utilities.validation.ValidationMessage; 075import org.hl7.fhir.utilities.validation.ValidationOptions; 076 077import com.google.gson.JsonSyntaxException; 078 079 080/** 081 * This is the standard interface used for access to underlying FHIR 082 * services through the tools and utilities provided by the reference 083 * implementation. 084 * 085 * The functionality it provides is 086 * - get access to parsers, validators, narrative builders etc 087 * (you can't create these directly because they need access 088 * to the right context for their information) 089 * 090 * - find resources that the tools need to carry out their tasks 091 * 092 * - provide access to terminology services they need. 093 * (typically, these terminology service requests are just 094 * passed through to the local implementation's terminology 095 * service) 096 * 097 * @author Grahame 098 */ 099public interface IWorkerContext { 100 101 public class CodingValidationRequest { 102 private Coding coding; 103 private ValidationResult result; 104 private CacheToken cacheToken; 105 106 public CodingValidationRequest(Coding coding) { 107 super(); 108 this.coding = coding; 109 } 110 111 public ValidationResult getResult() { 112 return result; 113 } 114 115 public void setResult(ValidationResult result) { 116 this.result = result; 117 } 118 119 public Coding getCoding() { 120 return coding; 121 } 122 123 public boolean hasResult() { 124 return result != null; 125 } 126 127 /** 128 * internal logic; external users of batch validation should ignore this property 129 * 130 * @return 131 */ 132 public CacheToken getCacheToken() { 133 return cacheToken; 134 } 135 136 /** 137 * internal logic; external users of batch validation should ignore this property 138 * 139 * @param cacheToken 140 */ 141 public void setCacheToken(CacheToken cacheToken) { 142 this.cacheToken = cacheToken; 143 } 144 145 146 } 147 148 public class PackageVersion { 149 private String id; 150 private String version; 151 152 public PackageVersion(String source) { 153 if (source == null) { 154 throw new Error("Source cannot be null"); 155 } 156 if (!source.contains("#")) { 157 throw new FHIRException("Source "); 158 } 159 id = source.substring(0, source.indexOf("#")); 160 version = source.substring(source.indexOf("#")+1); 161 } 162 public PackageVersion(String id, String version) { 163 super(); 164 this.id = id; 165 this.version = version; 166 } 167 public String getId() { 168 return id; 169 } 170 public String getVersion() { 171 return version; 172 } 173 public boolean isExamplesPackage() { 174 boolean b = id.startsWith("hl7.fhir.") && id.endsWith(".examples"); 175 return b; 176 } 177 @Override 178 public String toString() { 179 return id+"#"+version; 180 } 181 182 } 183 184 public class PackageDetails extends PackageVersion { 185 private String name; 186 private String canonical; 187 private String web; 188 public PackageDetails(String id, String version, String name, String canonical, String web) { 189 super(id, version); 190 this.name = name; 191 this.canonical = canonical; 192 this.web = web; 193 } 194 public String getName() { 195 return name; 196 } 197 public String getCanonical() { 198 return canonical; 199 } 200 public String getWeb() { 201 return web; 202 } 203 204 } 205 206 public interface ICanonicalResourceLocator { 207 void findResource(Object caller, String url); // if it can be found, put it in the context 208 } 209 210 public interface IContextResourceLoader { 211 /** 212 * @return List of the resource types that should be loaded 213 */ 214 String[] getTypes(); 215 216 /** 217 * Request to actually load the resources and do whatever is required 218 * 219 * @param stream 220 * @param isJson 221 * @return A bundle because some single resources become multiple resources after loading 222 * @throws FHIRException 223 * @throws IOException 224 */ 225 Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException; 226 227 /** 228 * Load a single resources (lazy load) 229 * 230 * @param stream 231 * @param isJson 232 * @return 233 * @throws FHIRException - throw this if you a single resource can't be returned - can't lazy load in this circumstance 234 * @throws IOException 235 */ 236 Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException; 237 238 /** 239 * get the path for references to this resource. 240 * @param resource 241 * @return null if not tracking paths 242 */ 243 String getResourcePath(Resource resource); 244 245 /** 246 * called when a mew package is being loaded 247 * 248 * this is called by loadPacakgeAndDependencies when a new package is loaded 249 * @param npm 250 * @return 251 * @throws IOException 252 * @throws JsonSyntaxException 253 */ 254 IContextResourceLoader getNewLoader(NpmPackage npm) throws JsonSyntaxException, IOException; 255 } 256 257 /** 258 * Get the versions of the definitions loaded in context 259 * @return 260 */ 261 public String getVersion(); 262 263 /** 264 * return the link to the base of the specification for the loaded version e.g. http://hl7.org/fhir/R4 265 */ 266 public String getSpecUrl(); 267 268 // get the UCUM service (might not be available) 269 public UcumService getUcumService(); 270 271 // -- Parsers (read and write instances) ---------------------------------------- 272 273 274 /** 275 * Get a parser to read/write instances. Use the defined type (will be extended 276 * as further types are added, though the only currently anticipate type is RDF) 277 * 278 * XML/JSON - the standard renderers 279 * XHTML - render the narrative only (generate it if necessary) 280 * 281 * @param type 282 * @return 283 */ 284 public IParser getParser(ParserType type); 285 286 /** 287 * Get a parser to read/write instances. Determine the type 288 * from the stated type. Supported value for type: 289 * - the recommended MIME types 290 * - variants of application/xml and application/json 291 * - _format values xml, json 292 * 293 * @param type 294 * @return 295 */ 296 public IParser getParser(String type); 297 298 /** 299 * Get a JSON parser 300 * 301 * @return 302 */ 303 public IParser newJsonParser(); 304 305 /** 306 * Get an XML parser 307 * 308 * @return 309 */ 310 public IParser newXmlParser(); 311 312 /** 313 * Get a validator that can check whether a resource is valid 314 * 315 * @return a prepared generator 316 * @throws FHIRException 317 * @ 318 */ 319 public IResourceValidator newValidator() throws FHIRException; 320 321 // -- resource fetchers --------------------------------------------------- 322 323 /** 324 * Find an identified resource. The most common use of this is to access the the 325 * standard conformance resources that are part of the standard - structure 326 * definitions, value sets, concept maps, etc. 327 * 328 * Also, the narrative generator uses this, and may access any kind of resource 329 * 330 * The URI is called speculatively for things that might exist, so not finding 331 * a matching resouce, return null, not an error 332 * 333 * The URI can have one of 3 formats: 334 * - a full URL e.g. http://acme.org/fhir/ValueSet/[id] 335 * - a relative URL e.g. ValueSet/[id] 336 * - a logical id e.g. [id] 337 * 338 * It's an error if the second form doesn't agree with class_. It's an 339 * error if class_ is null for the last form 340 * 341 * @param resource 342 * @param Reference 343 * @return 344 * @throws FHIRException 345 * @throws Exception 346 */ 347 public <T extends Resource> T fetchResource(Class<T> class_, String uri); 348 public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri) throws FHIRException; 349 public <T extends Resource> T fetchResource(Class<T> class_, String uri, String version); 350 351 /** has the same functionality as fetchResource, but passes in information about the source of the 352 * reference (this may affect resolution of version) 353 * 354 * @param <T> 355 * @param class_ 356 * @param uri 357 * @param canonicalForSource 358 * @return 359 */ 360 public <T extends Resource> T fetchResource(Class<T> class_, String uri, CanonicalResource canonicalForSource); 361 362 /** 363 * Variation of fetchResource when you have a string type, and don't need the right class 364 * 365 * The URI can have one of 3 formats: 366 * - a full URL e.g. http://acme.org/fhir/ValueSet/[id] 367 * - a relative URL e.g. ValueSet/[id] 368 * - a logical id e.g. [id] 369 * 370 * if type == null, the URI can't be a simple logical id 371 * 372 * @param type 373 * @param uri 374 * @return 375 */ 376 public Resource fetchResourceById(String type, String uri); 377 378 /** 379 * find whether a resource is available. 380 * 381 * Implementations of the interface can assume that if hasResource ruturns 382 * true, the resource will usually be fetched subsequently 383 * 384 * @param class_ 385 * @param uri 386 * @return 387 */ 388 public <T extends Resource> boolean hasResource(Class<T> class_, String uri); 389 390 /** 391 * cache a resource for later retrieval using fetchResource. 392 * 393 * Note that various context implementations will have their own ways of loading 394 * rseources, and not all need implement cacheResource. 395 * 396 * If the resource is loaded out of a package, call cacheResourceFromPackage instead 397 * @param res 398 * @throws FHIRException 399 */ 400 public void cacheResource(Resource res) throws FHIRException; 401 402 /** 403 * cache a resource for later retrieval using fetchResource. 404 * 405 * The package information is used to help manage the cache internally, and to 406 * help with reference resolution. Packages should be define using cachePackage (but don't have to be) 407 * 408 * Note that various context implementations will have their own ways of loading 409 * rseources, and not all need implement cacheResource 410 * 411 * @param res 412 * @throws FHIRException 413 */ 414 public void cacheResourceFromPackage(Resource res, PackageVersion packageDetails) throws FHIRException; 415 416 /** 417 * Inform the cache about package dependencies. This can be used to help resolve references 418 * 419 * Note that the cache doesn't load dependencies 420 * 421 * @param packageInfo 422 */ 423 public void cachePackage(PackageDetails packageDetails, List<PackageVersion> dependencies); 424 425 // -- profile services --------------------------------------------------------- 426 427 /** 428 * @return a list of the resource names defined for this version 429 */ 430 public List<String> getResourceNames(); 431 /** 432 * @return a set of the resource names defined for this version 433 */ 434 public Set<String> getResourceNamesAsSet(); 435 436 /** 437 * @return a list of the resource and type names defined for this version 438 */ 439 public List<String> getTypeNames(); 440 441 /** 442 * @return a list of all structure definitions, with snapshots generated (if possible) 443 */ 444 public List<StructureDefinition> allStructures(); 445 446 /** 447 * @return a list of all structure definitions, without trying to generate snapshots 448 */ 449 public List<StructureDefinition> getStructures(); 450 451 /** 452 * @return a list of all conformance resources 453 */ 454 public List<CanonicalResource> allConformanceResources(); 455 456 /** 457 * Given a structure definition, generate a snapshot (or regenerate it) 458 * @param p 459 * @throws DefinitionException 460 * @throws FHIRException 461 */ 462 public void generateSnapshot(StructureDefinition p) throws DefinitionException, FHIRException; 463 public void generateSnapshot(StructureDefinition mr, boolean ifLogical); 464 465 // -- Terminology services ------------------------------------------------------ 466 467 /** 468 * Set the expansion parameters passed through the terminology server when txServer calls are made 469 * 470 * Note that the Validation Options override these when they are specified on validateCode 471 */ 472 public Parameters getExpansionParameters(); 473 474 /** 475 * Get the expansion parameters passed through the terminology server when txServer calls are made 476 * 477 * Note that the Validation Options override these when they are specified on validateCode 478 */ 479 public void setExpansionProfile(Parameters expParameters); 480 481 // these are the terminology services used internally by the tools 482 /** 483 * Find the code system definition for the nominated system uri. 484 * return null if there isn't one (then the tool might try 485 * supportsSystem) 486 * 487 * @param system 488 * @return 489 */ 490 public CodeSystem fetchCodeSystem(String system); 491 public CodeSystem fetchCodeSystem(String system, String version); 492 493 /** 494 * True if the underlying terminology service provider will do 495 * expansion and code validation for the terminology. Corresponds 496 * to the extension 497 * 498 * http://hl7.org/fhir/StructureDefinition/capabilitystatement-supported-system 499 * 500 * in the Conformance resource 501 * 502 * @param system 503 * @return 504 * @throws Exception 505 */ 506 public boolean supportsSystem(String system) throws TerminologyServiceException; 507 508 /** 509 * find concept maps for a source 510 * @param url 511 * @return 512 * @throws FHIRException 513 */ 514 public List<ConceptMap> findMapsForSource(String url) throws FHIRException; 515 516 /** 517 * ValueSet Expansion - see $expand 518 * 519 * @param source 520 * @return 521 */ 522 public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical); 523 524 /** 525 * ValueSet Expansion - see $expand 526 * 527 * @param source 528 * @return 529 */ 530 public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical, boolean incompleteOk); 531 532 /** 533 * ValueSet Expansion - see $expand, but resolves the binding first 534 * 535 * @param source 536 * @return 537 * @throws FHIRException 538 */ 539 public ValueSetExpansionOutcome expandVS(ElementDefinitionBindingComponent binding, boolean cacheOk, boolean heiarchical) throws FHIRException; 540 541 /** 542 * Value set expanion inside the internal expansion engine - used 543 * for references to supported system (see "supportsSystem") for 544 * which there is no value set. 545 * 546 * @param inc 547 * @return 548 * @throws FHIRException 549 */ 550 ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException; 551 552 Locale getLocale(); 553 554 void setLocale(Locale locale); 555 556 String formatMessage(String theMessage, Object... theMessageArguments); 557 558 void setValidationMessageLanguage(Locale locale); 559 560 class ValidationResult { 561 private ConceptDefinitionComponent definition; 562 private String system; 563 private IssueSeverity severity; 564 private String message; 565 private TerminologyServiceErrorClass errorClass; 566 private String txLink; 567 568 @Override 569 public String toString() { 570 return "ValidationResult [definition=" + definition + ", system=" + system + ", severity=" + severity + ", message=" + message + ", errorClass=" 571 + errorClass + ", txLink=" + txLink + "]"; 572 } 573 574 public ValidationResult(IssueSeverity severity, String message) { 575 this.severity = severity; 576 this.message = message; 577 } 578 579 public ValidationResult(String system, ConceptDefinitionComponent definition) { 580 this.system = system; 581 this.definition = definition; 582 } 583 584 public ValidationResult(IssueSeverity severity, String message, String system, ConceptDefinitionComponent definition) { 585 this.severity = severity; 586 this.message = message; 587 this.system = system; 588 this.definition = definition; 589 } 590 591 public ValidationResult(IssueSeverity severity, String message, TerminologyServiceErrorClass errorClass) { 592 this.severity = severity; 593 this.message = message; 594 this.errorClass = errorClass; 595 } 596 597 public boolean isOk() { 598 return severity == null || severity == IssueSeverity.INFORMATION || severity == IssueSeverity.WARNING; 599 } 600 601 public String getSystem() { 602 return system; 603 } 604 605 public String getDisplay() { 606 return definition == null ? null : definition.getDisplay(); 607 } 608 609 public String getCode() { 610 return definition == null ? null : definition.getCode(); 611 } 612 613 public String getDefinition() { 614 return definition == null ? null : definition.getDefinition(); 615 } 616 617 public ConceptDefinitionComponent asConceptDefinition() { 618 return definition; 619 } 620 621 public IssueSeverity getSeverity() { 622 return severity; 623 } 624 625 public String getMessage() { 626 return message; 627 } 628 629 public boolean IsNoService() { 630 return errorClass == TerminologyServiceErrorClass.NOSERVICE; 631 } 632 633 public TerminologyServiceErrorClass getErrorClass() { 634 return errorClass; 635 } 636 637 public ValidationResult setSeverity(IssueSeverity severity) { 638 this.severity = severity; 639 return this; 640 } 641 642 public ValidationResult setMessage(String message) { 643 this.message = message; 644 return this; 645 } 646 647 public ValidationResult setErrorClass(TerminologyServiceErrorClass errorClass) { 648 this.errorClass = errorClass; 649 return this; 650 } 651 652 public String getTxLink() { 653 return txLink; 654 } 655 656 public ValidationResult setTxLink(String txLink) { 657 this.txLink = txLink; 658 return this; 659 } 660 661 public boolean hasMessage() { 662 return message != null; 663 } 664 665 public Coding asCoding() { 666 if (isOk() && definition != null && definition.getCode() != null) { 667 return new Coding(system, definition.getCode(), definition.getDisplay()); 668 } else { 669 return null; 670 } 671 } 672 } 673 674 /** 675 * Validation of a code - consult the terminology infrstructure and/or service 676 * to see whether it is known. If known, return a description of it 677 * 678 * note: always return a result, with either an error or a code description 679 * 680 * corresponds to 2 terminology service calls: $validate-code and $lookup 681 * 682 * in this case, the system will be inferred from the value set. It's an error to call this one without the value set 683 * 684 * @param options - validation options (required) 685 * @param code he code to validate (required) 686 * @param vs the applicable valueset (required) 687 * @return 688 */ 689 public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs); 690 691 /** 692 * Validation of a code - consult the terminology infrstructure and/or service 693 * to see whether it is known. If known, return a description of it 694 * 695 * note: always return a result, with either an error or a code description 696 * 697 * corresponds to 2 terminology service calls: $validate-code and $lookup 698 * 699 * @param options - validation options (required) 700 * @param system - equals Coding.system (required) 701 * @param code - equals Coding.code (required) 702 * @param display - equals Coding.display (optional) 703 * @return 704 */ 705 public ValidationResult validateCode(ValidationOptions options, String system, String version, String code, String display); 706 707 /** 708 * Validation of a code - consult the terminology infrstructure and/or service 709 * to see whether it is known. If known, return a description of it 710 * 711 * note: always return a result, with either an error or a code description 712 * 713 * corresponds to 2 terminology service calls: $validate-code and $lookup 714 * 715 * @param options - validation options (required) 716 * @param system - equals Coding.system (required) 717 * @param code - equals Coding.code (required) 718 * @param display - equals Coding.display (optional) 719 * @param vs the applicable valueset (optional) 720 * @return 721 */ 722 public ValidationResult validateCode(ValidationOptions options, String system, String version, String code, String display, ValueSet vs); 723 724 /** 725 * Validation of a code - consult the terminology infrstructure and/or service 726 * to see whether it is known. If known, return a description of it 727 * 728 * note: always return a result, with either an error or a code description 729 * 730 * corresponds to 2 terminology service calls: $validate-code and $lookup 731 * 732 * Note that this doesn't validate binding strength (e.g. is just text allowed?) 733 * 734 * @param options - validation options (required) 735 * @param code - CodeableConcept to validate 736 * @param vs the applicable valueset (optional) 737 * @return 738 */ 739 public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs); 740 741 /** 742 * Validation of a code - consult the terminology infrstructure and/or service 743 * to see whether it is known. If known, return a description of it 744 * 745 * note: always return a result, with either an error or a code description 746 * 747 * corresponds to 2 terminology service calls: $validate-code and $lookup 748 * 749 * in this case, the system will be inferred from the value set. It's an error to call this one without the value set 750 * 751 * @param options - validation options (required) 752 * @param code - Coding to validate 753 * @param vs the applicable valueset (optional) 754 * @return 755 */ 756 public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs); 757 758 public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs, ValidationContextCarrier ctxt); 759 760 public void validateCodeBatch(ValidationOptions options, List<? extends CodingValidationRequest> codes, ValueSet vs); 761 762 /** 763 * returns the recommended tla for the type (from the structure definitions) 764 * 765 * @param name 766 * @return 767 */ 768 public String getAbbreviation(String name); 769 770 771 /** 772 * translate an OID to a URI (look through known NamingSystems) 773 * @param code 774 * @return 775 */ 776 public String oid2Uri(String code); 777 778 /** 779 * @return true if the contxt has a terminology caching service internally 780 */ 781 public boolean hasCache(); 782 783 public interface ILoggingService { 784 public enum LogCategory { 785 INIT, 786 PROGRESS, 787 TX, 788 CONTEXT, 789 GENERATE, 790 HTML 791 } 792 public void logMessage(String message); // status messages, always display 793 public void logDebugMessage(LogCategory category, String message); // verbose; only when debugging 794 } 795 796 public void setLogger(ILoggingService logger); 797 public ILoggingService getLogger(); 798 799 public boolean isNoTerminologyServer(); 800 public Set<String> getCodeSystemsUsed(); 801 public TranslationServices translator(); 802 public List<StructureMap> listTransforms(); 803 public StructureMap getTransform(String url); 804 805 public String getOverrideVersionNs(); 806 public void setOverrideVersionNs(String value); 807 808 public StructureDefinition fetchTypeDefinition(String typeName); 809 public StructureDefinition fetchRawProfile(String url); 810 811 public void setUcumService(UcumService ucumService); 812 813 public String getLinkForUrl(String corePath, String s); 814 public Map<String, byte[]> getBinaries(); 815 816 /** 817 * Load relevant resources of the appropriate types (as specified by the loader) from the nominated package 818 * 819 * note that the package system uses lazy loading; the loader will be called later when the classes that use the context need the relevant resource 820 * 821 * @param pi - the package to load 822 * @param loader - an implemenation of IContextResourceLoader that knows how to read the resources in the package (e.g. for the appropriate version). 823 * @return the number of resources loaded 824 */ 825 int loadFromPackage(NpmPackage pi, IContextResourceLoader loader) throws FileNotFoundException, IOException, FHIRException; 826 827 /** 828 * Load relevant resources of the appropriate types (as specified by the loader) from the nominated package 829 * 830 * note that the package system uses lazy loading; the loader will be called later when the classes that use the context need the relevant resource 831 * 832 * Deprecated - use the simpler method where the types come from the loader. 833 * 834 * @param pi - the package to load 835 * @param loader - an implemenation of IContextResourceLoader that knows how to read the resources in the package (e.g. for the appropriate version). 836 * @param types - which types of resources to load 837 * @return the number of resources loaded 838 */ 839 @Deprecated 840 int loadFromPackage(NpmPackage pi, IContextResourceLoader loader, String[] types) throws FileNotFoundException, IOException, FHIRException; 841 842 /** 843 * Load relevant resources of the appropriate types (as specified by the loader) from the nominated package 844 * 845 * note that the package system uses lazy loading; the loader will be called later when the classes that use the context need the relevant resource 846 * 847 * This method also loads all the packages that the package depends on (recursively) 848 * 849 * @param pi - the package to load 850 * @param loader - an implemenation of IContextResourceLoader that knows how to read the resources in the package (e.g. for the appropriate version). 851 * @param pcm - used to find and load additional dependencies 852 * @return the number of resources loaded 853 */ 854 int loadFromPackageAndDependencies(NpmPackage pi, IContextResourceLoader loader, BasePackageCacheManager pcm) throws FileNotFoundException, IOException, FHIRException; 855 856 public boolean hasPackage(String id, String ver); 857 public boolean hasPackage(PackageVersion pack); 858 public PackageDetails getPackage(PackageVersion pack); 859 860 public int getClientRetryCount(); 861 public IWorkerContext setClientRetryCount(int value); 862 863 public TimeTracker clock(); 864 865 public PackageVersion getPackageForUrl(String url); 866}