Repository: FHIR/sushi
Pull request #1548 (2024-12-23 14:58:13)

Support fishing all resource types from dependency packages and input/*
**Description:** In the past, SUSHI only loaded specific resource types from dependency packages and predefined resources in input/* (i.e., StructureDefinitions, ValueSets, and CodeSystems). The recent integration of FPL 2.0.0 now loads all resource types, but SUSHI still did not return them in its results since it only fished (i.e. searched) for the previously supported types. This PR adds support for fishing those types by interpreting a fishing call for the `Type.Instance` type as a wildcard type (since a FSH `Instance` can be literally any type).

This also adds a new `fishForMetadatas` function that will return _all_ the matching `Metadata`s instead of just the first one. This allows for smarter resolution of `Canonical(...)` keywords to ensure that a matched type is resolved when one is available. This change, however, required that I add support for `fishForMetadatas` in all the `Fishable` implementations (not just FHIRDefinitions, but also Tank, Package, some exporters, etc.).

Backstory for `fishForMetadatas` change: Regression failed when I added support for fishing on all resource types because it introduced new types that _could_ now come up in search results _before_ the types it returned in previous versions. In one specific case, an IG was assigning [CarePlan.instantiatesCanonical](https://hl7.org/fhir/R4/careplan-definitions.html#CarePlan.instantiatesCanonical) to `Canonical(SomeGuideline)`. In previous versions of SUSHI, `Canonical(SomeGuideline)` resolved to a `PlanDefinition` defined in `input/fsh` -- but with support for finding additional resource types in packages and predefined inputs, it was now resolving to a `Library` in `input/resources`. This was correct behavior because SUSHI prioritizes predefined resource above FSH definitions (to allow for "patched" resources to override FSH resources) -- but it caused errors because `CarePlan.instantiatesCanonical` allowed for `canonical<PlanDefinition>` but not `canonical<Library>`, so it threw a mismatched type exception (_Canonical(Library) is not one of the allowed types..._). This seemed like an unfortunate error since there _was_ a valid type in scope (the `PlanDefinition` defined in FSH), so I updated SUSHI to look through all the matches if the first match does not satisfy the canonical requirements. Now the regression passes with no changes.

**Testing Instructions:** I've created a simple project that tests both aspects of this: (1) That additional resource types are now loaded (in this case, from predefined resource), and (2) that SUSHI intelligently chooses the right resource based on required Canonical type. You can try running the project using SUSHI 3.13.1, and then this PR branch. The project: [AllTypesTest.zip](https://github.com/user-attachments/files/18230610/AllTypesTest.zip)

**Related Issues:**
* #988 
* #1389 
* #1043 



Patch:
diff --git a/src/export/InstanceExporter.ts b/src/export/InstanceExporter.ts
index 076a10d..bccc074 100644
--- a/src/export/InstanceExporter.ts
+++ b/src/export/InstanceExporter.ts
@@ -757,6 +757,11 @@ export class InstanceExporter implements Fishable {
     return this.fisher.fishForMetadata(item, Type.Instance);
   }
 
+  fishForMetadatas(item: string): Metadata[] {
+    // If it's in the tank, it can get the metadata from there (no need to export like in fishForFHIR)
+    return this.fisher.fishForMetadatas(item, Type.Instance);
+  }
+
   applyInsertRules(): void {
     const instances = this.tank.getAllInstances();
     for (const instance of instances) {
diff --git a/src/export/Package.ts b/src/export/Package.ts
index 4938eec..28bd789 100644
--- a/src/export/Package.ts
+++ b/src/export/Package.ts
@@ -25,6 +25,23 @@ export class Package implements Fishable {
     item: string,
     ...types: Type[]
   ): StructureDefinition | ValueSet | CodeSystem | InstanceDefinition | undefined {
+    return this.internalFish(item, types, true)[0];
+  }
+
+  fishAll(
+    item: string,
+    ...types: Type[]
+  ): (StructureDefinition | ValueSet | CodeSystem | InstanceDefinition)[] {
+    return this.internalFish(item, types, false);
+  }
+
+  private internalFish(
+    item: string,
+    types: Type[],
+    stopOnFirstMatch: boolean
+  ): (StructureDefinition | ValueSet | CodeSystem | InstanceDefinition)[] {
+    const results: (StructureDefinition | ValueSet | CodeSystem | InstanceDefinition)[] = [];
+
     // No types passed in means to search ALL supported types
     if (types.length === 0) {
       types = [
@@ -161,9 +178,13 @@ export class Package implements Fishable {
           break;
       }
       if (def) {
-        return def;
+        if (stopOnFirstMatch) {
+          return [def];
+        }
+        results.push(def);
       }
     }
+    return results;
   }
 
   fishForFHIR(item: string, ...types: Type[]): any | undefined {
@@ -172,6 +193,33 @@ export class Package implements Fishable {
 
   fishForMetadata(item: string, ...types: Type[]): Metadata | undefined {
     const result = this.fish(item, ...types);
+    if (result) {
+      return this.extractMetadata(result);
+    } else if (
+      // If nothing is returned, perhaps the Package itself is being referenced
+      item != null &&
+      (item === this.config.packageId || item === this.config.name || item === this.config.id)
+    ) {
+      return this.extractImplementationGuideMetadataFromConfig();
+    }
+  }
+
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[] {
+    const results = this.fishAll(item, ...types);
+    const metadatas = results.map(result => this.extractMetadata(result));
+    // Also handle cases where the Package itself is being referenced
+    if (
+      item != null &&
+      (item === this.config.packageId || item === this.config.name || item === this.config.id)
+    ) {
+      metadatas.push(this.extractImplementationGuideMetadataFromConfig());
+    }
+    return metadatas;
+  }
+
+  private extractMetadata(
+    result: StructureDefinition | ValueSet | CodeSystem | InstanceDefinition
+  ): Metadata {
     if (result) {
       const metadata: Metadata = {
         id: result.id,
@@ -217,24 +265,22 @@ export class Package implements Fishable {
         }
       }
       return metadata;
-    } else if (
-      // If nothing is returned, perhaps the Package itself is being referenced
-      item != null &&
-      (item === this.config.packageId || item === this.config.name || item === this.config.id)
-    ) {
-      const metadata: Metadata = {
-        id: this.config.packageId || this.config.id,
-        name: this.config.name,
-        url:
-          this.config.url ||
-          `${this.config.canonical}/ImplementationGuide/${this.config.packageId || this.config.id}`,
-        version: this.config.version,
-        resourceType: 'ImplementationGuide'
-      };
-      return metadata;
     }
   }
 
+  private extractImplementationGuideMetadataFromConfig(): Metadata {
+    const metadata: Metadata = {
+      id: this.config.packageId || this.config.id,
+      name: this.config.name,
+      url:
+        this.config.url ||
+        `${this.config.canonical}/ImplementationGuide/${this.config.packageId || this.config.id}`,
+      version: this.config.version,
+      resourceType: 'ImplementationGuide'
+    };
+    return metadata;
+  }
+
   // Resets all the definition arrays to be zero-length. This is useful for re-using a package during testing.
   clearAllDefinitions() {
     this.profiles.length = 0;
diff --git a/src/export/StructureDefinitionExporter.ts b/src/export/StructureDefinitionExporter.ts
index e585cdf..402dc70 100644
--- a/src/export/StructureDefinitionExporter.ts
+++ b/src/export/StructureDefinitionExporter.ts
@@ -1459,6 +1459,11 @@ export class StructureDefinitionExporter implements Fishable {
     return this.fisher.fishForMetadata(item, ...types);
   }
 
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[] {
+    // If it's in the tank, it can get the metadata from there (no need to export like in fishForFHIR)
+    return this.fisher.fishForMetadatas(item, ...types);
+  }
+
   applyInsertRules(): void {
     const invariants = this.tank.getAllInvariants();
     for (const inv of invariants) {
diff --git a/src/fhirdefs/FHIRDefinitions.ts b/src/fhirdefs/FHIRDefinitions.ts
index 9d42013..b41d87b 100644
--- a/src/fhirdefs/FHIRDefinitions.ts
+++ b/src/fhirdefs/FHIRDefinitions.ts
@@ -158,7 +158,7 @@ export class FHIRDefinitions extends BasePackageLoader implements Fishable {
 
   fishForPredefinedResource(item: string, ...types: Type[]): any | undefined {
     return this.findResourceJSON(item, {
-      type: types,
+      type: normalizeTypes(types),
       scope: PREDEFINED_PACKAGE_NAME,
       sort: DEFAULT_SORT
     });
@@ -166,16 +166,25 @@ export class FHIRDefinitions extends BasePackageLoader implements Fishable {
 
   fishForPredefinedResourceMetadata(item: string, ...types: Type[]): Metadata | undefined {
     const info = this.findResourceInfo(item, {
-      type: types,
+      type: normalizeTypes(types),
       scope: PREDEFINED_PACKAGE_NAME,
       sort: DEFAULT_SORT
     });
     return convertInfoToMetadata(info);
   }
 
+  fishForPredefinedResourceMetadatas(item: string, ...types: Type[]): Metadata[] {
+    const infos = this.findResourceInfos(item, {
+      type: normalizeTypes(types),
+      scope: PREDEFINED_PACKAGE_NAME,
+      sort: DEFAULT_SORT
+    });
+    return infos.map(info => convertInfoToMetadata(info));
+  }
+
   fishForFHIR(item: string, ...types: Type[]): any | undefined {
     const def = this.findResourceJSON(item, {
-      type: types,
+      type: normalizeTypes(types),
       sort: DEFAULT_SORT
     });
     if (def) {
@@ -189,7 +198,7 @@ export class FHIRDefinitions extends BasePackageLoader implements Fishable {
 
   fishForMetadata(item: string, ...types: Type[]): Metadata | undefined {
     const info = this.findResourceInfo(item, {
-      type: types,
+      type: normalizeTypes(types),
       sort: DEFAULT_SORT
     });
     if (info) {
@@ -200,6 +209,24 @@ export class FHIRDefinitions extends BasePackageLoader implements Fishable {
       return materializeImpliedExtensionMetadata(item, this);
     }
   }
+
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[] {
+    const infos = this.findResourceInfos(item, {
+      type: normalizeTypes(types),
+      sort: DEFAULT_SORT
+    });
+    if (infos.length) {
+      return infos.map(info => convertInfoToMetadata(info));
+    }
+    // If it's an "implied extension", try to materialize it. See:http://hl7.org/fhir/versions.html#extensions
+    if (IMPLIED_EXTENSION_REGEX.test(item) && types.some(t => t === Type.Extension)) {
+      const info = materializeImpliedExtensionMetadata(item, this);
+      if (info) {
+        return [info];
+      }
+    }
+    return [];
+  }
 }
 
 export async function createFHIRDefinitions(
@@ -223,6 +250,11 @@ export async function createFHIRDefinitions(
   return fhirDefinitions;
 }
 
+function normalizeTypes(types?: Type[]): undefined | string[] {
+  // Instance is like a wildcard, allowing anything -- so treat it like no types are passed in at all
+  return types?.some(t => t === Type.Instance) ? undefined : types;
+}
+
 function convertInfoToMetadata(info: ResourceInfo): Metadata {
   if (info) {
     // Note: explicitly return undefined instead of null to keep tests happy
diff --git a/src/fhirtypes/ElementDefinition.ts b/src/fhirtypes/ElementDefinition.ts
index de4bde7..766205f 100644
--- a/src/fhirtypes/ElementDefinition.ts
+++ b/src/fhirtypes/ElementDefinition.ts
@@ -1944,7 +1944,7 @@ export class ElementDefinition {
       case 'Canonical':
         value = value as FshCanonical;
         // Get the canonical url of the entity
-        const canonicalDefinition = fisher.fishForMetadata(
+        let canonicalDefinition = fisher.fishForMetadata(
           value.entityName,
           Type.Resource,
           Type.Logical,
@@ -1963,7 +1963,30 @@ export class ElementDefinition {
             fisher
           )
         ) {
-          throw new InvalidTypeError(`Canonical(${canonicalDefinition.resourceType})`, this.type);
+          // The first fishing result didn't work. Now check all results in case the fishing matches multiple results.
+          const allMatchingMetadatas = fisher.fishForMetadatas(
+            value.entityName,
+            Type.Resource,
+            Type.Logical,
+            Type.Type,
+            Type.Profile,
+            Type.Extension,
+            Type.ValueSet,
+            Type.CodeSystem,
+            Type.Instance
+          );
+          const otherCanonicalDefinition = allMatchingMetadatas.find(md =>
+            this.typeSatisfiesTargetProfile(
+              md?.resourceType,
+              (value as FshCanonical).sourceInfo,
+              fisher
+            )
+          );
+          if (otherCanonicalDefinition) {
+            canonicalDefinition = otherCanonicalDefinition;
+          } else {
+            throw new InvalidTypeError(`Canonical(${canonicalDefinition.resourceType})`, this.type);
+          }
         }
         if (canonicalDefinition?.url) {
           canonicalUrl = canonicalDefinition.url;
diff --git a/src/import/FSHTank.ts b/src/import/FSHTank.ts
index bb380d9..3628070 100644
--- a/src/import/FSHTank.ts
+++ b/src/import/FSHTank.ts
@@ -199,6 +199,56 @@ export class FSHTank implements Fishable {
     | RuleSet
     | Mapping
     | undefined {
+    return this.internalFish(item, types, true)[0];
+  }
+
+  fishAll(
+    item: string,
+    ...types: Type[]
+  ): (
+    | Profile
+    | Extension
+    | Logical
+    | Resource
+    | FshValueSet
+    | FshCodeSystem
+    | Instance
+    | Invariant
+    | RuleSet
+    | Mapping
+  )[] {
+    return this.internalFish(item, types, false);
+  }
+
+  private internalFish(
+    item: string,
+    types: Type[],
+    stopOnFirstMatch: boolean
+  ): (
+    | Profile
+    | Extension
+    | Logical
+    | Resource
+    | FshValueSet
+    | FshCodeSystem
+    | Instance
+    | Invariant
+    | RuleSet
+    | Mapping
+  )[] {
+    const results: (
+      | Profile
+      | Extension
+      | Logical
+      | Resource
+      | FshValueSet
+      | FshCodeSystem
+      | Instance
+      | Invariant
+      | RuleSet
+      | Mapping
+    )[] = [];
+
     // Resolve alias if necessary
     item = this.resolveAlias(item) ?? item;
 
@@ -222,222 +272,247 @@ export class FSHTank implements Fishable {
       ];
     }
 
+    const allInstances = this.getAllInstances();
     for (const t of types) {
-      let result;
+      let entitiesToSearch;
+      let entityMatcher: (x: any) => boolean;
+      let instanceMatcher: (instance: Instance) => boolean;
       switch (t) {
         case Type.Profile:
-          result = this.getAllProfiles().find(
-            p =>
+          entitiesToSearch = this.getAllProfiles();
+          entityMatcher = (p: Profile) => {
+            return (
               (p.name === base ||
                 p.id === base ||
                 getUrlFromFshDefinition(p, this.config.canonical) === base) &&
               (version == null || version === getVersionFromFshDefinition(p, this.config.version))
-          );
-          if (!result) {
-            result = this.getAllInstances().find(
-              profileInstance =>
-                profileInstance.instanceOf === 'StructureDefinition' &&
-                profileInstance.usage === 'Definition' &&
-                (profileInstance.name === base ||
-                  profileInstance.id === base ||
-                  getUrlFromFshDefinition(profileInstance, this.config.canonical) === base) &&
-                (version == null ||
-                  version === getVersionFromFshDefinition(profileInstance, this.config.version)) &&
-                profileInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'derivation' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'constraint'
-                ) &&
-                !profileInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'type' &&
-                    rule.value === 'Extension'
-                )
             );
-          }
+          };
+          instanceMatcher = (profileInstance: Instance) => {
+            return (
+              profileInstance.instanceOf === 'StructureDefinition' &&
+              profileInstance.usage === 'Definition' &&
+              (profileInstance.name === base ||
+                profileInstance.id === base ||
+                getUrlFromFshDefinition(profileInstance, this.config.canonical) === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(profileInstance, this.config.version)) &&
+              profileInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'derivation' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'constraint'
+              ) &&
+              !profileInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'type' &&
+                  rule.value === 'Extension'
+              )
+            );
+          };
           break;
         case Type.Extension:
-          result = this.getAllExtensions().find(
-            e =>
+          entitiesToSearch = this.getAllExtensions();
+          entityMatcher = (e: Extension) => {
+            return (
               (e.name === base ||
                 e.id === base ||
                 getUrlFromFshDefinition(e, this.config.canonical) === base) &&
               (version == null || version === getVersionFromFshDefinition(e, this.config.version))
-          );
-          if (!result) {
-            // There may be a matching definitional Instance of StructureDefinition with type Extension
-            result = this.getAllInstances().find(
-              extensionInstance =>
-                extensionInstance.instanceOf === 'StructureDefinition' &&
-                extensionInstance.usage === 'Definition' &&
-                (extensionInstance.name === base ||
-                  extensionInstance.id === base ||
-                  getUrlFromFshDefinition(extensionInstance, this.config.canonical) === base) &&
-                (version == null ||
-                  version ===
-                    getVersionFromFshDefinition(extensionInstance, this.config.version)) &&
-                extensionInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'derivation' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'constraint'
-                ) &&
-                extensionInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'type' &&
-                    rule.value === 'Extension'
-                )
             );
-          }
+          };
+          instanceMatcher = (extensionInstance: Instance) => {
+            return (
+              extensionInstance.instanceOf === 'StructureDefinition' &&
+              extensionInstance.usage === 'Definition' &&
+              (extensionInstance.name === base ||
+                extensionInstance.id === base ||
+                getUrlFromFshDefinition(extensionInstance, this.config.canonical) === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(extensionInstance, this.config.version)) &&
+              extensionInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'derivation' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'constraint'
+              ) &&
+              extensionInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'type' &&
+                  rule.value === 'Extension'
+              )
+            );
+          };
           break;
         case Type.Logical:
-          result = this.getAllLogicals().find(
-            l =>
+          entitiesToSearch = this.getAllLogicals();
+          entityMatcher = (l: Logical) => {
+            return (
               (l.name === base ||
                 l.id === base ||
                 getUrlFromFshDefinition(l, this.config.canonical) === base) &&
               (version == null || version === getVersionFromFshDefinition(l, this.config.version))
-          );
-          if (!result) {
-            result = this.getAllInstances().find(
-              logicalInstance =>
-                logicalInstance.instanceOf === 'StructureDefinition' &&
-                logicalInstance.usage === 'Definition' &&
-                (logicalInstance.name === base ||
-                  logicalInstance.id === base ||
-                  getUrlFromFshDefinition(logicalInstance, this.config.canonical) === base) &&
-                (version == null ||
-                  version === getVersionFromFshDefinition(logicalInstance, this.config.version)) &&
-                logicalInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'derivation' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'specialization'
-                ) &&
-                logicalInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'kind' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'logical'
-                )
             );
-          }
+          };
+          instanceMatcher = (logicalInstance: Instance) => {
+            return (
+              logicalInstance.instanceOf === 'StructureDefinition' &&
+              logicalInstance.usage === 'Definition' &&
+              (logicalInstance.name === base ||
+                logicalInstance.id === base ||
+                getUrlFromFshDefinition(logicalInstance, this.config.canonical) === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(logicalInstance, this.config.version)) &&
+              logicalInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'derivation' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'specialization'
+              ) &&
+              logicalInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'kind' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'logical'
+              )
+            );
+          };
           break;
         case Type.Resource:
-          result = this.getAllResources().find(
-            r =>
+          entitiesToSearch = this.getAllResources();
+          entityMatcher = (r: Resource) => {
+            return (
               (r.name === base ||
                 r.id === base ||
                 getUrlFromFshDefinition(r, this.config.canonical) === base) &&
               (version == null || version === getVersionFromFshDefinition(r, this.config.version))
-          );
-          if (!result) {
-            result = this.getAllInstances().find(
-              resourceInstance =>
-                resourceInstance.instanceOf === 'StructureDefinition' &&
-                resourceInstance.usage === 'Definition' &&
-                (resourceInstance.name === base ||
-                  resourceInstance.id === base ||
-                  getUrlFromFshDefinition(resourceInstance, this.config.canonical) === base) &&
-                (version == null ||
-                  version === getVersionFromFshDefinition(resourceInstance, this.config.version)) &&
-                resourceInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'derivation' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'specialization'
-                ) &&
-                resourceInstance.rules.some(
-                  rule =>
-                    rule instanceof AssignmentRule &&
-                    rule.path === 'kind' &&
-                    rule.value instanceof FshCode &&
-                    rule.value.code === 'resource'
-                )
             );
-          }
+          };
+          instanceMatcher = (resourceInstance: Instance) => {
+            return (
+              resourceInstance.instanceOf === 'StructureDefinition' &&
+              resourceInstance.usage === 'Definition' &&
+              (resourceInstance.name === base ||
+                resourceInstance.id === base ||
+                getUrlFromFshDefinition(resourceInstance, this.config.canonical) === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(resourceInstance, this.config.version)) &&
+              resourceInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'derivation' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'specialization'
+              ) &&
+              resourceInstance.rules.some(
+                rule =>
+                  rule instanceof AssignmentRule &&
+                  rule.path === 'kind' &&
+                  rule.value instanceof FshCode &&
+                  rule.value.code === 'resource'
+              )
+            );
+          };
           break;
         case Type.ValueSet:
-          result = this.getAllValueSets().find(
-            vs =>
+          entitiesToSearch = this.getAllValueSets();
+          entityMatcher = (vs: FshValueSet) => {
+            return (
               (vs.name === base ||
                 vs.id === base ||
                 getUrlFromFshDefinition(vs, this.config.canonical) === base ||
                 getNonInstanceValueFromRules(vs, 'name', '', 'name') === base) &&
               (version == null || version === getVersionFromFshDefinition(vs, this.config.version))
-          );
-          if (!result) {
-            result = this.getAllInstances().find(
-              vsInstance =>
-                vsInstance?.instanceOf === 'ValueSet' &&
-                (vsInstance?.usage === 'Definition' || vsInstance?.usage === 'Inline') &&
-                (vsInstance?.name === base ||
-                  vsInstance.id === base ||
-                  getUrlFromFshDefinition(vsInstance, this.config.canonical) === base ||
-                  getNonInstanceValueFromRules(vsInstance, 'name', '', 'name') === base) &&
-                (version == null ||
-                  version === getVersionFromFshDefinition(vsInstance, this.config.version))
             );
-          }
+          };
+          instanceMatcher = (vsInstance: Instance) => {
+            return (
+              vsInstance?.instanceOf === 'ValueSet' &&
+              (vsInstance?.usage === 'Definition' || vsInstance?.usage === 'Inline') &&
+              (vsInstance?.name === base ||
+                vsInstance.id === base ||
+                getUrlFromFshDefinition(vsInstance, this.config.canonical) === base ||
+                getNonInstanceValueFromRules(vsInstance, 'name', '', 'name') === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(vsInstance, this.config.version))
+            );
+          };
           break;
         case Type.CodeSystem:
-          result = this.getAllCodeSystems().find(
-            cs =>
+          entitiesToSearch = this.getAllCodeSystems();
+          entityMatcher = (cs: FshCodeSystem) => {
+            return (
               (cs.name === base ||
                 cs.id === base ||
                 getUrlFromFshDefinition(cs, this.config.canonical) === base ||
                 getNonInstanceValueFromRules(cs, 'name', '', 'name') === base) &&
               (version == null || version === getVersionFromFshDefinition(cs, this.config.version))
-          );
-          if (!result) {
-            result = this.getAllInstances().find(
-              csInstance =>
-                csInstance?.instanceOf === 'CodeSystem' &&
-                (csInstance?.usage === 'Definition' || csInstance?.usage === 'Inline') &&
-                (csInstance?.name === base ||
-                  csInstance.id === base ||
-                  getUrlFromFshDefinition(csInstance, this.config.canonical) === base ||
-                  getNonInstanceValueFromRules(csInstance, 'name', '', 'name') === base) &&
-                (version == null ||
-                  version === getVersionFromFshDefinition(csInstance, this.config.version))
             );
-          }
+          };
+          instanceMatcher = (csInstance: Instance) => {
+            return (
+              csInstance?.instanceOf === 'CodeSystem' &&
+              (csInstance?.usage === 'Definition' || csInstance?.usage === 'Inline') &&
+              (csInstance?.name === base ||
+                csInstance.id === base ||
+                getUrlFromFshDefinition(csInstance, this.config.canonical) === base ||
+                getNonInstanceValueFromRules(csInstance, 'name', '', 'name') === base) &&
+              (version == null ||
+                version === getVersionFromFshDefinition(csInstance, this.config.version))
+            );
+          };
           break;
         case Type.Instance:
-          result = this.getAllInstances().find(
-            i =>
+          entitiesToSearch = allInstances;
+          entityMatcher = (i: Instance) => {
+            return (
               (i.name === base || i.id === base) &&
               (version == null || version === getVersionFromFshDefinition(i, this.config.version))
-          );
+            );
+          };
           break;
         case Type.Invariant:
-          result = this.getAllInvariants().find(i => i.name === base);
+          entitiesToSearch = this.getAllInvariants();
+          entityMatcher = (i: Invariant) => i.name === base;
           break;
         case Type.RuleSet:
-          result = this.getAllRuleSets().find(r => r.name === base);
+          entitiesToSearch = this.getAllRuleSets();
+          entityMatcher = (rs: RuleSet) => rs.name === base;
           break;
         case Type.Mapping:
-          result = this.getAllMappings().find(m => m.name === base);
+          entitiesToSearch = this.getAllMappings();
+          entityMatcher = (m: Mapping) => m.name === base;
           break;
         case Type.Type:
         default:
           // Tank doesn't support these types
-          break;
+          continue;
       }
-      if (result != null) {
-        return result;
+      if (stopOnFirstMatch) {
+        const entity = entitiesToSearch.find(entityMatcher);
+        if (entity) {
+          return [entity];
+        }
+        if (instanceMatcher) {
+          const instance = allInstances.find(instanceMatcher);
+          if (instance) {
+            return [instance];
+          }
+        }
+      } else {
+        results.push(...entitiesToSearch.filter(entityMatcher));
+        if (instanceMatcher) {
+          results.push(...allInstances.filter(instanceMatcher));
+        }
       }
     }
-    // No match, return undefined
-    return;
+    return results;
   }
 
   fishForAppliedRuleSet(item: string): RuleSet | undefined {
@@ -451,23 +526,44 @@ export class FSHTank implements Fishable {
 
   fishForMetadata(item: string, ...types: Type[]): Metadata | undefined {
     const result = this.fish(item, ...types);
-    if (result) {
-      applyInsertRules(result, this);
+    return this.extractMetadataFromEntity(result);
+  }
+
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[] {
+    const results = this.fishAll(item, ...types);
+    return results.map(result => this.extractMetadataFromEntity(result));
+  }
+
+  private extractMetadataFromEntity(
+    entity:
+      | Profile
+      | Extension
+      | Logical
+      | Resource
+      | FshValueSet
+      | FshCodeSystem
+      | Instance
+      | Invariant
+      | RuleSet
+      | Mapping
+  ): Metadata {
+    if (entity) {
+      applyInsertRules(entity, this);
       const meta: Metadata = {
-        id: result.id,
-        name: result.name
+        id: entity.id,
+        name: entity.name
       };
       if (
-        result instanceof Profile ||
-        result instanceof Extension ||
-        result instanceof Logical ||
-        result instanceof Resource
+        entity instanceof Profile ||
+        entity instanceof Extension ||
+        entity instanceof Logical ||
+        entity instanceof Resource
       ) {
-        meta.url = getUrlFromFshDefinition(result, this.config.canonical);
-        meta.parent = result.parent;
+        meta.url = getUrlFromFshDefinition(entity, this.config.canonical);
+        meta.parent = entity.parent;
         meta.resourceType = 'StructureDefinition';
         const imposeProfiles = this.findExtensionValues(
-          result,
+          entity,
           IMPOSE_PROFILE_EXTENSION,
           'structuredefinition-imposeProfile',
           'SDImposeProfile'
@@ -475,33 +571,32 @@ export class FSHTank implements Fishable {
         if (imposeProfiles.length) {
           meta.imposeProfiles = imposeProfiles;
         }
-        if (result instanceof Logical) {
+        if (entity instanceof Logical) {
           // Logical models should always use an absolute URL as their StructureDefinition.type
           // unless HL7 published them. In that case, the URL is relative to
           // http://hl7.org/fhir/StructureDefinition/.
           // Ref: https://chat.fhir.org/#narrow/stream/179177-conformance/topic/StructureDefinition.2Etype.20for.20Logical.20Models.2FCustom.20Resources/near/240488388
           const HL7_URL = 'http://hl7.org/fhir/StructureDefinition/';
           meta.sdType = meta.url.startsWith(HL7_URL) ? meta.url.slice(HL7_URL.length) : meta.url;
-          meta.canBeTarget = this.hasLogicalCharacteristic(result, 'can-be-target');
-          meta.canBind = this.hasLogicalCharacteristic(result, 'can-bind');
+          meta.canBeTarget = this.hasLogicalCharacteristic(entity, 'can-be-target');
+          meta.canBind = this.hasLogicalCharacteristic(entity, 'can-bind');
         }
-      } else if (result instanceof FshValueSet || result instanceof FshCodeSystem) {
-        meta.url = getUrlFromFshDefinition(result, this.config.canonical);
-        if (result instanceof FshValueSet) {
+      } else if (entity instanceof FshValueSet || entity instanceof FshCodeSystem) {
+        meta.url = getUrlFromFshDefinition(entity, this.config.canonical);
+        if (entity instanceof FshValueSet) {
           meta.resourceType = 'ValueSet';
         } else {
           meta.resourceType = 'CodeSystem';
         }
-      } else if (result instanceof Instance) {
-        const assignedUrl = getNonInstanceValueFromRules(result, 'url', '', 'url');
+      } else if (entity instanceof Instance) {
+        const assignedUrl = getNonInstanceValueFromRules(entity, 'url', '', 'url');
         if (typeof assignedUrl === 'string') {
           meta.url = assignedUrl;
         }
-        meta.instanceUsage = result.usage;
+        meta.instanceUsage = entity.usage;
       }
       return meta;
     }
-    return;
   }
 
   // eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/src/utils/Fishable.ts b/src/utils/Fishable.ts
index b2c1fa3..f382307 100644
--- a/src/utils/Fishable.ts
+++ b/src/utils/Fishable.ts
@@ -33,4 +33,5 @@ export interface Metadata {
 export interface Fishable {
   fishForFHIR(item: string, ...types: Type[]): any | undefined;
   fishForMetadata(item: string, ...types: Type[]): Metadata | undefined;
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[];
 }
diff --git a/src/utils/MasterFisher.ts b/src/utils/MasterFisher.ts
index b8316d9..80fdad7 100644
--- a/src/utils/MasterFisher.ts
+++ b/src/utils/MasterFisher.ts
@@ -1,3 +1,4 @@
+import { isEqual, uniqWith } from 'lodash';
 import { Fishable, Type, Metadata } from './Fishable';
 import { FSHTank } from '../import';
 import { FHIRDefinitions } from '../fhirdefs';
@@ -71,29 +72,69 @@ export class MasterFisher implements Fishable {
     let result = this.fhir.fishForPredefinedResourceMetadata(item, ...types);
     if (result != null) return result;
 
-    const fishables = [this.pkg, this.tank, this.fhir].filter(f => f != null);
+    const fishables: Fishable[] = [this.pkg, this.tank, this.fhir].filter(f => f != null);
     for (const fishable of fishables) {
       result = fishable.fishForMetadata(item, ...types);
-      if (result) {
+      if (result != null) {
+        return this.fixMetadata(result, item, types, fishable, fishables);
+      }
+    }
+  }
+
+  /**
+   * Searches for the Metadatas associated with the passed in name/id/url.  It will first search
+   * through the local package (which contains FHIR artifacts exported so far), then through the
+   * tank, then through the external FHIR definitions. This function is useful because it gets
+   * commonly used information without having to force an export. This helps to reduce the risk
+   * of circular dependencies causing problems.
+   * @param item - the item/name/id url to fish for
+   * @param types - the allowable types to fish for
+   */
+  fishForMetadatas(item: string, ...types: Type[]): Metadata[] {
+    // Resolve the alias if necessary
+    item = this.tank?.resolveAlias(item) ?? item;
+
+    const metadatas = this.fhir.fishForPredefinedResourceMetadatas(item, ...types);
+
+    const fishables: Fishable[] = [this.pkg, this.tank, this.fhir].filter(f => f != null);
+    for (const fishable of fishables) {
+      const results = fishable
+        .fishForMetadatas(item, ...types)
+        .map(result => this.fixMetadata(result, item, types, fishable, fishables));
+      metadatas.push(...results);
+    }
+    // It's possible to get duplicates for predefined resource or resources in package and tank, do de-dupe them
+    return uniqWith(metadatas, isEqual);
+  }
+
+  private fixMetadata(
+    metadata: Metadata,
+    item: string,
+    types: Type[],
+    fishable: Fishable,
+    fishables: Fishable[]
+  ) {
+    if (metadata) {
+      if (fishable instanceof FSHTank) {
         // If it came from the tank, we need to get the sdType because the tank doesn't know.
-        if (fishable instanceof FSHTank) {
-          result.sdType = this.findSdType(result, types, fishables);
-        }
+        metadata.sdType = this.findSdType(metadata, types, fishables);
         // When an Instance comes from the FSHTank, the FSHTank doesn't know its resourceType,
         // only its InstanceOf. But here we have access to the other fishers, so we can try
         // to figure that resourceType out here
-        if (fishable instanceof FSHTank && !result.resourceType) {
-          const fshDefinition = fishable.fish(item, ...types);
+        if (!metadata.resourceType) {
+          const fshDefinition = fishable
+            .fishAll(item, ...types)
+            .find(e => e.id == metadata.id && e.name == metadata.name);
           if (fshDefinition instanceof Instance) {
-            result.resourceType = this.fishForMetadata(fshDefinition.instanceOf)?.sdType;
+            metadata.resourceType = this.fishForMetadata(fshDefinition.instanceOf)?.sdType;
           }
         }
-        // Add url to metadata for non-inline Instances
-        if (!result.url && result.instanceUsage !== 'Inline') {
-          result.url = `${this.pkg.config.canonical}/${result.resourceType}/${result.id}`;
-        }
-        return result;
       }
+      // Add url to metadata for non-inline Instances
+      if (!metadata.url && metadata.instanceUsage !== 'Inline') {
+        metadata.url = `${this.pkg.config.canonical}/${metadata.resourceType}/${metadata.id}`;
+      }
+      return metadata;
     }
   }
 


Test patch:
diff --git a/test/export/InstanceExporter.test.ts b/test/export/InstanceExporter.test.ts
index ff3a19e..024611f 100644
--- a/test/export/InstanceExporter.test.ts
+++ b/test/export/InstanceExporter.test.ts
@@ -1,3 +1,4 @@
+import { cloneDeep } from 'lodash';
 import {
   CodeSystemExporter,
   InstanceExporter,
@@ -39,6 +40,7 @@ import {
   TestFisher
 } from '../testhelpers';
 import { InstanceDefinition } from '../../src/fhirtypes';
+import { Type } from '../../src/utils';
 import { minimalConfig } from '../utils/minimalConfig';
 
 describe('InstanceExporter', () => {
@@ -46,6 +48,7 @@ describe('InstanceExporter', () => {
   let doc: FSHDocument;
   let tank: FSHTank;
   let pkg: Package;
+  let fisher: TestFisher;
   let sdExporter: StructureDefinitionExporter;
   let csExporter: CodeSystemExporter;
   let vsExporter: ValueSetExporter;
@@ -61,7 +64,7 @@ describe('InstanceExporter', () => {
     doc = new FSHDocument('fileName');
     tank = new FSHTank([doc], minimalConfig);
     pkg = new Package(tank.config);
-    const fisher = new TestFisher(tank, defs, pkg);
+    fisher = new TestFisher(tank, defs, pkg);
     sdExporter = new StructureDefinitionExporter(tank, pkg, fisher);
     csExporter = new CodeSystemExporter(tank, pkg, fisher);
     vsExporter = new ValueSetExporter(tank, pkg, fisher);
@@ -6693,6 +6696,58 @@ describe('InstanceExporter', () => {
       expect(exported.instantiatesCanonical).toEqual(['http://example.org/PlanDefition/1']); // instantiatesCanonical is set
     });
 
+    it('should assign the right matching Canonical when the Canonical lookup matches multiple types', () => {
+      // Instance: MyClinicalGuidelinePD
+      // InstanceOf: PlanDefinition
+      // * id = "MyClinicalGuideline"
+      // * status = #active
+      const guidelinePD = new Instance('MyClinicalGuidelinePD');
+      guidelinePD.instanceOf = 'PlanDefinition';
+      const idRule = new AssignmentRule('id');
+      idRule.value = 'MyClinicalGuideline';
+      const statusRule = new AssignmentRule('status');
+      statusRule.value = new FshCode('active');
+      guidelinePD.rules.push(idRule, statusRule);
+      doc.instances.set(guidelinePD.name, guidelinePD);
+
+      // Instance: MyClinicalGuidelineLib
+      // InstanceOf: Library
+      // * id = "MyClinicalGuideline"
+      // * status = #active
+      // * type = #logic-library
+      const guidelineLib = new Instance('MyClinicalGuidelineLib');
+      guidelineLib.instanceOf = 'Library';
+      const typeRule = new AssignmentRule('type');
+      typeRule.value = new FshCode('logic-library');
+      // the id and status rules are the same as the pd one, so re-use them
+      guidelineLib.rules.push(cloneDeep(idRule), cloneDeep(statusRule), typeRule);
+      doc.instances.set(guidelineLib.name, guidelineLib);
+
+      // Instance: MainPD
+      // InstanceOf: PlanDefinition
+      // * status = #active
+      // * library = Canonical(MyClinicalGuideline)
+      // * action.definitionCanonical = Canonical(MyClinicalGuideline)
+      const mainPD = new Instance('MainPD');
+      mainPD.instanceOf = 'PlanDefinition';
+      const libraryRule = new AssignmentRule('library');
+      libraryRule.value = new FshCanonical('MyClinicalGuideline'); // NOTE: same canonical ref as actionRule
+      const actionRule = new AssignmentRule('action.definitionCanonical');
+      actionRule.value = new FshCanonical('MyClinicalGuideline'); // NOTE: same canonical ref as libraryRule
+      // the status rule is the same as the pd one so reuse it
+      mainPD.rules.push(cloneDeep(statusRule), libraryRule, actionRule);
+      doc.instances.set(mainPD.name, mainPD);
+
+      const exported = exportInstance(mainPD);
+      expect(loggerSpy.getAllLogs('error')).toBeEmpty();
+      expect(exported.library).toEqual([
+        'http://hl7.org/fhir/us/minimal/Library/MyClinicalGuideline'
+      ]);
+      expect(exported.action[0].definitionCanonical).toEqual(
+        'http://hl7.org/fhir/us/minimal/PlanDefinition/MyClinicalGuideline'
+      );
+    });
+
     it('should assign a Canonical as a #id fragment when referring to a contained resource created as a ValueSet entity', () => {
       // ValueSet: ContainedValueSet
       // Id: contained-value-set
@@ -11822,6 +11877,38 @@ describe('InstanceExporter', () => {
       expect(exported.description).toBeUndefined();
     });
   });
+
+  describe('#fishForMetadata', () => {
+    let fisherSpy: jest.SpyInstance;
+    beforeEach(() => {
+      fisherSpy = jest.spyOn(fisher, 'fishForMetadata');
+    });
+
+    afterEach(() => {
+      fisherSpy.mockReset();
+    });
+
+    it('should use the passed in fisher to fish metadata for instances', () => {
+      expect(exporter.fishForMetadata('some-item')).toBeUndefined();
+      expect(fisherSpy).toHaveBeenCalledWith('some-item', Type.Instance);
+    });
+  });
+
+  describe('#fishForMetadatas', () => {
+    let fisherSpy: jest.SpyInstance;
+    beforeEach(() => {
+      fisherSpy = jest.spyOn(fisher, 'fishForMetadatas');
+    });
+
+    afterEach(() => {
+      fisherSpy.mockReset();
+    });
+
+    it('should use the passed in fisher to fish metadatas for instances', () => {
+      expect(exporter.fishForMetadatas('some-item')).toBeEmpty();
+      expect(fisherSpy).toHaveBeenCalledWith('some-item', Type.Instance);
+    });
+  });
 });
 
 describe('InstanceExporter R5', () => {
diff --git a/test/export/Package.test.ts b/test/export/Package.test.ts
index b2b5f1a..ea91a17 100644
--- a/test/export/Package.test.ts
+++ b/test/export/Package.test.ts
@@ -172,6 +172,13 @@ describe('Package', () => {
     codeSystem1.url = 'http://hl7.org/fhir/us/minimal/CodeSystem/numerics';
     codeSystem1.version = '4.0.1';
     pkg.codeSystems.push(codeSystem1);
+    // CodeSystem[1]: Cheeses / cheese-flavors
+    const codeSystem2 = new CodeSystem();
+    codeSystem2.name = 'Cheeses';
+    codeSystem2.id = 'cheese-flavors';
+    codeSystem2.url = 'http://hl7.org/fhir/us/minimal/CodeSystem/cheese-flavors';
+    codeSystem2.version = '4.0.1';
+    pkg.codeSystems.push(codeSystem2);
     // Instance[0]: DrSue / dr-sue / Practitioner
     const instance0 = new InstanceDefinition();
     instance0._instanceMeta.name = 'DrSue';
@@ -1136,4 +1143,70 @@ describe('Package', () => {
       expect(packageMetadata.resourceType).toEqual('ImplementationGuide');
     });
   });
+
+  describe('#fishForMetadatas()', () => {
+    it('should return all matches when there are multiple matches', () => {
+      const cheesesByID = pkg.fishForMetadatas('cheese-flavors');
+      expect(cheesesByID).toHaveLength(2);
+      expect(cheesesByID).toEqual([
+        {
+          id: 'cheese-flavors',
+          name: 'Cheeses',
+          url: 'http://hl7.org/fhir/us/minimal/ValueSet/cheese-flavors',
+          version: '4.0.1',
+          resourceType: 'ValueSet'
+        },
+        {
+          id: 'cheese-flavors',
+          name: 'Cheeses',
+          url: 'http://hl7.org/fhir/us/minimal/CodeSystem/cheese-flavors',
+          version: '4.0.1',
+          resourceType: 'CodeSystem'
+        }
+      ]);
+      expect(pkg.fishForMetadatas('Cheeses')).toEqual(cheesesByID);
+      expect(
+        pkg.fishForMetadatas('http://hl7.org/fhir/us/minimal/ValueSet/cheese-flavors')
+      ).toEqual(cheesesByID.slice(0, 1));
+      expect(
+        pkg.fishForMetadatas('http://hl7.org/fhir/us/minimal/CodeSystem/cheese-flavors')
+      ).toEqual(cheesesByID.slice(1, 2));
+    });
+
+    it('should return one match when there is a single match', () => {
+      const funnyProfileByID = pkg.fishForMetadatas('fun-ny');
+      expect(funnyProfileByID).toHaveLength(1);
+      expect(funnyProfileByID[0]).toEqual({
+        id: 'fun-ny',
+        name: 'Funny',
+        sdType: 'Condition',
+        url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/fun-ny',
+        parent: 'http://hl7.org/fhir/StructureDefinition/Condition',
+        resourceType: 'StructureDefinition',
+        version: '1.0.0'
+      });
+      expect(pkg.fishForMetadatas('Funny')).toEqual(funnyProfileByID);
+      expect(
+        pkg.fishForMetadatas('http://hl7.org/fhir/us/minimal/StructureDefinition/fun-ny')
+      ).toEqual(funnyProfileByID);
+    });
+
+    it('should return package metadata with an auto-generated url when url is missing', () => {
+      delete pkg.config.url;
+      const packageMetadatas = pkg.fishForMetadatas('MinimalIG');
+
+      expect(packageMetadatas).toHaveLength(1);
+      expect(packageMetadatas[0].id).toEqual(minimalConfig.id);
+      expect(packageMetadatas[0].name).toEqual(minimalConfig.name);
+      expect(packageMetadatas[0].url).toEqual(
+        `${minimalConfig.canonical}/ImplementationGuide/${minimalConfig.id}`
+      );
+      expect(packageMetadatas[0].resourceType).toEqual('ImplementationGuide');
+    });
+
+    it('should return empty array when there are no matches', () => {
+      const packageMetadatas = pkg.fishForMetadatas('NonExistentThing');
+      expect(packageMetadatas).toBeEmpty();
+    });
+  });
 });
diff --git a/test/export/StructureDefinitionExporter.test.ts b/test/export/StructureDefinitionExporter.test.ts
index 797b0f5..1f76607 100644
--- a/test/export/StructureDefinitionExporter.test.ts
+++ b/test/export/StructureDefinitionExporter.test.ts
@@ -53,7 +53,7 @@ import {
   PREDEFINED_PACKAGE_NAME,
   PREDEFINED_PACKAGE_VERSION
 } from '../../src/ig/predefinedResources';
-import { logMessage } from '../../src/utils/FSHLogger';
+import { logMessage, Type } from '../../src/utils';
 
 describe('StructureDefinitionExporter R4', () => {
   let defs: TestFHIRDefinitions;
@@ -10818,6 +10818,38 @@ describe('StructureDefinitionExporter R4', () => {
       );
     });
   });
+
+  describe('#fishForMetadata', () => {
+    let fisherSpy: jest.SpyInstance;
+    beforeEach(() => {
+      fisherSpy = jest.spyOn(fisher, 'fishForMetadata');
+    });
+
+    afterEach(() => {
+      fisherSpy.mockReset();
+    });
+
+    it('should use the passed in fisher to fish metadata for instances', () => {
+      expect(exporter.fishForMetadata('some-item', Type.Profile, Type.Extension)).toBeUndefined();
+      expect(fisherSpy).toHaveBeenCalledWith('some-item', Type.Profile, Type.Extension);
+    });
+  });
+
+  describe('#fishForMetadatas', () => {
+    let fisherSpy: jest.SpyInstance;
+    beforeEach(() => {
+      fisherSpy = jest.spyOn(fisher, 'fishForMetadatas');
+    });
+
+    afterEach(() => {
+      fisherSpy.mockReset();
+    });
+
+    it('should use the passed in fisher to fish metadatas for instances', () => {
+      expect(exporter.fishForMetadatas('some-item', Type.Profile, Type.Extension)).toBeEmpty();
+      expect(fisherSpy).toHaveBeenCalledWith('some-item', Type.Profile, Type.Extension);
+    });
+  });
 });
 
 describe('StructureDefinitionExporter R5', () => {
diff --git a/test/fhirdefs/FHIRDefinitions.test.ts b/test/fhirdefs/FHIRDefinitions.test.ts
index 50113d4..891573c 100644
--- a/test/fhirdefs/FHIRDefinitions.test.ts
+++ b/test/fhirdefs/FHIRDefinitions.test.ts
@@ -9,6 +9,9 @@ import {
 } from '../testhelpers';
 import { R5_DEFINITIONS_NEEDED_IN_R4 } from '../../src/fhirdefs/R5DefsForR4';
 import { InMemoryVirtualPackage } from 'fhir-package-loader';
+import { StructureDefinition, ValueSet, CodeSystem } from '../../src/fhirtypes';
+import { PREDEFINED_PACKAGE_NAME, PREDEFINED_PACKAGE_VERSION } from '../../src/ig';
+import { logMessage } from '../../src/utils';
 
 describe('FHIRDefinitions', () => {
   let defs: FHIRDefinitions;
@@ -35,6 +38,29 @@ describe('FHIRDefinitions', () => {
     await r4bDefs.loadVirtualPackage(getLocalVirtualPackage(testDefsPath('r4b-definitions')));
     r5Defs = await createFHIRDefinitions();
     await r5Defs.loadVirtualPackage(getLocalVirtualPackage(testDefsPath('r5-definitions')));
+    // Add custom/predefined resources. This approximates SUSHI behavior by using the special package name.
+    const predefinedResourceMap = new Map<string, any>();
+    const myPredefinedProfile = new StructureDefinition();
+    myPredefinedProfile.name = 'MyPredefinedProfile';
+    myPredefinedProfile.id = 'my-predefined-profile';
+    myPredefinedProfile.url = 'http://example.com/StructureDefinition/my-predefined-profile';
+    predefinedResourceMap.set('my-predefined-profile', myPredefinedProfile.toJSON(true));
+    const someCodesPredefinedValueSet = new ValueSet();
+    someCodesPredefinedValueSet.name = 'SomeCodes';
+    someCodesPredefinedValueSet.id = 'some-codes';
+    someCodesPredefinedValueSet.url = 'http://example.com/ValueSet/some-codes';
+    predefinedResourceMap.set('some-codes-vs', someCodesPredefinedValueSet);
+    const someCodesPredefinedCodeSystem = new CodeSystem();
+    someCodesPredefinedCodeSystem.name = 'SomeCodes';
+    someCodesPredefinedCodeSystem.id = 'some-codes';
+    someCodesPredefinedCodeSystem.url = 'http://example.com/CodeSystem/some-codes';
+    predefinedResourceMap.set('some-codes-cs', someCodesPredefinedCodeSystem);
+    const predefinedPkg = new InMemoryVirtualPackage(
+      { name: PREDEFINED_PACKAGE_NAME, version: PREDEFINED_PACKAGE_VERSION },
+      predefinedResourceMap,
+      { log: logMessage, allowNonResources: true }
+    );
+    await defs.loadVirtualPackage(predefinedPkg);
   });
 
   beforeEach(() => {
@@ -200,6 +226,18 @@ describe('FHIRDefinitions', () => {
       ).toEqual(allergyStatusCodeSystemByID);
     });
 
+    it('should find other types when the fished type is Type.Instance', () => {
+      const individualGenderSearchParamByID = defs.fishForFHIR('individual-gender', Type.Instance);
+      expect(individualGenderSearchParamByID.url).toBe(
+        'http://hl7.org/fhir/SearchParameter/individual-gender'
+      );
+      expect(individualGenderSearchParamByID.version).toBe('4.0.1');
+      expect(defs.fishForFHIR('gender', Type.Instance)).toEqual(individualGenderSearchParamByID);
+      expect(
+        defs.fishForFHIR('http://hl7.org/fhir/SearchParameter/individual-gender', Type.Instance)
+      ).toEqual(individualGenderSearchParamByID);
+    });
+
     it('should find the time-traveling R5 FHIR resources when R4 is loaded', () => {
       ['ActorDefinition', 'Requirements', 'SubscriptionTopic', 'TestPlan'].forEach(r => {
         const resourceById = defs.fishForFHIR(r, Type.Resource);
@@ -335,8 +373,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(conditionByID).toBeUndefined();
 
@@ -347,8 +384,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(booleanByID).toBeUndefined();
 
@@ -359,8 +395,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(addressByID).toBeUndefined();
 
@@ -371,8 +406,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(vitalSignsProfileByID).toBeUndefined();
 
@@ -383,8 +417,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Profile,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(maidenNameExtensionByID).toBeUndefined();
 
@@ -395,8 +428,7 @@ describe('FHIRDefinitions', () => {
         Type.Logical,
         Type.Type,
         Type.Profile,
-        Type.Extension,
-        Type.Instance
+        Type.Extension
       );
       expect(allergyStatusValueSetByID).toBeUndefined();
 
@@ -407,8 +439,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Profile,
         Type.Extension,
-        Type.ValueSet,
-        Type.Instance
+        Type.ValueSet
       );
       expect(w3cProvenanceCodeSystemByID).toBeUndefined();
 
@@ -419,9 +450,21 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(eLTSSServiceModelByID).toBeUndefined();
+
+      const individualGenderSearchParamByID = defs.fishForFHIR(
+        'individual-gender',
+        Type.Resource,
+        Type.Logical,
+        Type.Type,
+        Type.Profile,
+        Type.Extension,
+        Type.ValueSet,
+        Type.CodeSystem
+      );
+      expect(individualGenderSearchParamByID).toBeUndefined();
     });
 
     it('should globally find any definition', () => {
@@ -494,6 +537,16 @@ describe('FHIRDefinitions', () => {
       expect(
         defs.fishForFHIR('http://hl7.org/fhir/us/eltss/StructureDefinition/eLTSSServiceModel')
       ).toEqual(eLTSSServiceModelByID);
+
+      const individualGenderSearchParamByID = defs.fishForFHIR('individual-gender');
+      expect(individualGenderSearchParamByID.url).toBe(
+        'http://hl7.org/fhir/SearchParameter/individual-gender'
+      );
+      expect(individualGenderSearchParamByID.version).toBe('4.0.1');
+      expect(defs.fishForFHIR('gender')).toEqual(individualGenderSearchParamByID);
+      expect(defs.fishForFHIR('http://hl7.org/fhir/SearchParameter/individual-gender')).toEqual(
+        individualGenderSearchParamByID
+      );
     });
   });
 
@@ -700,6 +753,27 @@ describe('FHIRDefinitions', () => {
       ).toEqual(allergyStatusCodeSystemByID);
     });
 
+    it('should find other types when the fished type is Type.Instance', () => {
+      const individualGenderSearchParamByID = defs.fishForMetadata(
+        'individual-gender',
+        Type.Instance
+      );
+      expect(individualGenderSearchParamByID).toEqual({
+        id: 'individual-gender',
+        name: 'gender',
+        resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'SearchParameter-individual-gender.json')}`,
+        resourceType: 'SearchParameter',
+        url: 'http://hl7.org/fhir/SearchParameter/individual-gender',
+        version: '4.0.1'
+      });
+      expect(defs.fishForMetadata('gender', Type.Instance)).toEqual(
+        individualGenderSearchParamByID
+      );
+      expect(
+        defs.fishForMetadata('http://hl7.org/fhir/SearchParameter/individual-gender', Type.Instance)
+      ).toEqual(individualGenderSearchParamByID);
+    });
+
     it('should find the time-traveling R5 FHIR resources when R4 is loaded', () => {
       ['ActorDefinition', 'Requirements', 'SubscriptionTopic', 'TestPlan'].forEach(r => {
         const resourceById = defs.fishForMetadata(r, Type.Resource);
@@ -865,8 +939,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(conditionByID).toBeUndefined();
 
@@ -877,8 +950,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(booleanByID).toBeUndefined();
 
@@ -889,8 +961,7 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(addressByID).toBeUndefined();
 
@@ -901,8 +972,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Extension,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(vitalSignsProfileByID).toBeUndefined();
 
@@ -913,8 +983,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Profile,
         Type.ValueSet,
-        Type.CodeSystem,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(maidenNameExtensionByID).toBeUndefined();
 
@@ -925,8 +994,7 @@ describe('FHIRDefinitions', () => {
         Type.Logical,
         Type.Type,
         Type.Profile,
-        Type.Extension,
-        Type.Instance
+        Type.Extension
       );
       expect(allergyStatusValueSetByID).toBeUndefined();
 
@@ -937,8 +1005,7 @@ describe('FHIRDefinitions', () => {
         Type.Type,
         Type.Profile,
         Type.Extension,
-        Type.ValueSet,
-        Type.Instance
+        Type.ValueSet
       );
       expect(w3cProvenanceCodeSystemByID).toBeUndefined();
 
@@ -949,9 +1016,21 @@ describe('FHIRDefinitions', () => {
         Type.Profile,
         Type.Extension,
         Type.ValueSet,
-        Type.Instance
+        Type.CodeSystem
       );
       expect(eLTSSServiceModelByID).toBeUndefined();
+
+      const individualGenderSearchParamByID = defs.fishForFHIR(
+        'individual-gender',
+        Type.Resource,
+        Type.Logical,
+        Type.Type,
+        Type.Profile,
+        Type.Extension,
+        Type.ValueSet,
+        Type.CodeSystem
+      );
+      expect(individualGenderSearchParamByID).toBeUndefined();
     });
 
     it('should globally find any definition', () => {
@@ -1089,6 +1168,20 @@ describe('FHIRDefinitions', () => {
       expect(
         defs.fishForMetadata('http://hl7.org/fhir/us/eltss/StructureDefinition/eLTSSServiceModel')
       ).toEqual(eLTSSServiceModelByID);
+
+      const individualGenderSearchParamByID = defs.fishForMetadata('individual-gender');
+      expect(individualGenderSearchParamByID).toEqual({
+        id: 'individual-gender',
+        name: 'gender',
+        resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'SearchParameter-individual-gender.json')}`,
+        resourceType: 'SearchParameter',
+        url: 'http://hl7.org/fhir/SearchParameter/individual-gender',
+        version: '4.0.1'
+      });
+      expect(defs.fishForMetadata('gender')).toEqual(individualGenderSearchParamByID);
+      expect(defs.fishForMetadata('http://hl7.org/fhir/SearchParameter/individual-gender')).toEqual(
+        individualGenderSearchParamByID
+      );
     });
 
     it('should find logical models with the can-bind type characteristic extension', () => {
@@ -1111,6 +1204,201 @@ describe('FHIRDefinitions', () => {
     });
   });
 
+  describe('#fishForMetadatas', () => {
+    it('should return all matches when there are multiple matches', () => {
+      const allergyStatusValueSetByID = defs.fishForMetadatas(
+        'allergyintolerance-clinical',
+        Type.ValueSet,
+        Type.CodeSystem
+      );
+      expect(allergyStatusValueSetByID).toEqual([
+        {
+          id: 'allergyintolerance-clinical',
+          name: 'AllergyIntoleranceClinicalStatusCodes',
+          url: 'http://hl7.org/fhir/ValueSet/allergyintolerance-clinical',
+          version: '4.0.1',
+          resourceType: 'ValueSet',
+          resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'ValueSet-allergyintolerance-clinical.json')}`
+        },
+        {
+          id: 'allergyintolerance-clinical',
+          name: 'AllergyIntoleranceClinicalStatusCodes',
+          url: 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical',
+          version: '4.0.1',
+          resourceType: 'CodeSystem',
+          resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'CodeSystem-allergyintolerance-clinical.json')}`
+        }
+      ]);
+      expect(
+        defs.fishForMetadatas(
+          'AllergyIntoleranceClinicalStatusCodes',
+          Type.ValueSet,
+          Type.CodeSystem
+        )
+      ).toEqual(allergyStatusValueSetByID);
+      expect(
+        defs.fishForMetadatas(
+          'http://hl7.org/fhir/ValueSet/allergyintolerance-clinical',
+          Type.ValueSet,
+          Type.CodeSystem
+        )
+      ).toEqual(allergyStatusValueSetByID.slice(0, 1));
+      expect(
+        defs.fishForMetadatas(
+          'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical',
+          Type.ValueSet,
+          Type.CodeSystem
+        )
+      ).toEqual(allergyStatusValueSetByID.slice(1, 2));
+    });
+
+    it('should return one match when there is a single match', () => {
+      const conditionByID = defs.fishForMetadatas('Condition', Type.Resource);
+      expect(conditionByID).toHaveLength(1);
+      expect(conditionByID[0]).toEqual({
+        abstract: false,
+        id: 'Condition',
+        name: 'Condition',
+        sdType: 'Condition',
+        url: 'http://hl7.org/fhir/StructureDefinition/Condition',
+        version: '4.0.1',
+        parent: 'http://hl7.org/fhir/StructureDefinition/DomainResource',
+        resourceType: 'StructureDefinition',
+        resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'StructureDefinition-Condition.json')}`
+      });
+      expect(
+        defs.fishForMetadatas('http://hl7.org/fhir/StructureDefinition/Condition', Type.Resource)
+      ).toEqual(conditionByID);
+    });
+
+    it('should return empty array when there are no matches', () => {
+      const packageMetadatas = defs.fishForMetadatas('NonExistentThing');
+      expect(packageMetadatas).toBeEmpty();
+    });
+  });
+
+  describe('#allPredefinedResources', () => {
+    it('should return all predefined resources', () => {
+      const results = defs.allPredefinedResources();
+      expect(results).toEqual([
+        expect.objectContaining({
+          resourceType: 'StructureDefinition',
+          id: 'my-predefined-profile'
+        }),
+        expect.objectContaining({
+          resourceType: 'ValueSet',
+          id: 'some-codes'
+        }),
+        expect.objectContaining({
+          resourceType: 'CodeSystem',
+          id: 'some-codes'
+        })
+      ]);
+    });
+  });
+
+  describe('#fishForPredefinedResource', () => {
+    it('should find a matching predefined resource', () => {
+      const result = defs.fishForPredefinedResource('MyPredefinedProfile');
+      expect(result).toMatchObject({
+        resourceType: 'StructureDefinition',
+        id: 'my-predefined-profile'
+      });
+      // Check snapshot just to confirm it's really the full JSON, not just metadata
+      expect(result.snapshot).toBeDefined();
+      expect(defs.fishForPredefinedResource('my-predefined-profile')).toEqual(result);
+      expect(
+        defs.fishForPredefinedResource(
+          'http://example.com/StructureDefinition/my-predefined-profile'
+        )
+      ).toEqual(result);
+    });
+
+    it('should return undefined when there is no match', () => {
+      const result = defs.fishForPredefinedResource('NonExistentItem');
+      expect(result).toBeUndefined();
+    });
+  });
+
+  describe('#fishForPredefinedResourceMetadata', () => {
+    it('should find metadata for a matching predefined resource', () => {
+      const result = defs.fishForPredefinedResourceMetadata('MyPredefinedProfile');
+      expect(result).toEqual({
+        resourceType: 'StructureDefinition',
+        id: 'my-predefined-profile',
+        name: 'MyPredefinedProfile',
+        url: 'http://example.com/StructureDefinition/my-predefined-profile',
+        abstract: false,
+        resourcePath: 'virtual:sushi-local#LOCAL:my-predefined-profile'
+      });
+      expect(defs.fishForPredefinedResourceMetadata('my-predefined-profile')).toEqual(result);
+      expect(
+        defs.fishForPredefinedResourceMetadata(
+          'http://example.com/StructureDefinition/my-predefined-profile'
+        )
+      ).toEqual(result);
+    });
+
+    it('should return undefined when there is no match', () => {
+      const result = defs.fishForPredefinedResourceMetadata('NonExistentItem');
+      expect(result).toBeUndefined();
+    });
+  });
+
+  describe('#fishForPredefinedResourceMetadatas', () => {
+    it('should return all matches when there are multiple matches', () => {
+      const results = defs.fishForPredefinedResourceMetadatas('SomeCodes');
+      expect(results).toHaveLength(2);
+      expect(results).toEqual([
+        {
+          resourceType: 'ValueSet',
+          id: 'some-codes',
+          name: 'SomeCodes',
+          url: 'http://example.com/ValueSet/some-codes',
+          resourcePath: 'virtual:sushi-local#LOCAL:some-codes-vs'
+        },
+        {
+          resourceType: 'CodeSystem',
+          id: 'some-codes',
+          name: 'SomeCodes',
+          url: 'http://example.com/CodeSystem/some-codes',
+          resourcePath: 'virtual:sushi-local#LOCAL:some-codes-cs'
+        }
+      ]);
+      expect(defs.fishForPredefinedResourceMetadatas('some-codes')).toEqual(results);
+      expect(
+        defs.fishForPredefinedResourceMetadatas('http://example.com/ValueSet/some-codes')
+      ).toEqual(results.slice(0, 1));
+      expect(
+        defs.fishForPredefinedResourceMetadatas('http://example.com/CodeSystem/some-codes')
+      ).toEqual(results.slice(1, 2));
+    });
+
+    it('should return one match when there is a single match', () => {
+      const results = defs.fishForPredefinedResourceMetadatas('MyPredefinedProfile');
+      expect(results).toHaveLength(1);
+      expect(results[0]).toEqual({
+        resourceType: 'StructureDefinition',
+        id: 'my-predefined-profile',
+        name: 'MyPredefinedProfile',
+        url: 'http://example.com/StructureDefinition/my-predefined-profile',
+        abstract: false,
+        resourcePath: 'virtual:sushi-local#LOCAL:my-predefined-profile'
+      });
+      expect(defs.fishForPredefinedResourceMetadatas('my-predefined-profile')).toEqual(results);
+      expect(
+        defs.fishForPredefinedResourceMetadatas(
+          'http://example.com/StructureDefinition/my-predefined-profile'
+        )
+      ).toEqual(results);
+    });
+
+    it('should return empty array when there is no match', () => {
+      const results = defs.fishForPredefinedResourceMetadatas('NonExistentItem');
+      expect(results).toBeEmpty();
+    });
+  });
+
   describe('#loadSupplementalFHIRPackage()', () => {
     let testDefs: FHIRDefinitions;
     let supplementalFHIRDefinitionsFactoryMock: jest.Mock;
diff --git a/test/import/FSHTank.test.ts b/test/import/FSHTank.test.ts
index 43f9100..29e3c11 100644
--- a/test/import/FSHTank.test.ts
+++ b/test/import/FSHTank.test.ts
@@ -237,15 +237,19 @@ describe('FSHTank', () => {
     idAssignment.value = 'inst3';
     idRuleset.rules.push(idAssignment);
     doc3.ruleSets.set(idRuleset.name, idRuleset);
-
     doc3.invariants.set('Invariant1', new Invariant('Invariant1'));
     doc3.invariants.get('Invariant1').description = 'first invariant';
     doc3.invariants.get('Invariant1').severity = new FshCode('error');
     doc3.ruleSets.set('RuleSet1', new RuleSet('RuleSet1'));
     doc3.mappings.set('Mapping1', new Mapping('Mapping1'));
     doc3.mappings.get('Mapping1').id = 'map1';
+    const doc4 = new FSHDocument('doc4.fsh');
+    doc4.valueSets.set('SomeCodes', new FshValueSet('SomeCodes'));
+    doc4.valueSets.get('SomeCodes').id = 'some-codes';
+    doc4.codeSystems.set('SomeCodes', new FshCodeSystem('SomeCodes'));
+    doc4.codeSystems.get('SomeCodes').id = 'some-codes';
 
-    tank = new FSHTank([doc1, doc2, doc3], minimalConfig);
+    tank = new FSHTank([doc1, doc2, doc3, doc4], minimalConfig);
   });
 
   describe('#fish', () => {
@@ -854,6 +858,39 @@ describe('FSHTank', () => {
     });
   });
 
+  describe('#fishAll', () => {
+    it('should return all matches when there are multiple matches', () => {
+      const results = tank.fishAll('SomeCodes');
+      expect(results).toHaveLength(2);
+      expect(results[0]).toBeInstanceOf(FshValueSet);
+      expect(results[0].id).toBe('some-codes');
+      expect(results[1]).toBeInstanceOf(FshCodeSystem);
+      expect(results[1].id).toBe('some-codes');
+      expect(tank.fishAll('some-codes')).toEqual(results);
+      expect(tank.fishAll('http://hl7.org/fhir/us/minimal/ValueSet/some-codes')).toEqual(
+        results.slice(0, 1)
+      );
+      expect(tank.fishAll('http://hl7.org/fhir/us/minimal/CodeSystem/some-codes')).toEqual(
+        results.slice(1, 2)
+      );
+    });
+
+    it('should return one match when there is a single match', () => {
+      const results = tank.fishAll('Profile2');
+      expect(results).toHaveLength(1);
+      expect(results[0].id).toBe('prf2');
+      expect(tank.fishAll('prf2')).toEqual(results);
+      expect(tank.fishAll('http://hl7.org/fhir/us/minimal/StructureDefinition/prf2')).toEqual(
+        results
+      );
+    });
+
+    it('should return empty array when there are no matches', () => {
+      const results = tank.fishAll('NonExistentItem');
+      expect(results).toBeEmpty();
+    });
+  });
+
   describe('#fishForMetadata', () => {
     const prf1MD: Metadata = {
       id: 'prf1',
@@ -1265,6 +1302,58 @@ describe('FSHTank', () => {
     });
   });
 
+  describe('#fishForMetadatas', () => {
+    it('should return all matches when there are multiple matches', () => {
+      const results = tank.fishForMetadatas('SomeCodes');
+      expect(results).toHaveLength(2);
+      expect(results).toEqual([
+        {
+          id: 'some-codes',
+          name: 'SomeCodes',
+          url: 'http://hl7.org/fhir/us/minimal/ValueSet/some-codes',
+          resourceType: 'ValueSet'
+        },
+        {
+          id: 'some-codes',
+          name: 'SomeCodes',
+          url: 'http://hl7.org/fhir/us/minimal/CodeSystem/some-codes',
+          resourceType: 'CodeSystem'
+        }
+      ]);
+      expect(tank.fishForMetadatas('some-codes')).toEqual(results);
+      expect(tank.fishForMetadatas('http://hl7.org/fhir/us/minimal/ValueSet/some-codes')).toEqual(
+        results.slice(0, 1)
+      );
+      expect(tank.fishForMetadatas('http://hl7.org/fhir/us/minimal/CodeSystem/some-codes')).toEqual(
+        results.slice(1, 2)
+      );
+    });
+
+    it('should return one match when there is a single match', () => {
+      const results = tank.fishForMetadatas('Logical1');
+      expect(results).toHaveLength(1);
+      expect(results[0]).toEqual({
+        id: 'log1',
+        name: 'Logical1',
+        url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/log1',
+        sdType: 'http://hl7.org/fhir/us/minimal/StructureDefinition/log1',
+        parent: 'Element',
+        resourceType: 'StructureDefinition',
+        canBeTarget: false,
+        canBind: false
+      });
+      expect(tank.fishForMetadatas('log1')).toEqual(results);
+      expect(
+        tank.fishForMetadatas('http://hl7.org/fhir/us/minimal/StructureDefinition/log1')
+      ).toEqual(results);
+    });
+
+    it('should return empty array when there are no matches', () => {
+      const results = tank.fishForMetadatas('NonExistentItem');
+      expect(results).toBeEmpty();
+    });
+  });
+
   describe('#fishForFHIR', () => {
     it('should never return any results for fishForFHIR', () => {
       expect(tank.fishForFHIR('prf1')).toBeUndefined();
diff --git a/test/testhelpers/testdefs/r4-definitions/package/SearchParameter-individual-gender.json b/test/testhelpers/testdefs/r4-definitions/package/SearchParameter-individual-gender.json
new file mode 100644
index 0000000..15857d5
--- /dev/null
+++ b/test/testhelpers/testdefs/r4-definitions/package/SearchParameter-individual-gender.json
@@ -0,0 +1,32 @@
+{
+  "resourceType": "SearchParameter",
+  "id": "individual-gender",
+  "extension": [
+    {
+      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
+      "valueCode": "trial-use"
+    }
+  ],
+  "url": "http://hl7.org/fhir/SearchParameter/individual-gender",
+  "version": "4.0.1",
+  "name": "gender",
+  "status": "draft",
+  "experimental": false,
+  "date": "2019-11-01T09:29:23+11:00",
+  "publisher": "Health Level Seven International (Patient Administration)",
+  "contact": [
+    { "telecom": [{ "system": "url", "value": "http://hl7.org/fhir" }] },
+    {
+      "telecom": [
+        { "system": "url", "value": "http://www.hl7.org/Special/committees/pafm/index.cfm" }
+      ]
+    }
+  ],
+  "description": "Multiple Resources: \r\n\r\n* [Patient](patient.html): Gender of the patient\r\n* [Person](person.html): The gender of the person\r\n* [Practitioner](practitioner.html): Gender of the practitioner\r\n* [RelatedPerson](relatedperson.html): Gender of the related person\r\n",
+  "code": "gender",
+  "base": ["Patient", "Person", "Practitioner", "RelatedPerson"],
+  "type": "token",
+  "expression": "Patient.gender | Person.gender | Practitioner.gender | RelatedPerson.gender",
+  "xpath": "f:Patient/f:gender | f:Person/f:gender | f:Practitioner/f:gender | f:RelatedPerson/f:gender",
+  "xpathUsage": "normal"
+}
diff --git a/test/testhelpers/testdefs/r4-definitions/package/StructureDefinition-Library.json b/test/testhelpers/testdefs/r4-definitions/package/StructureDefinition-Library.json
new file mode 100644
index 0000000..1060066
--- /dev/null
+++ b/test/testhelpers/testdefs/r4-definitions/package/StructureDefinition-Library.json
@@ -0,0 +1,1797 @@
+{
+  "resourceType": "StructureDefinition",
+  "id": "Library",
+  "meta": { "lastUpdated": "2019-11-01T09:29:23.356+11:00" },
+  "extension": [
+    {
+      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
+      "valueString": "Base.Management"
+    },
+    {
+      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
+      "valueCode": "trial-use"
+    },
+    { "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm", "valueInteger": 2 },
+    {
+      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
+      "valueCode": "anonymous"
+    },
+    { "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg", "valueCode": "cds" }
+  ],
+  "url": "http://hl7.org/fhir/StructureDefinition/Library",
+  "version": "4.0.1",
+  "name": "Library",
+  "status": "draft",
+  "date": "2019-11-01T09:29:23+11:00",
+  "publisher": "Health Level Seven International (Clinical Decision Support)",
+  "contact": [
+    { "telecom": [{ "system": "url", "value": "http://hl7.org/fhir" }] },
+    {
+      "telecom": [
+        { "system": "url", "value": "http://www.hl7.org/Special/committees/dss/index.cfm" }
+      ]
+    }
+  ],
+  "description": "The Library resource is a general-purpose container for knowledge asset definitions. It can be used to describe and expose existing knowledge assets such as logic libraries and information model descriptions, as well as to describe a collection of knowledge assets.",
+  "fhirVersion": "4.0.1",
+  "mapping": [
+    { "identity": "rim", "uri": "http://hl7.org/v3", "name": "RIM Mapping" },
+    { "identity": "workflow", "uri": "http://hl7.org/fhir/workflow", "name": "Workflow Pattern" },
+    { "identity": "w5", "uri": "http://hl7.org/fhir/fivews", "name": "FiveWs Pattern Mapping" },
+    {
+      "identity": "objimpl",
+      "uri": "http://hl7.org/fhir/object-implementation",
+      "name": "Object Implementation Information"
+    }
+  ],
+  "kind": "resource",
+  "abstract": false,
+  "type": "Library",
+  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DomainResource",
+  "_baseDefinition": {
+    "extension": [
+      {
+        "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-codegen-super",
+        "valueString": "MetadataResource"
+      }
+    ]
+  },
+  "derivation": "specialization",
+  "snapshot": {
+    "element": [
+      {
+        "id": "Library",
+        "path": "Library",
+        "short": "Represents a library of quality improvement components",
+        "definition": "The Library resource is a general-purpose container for knowledge asset definitions. It can be used to describe and expose existing knowledge assets such as logic libraries and information model descriptions, as well as to describe a collection of knowledge assets.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library", "min": 0, "max": "*" },
+        "constraint": [
+          {
+            "key": "dom-2",
+            "severity": "error",
+            "human": "If the resource is contained in another resource, it SHALL NOT contain nested Resources",
+            "expression": "contained.contained.empty()",
+            "xpath": "not(parent::f:contained and f:contained)",
+            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
+          },
+          {
+            "key": "dom-3",
+            "severity": "error",
+            "human": "If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource or SHALL refer to the containing resource",
+            "expression": "contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(canonical) = '#').exists()).not()).trace('unmatched', id).empty()",
+            "xpath": "not(exists(for $id in f:contained/*/f:id/@value return $contained[not(parent::*/descendant::f:reference/@value=concat('#', $contained/*/id/@value) or descendant::f:reference[@value='#'])]))",
+            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
+          },
+          {
+            "key": "dom-4",
+            "severity": "error",
+            "human": "If a resource is contained in another resource, it SHALL NOT have a meta.versionId or a meta.lastUpdated",
+            "expression": "contained.meta.versionId.empty() and contained.meta.lastUpdated.empty()",
+            "xpath": "not(exists(f:contained/*/f:meta/f:versionId)) and not(exists(f:contained/*/f:meta/f:lastUpdated))",
+            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
+          },
+          {
+            "key": "dom-5",
+            "severity": "error",
+            "human": "If a resource is contained in another resource, it SHALL NOT have a security label",
+            "expression": "contained.meta.security.empty()",
+            "xpath": "not(exists(f:contained/*/f:meta/f:security))",
+            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
+          },
+          {
+            "extension": [
+              {
+                "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice",
+                "valueBoolean": true
+              },
+              {
+                "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice-explanation",
+                "valueMarkdown": "When a resource has no narrative, only systems that fully understand the data can display the resource to a human safely. Including a human readable representation in the resource makes for a much more robust eco-system and cheaper handling of resources by intermediary systems. Some ecosystems restrict distribution of resources to only those systems that do fully understand the resources, and as a consequence implementers may believe that the narrative is superfluous. However experience shows that such eco-systems often open up to new participants over time."
+              }
+            ],
+            "key": "dom-6",
+            "severity": "warning",
+            "human": "A resource should have narrative for robust management",
+            "expression": "text.`div`.exists()",
+            "xpath": "exists(f:text/h:div)",
+            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
+          },
+          {
+            "key": "lib-0",
+            "severity": "warning",
+            "human": "Name should be usable as an identifier for the module by machine processing applications such as code generation",
+            "expression": "name.matches('[A-Z]([A-Za-z0-9_]){0,254}')",
+            "xpath": "not(exists(f:name/@value)) or matches(f:name/@value, '[A-Z]([A-Za-z0-9_]){0,254}')"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          { "identity": "rim", "map": "Entity. Role, or Act" },
+          { "identity": "rim", "map": "Act[classCode=GROUPER;moodCode=EVN]" }
+        ]
+      },
+      {
+        "id": "Library.id",
+        "path": "Library.id",
+        "short": "Logical id of this artifact",
+        "definition": "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.",
+        "comment": "The only time that a resource does not have an id is when it is being submitted to the server using a create operation.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Resource.id", "min": 0, "max": "1" },
+        "type": [
+          {
+            "extension": [
+              {
+                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
+                "valueUrl": "string"
+              }
+            ],
+            "code": "http://hl7.org/fhirpath/System.String"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true
+      },
+      {
+        "id": "Library.meta",
+        "path": "Library.meta",
+        "short": "Metadata about the resource",
+        "definition": "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Resource.meta", "min": 0, "max": "1" },
+        "type": [{ "code": "Meta" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true
+      },
+      {
+        "id": "Library.implicitRules",
+        "path": "Library.implicitRules",
+        "short": "A set of rules under which this content was created",
+        "definition": "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.",
+        "comment": "Asserting this rule set restricts the content to be only understood by a limited set of trading partners. This inherently limits the usefulness of the data in the long term. However, the existing health eco-system is highly fractured, and not yet ready to define, collect, and exchange data in a generally computable sense. Wherever possible, implementers and/or specification writers should avoid using this element. Often, when used, the URL is a reference to an implementation guide that defines these special rules as part of it's narrative along with other profiles, value sets, etc.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Resource.implicitRules", "min": 0, "max": "1" },
+        "type": [{ "code": "uri" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": true,
+        "isModifierReason": "This element is labeled as a modifier because the implicit rules may provide additional knowledge about the resource that modifies it's meaning or interpretation",
+        "isSummary": true
+      },
+      {
+        "id": "Library.language",
+        "path": "Library.language",
+        "short": "Language of the resource content",
+        "definition": "The base language in which the resource is written.",
+        "comment": "Language is provided to support indexing and accessibility (typically, services such as text to speech use the language tag). The html language tag in the narrative applies  to the narrative. The language tag on the resource may be used to specify the language of other presentations generated from the data in the resource. Not all the content has to be in the base language. The Resource.language should not be assumed to apply to the narrative automatically. If a language is specified, it should it also be specified on the div element in the html (see rules in HTML5 for information about the relationship between xml:lang and the html lang attribute).",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Resource.language", "min": 0, "max": "1" },
+        "type": [{ "code": "code" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet",
+              "valueCanonical": "http://hl7.org/fhir/ValueSet/all-languages"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "Language"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
+              "valueBoolean": true
+            }
+          ],
+          "strength": "preferred",
+          "description": "A human language.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/languages"
+        }
+      },
+      {
+        "id": "Library.text",
+        "path": "Library.text",
+        "short": "Text summary of the resource, for human interpretation",
+        "definition": "A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.",
+        "comment": "Contained resources do not have narrative. Resources that are not contained SHOULD have a narrative. In some cases, a resource may only have text with little or no additional discrete data (as long as all minOccurs=1 elements are satisfied).  This may be necessary for data from legacy systems where information is captured as a \"text blob\" or where text is additionally entered raw or narrated and encoded information is added later.",
+        "alias": ["narrative", "html", "xhtml", "display"],
+        "min": 0,
+        "max": "1",
+        "base": { "path": "DomainResource.text", "min": 0, "max": "1" },
+        "type": [{ "code": "Narrative" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "Act.text?" }]
+      },
+      {
+        "id": "Library.contained",
+        "path": "Library.contained",
+        "short": "Contained, inline Resources",
+        "definition": "These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.",
+        "comment": "This should never be done when the content can be identified properly, as once identification is lost, it is extremely difficult (and context dependent) to restore it again. Contained resources may have profiles and tags In their meta elements, but SHALL NOT have security labels.",
+        "alias": ["inline resources", "anonymous resources", "contained resources"],
+        "min": 0,
+        "max": "*",
+        "base": { "path": "DomainResource.contained", "min": 0, "max": "*" },
+        "type": [{ "code": "Resource" }],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A" }]
+      },
+      {
+        "id": "Library.extension",
+        "path": "Library.extension",
+        "short": "Additional content defined by implementations",
+        "definition": "May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
+        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
+        "alias": ["extensions", "user content"],
+        "min": 0,
+        "max": "*",
+        "base": { "path": "DomainResource.extension", "min": 0, "max": "*" },
+        "type": [{ "code": "Extension" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          },
+          {
+            "key": "ext-1",
+            "severity": "error",
+            "human": "Must have either extensions or value[x], not both",
+            "expression": "extension.exists() != value.exists()",
+            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
+            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A" }]
+      },
+      {
+        "id": "Library.modifierExtension",
+        "path": "Library.modifierExtension",
+        "short": "Extensions that cannot be ignored",
+        "definition": "May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
+        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
+        "requirements": "Modifier extensions allow for extensions that *cannot* be safely ignored to be clearly distinguished from the vast majority of extensions which can be safely ignored.  This promotes interoperability by eliminating the need for implementers to prohibit the presence of extensions. For further information, see the [definition of modifier extensions](extensibility.html#modifierExtension).",
+        "alias": ["extensions", "user content"],
+        "min": 0,
+        "max": "*",
+        "base": { "path": "DomainResource.modifierExtension", "min": 0, "max": "*" },
+        "type": [{ "code": "Extension" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          },
+          {
+            "key": "ext-1",
+            "severity": "error",
+            "human": "Must have either extensions or value[x], not both",
+            "expression": "extension.exists() != value.exists()",
+            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
+            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
+          }
+        ],
+        "isModifier": true,
+        "isModifierReason": "Modifier extensions are expected to modify the meaning or interpretation of the resource that contains them",
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A" }]
+      },
+      {
+        "id": "Library.url",
+        "path": "Library.url",
+        "short": "Canonical identifier for this library, represented as a URI (globally unique)",
+        "definition": "An absolute URI that is used to identify this library when it is referenced in a specification, model, design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal address at which at which an authoritative instance of this library is (or will be) published. This URL can be the target of a canonical reference. It SHALL remain the same when the library is stored on different servers.",
+        "comment": "Can be a urn:uuid: or a urn:oid: but real http: addresses are preferred.  Multiple instances may share the same URL if they have a distinct version.\n\nThe determination of when to create a new version of a resource (same url, new version) vs. defining a new artifact is up to the author.  Considerations for making this decision are found in [Technical and Business Versions](resource.html#versions). \n\nIn some cases, the resource can no longer be found at the stated url, but the url itself cannot change. Implementations can use the [meta.source](resource.html#meta) element to indicate where the current master source of the resource can be found.",
+        "requirements": "Allows the library to be referenced by a single globally unique identifier.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.url", "min": 0, "max": "1" },
+        "type": [{ "code": "uri" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.url" },
+          { "identity": "w5", "map": "FiveWs.identifier" },
+          { "identity": "rim", "map": ".identifier[scope=BUSN;reliability=ISS]" }
+        ]
+      },
+      {
+        "id": "Library.identifier",
+        "path": "Library.identifier",
+        "short": "Additional identifier for the library",
+        "definition": "A formal identifier that is used to identify this library when it is represented in other formats, or referenced in a specification, model, design or an instance. e.g. CMS or NQF identifiers for a measure artifact. Note that at least one identifier is required for non-experimental active artifacts.",
+        "comment": "Typically, this is used for identifiers that can go in an HL7 V3 II (instance identifier) data type, and can then identify this library outside of FHIR, where it is not possible to use the logical URI.",
+        "requirements": "Allows externally provided and/or usable business identifiers to be easily associated with the module.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.identifier", "min": 0, "max": "*" },
+        "type": [{ "code": "Identifier" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.identifier" },
+          { "identity": "w5", "map": "FiveWs.identifier" },
+          { "identity": "rim", "map": ".identifier" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.version",
+        "path": "Library.version",
+        "short": "Business version of the library",
+        "definition": "The identifier that is used to identify this version of the library when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the library author and is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is not available. There is also no expectation that versions can be placed in a lexicographical sequence. To provide a version consistent with the Decision Support Service specification, use the format Major.Minor.Revision (e.g. 1.0.0). For more information on versioning knowledge assets, refer to the Decision Support Service specification. Note that a version is required for non-experimental active artifacts.",
+        "comment": "There may be different library instances that have the same identifier but different versions.  The version can be appended to the url in a reference to allow a reference to a particular business version of the library with the format [url]|[version].",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.version", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.version" },
+          { "identity": "w5", "map": "FiveWs.version" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.name",
+        "path": "Library.name",
+        "short": "Name for this library (computer friendly)",
+        "definition": "A natural language name identifying the library. This name should be usable as an identifier for the module by machine processing applications such as code generation.",
+        "comment": "The name is not expected to be globally unique. The name should be a simple alphanumeric type name to ensure that it is machine-processing friendly.",
+        "requirements": "Support human navigation and code generation.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.name", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "condition": ["inv-0"],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [{ "identity": "rim", "map": "N/A" }]
+      },
+      {
+        "id": "Library.title",
+        "path": "Library.title",
+        "short": "Name for this library (human friendly)",
+        "definition": "A short, descriptive, user-friendly title for the library.",
+        "comment": "This name does not need to be machine-processing friendly and may contain punctuation, white-space, etc.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.title", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.title" },
+          { "identity": "rim", "map": ".title" }
+        ]
+      },
+      {
+        "id": "Library.subtitle",
+        "path": "Library.subtitle",
+        "short": "Subordinate title of the library",
+        "definition": "An explanatory or alternate title for the library giving additional information about its content.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.subtitle", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false
+      },
+      {
+        "id": "Library.status",
+        "path": "Library.status",
+        "short": "draft | active | retired | unknown",
+        "definition": "The status of this library. Enables tracking the life-cycle of the content.",
+        "comment": "Allows filtering of libraries that are appropriate for use vs. not.",
+        "min": 1,
+        "max": "1",
+        "base": { "path": "Library.status", "min": 1, "max": "1" },
+        "type": [{ "code": "code" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": true,
+        "isModifierReason": "This is labeled as \"Is Modifier\" because applications should not use a retired {{title}} without due consideration",
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "PublicationStatus"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
+              "valueBoolean": true
+            }
+          ],
+          "strength": "required",
+          "description": "The lifecycle status of an artifact.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/publication-status|4.0.1"
+        },
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.status" },
+          { "identity": "w5", "map": "FiveWs.status" },
+          { "identity": "rim", "map": ".status" }
+        ]
+      },
+      {
+        "id": "Library.experimental",
+        "path": "Library.experimental",
+        "short": "For testing purposes, not real usage",
+        "definition": "A Boolean value to indicate that this library is authored for testing purposes (or education/evaluation/marketing) and is not intended to be used for genuine usage.",
+        "comment": "Allows filtering of librarys that are appropriate for use versus not.",
+        "requirements": "Enables experimental content to be developed following the same lifecycle that would be used for a production-level library.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.experimental", "min": 0, "max": "1" },
+        "type": [{ "code": "boolean" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.experimental" },
+          { "identity": "w5", "map": "FiveWs.class" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.type",
+        "path": "Library.type",
+        "short": "logic-library | model-definition | asset-collection | module-definition",
+        "definition": "Identifies the type of library such as a Logic Library, Model Definition, Asset Collection, or Module Definition.",
+        "min": 1,
+        "max": "1",
+        "base": { "path": "Library.type", "min": 1, "max": "1" },
+        "type": [{ "code": "CodeableConcept" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "LibraryType"
+            }
+          ],
+          "strength": "extensible",
+          "description": "The type of knowledge asset this library contains.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/library-type"
+        },
+        "mapping": [
+          { "identity": "w5", "map": "FiveWs.what[x]" },
+          { "identity": "rim", "map": ".code" }
+        ]
+      },
+      {
+        "id": "Library.subject[x]",
+        "path": "Library.subject[x]",
+        "short": "Type of individual the library content is focused on",
+        "definition": "A code or group definition that describes the intended subject of the contents of the library.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.subject[x]", "min": 0, "max": "1" },
+        "type": [
+          { "code": "CodeableConcept" },
+          {
+            "code": "Reference",
+            "targetProfile": ["http://hl7.org/fhir/StructureDefinition/Group"]
+          }
+        ],
+        "meaningWhenMissing": "Patient",
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "SubjectType"
+            }
+          ],
+          "strength": "extensible",
+          "description": "The possible types of subjects for a library (E.g. Patient, Practitioner, Organization, Location, etc.).",
+          "valueSet": "http://hl7.org/fhir/ValueSet/subject-type"
+        }
+      },
+      {
+        "id": "Library.date",
+        "path": "Library.date",
+        "short": "Date last changed",
+        "definition": "The date  (and optionally time) when the library was published. The date must change when the business version changes and it must change if the status code changes. In addition, it should change when the substantive content of the library changes.",
+        "comment": "Note that this is not the same as the resource last-modified-date, since the resource may be a secondary representation of the library. Additional specific dates may be added as extensions or be found by consulting Provenances associated with past versions of the resource.",
+        "alias": ["Revision Date"],
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.date", "min": 0, "max": "1" },
+        "type": [{ "code": "dateTime" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.date" },
+          { "identity": "w5", "map": "FiveWs.recorded" },
+          { "identity": "rim", "map": ".participation[typeCode=AUT].time" }
+        ]
+      },
+      {
+        "id": "Library.publisher",
+        "path": "Library.publisher",
+        "short": "Name of the publisher (organization or individual)",
+        "definition": "The name of the organization or individual that published the library.",
+        "comment": "Usually an organization but may be an individual. The publisher (or steward) of the library is the organization or individual primarily responsible for the maintenance and upkeep of the library. This is not necessarily the same individual or organization that developed and initially authored the content. The publisher is the primary point of contact for questions or issues with the library. This item SHOULD be populated unless the information is available from context.",
+        "requirements": "Helps establish the \"authority/credibility\" of the library.  May also allow for contact.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.publisher", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.publisher" },
+          { "identity": "w5", "map": "FiveWs.witness" },
+          { "identity": "rim", "map": ".participation[typeCode=AUT].role" }
+        ]
+      },
+      {
+        "id": "Library.contact",
+        "path": "Library.contact",
+        "short": "Contact details for the publisher",
+        "definition": "Contact details to assist a user in finding and communicating with the publisher.",
+        "comment": "May be a web site, an email address, a telephone number, etc.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.contact", "min": 0, "max": "*" },
+        "type": [{ "code": "ContactDetail" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.contact" },
+          { "identity": "rim", "map": ".participation[typeCode=CALLBCK].role" }
+        ]
+      },
+      {
+        "id": "Library.description",
+        "path": "Library.description",
+        "short": "Natural language description of the library",
+        "definition": "A free text natural language description of the library from a consumer's perspective.",
+        "comment": "This description can be used to capture details such as why the library was built, comments about misuse, instructions for clinical use and interpretation, literature references, examples from the paper world, etc. It is not a rendering of the library as conveyed in the 'text' field of the resource itself. This item SHOULD be populated unless the information is available from context (e.g. the language of the library is presumed to be the predominant language in the place the library was created).",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.description", "min": 0, "max": "1" },
+        "type": [{ "code": "markdown" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.description" },
+          { "identity": "rim", "map": ".text" }
+        ]
+      },
+      {
+        "id": "Library.useContext",
+        "path": "Library.useContext",
+        "short": "The context that the content is intended to support",
+        "definition": "The content was developed with a focus and intent of supporting the contexts that are listed. These contexts may be general categories (gender, age, ...) or may be references to specific programs (insurance plans, studies, ...) and may be used to assist with indexing and searching for appropriate library instances.",
+        "comment": "When multiple useContexts are specified, there is no expectation that all or any of the contexts apply.",
+        "requirements": "Assist in searching for appropriate content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.useContext", "min": 0, "max": "*" },
+        "type": [{ "code": "UsageContext" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.useContext" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.jurisdiction",
+        "path": "Library.jurisdiction",
+        "short": "Intended jurisdiction for library (if applicable)",
+        "definition": "A legal or geographic region in which the library is intended to be used.",
+        "comment": "It may be possible for the library to be used in jurisdictions other than those for which it was originally designed or intended.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.jurisdiction", "min": 0, "max": "*" },
+        "type": [{ "code": "CodeableConcept" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "Jurisdiction"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
+              "valueBoolean": true
+            }
+          ],
+          "strength": "extensible",
+          "description": "Countries and regions within which this artifact is targeted for use.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/jurisdiction"
+        },
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.jurisdiction" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.purpose",
+        "path": "Library.purpose",
+        "short": "Why this library is defined",
+        "definition": "Explanation of why this library is needed and why it has been designed as it has.",
+        "comment": "This element does not describe the usage of the library. Instead, it provides traceability of ''why'' the resource is either needed or ''why'' it is defined as it is.  This may be used to point to source materials or specifications that drove the structure of this library.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.purpose", "min": 0, "max": "1" },
+        "type": [{ "code": "markdown" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.purpose" },
+          { "identity": "w5", "map": "FiveWs.why[x]" },
+          { "identity": "rim", "map": ".reasonCode.text" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.usage",
+        "path": "Library.usage",
+        "short": "Describes the clinical usage of the library",
+        "definition": "A detailed description of how the library is used from a clinical perspective.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.usage", "min": 0, "max": "1" },
+        "type": [{ "code": "string" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.copyright",
+        "path": "Library.copyright",
+        "short": "Use and/or publishing restrictions",
+        "definition": "A copyright statement relating to the library and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the library.",
+        "requirements": "Consumers must be able to determine any legal restrictions on the use of the library and/or its content.",
+        "alias": ["License", "Restrictions"],
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.copyright", "min": 0, "max": "1" },
+        "type": [{ "code": "markdown" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.copyright" },
+          { "identity": "rim", "map": "N/A (to add?)" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.approvalDate",
+        "path": "Library.approvalDate",
+        "short": "When the library was approved by publisher",
+        "definition": "The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.",
+        "comment": "The 'date' element may be more recent than the approval date because of minor changes or editorial corrections.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.approvalDate", "min": 0, "max": "1" },
+        "type": [{ "code": "date" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.approvalDate" },
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=\"SUBJ\"].act[classCode=CACT;moodCode=EVN;code=\"approval\"].effectiveTime"
+          },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.lastReviewDate",
+        "path": "Library.lastReviewDate",
+        "short": "When the library was last reviewed",
+        "definition": "The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.",
+        "comment": "If specified, this date follows the original approval date.",
+        "requirements": "Gives a sense of how \"current\" the content is.  Resources that have not been reviewed in a long time may have a risk of being less appropriate/relevant.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.lastReviewDate", "min": 0, "max": "1" },
+        "type": [{ "code": "date" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.lastReviewDate" },
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=\"SUBJ\"; subsetCode=\"RECENT\"].act[classCode=CACT;moodCode=EVN;code=\"review\"].effectiveTime"
+          },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.effectivePeriod",
+        "path": "Library.effectivePeriod",
+        "short": "When the library is expected to be used",
+        "definition": "The period during which the library content was or is planned to be in active use.",
+        "comment": "The effective period for a library  determines when the content is applicable for usage and is independent of publication and review dates. For example, a measure intended to be used for the year 2016 might be published in 2015.",
+        "requirements": "Allows establishing a transition before a resource comes into effect and also allows for a sunsetting  process when new versions of the library are or are expected to be used instead.",
+        "min": 0,
+        "max": "1",
+        "base": { "path": "Library.effectivePeriod", "min": 0, "max": "1" },
+        "type": [{ "code": "Period" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.effectivePeriod" },
+          { "identity": "rim", "map": "N/A (to add?)" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.topic",
+        "path": "Library.topic",
+        "short": "E.g. Education, Treatment, Assessment, etc.",
+        "definition": "Descriptive topics related to the content of the library. Topics provide a high-level categorization of the library that can be useful for filtering and searching.",
+        "requirements": "Repositories must be able to determine how to categorize the library so that it can be found by topical searches.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.topic", "min": 0, "max": "*" },
+        "type": [{ "code": "CodeableConcept" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "DefinitionTopic"
+            }
+          ],
+          "strength": "example",
+          "description": "High-level categorization of the definition, used for searching, sorting, and filtering.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/definition-topic"
+        },
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.author",
+        "path": "Library.author",
+        "short": "Who authored the content",
+        "definition": "An individiual or organization primarily involved in the creation and maintenance of the content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.author", "min": 0, "max": "*" },
+        "type": [{ "code": "ContactDetail" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": ".participation[typeCode=AUT]" }]
+      },
+      {
+        "id": "Library.editor",
+        "path": "Library.editor",
+        "short": "Who edited the content",
+        "definition": "An individual or organization primarily responsible for internal coherence of the content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.editor", "min": 0, "max": "*" },
+        "type": [{ "code": "ContactDetail" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false
+      },
+      {
+        "id": "Library.reviewer",
+        "path": "Library.reviewer",
+        "short": "Who reviewed the content",
+        "definition": "An individual or organization primarily responsible for review of some aspect of the content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.reviewer", "min": 0, "max": "*" },
+        "type": [{ "code": "ContactDetail" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".participation[typeCode=VRF] {not clear whether VRF best corresponds to reviewer or endorser}"
+          }
+        ]
+      },
+      {
+        "id": "Library.endorser",
+        "path": "Library.endorser",
+        "short": "Who endorsed the content",
+        "definition": "An individual or organization responsible for officially endorsing the content for use in some setting.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.endorser", "min": 0, "max": "*" },
+        "type": [{ "code": "ContactDetail" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".participation[typeCode=VRF] {not clear whether VRF best corresponds to reviewer or endorser}"
+          }
+        ]
+      },
+      {
+        "id": "Library.relatedArtifact",
+        "path": "Library.relatedArtifact",
+        "short": "Additional documentation, citations, etc.",
+        "definition": "Related artifacts such as additional documentation, justification, or bibliographic references.",
+        "comment": "Each related artifact is either an attachment, or a reference to another resource, but not both.",
+        "requirements": "Libraries must be able to provide enough information for consumers of the content (and/or interventions or results produced by the content) to be able to determine and understand the justification for and evidence in support of the content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.relatedArtifact", "min": 0, "max": "*" },
+        "type": [{ "code": "RelatedArtifact" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=DOC,RSON,PREV, DRIV, USE, COMP] {successor would be PREV w/ inversionInd=true; No support for citation}"
+          }
+        ]
+      },
+      {
+        "id": "Library.parameter",
+        "path": "Library.parameter",
+        "short": "Parameters defined by the library",
+        "definition": "The parameter element defines parameters used by the library.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.parameter", "min": 0, "max": "*" },
+        "type": [{ "code": "ParameterDefinition" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.dataRequirement",
+        "path": "Library.dataRequirement",
+        "short": "What data is referenced by this library",
+        "definition": "Describes a set of data that must be provided in order to be able to successfully perform the computations defined by the library.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.dataRequirement", "min": 0, "max": "*" },
+        "type": [{ "code": "DataRequirement" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": false,
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.content",
+        "path": "Library.content",
+        "short": "Contents of the library, either embedded or referenced",
+        "definition": "The content of the library as an Attachment. The content may be a reference to a url, or may be directly embedded as a base-64 string. Either way, the contentType of the attachment determines how to interpret the content.",
+        "min": 0,
+        "max": "*",
+        "base": { "path": "Library.content", "min": 0, "max": "*" },
+        "type": [{ "code": "Attachment" }],
+        "constraint": [
+          {
+            "key": "ele-1",
+            "severity": "error",
+            "human": "All FHIR elements must have a @value or children",
+            "expression": "hasValue() or (children().count() > id.count())",
+            "xpath": "@value|f:*|h:div",
+            "source": "http://hl7.org/fhir/StructureDefinition/Element"
+          }
+        ],
+        "isModifier": false,
+        "isSummary": true,
+        "mapping": [{ "identity": "rim", "map": ".text" }]
+      }
+    ]
+  },
+  "differential": {
+    "element": [
+      {
+        "id": "Library",
+        "path": "Library",
+        "short": "Represents a library of quality improvement components",
+        "definition": "The Library resource is a general-purpose container for knowledge asset definitions. It can be used to describe and expose existing knowledge assets such as logic libraries and information model descriptions, as well as to describe a collection of knowledge assets.",
+        "min": 0,
+        "max": "*",
+        "constraint": [
+          {
+            "key": "lib-0",
+            "severity": "warning",
+            "human": "Name should be usable as an identifier for the module by machine processing applications such as code generation",
+            "expression": "name.matches('[A-Z]([A-Za-z0-9_]){0,254}')",
+            "xpath": "not(exists(f:name/@value)) or matches(f:name/@value, '[A-Z]([A-Za-z0-9_]){0,254}')"
+          }
+        ],
+        "mapping": [{ "identity": "rim", "map": "Act[classCode=GROUPER;moodCode=EVN]" }]
+      },
+      {
+        "id": "Library.url",
+        "path": "Library.url",
+        "short": "Canonical identifier for this library, represented as a URI (globally unique)",
+        "definition": "An absolute URI that is used to identify this library when it is referenced in a specification, model, design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal address at which at which an authoritative instance of this library is (or will be) published. This URL can be the target of a canonical reference. It SHALL remain the same when the library is stored on different servers.",
+        "comment": "Can be a urn:uuid: or a urn:oid: but real http: addresses are preferred.  Multiple instances may share the same URL if they have a distinct version.\n\nThe determination of when to create a new version of a resource (same url, new version) vs. defining a new artifact is up to the author.  Considerations for making this decision are found in [Technical and Business Versions](resource.html#versions). \n\nIn some cases, the resource can no longer be found at the stated url, but the url itself cannot change. Implementations can use the [meta.source](resource.html#meta) element to indicate where the current master source of the resource can be found.",
+        "requirements": "Allows the library to be referenced by a single globally unique identifier.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "uri" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.url" },
+          { "identity": "w5", "map": "FiveWs.identifier" },
+          { "identity": "rim", "map": ".identifier[scope=BUSN;reliability=ISS]" }
+        ]
+      },
+      {
+        "id": "Library.identifier",
+        "path": "Library.identifier",
+        "short": "Additional identifier for the library",
+        "definition": "A formal identifier that is used to identify this library when it is represented in other formats, or referenced in a specification, model, design or an instance. e.g. CMS or NQF identifiers for a measure artifact. Note that at least one identifier is required for non-experimental active artifacts.",
+        "comment": "Typically, this is used for identifiers that can go in an HL7 V3 II (instance identifier) data type, and can then identify this library outside of FHIR, where it is not possible to use the logical URI.",
+        "requirements": "Allows externally provided and/or usable business identifiers to be easily associated with the module.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "Identifier" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.identifier" },
+          { "identity": "w5", "map": "FiveWs.identifier" },
+          { "identity": "rim", "map": ".identifier" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.version",
+        "path": "Library.version",
+        "short": "Business version of the library",
+        "definition": "The identifier that is used to identify this version of the library when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the library author and is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is not available. There is also no expectation that versions can be placed in a lexicographical sequence. To provide a version consistent with the Decision Support Service specification, use the format Major.Minor.Revision (e.g. 1.0.0). For more information on versioning knowledge assets, refer to the Decision Support Service specification. Note that a version is required for non-experimental active artifacts.",
+        "comment": "There may be different library instances that have the same identifier but different versions.  The version can be appended to the url in a reference to allow a reference to a particular business version of the library with the format [url]|[version].",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.version" },
+          { "identity": "w5", "map": "FiveWs.version" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.name",
+        "path": "Library.name",
+        "short": "Name for this library (computer friendly)",
+        "definition": "A natural language name identifying the library. This name should be usable as an identifier for the module by machine processing applications such as code generation.",
+        "comment": "The name is not expected to be globally unique. The name should be a simple alphanumeric type name to ensure that it is machine-processing friendly.",
+        "requirements": "Support human navigation and code generation.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }],
+        "condition": ["inv-0"],
+        "isSummary": true,
+        "mapping": [{ "identity": "rim", "map": "N/A" }]
+      },
+      {
+        "id": "Library.title",
+        "path": "Library.title",
+        "short": "Name for this library (human friendly)",
+        "definition": "A short, descriptive, user-friendly title for the library.",
+        "comment": "This name does not need to be machine-processing friendly and may contain punctuation, white-space, etc.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.title" },
+          { "identity": "rim", "map": ".title" }
+        ]
+      },
+      {
+        "id": "Library.subtitle",
+        "path": "Library.subtitle",
+        "short": "Subordinate title of the library",
+        "definition": "An explanatory or alternate title for the library giving additional information about its content.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }]
+      },
+      {
+        "id": "Library.status",
+        "path": "Library.status",
+        "short": "draft | active | retired | unknown",
+        "definition": "The status of this library. Enables tracking the life-cycle of the content.",
+        "comment": "Allows filtering of libraries that are appropriate for use vs. not.",
+        "min": 1,
+        "max": "1",
+        "type": [{ "code": "code" }],
+        "isModifier": true,
+        "isModifierReason": "This is labeled as \"Is Modifier\" because applications should not use a retired {{title}} without due consideration",
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "PublicationStatus"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
+              "valueBoolean": true
+            }
+          ],
+          "strength": "required",
+          "description": "The lifecycle status of an artifact.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/publication-status|4.0.1"
+        },
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.status" },
+          { "identity": "w5", "map": "FiveWs.status" },
+          { "identity": "rim", "map": ".status" }
+        ]
+      },
+      {
+        "id": "Library.experimental",
+        "path": "Library.experimental",
+        "short": "For testing purposes, not real usage",
+        "definition": "A Boolean value to indicate that this library is authored for testing purposes (or education/evaluation/marketing) and is not intended to be used for genuine usage.",
+        "comment": "Allows filtering of librarys that are appropriate for use versus not.",
+        "requirements": "Enables experimental content to be developed following the same lifecycle that would be used for a production-level library.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "boolean" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.experimental" },
+          { "identity": "w5", "map": "FiveWs.class" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.type",
+        "path": "Library.type",
+        "short": "logic-library | model-definition | asset-collection | module-definition",
+        "definition": "Identifies the type of library such as a Logic Library, Model Definition, Asset Collection, or Module Definition.",
+        "min": 1,
+        "max": "1",
+        "type": [{ "code": "CodeableConcept" }],
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "LibraryType"
+            }
+          ],
+          "strength": "extensible",
+          "description": "The type of knowledge asset this library contains.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/library-type"
+        },
+        "mapping": [
+          { "identity": "w5", "map": "FiveWs.what[x]" },
+          { "identity": "rim", "map": ".code" }
+        ]
+      },
+      {
+        "id": "Library.subject[x]",
+        "path": "Library.subject[x]",
+        "short": "Type of individual the library content is focused on",
+        "definition": "A code or group definition that describes the intended subject of the contents of the library.",
+        "min": 0,
+        "max": "1",
+        "type": [
+          { "code": "CodeableConcept" },
+          {
+            "code": "Reference",
+            "targetProfile": ["http://hl7.org/fhir/StructureDefinition/Group"]
+          }
+        ],
+        "meaningWhenMissing": "Patient",
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "SubjectType"
+            }
+          ],
+          "strength": "extensible",
+          "description": "The possible types of subjects for a library (E.g. Patient, Practitioner, Organization, Location, etc.).",
+          "valueSet": "http://hl7.org/fhir/ValueSet/subject-type"
+        }
+      },
+      {
+        "id": "Library.date",
+        "path": "Library.date",
+        "short": "Date last changed",
+        "definition": "The date  (and optionally time) when the library was published. The date must change when the business version changes and it must change if the status code changes. In addition, it should change when the substantive content of the library changes.",
+        "comment": "Note that this is not the same as the resource last-modified-date, since the resource may be a secondary representation of the library. Additional specific dates may be added as extensions or be found by consulting Provenances associated with past versions of the resource.",
+        "alias": ["Revision Date"],
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "dateTime" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.date" },
+          { "identity": "w5", "map": "FiveWs.recorded" },
+          { "identity": "rim", "map": ".participation[typeCode=AUT].time" }
+        ]
+      },
+      {
+        "id": "Library.publisher",
+        "path": "Library.publisher",
+        "short": "Name of the publisher (organization or individual)",
+        "definition": "The name of the organization or individual that published the library.",
+        "comment": "Usually an organization but may be an individual. The publisher (or steward) of the library is the organization or individual primarily responsible for the maintenance and upkeep of the library. This is not necessarily the same individual or organization that developed and initially authored the content. The publisher is the primary point of contact for questions or issues with the library. This item SHOULD be populated unless the information is available from context.",
+        "requirements": "Helps establish the \"authority/credibility\" of the library.  May also allow for contact.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.publisher" },
+          { "identity": "w5", "map": "FiveWs.witness" },
+          { "identity": "rim", "map": ".participation[typeCode=AUT].role" }
+        ]
+      },
+      {
+        "id": "Library.contact",
+        "path": "Library.contact",
+        "short": "Contact details for the publisher",
+        "definition": "Contact details to assist a user in finding and communicating with the publisher.",
+        "comment": "May be a web site, an email address, a telephone number, etc.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ContactDetail" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.contact" },
+          { "identity": "rim", "map": ".participation[typeCode=CALLBCK].role" }
+        ]
+      },
+      {
+        "id": "Library.description",
+        "path": "Library.description",
+        "short": "Natural language description of the library",
+        "definition": "A free text natural language description of the library from a consumer's perspective.",
+        "comment": "This description can be used to capture details such as why the library was built, comments about misuse, instructions for clinical use and interpretation, literature references, examples from the paper world, etc. It is not a rendering of the library as conveyed in the 'text' field of the resource itself. This item SHOULD be populated unless the information is available from context (e.g. the language of the library is presumed to be the predominant language in the place the library was created).",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "markdown" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.description" },
+          { "identity": "rim", "map": ".text" }
+        ]
+      },
+      {
+        "id": "Library.useContext",
+        "path": "Library.useContext",
+        "short": "The context that the content is intended to support",
+        "definition": "The content was developed with a focus and intent of supporting the contexts that are listed. These contexts may be general categories (gender, age, ...) or may be references to specific programs (insurance plans, studies, ...) and may be used to assist with indexing and searching for appropriate library instances.",
+        "comment": "When multiple useContexts are specified, there is no expectation that all or any of the contexts apply.",
+        "requirements": "Assist in searching for appropriate content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "UsageContext" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.useContext" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.jurisdiction",
+        "path": "Library.jurisdiction",
+        "short": "Intended jurisdiction for library (if applicable)",
+        "definition": "A legal or geographic region in which the library is intended to be used.",
+        "comment": "It may be possible for the library to be used in jurisdictions other than those for which it was originally designed or intended.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "CodeableConcept" }],
+        "isSummary": true,
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "Jurisdiction"
+            },
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
+              "valueBoolean": true
+            }
+          ],
+          "strength": "extensible",
+          "description": "Countries and regions within which this artifact is targeted for use.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/jurisdiction"
+        },
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.jurisdiction" },
+          { "identity": "rim", "map": "N/A (to add?)" }
+        ]
+      },
+      {
+        "id": "Library.purpose",
+        "path": "Library.purpose",
+        "short": "Why this library is defined",
+        "definition": "Explanation of why this library is needed and why it has been designed as it has.",
+        "comment": "This element does not describe the usage of the library. Instead, it provides traceability of ''why'' the resource is either needed or ''why'' it is defined as it is.  This may be used to point to source materials or specifications that drove the structure of this library.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "markdown" }],
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.purpose" },
+          { "identity": "w5", "map": "FiveWs.why[x]" },
+          { "identity": "rim", "map": ".reasonCode.text" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.usage",
+        "path": "Library.usage",
+        "short": "Describes the clinical usage of the library",
+        "definition": "A detailed description of how the library is used from a clinical perspective.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "string" }],
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.copyright",
+        "path": "Library.copyright",
+        "short": "Use and/or publishing restrictions",
+        "definition": "A copyright statement relating to the library and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the library.",
+        "requirements": "Consumers must be able to determine any legal restrictions on the use of the library and/or its content.",
+        "alias": ["License", "Restrictions"],
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "markdown" }],
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.copyright" },
+          { "identity": "rim", "map": "N/A (to add?)" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.approvalDate",
+        "path": "Library.approvalDate",
+        "short": "When the library was approved by publisher",
+        "definition": "The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.",
+        "comment": "The 'date' element may be more recent than the approval date because of minor changes or editorial corrections.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "date" }],
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.approvalDate" },
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=\"SUBJ\"].act[classCode=CACT;moodCode=EVN;code=\"approval\"].effectiveTime"
+          },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.lastReviewDate",
+        "path": "Library.lastReviewDate",
+        "short": "When the library was last reviewed",
+        "definition": "The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.",
+        "comment": "If specified, this date follows the original approval date.",
+        "requirements": "Gives a sense of how \"current\" the content is.  Resources that have not been reviewed in a long time may have a risk of being less appropriate/relevant.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "date" }],
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.lastReviewDate" },
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=\"SUBJ\"; subsetCode=\"RECENT\"].act[classCode=CACT;moodCode=EVN;code=\"review\"].effectiveTime"
+          },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.effectivePeriod",
+        "path": "Library.effectivePeriod",
+        "short": "When the library is expected to be used",
+        "definition": "The period during which the library content was or is planned to be in active use.",
+        "comment": "The effective period for a library  determines when the content is applicable for usage and is independent of publication and review dates. For example, a measure intended to be used for the year 2016 might be published in 2015.",
+        "requirements": "Allows establishing a transition before a resource comes into effect and also allows for a sunsetting  process when new versions of the library are or are expected to be used instead.",
+        "min": 0,
+        "max": "1",
+        "type": [{ "code": "Period" }],
+        "isSummary": true,
+        "mapping": [
+          { "identity": "workflow", "map": "Definition.effectivePeriod" },
+          { "identity": "rim", "map": "N/A (to add?)" },
+          { "identity": "objimpl", "map": "no-gen-base" }
+        ]
+      },
+      {
+        "id": "Library.topic",
+        "path": "Library.topic",
+        "short": "E.g. Education, Treatment, Assessment, etc.",
+        "definition": "Descriptive topics related to the content of the library. Topics provide a high-level categorization of the library that can be useful for filtering and searching.",
+        "requirements": "Repositories must be able to determine how to categorize the library so that it can be found by topical searches.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "CodeableConcept" }],
+        "binding": {
+          "extension": [
+            {
+              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
+              "valueString": "DefinitionTopic"
+            }
+          ],
+          "strength": "example",
+          "description": "High-level categorization of the definition, used for searching, sorting, and filtering.",
+          "valueSet": "http://hl7.org/fhir/ValueSet/definition-topic"
+        },
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.author",
+        "path": "Library.author",
+        "short": "Who authored the content",
+        "definition": "An individiual or organization primarily involved in the creation and maintenance of the content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ContactDetail" }],
+        "mapping": [{ "identity": "rim", "map": ".participation[typeCode=AUT]" }]
+      },
+      {
+        "id": "Library.editor",
+        "path": "Library.editor",
+        "short": "Who edited the content",
+        "definition": "An individual or organization primarily responsible for internal coherence of the content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ContactDetail" }]
+      },
+      {
+        "id": "Library.reviewer",
+        "path": "Library.reviewer",
+        "short": "Who reviewed the content",
+        "definition": "An individual or organization primarily responsible for review of some aspect of the content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ContactDetail" }],
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".participation[typeCode=VRF] {not clear whether VRF best corresponds to reviewer or endorser}"
+          }
+        ]
+      },
+      {
+        "id": "Library.endorser",
+        "path": "Library.endorser",
+        "short": "Who endorsed the content",
+        "definition": "An individual or organization responsible for officially endorsing the content for use in some setting.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ContactDetail" }],
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".participation[typeCode=VRF] {not clear whether VRF best corresponds to reviewer or endorser}"
+          }
+        ]
+      },
+      {
+        "id": "Library.relatedArtifact",
+        "path": "Library.relatedArtifact",
+        "short": "Additional documentation, citations, etc.",
+        "definition": "Related artifacts such as additional documentation, justification, or bibliographic references.",
+        "comment": "Each related artifact is either an attachment, or a reference to another resource, but not both.",
+        "requirements": "Libraries must be able to provide enough information for consumers of the content (and/or interventions or results produced by the content) to be able to determine and understand the justification for and evidence in support of the content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "RelatedArtifact" }],
+        "mapping": [
+          {
+            "identity": "rim",
+            "map": ".outboundRelationship[typeCode=DOC,RSON,PREV, DRIV, USE, COMP] {successor would be PREV w/ inversionInd=true; No support for citation}"
+          }
+        ]
+      },
+      {
+        "id": "Library.parameter",
+        "path": "Library.parameter",
+        "short": "Parameters defined by the library",
+        "definition": "The parameter element defines parameters used by the library.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "ParameterDefinition" }],
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.dataRequirement",
+        "path": "Library.dataRequirement",
+        "short": "What data is referenced by this library",
+        "definition": "Describes a set of data that must be provided in order to be able to successfully perform the computations defined by the library.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "DataRequirement" }],
+        "mapping": [{ "identity": "rim", "map": "N/A (to add?)" }]
+      },
+      {
+        "id": "Library.content",
+        "path": "Library.content",
+        "short": "Contents of the library, either embedded or referenced",
+        "definition": "The content of the library as an Attachment. The content may be a reference to a url, or may be directly embedded as a base-64 string. Either way, the contentType of the attachment determines how to interpret the content.",
+        "min": 0,
+        "max": "*",
+        "type": [{ "code": "Attachment" }],
+        "isSummary": true,
+        "mapping": [{ "identity": "rim", "map": ".text" }]
+      }
+    ]
+  }
+}
diff --git a/test/utils/MasterFisher.test.ts b/test/utils/MasterFisher.test.ts
index 0e1f8e4..b183cd0 100644
--- a/test/utils/MasterFisher.test.ts
+++ b/test/utils/MasterFisher.test.ts
@@ -1,4 +1,3 @@
-import fs from 'fs-extra';
 import { FSHDocument, FSHTank } from '../../src/import';
 import { Profile, Instance } from '../../src/fshtypes';
 import { Package } from '../../src/export';
@@ -9,6 +8,7 @@ import { minimalConfig } from './minimalConfig';
 import { cloneDeep } from 'lodash';
 import { getTestFHIRDefinitions, testDefsPath, TestFHIRDefinitions } from '../testhelpers';
 import { PREDEFINED_PACKAGE_NAME, PREDEFINED_PACKAGE_VERSION } from '../../src/ig';
+import { Metadata } from '../../src/utils';
 
 describe('MasterFisher', () => {
   let fisher: MasterFisher;
@@ -81,36 +81,55 @@ describe('MasterFisher', () => {
     const result = fisher.fishForFHIR('Profile1');
     expect(result).toBeUndefined(); // NOTE: It is only in the tank and the tank does not support FHIR
 
-    const resultMD = fisher.fishForMetadata('Profile1');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       id: 'prf1',
       name: 'Profile1',
       sdType: 'Procedure',
       url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/prf1',
       parent: 'Procedure',
       resourceType: 'StructureDefinition'
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('Profile1');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('Profile1');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
   it('should find the correct sdType for a profile of a profile that is only in the tank', () => {
     const result = fisher.fishForFHIR('Profile2');
     expect(result).toBeUndefined(); // NOTE: It is only in the tank and the tank does not support FHIR
 
-    const resultMD = fisher.fishForMetadata('Profile2');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       id: 'Profile2',
       name: 'Profile2',
       sdType: 'Observation',
       url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/Profile2',
       parent: 'bp',
       resourceType: 'StructureDefinition'
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('Profile2');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('Profile2');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
   it('should log an error when encountering circular dependencies when determining sdType', () => {
     const result = fisher.fishForFHIR('my-dr');
     expect(result).toBeUndefined(); // NOTE: It is only in the tank and the tank does not support FHIR
 
+    const expectedMD: Metadata = {
+      id: 'my-dr',
+      name: 'Practitioner',
+      sdType: undefined,
+      url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/my-dr',
+      parent: 'Practitioner',
+      resourceType: 'StructureDefinition'
+    };
+
     // This next line causes the fisher to have to look up the parent chain to find the sdType.  This
     // will cause an error because Practitioner basically declares itself as its own parent.
     const resultMD = fisher.fishForMetadata('my-dr');
@@ -118,14 +137,17 @@ describe('MasterFisher', () => {
       /Circular dependency .* Practitioner < Practitioner/
     );
     expect(loggerSpy.getLastMessage()).toMatch(/File: Practitioner\.fsh.*Line: 2 - 4\D*/s);
-    expect(resultMD).toEqual({
-      id: 'my-dr',
-      name: 'Practitioner',
-      sdType: undefined,
-      url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/my-dr',
-      parent: 'Practitioner',
-      resourceType: 'StructureDefinition'
-    });
+    expect(resultMD).toEqual(expectedMD);
+
+    loggerSpy.reset();
+    // This next line causes the fisher to have to look up the parent chain to find the sdType.  This
+    // will cause an error because Practitioner basically declares itself as its own parent.
+    const resultMDs = fisher.fishForMetadatas('my-dr');
+    expect(loggerSpy.getLastMessage()).toMatch(
+      /Circular dependency .* Practitioner < Practitioner/
+    );
+    expect(loggerSpy.getLastMessage()).toMatch(/File: Practitioner\.fsh.*Line: 2 - 4\D*/s);
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
   it('should find a profile that is only in the package (not likely, but good to test)', () => {
@@ -133,24 +155,28 @@ describe('MasterFisher', () => {
     expect(result.id).toBe('profile3');
     expect(result.fhirVersion).toBe('4.0.1');
 
-    const resultMD = fisher.fishForMetadata('Profile3');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       id: 'profile3',
       name: 'Profile3',
       sdType: 'Condition',
       url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/profile3',
       parent: 'http://hl7.org/fhir/StructureDefinition/Condition',
       resourceType: 'StructureDefinition'
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('Profile3');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('Profile3');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
-  it('should find a profile that is only in the FHIR definitions', () => {
+  it('should find a resource that is only in the FHIR definitions', () => {
     const result = fisher.fishForFHIR('Patient');
     expect(result.id).toBe('Patient');
     expect(result.fhirVersion).toBe('4.0.1');
 
-    const resultMD = fisher.fishForMetadata('Patient');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       abstract: false,
       id: 'Patient',
       name: 'Patient',
@@ -160,26 +186,57 @@ describe('MasterFisher', () => {
       parent: 'http://hl7.org/fhir/StructureDefinition/DomainResource',
       resourceType: 'StructureDefinition',
       resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${testDefsPath('r4-definitions', 'package', 'StructureDefinition-Patient.json')}`
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('Patient');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('Patient');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
-  it('should return the profile from the package when it exists in the package and FHIR definitions', () => {
+  it('should return the profile from the package first when it exists in the package and FHIR definitions', () => {
+    // fishForFHIR only returns the first match (the one from the package)
     const result = fisher.fishForFHIR('vitalsigns');
     expect(result.name).toBe('MyVitalSigns');
     expect(result.fhirVersion).toBe('4.0.1');
 
-    const resultMD = fisher.fishForMetadata('vitalsigns');
-    expect(resultMD).toEqual({
+    const expectedPackageMD: Metadata = {
       id: 'vitalsigns',
       name: 'MyVitalSigns',
       sdType: 'Observation',
       url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/vitalsigns',
       parent: 'http://hl7.org/fhir/StructureDefinition/Observation',
       resourceType: 'StructureDefinition'
-    });
+    };
+
+    const fhirVitalSignsPath = testDefsPath(
+      'r4-definitions',
+      'package',
+      'StructureDefinition-vitalsigns.json'
+    );
+    const expectedFHIRMD: Metadata = {
+      id: 'vitalsigns',
+      name: 'observation-vitalsigns',
+      sdType: 'Observation',
+      url: 'http://hl7.org/fhir/StructureDefinition/vitalsigns',
+      parent: 'http://hl7.org/fhir/StructureDefinition/Observation',
+      abstract: false,
+      version: '4.0.1',
+      resourceType: 'StructureDefinition',
+      resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${fhirVitalSignsPath}`
+    };
+
+    // fishForMetada only returns the first match (the one from the package)
+    const resultMD = fisher.fishForMetadata('vitalsigns');
+    expect(resultMD).toEqual(expectedPackageMD);
+
+    // fishForMetadas returns all matches
+    const resultMDs = fisher.fishForMetadatas('vitalsigns');
+    expect(resultMDs).toEqual([expectedPackageMD, expectedFHIRMD]);
   });
 
-  it('should return a profile that is predefined when it also exists in the package', async () => {
+  it('should return a profile that is predefined first when it also exists in the package', async () => {
     const fhirVitalSignsPath = testDefsPath(
       'r4-definitions',
       'package',
@@ -189,67 +246,126 @@ describe('MasterFisher', () => {
     // Mark vital signs as predefined
     defs.loadCustomResources(fhirVitalSignsPath);
 
-    // Result should match the fhir defined version, not our defined version
-    const fhirDefinedVitalSigns = fs.readJSONSync(fhirVitalSignsPath);
-    const result = fisher.fishForFHIR('vitalsigns');
-    expect(result.name).toBe(fhirDefinedVitalSigns.name);
-
-    const resultMD = fisher.fishForMetadata('vitalsigns');
-    expect(resultMD).toEqual({
+    const expectedPredefinedMD: Metadata = {
+      id: 'vitalsigns',
+      name: 'observation-vitalsigns',
+      sdType: 'Observation',
+      url: 'http://hl7.org/fhir/StructureDefinition/vitalsigns',
+      parent: 'http://hl7.org/fhir/StructureDefinition/Observation',
       abstract: false,
-      id: fhirDefinedVitalSigns.id,
-      name: fhirDefinedVitalSigns.name,
-      sdType: fhirDefinedVitalSigns.type,
-      url: fhirDefinedVitalSigns.url,
-      version: fhirDefinedVitalSigns.version,
-      parent: fhirDefinedVitalSigns.baseDefinition,
+      version: '4.0.1',
       resourceType: 'StructureDefinition',
       resourcePath: `virtual:${PREDEFINED_PACKAGE_NAME}#${PREDEFINED_PACKAGE_VERSION}:${fhirVitalSignsPath}`
-    });
+    };
+
+    const expectedPackageMD: Metadata = {
+      id: 'vitalsigns',
+      name: 'MyVitalSigns',
+      sdType: 'Observation',
+      url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/vitalsigns',
+      parent: 'http://hl7.org/fhir/StructureDefinition/Observation',
+      resourceType: 'StructureDefinition'
+    };
+
+    const expectedFHIRMD: Metadata = {
+      id: 'vitalsigns',
+      name: 'observation-vitalsigns',
+      sdType: 'Observation',
+      url: 'http://hl7.org/fhir/StructureDefinition/vitalsigns',
+      parent: 'http://hl7.org/fhir/StructureDefinition/Observation',
+      abstract: false,
+      version: '4.0.1',
+      resourceType: 'StructureDefinition',
+      resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${fhirVitalSignsPath}`
+    };
+
+    // fishForFHIR only returns the first match (the predefined one)
+    const result = fisher.fishForFHIR('vitalsigns');
+    expect(result.name).toBe('observation-vitalsigns');
+
+    // fishForMetadata only returns the first match (the predefined one)
+    const resultMD = fisher.fishForMetadata('vitalsigns');
+    expect(resultMD).toEqual(expectedPredefinedMD);
+
+    // fishForMetadas returns all matches
+    const resultMDs = fisher.fishForMetadatas('vitalsigns');
+    expect(resultMDs).toEqual([expectedPredefinedMD, expectedPackageMD, expectedFHIRMD]);
   });
 
   it('should find an Instance that is only in the Tank', () => {
     const result = fisher.fishForFHIR('Instance1');
     expect(result).toBeUndefined();
 
-    const resultMD = fisher.fishForMetadata('Instance1');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       id: 'inst1',
       name: 'Instance1',
       instanceUsage: 'Example',
       resourceType: 'Procedure',
       sdType: undefined,
       url: 'http://hl7.org/fhir/us/minimal/Procedure/inst1'
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('Instance1');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('Instance1');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
   it('should find an inline Instance that is only in the Tank', () => {
     const result = fisher.fishForFHIR('InlineInstance');
     expect(result).toBeUndefined();
 
-    const resultMD = fisher.fishForMetadata('InlineInstance');
-    expect(resultMD).toEqual({
+    const expectedMD: Metadata = {
       id: 'inline-instance',
       name: 'InlineInstance',
       instanceUsage: 'Inline',
       resourceType: 'Procedure',
       sdType: undefined
-    });
+    };
+
+    const resultMD = fisher.fishForMetadata('InlineInstance');
+    expect(resultMD).toEqual(expectedMD);
+
+    const resultMDs = fisher.fishForMetadatas('InlineInstance');
+    expect(resultMDs).toEqual([expectedMD]);
   });
 
   it('should not return the FHIR def for a resource if there is a profile w/ the same name in the tank', () => {
     const result = fisher.fishForFHIR('Organization');
     expect(result).toBeUndefined();
 
-    const resultMD = fisher.fishForMetadata('Organization');
-    expect(resultMD).toEqual({
+    const expectedProfileMD: Metadata = {
       id: 'my-org',
       name: 'Organization',
       sdType: 'Organization',
       url: 'http://hl7.org/fhir/us/minimal/StructureDefinition/my-org',
       parent: 'http://hl7.org/fhir/StructureDefinition/Organization',
       resourceType: 'StructureDefinition'
-    });
+    };
+
+    const fhirOrganizationPath = testDefsPath(
+      'r4-definitions',
+      'package',
+      'StructureDefinition-Organization.json'
+    );
+    const expectedFHIRMD: Metadata = {
+      id: 'Organization',
+      name: 'Organization',
+      sdType: 'Organization',
+      url: 'http://hl7.org/fhir/StructureDefinition/Organization',
+      parent: 'http://hl7.org/fhir/StructureDefinition/DomainResource',
+      abstract: false,
+      version: '4.0.1',
+      resourceType: 'StructureDefinition',
+      resourcePath: `virtual:hl7.fhir.r4.core#4.0.1:${fhirOrganizationPath}`
+    };
+
+    const resultMD = fisher.fishForMetadata('Organization');
+    expect(resultMD).toEqual(expectedProfileMD);
+
+    const resultMDs = fisher.fishForMetadatas('Organization');
+    expect(resultMDs).toEqual([expectedProfileMD, expectedFHIRMD]);
   });
 
   it('should support fishing using aliases when fishing the Tank', () => {
@@ -258,6 +374,10 @@ describe('MasterFisher', () => {
 
     const resultMD = fisher.fishForMetadata('TankProfile1');
     expect(resultMD.id).toBe('prf1');
+
+    const resultMDs = fisher.fishForMetadatas('TankProfile1');
+    expect(resultMDs).toHaveLength(1);
+    expect(resultMDs[0].id).toBe('prf1');
   });
 
   it('should support fishing using aliases when fishing the Pkg', () => {
@@ -266,6 +386,10 @@ describe('MasterFisher', () => {
 
     const resultMD = fisher.fishForMetadata('PkgProfile3');
     expect(resultMD.id).toBe('profile3');
+
+    const resultMDs = fisher.fishForMetadatas('PkgProfile3');
+    expect(resultMDs).toHaveLength(1);
+    expect(resultMDs[0].id).toBe('profile3');
   });
 
   it('should support fishing using aliases when fishing the FHIR definitions', () => {
@@ -274,13 +398,20 @@ describe('MasterFisher', () => {
 
     const resultMD = fisher.fishForMetadata('FHIRPatient');
     expect(resultMD.id).toBe('Patient');
+
+    const resultMDs = fisher.fishForMetadatas('FHIRPatient');
+    expect(resultMDs).toHaveLength(1);
+    expect(resultMDs[0].id).toBe('Patient');
   });
 
-  it('should return undefined when fishing for something that is not in any locations', () => {
+  it('should return undefined or empty list when fishing for something that is not in any locations', () => {
     const result = fisher.fishForFHIR('Foo');
     expect(result).toBeUndefined();
 
     const resultMD = fisher.fishForMetadata('Foo');
     expect(resultMD).toBeUndefined();
+
+    const resultMDs = fisher.fishForMetadatas('Foo');
+    expect(resultMDs).toBeEmpty();
   });
 });