@@ -1787,7 +1787,11 @@ private void WriteEnum(
17871787 $ "(systems: { vs . ReferencedCodeSystems . Count } )") ;
17881788 }
17891789
1790- _writer . WriteLineIndented ( $ "[FhirEnumeration(\" { name } \" , \" { vs . URL } \" )]") ;
1790+
1791+
1792+ var defaultSystem = GetDefaultCodeSystem ( vs . Concepts ) ;
1793+
1794+ _writer . WriteLineIndented ( $ "[FhirEnumeration(\" { name } \" , \" { vs . URL } \" , \" { defaultSystem } \" )]") ;
17911795
17921796 _writer . WriteLineIndented ( $ "public enum { nameSanitized } ") ;
17931797
@@ -1812,7 +1816,10 @@ private void WriteEnum(
18121816
18131817 string display = FhirUtils . SanitizeForValue ( concept . Display ) ;
18141818
1815- _writer . WriteLineIndented ( $ "[EnumLiteral(\" { codeValue } \" , \" { concept . System } \" ), Description(\" { display } \" )]") ;
1819+ if ( concept . System != defaultSystem )
1820+ _writer . WriteLineIndented ( $ "[EnumLiteral(\" { codeValue } \" , \" { concept . System } \" ), Description(\" { display } \" )]") ;
1821+ else
1822+ _writer . WriteLineIndented ( $ "[EnumLiteral(\" { codeValue } \" ), Description(\" { display } \" )]") ;
18161823
18171824 if ( usedLiterals . Contains ( codeName ) )
18181825 {
@@ -1846,6 +1853,14 @@ private void WriteEnum(
18461853 } ) ;
18471854 }
18481855
1856+ private static string GetDefaultCodeSystem ( List < FhirConcept > concepts )
1857+ {
1858+ return concepts . Select ( c => c . System )
1859+ . GroupBy ( c => c )
1860+ . OrderByDescending ( c => c . Count ( ) )
1861+ . First ( ) . Key ;
1862+ }
1863+
18491864 /// <summary>Convert enum value - see Template-Model.tt#2061.</summary>
18501865 /// <param name="name">The name.</param>
18511866 /// <returns>The enum converted value.</returns>
0 commit comments