Repository: FHIR/sushi (ts)

Issue:
Extension names are conflicting
It seems like it can cause issues in SUSHI when two extensions start with the same string of characters. As an example, something like this:
```
Extension:      FastqPaired
Id:             FastqPaired
Title:          "Fastq Paired"
Description:    "Represents paired read data generated from sequencing performed on this specimen."

* extension contains
    forward 1..1 MS and
    forwardByteSize 0..1 and
    forwardChecksum 0..1 and
    reverse 1..1 MS and
    reverseByteSize 0..1 and
    reverseChecksum 0..1

* extension[forward] ^short = "Forward read file location"
* extension[forward].value[x] only string

* extension[forwardByteSize] ^short = "Forward file size in bytes"
* extension[forwardByteSize].value[x] only decimal

* extension[forwardChecksum] ^short = "Forward file MD5 checksum"
* extension[forwardChecksum].value[x] only string

* extension[reverse] ^short = "Reverse read file location"
* extension[reverse].value[x] only string

* extension[reverseByteSize] ^short = "Reverse file size in bytes"
* extension[reverseByteSize].value[x] only decimal

* extension[reverseChecksum] ^short = "Reverse file MD5 checksum"
* extension[reverseChecksum].value[x] only string
```
does not seem to work, because the `reverse` and `reverseByteSize` extensions conflict, and SUSHI gets them confused with each other. If you rename the byte size extensions as follows, things work:
```
Id:             FastqPaired
Title:          "Fastq Paired"
Description:    "Represents paired read data generated from sequencing performed on this specimen."

* extension contains
    forward 1..1 MS and
    byteSizeForward 0..1 and
    forwardChecksum 0..1 and
    reverse 1..1 MS and
    byteSizeReverse 0..1 and
    reverseChecksum 0..1

* extension[forward] ^short = "Forward read file location"
* extension[forward].value[x] only string

* extension[byteSizeForward] ^short = "Forward file size in bytes"
* extension[byteSizeForward].value[x] only decimal

* extension[forwardChecksum] ^short = "Forward file MD5 checksum"
* extension[forwardChecksum].value[x] only string

* extension[reverse] ^short = "Reverse read file location"
* extension[reverse].value[x] only string

* extension[byteSizeReverse] ^short = "Reverse file size in bytes"
* extension[byteSizeReverse].value[x] only decimal

* extension[reverseChecksum] ^short = "Reverse file MD5 checksum"
* extension[reverseChecksum].value[x] only string
```

Pull request:
Fix conflicting extension names
Fixes #531, and adds code that fixes the skipped test introduced by https://github.com/FHIR/sushi/pull/537.

To test, you can unskip that test on master, and see that it fails, and then see that on this branch, that test passes. You can also test with the example given in the issue description.

Patch:
diff --git a/src/fhirtypes/ElementDefinition.ts b/src/fhirtypes/ElementDefinition.ts
index 086767e..f07dae6 100644
--- a/src/fhirtypes/ElementDefinition.ts
+++ b/src/fhirtypes/ElementDefinition.ts
@@ -419,7 +419,7 @@ export class ElementDefinition {
 
   getSlices() {
     return this.structDef.elements.filter(
-      e => e.id !== this.id && e.path === this.path && e.id.startsWith(this.id)
+      e => e.id !== this.id && e.path === this.path && e.id.startsWith(`${this.id}:`)
     );
   }
 


Test patch:
diff --git a/test/export/StructureDefinitionExporter.test.ts b/test/export/StructureDefinitionExporter.test.ts
index 6fa0ff0..0cbc018 100644
--- a/test/export/StructureDefinitionExporter.test.ts
+++ b/test/export/StructureDefinitionExporter.test.ts
@@ -343,7 +343,7 @@ describe('StructureDefinitionExporter', () => {
     expect(exported.derivation).toBe('constraint');
   });
 
-  it.skip('should export sub-extensions, with similar starting names and different types', () => {
+  it('should export sub-extensions, with similar starting names and different types', () => {
     const ruleString = new OnlyRule('extension[Foo].value[x]');
     ruleString.types = [{ type: 'string' }];
     const ruleDecimal = new OnlyRule('extension[FooBar].value[x]');