nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: FHIR/sushi
Pull request #1382 (2023-11-07 20:22:39)

CaretValueRule codes are quoted if they contain spaces
Completes task [CIMPL-1200](https://standardhealthrecord.atlassian.net/browse/CIMPL-1200).

Codes in FSH are quoted if they contain any space characters. When producing FSH for a CaretValueRule, if it is a code caret rule, quote codes that contain space characters.


Patch:
diff --git a/src/fshtypes/rules/CaretValueRule.ts b/src/fshtypes/rules/CaretValueRule.ts
index f3e300d..2f9c26b 100644
--- a/src/fshtypes/rules/CaretValueRule.ts
+++ b/src/fshtypes/rules/CaretValueRule.ts
@@ -44,11 +44,22 @@ export class CaretValueRule extends Rule {
     } else if (this.value) {
       value = this.value._instanceMeta.name;
     }
-    let printablePath;
+    let printablePath: string;
     if (this.isCodeCaretRule) {
-      printablePath = this.pathArray.length
-        ? this.pathArray.map(code => `#${code}`).join(' ') + ' '
-        : '';
+      if (this.pathArray.length) {
+        printablePath =
+          this.pathArray
+            .map(code => {
+              if (/\s/.test(code)) {
+                return `#"${fshifyString(code)}"`;
+              } else {
+                return `#${code}`;
+              }
+            })
+            .join(' ') + ' ';
+      } else {
+        printablePath = '';
+      }
     } else {
       printablePath = this.path !== '' ? this.path + ' ' : '';
     }


Test patch:
diff --git a/test/fshtypes/rules/CaretValueRule.test.ts b/test/fshtypes/rules/CaretValueRule.test.ts
index f00eb1c..3558797 100644
--- a/test/fshtypes/rules/CaretValueRule.test.ts
+++ b/test/fshtypes/rules/CaretValueRule.test.ts
@@ -207,5 +207,15 @@ describe('CaretValueRule', () => {
 
       expect(rule.toFSH()).toBe('* ^extension.url = Canonical(OwlExtension)');
     });
+
+    it('should produce FSH for a CaretValueRule with isCodeCaretRule where the code contains a space', () => {
+      const rule = new CaretValueRule('');
+      rule.pathArray = ['duck', 'big duck'];
+      rule.isCodeCaretRule = true;
+      rule.caretPath = 'display';
+      rule.value = 'is it a big duck or a goose?';
+
+      expect(rule.toFSH()).toBe('* #duck #"big duck" ^display = "is it a big duck or a goose?"');
+    });
   });
 });
Repository: FHIR/sushi
Pull request #1390 (2023-11-20 17:05:45)

