diff --git a/app/assets/javascripts/templates/patient_builder/edit_codes_selection.hbs b/app/assets/javascripts/templates/patient_builder/edit_codes_selection.hbs index 0a5e8335b..6f4f6ca0c 100644 --- a/app/assets/javascripts/templates/patient_builder/edit_codes_selection.hbs +++ b/app/assets/javascripts/templates/patient_builder/edit_codes_selection.hbs @@ -3,10 +3,10 @@ diff --git a/app/assets/javascripts/views/patient_builder/edit_codes_selection.js.coffee b/app/assets/javascripts/views/patient_builder/edit_codes_selection.js.coffee index 317d97f80..01c245056 100644 --- a/app/assets/javascripts/views/patient_builder/edit_codes_selection.js.coffee +++ b/app/assets/javascripts/views/patient_builder/edit_codes_selection.js.coffee @@ -88,5 +88,5 @@ class Thorax.Views.EditCodeSelectionView extends Thorax.Views.BuilderChildView updateCodeSystems: -> # Maps code system name to code system uri @codeSystemMap = @measure.codeSystemMap() unless @codeSystemMap - @codeSystems = _((@codeSystemMap[concept.system] || concept.system) for concept in @concepts || []).uniq() + @codeSystems = _((@codeSystemMap[concept.system] || concept.system) for concept in @concepts || []).uniq().sort() @render() diff --git a/app/assets/javascripts/views/patient_builder/inputs/code.js.coffee b/app/assets/javascripts/views/patient_builder/inputs/code.js.coffee index 0d0619667..db6c4ee58 100644 --- a/app/assets/javascripts/views/patient_builder/inputs/code.js.coffee +++ b/app/assets/javascripts/views/patient_builder/inputs/code.js.coffee @@ -125,6 +125,8 @@ class Thorax.Views.InputCodeView extends Thorax.Views.BonnieView @valueSetCodesByCodeSystem.push codeSystemList codeSystemList.codes.push { code: code, display_name: displayName } + # Sort code systems by name + @valueSetCodesByCodeSystem.sort( (a, b) -> a.name?.localeCompare(b.name) ) # wipeout code system selection and replace options codeSystemSelect = @$('select[name="vs_codesystem"]').empty() @valueSetCodesByCodeSystem.forEach (codeSystem) => @@ -138,6 +140,9 @@ class Thorax.Views.InputCodeView extends Thorax.Views.BonnieView _populateValueSetCodeDropdown: -> # wipeout code system selection and replace options codeSelect = @$('select[name="vs_code"]').empty() + + # Sort codes + @selectedCodeSystem.codes.sort( (a, b) -> a.code?.localeCompare(b.code) ) @selectedCodeSystem.codes.forEach (code) => $("").appendTo(codeSelect) codeSelect.find('option:first').prop('selected', true) diff --git a/app/assets/javascripts/views/patient_builder/inputs/coding.js.coffee b/app/assets/javascripts/views/patient_builder/inputs/coding.js.coffee index a4ef8826e..001743f79 100644 --- a/app/assets/javascripts/views/patient_builder/inputs/coding.js.coffee +++ b/app/assets/javascripts/views/patient_builder/inputs/coding.js.coffee @@ -168,6 +168,8 @@ class Thorax.Views.InputCodingView extends Thorax.Views.BonnieView @valueSetCodesByCodeSystem.push codeSystemList codeSystemList.codes.push { code: code, display_name: displayName } + # Sort code systems by name + @valueSetCodesByCodeSystem.sort( (a, b) -> a.name?.localeCompare(b.name) ) # wipeout code system selection and replace options codeSystemSelect = @$('select[name="vs_codesystem"]').empty() @valueSetCodesByCodeSystem.forEach (codeSystem) => @@ -181,6 +183,9 @@ class Thorax.Views.InputCodingView extends Thorax.Views.BonnieView _populateValueSetCodeDropdown: -> # wipeout code system selection and replace options codeSelect = @$('select[name="vs_code"]').empty() + + # Sort codes + @selectedCodeSystem.codes.sort( (a, b) -> a.code?.localeCompare(b.code) ) @selectedCodeSystem.codes.forEach (code) => $("").appendTo(codeSelect) codeSelect.find('option:first').prop('selected', true)