@@ -317,7 +317,7 @@ private void generateExpansion(RenderingStatus status, ResourceWrapper res, Xhtm
317
317
tr .td ().b ().addText (designations .get (url ));
318
318
}
319
319
for (String lang : langs ) {
320
- tr .td ().b ().addText (describeLang (lang ));
320
+ tr .td ().b ().addText (describeVSLang (lang , displang ));
321
321
}
322
322
}
323
323
}
@@ -355,6 +355,67 @@ private void generateExpansion(RenderingStatus status, ResourceWrapper res, Xhtm
355
355
356
356
}
357
357
358
+ protected String describeVSLang (String lang , String displang ) {
359
+
360
+ // special cases:
361
+ if ("fr-CA" .equals (lang )) {
362
+ return "French (Canadian)" ; // this one was omitted from the value set
363
+ }
364
+ ValueSet v = getContext ().getWorker ().findTxResource (ValueSet .class , "http://hl7.org/fhir/ValueSet/languages" );
365
+ if (v != null ) {
366
+ ConceptReferenceComponent l = null ;
367
+ for (ConceptReferenceComponent cc : v .getCompose ().getIncludeFirstRep ().getConcept ()) {
368
+ if (cc .getCode ().equals (lang ))
369
+ l = cc ;
370
+ }
371
+ if (l == null ) {
372
+ if (lang .contains ("-" )) {
373
+ lang = lang .substring (0 , lang .indexOf ("-" ));
374
+ }
375
+ for (ConceptReferenceComponent cc : v .getCompose ().getIncludeFirstRep ().getConcept ()) {
376
+ if (cc .getCode ().equals (lang )) {
377
+ l = cc ;
378
+ break ;
379
+ }
380
+ }
381
+ if (l == null ) {
382
+ for (ConceptReferenceComponent cc : v .getCompose ().getIncludeFirstRep ().getConcept ()) {
383
+ if (cc .getCode ().startsWith (lang +"-" )) {
384
+ l = cc ;
385
+ break ;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ if (l != null ) {
391
+ if (lang .contains ("-" ))
392
+ lang = lang .substring (0 , lang .indexOf ("-" ));
393
+ String en = l .getDisplay ();
394
+ String nativelang = null ;
395
+ for (ConceptReferenceDesignationComponent cd : l .getDesignation ()) {
396
+ if (cd .getLanguage ().equals (lang ))
397
+ nativelang = cd .getValue ();
398
+ }
399
+ return context .formatPhrase (langsMatch (lang , displang ) ? RenderingContext .VALUE_SET_OTHER_DISPLAY : RenderingContext .TX_DISPLAY_LANG , nativelang == null ? en : nativelang );
400
+ }
401
+ }
402
+ return lang ;
403
+ }
404
+
405
+
406
+ private boolean langsMatch (String lang , String displang ) {
407
+ if (lang == null ) {
408
+ return displang == null ;
409
+ } else if (lang .equals (displang )) {
410
+ return true ;
411
+ } else if (displang == null ) {
412
+ return false ;
413
+ } else {
414
+ String l1 = lang .contains ("-" ) ? lang .substring (0 , lang .indexOf ("-" )) : lang ;
415
+ String l2 = displang .contains ("-" ) ? displang .substring (0 , displang .indexOf ("-" )) : displang ;
416
+ return l1 .equals (l2 );
417
+ }
418
+ }
358
419
359
420
private void scanForProperties (ValueSetExpansionComponent exp , List <String > langs , Map <String , String > properties ) {
360
421
properties .clear ();
@@ -679,32 +740,32 @@ private String formatSCTDate(String ds) {
679
740
680
741
private String describeModule (String module ) {
681
742
switch (module ) {
682
- case "900000000000207008" : context .formatPhrase (RenderingContext .VALUE_SET_INT );
683
- case "449081005" : context .formatPhrase (RenderingContext .VALUE_SET_SPAN );
684
- case "11000221109" : context .formatPhrase (RenderingContext .VALUE_SET_AR );
685
- case "32506021000036107" : context .formatPhrase (RenderingContext .VALUE_SET_AUS );
686
- case "11000234105" : context .formatPhrase (RenderingContext .VALUE_SET_AT );
687
- case "11000172109" : context .formatPhrase (RenderingContext .VALUE_SET_BE );
688
- case "20621000087109" : context .formatPhrase (RenderingContext .VALUE_SET_CA_EN );
689
- case "20611000087101" : context .formatPhrase (RenderingContext .VALUE_SET_CA_FR );
690
- case "554471000005108" : context .formatPhrase (RenderingContext .VALUE_SET_DANISH );
691
- case "11000181102 " : context .formatPhrase (RenderingContext .VALUE_SET_EE );
692
- case "11000229106" : context .formatPhrase (RenderingContext .VALUE_SET_FI );
693
- case "11000274103" : context .formatPhrase (RenderingContext .VALUE_SET_DE );
694
- case "1121000189102" : context .formatPhrase (RenderingContext .VALUE_SET_IN );
695
- case "11000220105" : context .formatPhrase (RenderingContext .VALUE_SET_IE );
696
- case "11000146104" : context .formatPhrase (RenderingContext .VALUE_SET_DUTCH );
697
- case "21000210109" : context .formatPhrase (RenderingContext .VALUE_SET_NZ );
698
- case "51000202101 " : context .formatPhrase (RenderingContext .VALUE_SET_NO );
699
- case "11000267109" : context .formatPhrase (RenderingContext .VALUE_SET_KR );
700
- case "900000001000122104" : context .formatPhrase (RenderingContext .VALUE_ES_ES );
701
- case "45991000052106" : context .formatPhrase (RenderingContext .VALUE_SET_SWEDISH );
702
- case "2011000195101" : context .formatPhrase (RenderingContext .VALUE_SET_CH );
703
- case "83821000000107" : context .formatPhrase (RenderingContext .VALUE_SET_UK );
704
- case "999000021000000109" : context .formatPhrase (RenderingContext .VALUE_SET_UK_CLIN );
705
- case "5631000179106" : context .formatPhrase (RenderingContext .VALUE_SET_UY );
706
- case "731000124108" : context .formatPhrase (RenderingContext .VALUE_SET_US );
707
- case "5991000124107" : context .formatPhrase (RenderingContext .VALUE_SET_US_ICD10CM );
743
+ case "900000000000207008" : return context .formatPhrase (RenderingContext .VALUE_SET_INT );
744
+ case "449081005" : return context .formatPhrase (RenderingContext .VALUE_SET_SPAN );
745
+ case "11000221109" : return context .formatPhrase (RenderingContext .VALUE_SET_AR );
746
+ case "32506021000036107" : return context .formatPhrase (RenderingContext .VALUE_SET_AUS );
747
+ case "11000234105" : return context .formatPhrase (RenderingContext .VALUE_SET_AT );
748
+ case "11000172109" : return context .formatPhrase (RenderingContext .VALUE_SET_BE );
749
+ case "20621000087109" : return context .formatPhrase (RenderingContext .VALUE_SET_CA_EN );
750
+ case "20611000087101" : return context .formatPhrase (RenderingContext .VALUE_SET_CA_FR );
751
+ case "554471000005108" : return context .formatPhrase (RenderingContext .VALUE_SET_DANISH );
752
+ case "11000181102 " : return context .formatPhrase (RenderingContext .VALUE_SET_EE );
753
+ case "11000229106" : return context .formatPhrase (RenderingContext .VALUE_SET_FI );
754
+ case "11000274103" : return context .formatPhrase (RenderingContext .VALUE_SET_DE );
755
+ case "1121000189102" : return context .formatPhrase (RenderingContext .VALUE_SET_IN );
756
+ case "11000220105" : return context .formatPhrase (RenderingContext .VALUE_SET_IE );
757
+ case "11000146104" : return context .formatPhrase (RenderingContext .VALUE_SET_DUTCH );
758
+ case "21000210109" : return context .formatPhrase (RenderingContext .VALUE_SET_NZ );
759
+ case "51000202101 " : return context .formatPhrase (RenderingContext .VALUE_SET_NO );
760
+ case "11000267109" : return context .formatPhrase (RenderingContext .VALUE_SET_KR );
761
+ case "900000001000122104" : return context .formatPhrase (RenderingContext .VALUE_ES_ES );
762
+ case "45991000052106" : return context .formatPhrase (RenderingContext .VALUE_SET_SWEDISH );
763
+ case "2011000195101" : return context .formatPhrase (RenderingContext .VALUE_SET_CH );
764
+ case "83821000000107" : return context .formatPhrase (RenderingContext .VALUE_SET_UK );
765
+ case "999000021000000109" : return context .formatPhrase (RenderingContext .VALUE_SET_UK_CLIN );
766
+ case "5631000179106" : return context .formatPhrase (RenderingContext .VALUE_SET_UY );
767
+ case "731000124108" : return context .formatPhrase (RenderingContext .VALUE_SET_US );
768
+ case "5991000124107" : return context .formatPhrase (RenderingContext .VALUE_SET_US_ICD10CM );
708
769
default :
709
770
return module ;
710
771
}
@@ -831,8 +892,10 @@ private void scanForDesignations(ValueSetExpansionContainsComponent c, List<Stri
831
892
}
832
893
for (ConceptReferenceDesignationComponent d : c .getDesignation ()) {
833
894
String lang = d .getLanguage ();
834
- if (!Utilities .noString (lang ) && !langs .contains (lang )) {
835
- langs .add (lang );
895
+ if (!Utilities .noString (lang )) {
896
+ if (!langs .contains (lang )) {
897
+ langs .add (lang );
898
+ }
836
899
} else {
837
900
// can we present this as a designation that we know?
838
901
String disp = getDisplayForDesignation (d );
@@ -1208,6 +1271,8 @@ private String getDisplayForUrl(String url) {
1208
1271
return context .formatPhrase (RenderingContext .VALUE_SET_SPEC_NAME );
1209
1272
case "http://snomed.info/sct#900000000000013009" :
1210
1273
return context .formatPhrase (RenderingContext .VALUE_SET_SYNONYM );
1274
+ case "http://terminology.hl7.org/CodeSystem/designation-usage#display" :
1275
+ return context .formatPhrase (RenderingContext .VALUE_SET_OTHER_DISPLAY );
1211
1276
default :
1212
1277
// As specified in http://www.hl7.org/fhir/valueset-definitions.html#ValueSet.compose.include.concept.designation.use and in http://www.hl7.org/fhir/codesystem-definitions.html#CodeSystem.concept.designation.use the terminology binding is extensible.
1213
1278
return url ;
0 commit comments