Add Characteristics to Logical FSH representation
Completes task [CIMPL-1206](https://standardhealthrecord.atlassian.net/browse/CIMPL-1206).

Adds an implementation of `metadataToFSH` to `Logical` so that characteristics will be included in the FSH representation. If no characteristics are present, the keyword is not added.


Patch:
diff --git a/src/fshtypes/Logical.ts b/src/fshtypes/Logical.ts
index ba55d39..2e94683 100644
--- a/src/fshtypes/Logical.ts
+++ b/src/fshtypes/Logical.ts
@@ -18,6 +18,18 @@ export class Logical extends FshStructure {
     return 'Logical';
   }
 
+  metadataToFSH(): string {
+    const sdMetadata = super.metadataToFSH();
+    if (this.characteristics.length) {
+      const characteristicsFsh = this.characteristics
+        .map(characteristic => `#${characteristic}`)
+        .join(', ');
+      return `${sdMetadata}${EOL}Characteristics: ${characteristicsFsh}`;
+    } else {
+      return sdMetadata;
+    }
+  }
+
   toFSH(): string {
     const metadataFSH = this.metadataToFSH();
     const rulesFSH = this.rules.map(r => r.toFSH()).join(EOL);


Test patch:
diff --git a/test/fshtypes/Logical.test.ts b/test/fshtypes/Logical.test.ts
index 2eb0d2f..dbc02de 100644
--- a/test/fshtypes/Logical.test.ts
+++ b/test/fshtypes/Logical.test.ts
@@ -33,12 +33,14 @@ describe('Logical', () => {
       input.id = 'my-model';
       input.title = 'My Model';
       input.description = 'A new model for logical modeling.';
+      input.characteristics = ['can-be-target', 'has-size', 'has-length'];
       const expectedResult = [
         'Logical: MyModel',
         'Parent: Base',
         'Id: my-model',
         'Title: "My Model"',
-        'Description: "A new model for logical modeling."'
+        'Description: "A new model for logical modeling."',
+        'Characteristics: #can-be-target, #has-size, #has-length'
       ].join(EOL);
       expect(input.toFSH()).toEqual(expectedResult);
     });
Repository: FHIR/sushi
Pull request #1437 (2024-03-11 17:36:56)

Update alias regex
Small PR to update the Alias regular expression to require at least one other character besides `$`.

I ran a regression and there were three repos that actually did have Aliases that were just `$`, so they get a new warning now. The three repos are [joofio/ufis-ig#main](https://github.com/joofio/ufis-ig/tree/main/), [joofio/ufis-swe-ig#main](https://github.com/joofio/ufis-swe-ig/tree/main/), and [hl7-eu/gravitate-health#master](https://github.com/hl7-eu/gravitate-health/tree/master/), if you wanted to run a regression on them specifically. The first two also had aliases with unsupported characters, so it would already have been receiving at least one new warning before this PR.


Patch:
diff --git a/src/import/FSHImporter.ts b/src/import/FSHImporter.ts
index bdde62d..96c00d7 100644
--- a/src/import/FSHImporter.ts
+++ b/src/import/FSHImporter.ts
@@ -132,7 +132,7 @@ enum Flag {
 const FLAGS = ['MS', 'SU', '?!', 'TU', 'N', 'D'];
 const INDENT_WIDTH = 2;
 const DEFAULT_START_COLUMN = 1;
-const aliasRegex = /^\$?[a-zA-z0-9_\-\.]*$/;
+const aliasRegex = /^\$?[a-zA-z0-9_\-\.]+$/;
 
 function unescapeUnicode(match: string, p1: string): string {
   return JSON.parse(`"\\${p1}"`);


Test patch:
diff --git a/test/import/FSHImporter.Alias.test.ts b/test/import/FSHImporter.Alias.test.ts
index 55af69e..bf3d47a 100644
--- a/test/import/FSHImporter.Alias.test.ts
+++ b/test/import/FSHImporter.Alias.test.ts
@@ -439,5 +439,28 @@ describe('FSHImporter', () => {
         /\$N\*tAll\*wed includes unsupported characters/
       );
     });
+
+    it('should resolve but log a warning when an alias contains ONLY a $', () => {
+      // Depending on how you read the FSH spec, this may technically be allowed FSH,
+      // but SUSHI will warn about it.
+      const input = leftAlign(`
+      Alias: $ = http://example.org
+
+      Profile: ObservationProfile
+      Parent: Observation
+      * code = $#foo
+      `);
+
+      const results = importText([new RawFSH(input, 'Alias.fsh')]);
+      expect(results.length).toBe(1);
+      const rule = results[0].profiles.get('ObservationProfile').rules[0] as AssignmentRule;
+      // The $ alias does still resolve because only a warning is logged
+      expect(rule.value).toEqual(
+        new FshCode('foo', 'http://example.org').withFile('Alias.fsh').withLocation([6, 10, 6, 14])
+      );
+      expect(loggerSpy.getAllMessages('error')).toHaveLength(0);
+      expect(loggerSpy.getAllMessages('warn')).toHaveLength(1);
+      expect(loggerSpy.getLastMessage('warn')).toMatch(/\$ includes unsupported characters/);
+    });
   });
 });