diff --git a/app/femr/common/ItemModelMapper.java b/app/femr/common/ItemModelMapper.java index 1794ce50c..30b131908 100644 --- a/app/femr/common/ItemModelMapper.java +++ b/app/femr/common/ItemModelMapper.java @@ -327,9 +327,9 @@ public PatientEncounterItem createPatientEncounterItem(IPatientEncounter patient patientEncounterItem.setPharmacistFullName(patientEncounter.getPharmacist().getFirstName() + " " + patientEncounter.getPharmacist().getLastName()); // Andrew Change } patientEncounterItem.setTurnAroundTime(dateUtils.getTurnAroundTime(patientEncounterItem)); - if (patientEncounter.getLanguageCode() != null ) { - patientEncounterItem.setLanguageCode(patientEncounter.getLanguageCode()); - } + // if (patientEncounter.getLanguageCode() != null ) { + patientEncounterItem.setLanguageCode("en"); + //} return patientEncounterItem; diff --git a/app/femr/common/dtos/CurrentUser.java b/app/femr/common/dtos/CurrentUser.java index 4fbb67f89..b4465990c 100644 --- a/app/femr/common/dtos/CurrentUser.java +++ b/app/femr/common/dtos/CurrentUser.java @@ -78,5 +78,11 @@ public long getTimeout2() { return SessionTimeOut; } - public String getLanguageCode() { return langCode;} + public String getLanguageCode() { + return this.langCode; + } + + public void setLanguageCode(String languageCode) { + this.langCode = languageCode; + } } \ No newline at end of file diff --git a/app/femr/ui/controllers/SettingsController.java b/app/femr/ui/controllers/SettingsController.java index 25e0cac1f..37540e0c0 100644 --- a/app/femr/ui/controllers/SettingsController.java +++ b/app/femr/ui/controllers/SettingsController.java @@ -47,34 +47,19 @@ public Result index() { return ok(femr.ui.views.html.settings.index.render(currentUser, assetsFinder)); } - public Result update() { + public Result update(String languageCode) { CurrentUser currentUser = sessionService.retrieveCurrentUserSession(); if (currentUser == null) { return unauthorized(); } - IndexViewModelGet viewModelGet = new IndexViewModelGet(); - Form editViewModelForm = formFactory.form(EditViewModel.class).bindFromRequest(); - if (editViewModelForm.hasErrors()) { - return badRequest(index.render(currentUser, assetsFinder)); - } - - EditViewModel viewModel = editViewModelForm.get(); ServiceResponse userServiceResponse = userService.retrieveUser(currentUser.getId()); if (userServiceResponse.hasErrors()) { return internalServerError(); } UserItem userItem = userServiceResponse.getResponseObject(); - userItem.setFirstName(viewModel.getFirstName()); - userItem.setLastName(viewModel.getLastName()); - userItem.setLanguageCode(viewModel.getLanguageCode()); - - if (StringUtils.isNotNullOrWhiteSpace(viewModel.getPasswordReset()) && viewModel.getPasswordReset().equals("on")) { - userItem.setPasswordReset(true); - } else { - userItem.setPasswordReset(false); - } + userItem.setLanguageCode(languageCode); ServiceResponse updateResponse = userService.updateUser(userItem, null); diff --git a/app/femr/ui/views/admin/index.scala.html b/app/femr/ui/views/admin/index.scala.html index b7580ad60..4e2dc0b06 100644 --- a/app/femr/ui/views/admin/index.scala.html +++ b/app/femr/ui/views/admin/index.scala.html @@ -9,9 +9,7 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = @currentUser.getLanguageCode(); - updateLanguage(initialLanguage); + updateLanguage("@{currentUser.getLanguageCode()}"); document.getElementById('languageSelect').value = initialLanguage; }); diff --git a/app/femr/ui/views/feedback/feedback.scala.html b/app/femr/ui/views/feedback/feedback.scala.html index 2e9205de8..1448c660e 100644 --- a/app/femr/ui/views/feedback/feedback.scala.html +++ b/app/femr/ui/views/feedback/feedback.scala.html @@ -12,15 +12,15 @@ .then(response => response.json()) .then(data => { languageData = data; - const storedLanguage = localStorage.getItem('languageCode') || 'en'; - updateLanguage(storedLanguage); - document.getElementById('languageSelect').value = storedLanguage; + try { + let languageCode = "@{currentUser.getLanguageCode()}"; + updateLanguage(languageCode); + } catch (error) { + const languageCode = "en"; + updateLanguage(languageCode); + } }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { diff --git a/app/femr/ui/views/home/index.scala.html b/app/femr/ui/views/home/index.scala.html index 6d136d6f9..4548d6be2 100644 --- a/app/femr/ui/views/home/index.scala.html +++ b/app/femr/ui/views/home/index.scala.html @@ -16,40 +16,46 @@ } diff --git a/app/femr/ui/views/layouts/admin.scala.html b/app/femr/ui/views/layouts/admin.scala.html index 9903db9d2..46075f4c2 100644 --- a/app/femr/ui/views/layouts/admin.scala.html +++ b/app/femr/ui/views/layouts/admin.scala.html @@ -28,16 +28,15 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = @currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + try { + let languageCode = "@{currentUser.getLanguageCode()}"; + updateLanguage(languageCode); + } catch (error) { + const languageCode = "en"; + updateLanguage(languageCode); + } }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { diff --git a/app/femr/ui/views/layouts/settings.scala.html b/app/femr/ui/views/layouts/settings.scala.html index 845d50f33..31b45b1ef 100644 --- a/app/femr/ui/views/layouts/settings.scala.html +++ b/app/femr/ui/views/layouts/settings.scala.html @@ -24,16 +24,9 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { @@ -71,7 +64,7 @@

Settings Panel

-

Language Preference.

+

Language Preference

@message diff --git a/app/femr/ui/views/manager/index.scala.html b/app/femr/ui/views/manager/index.scala.html index 99647a244..eb60057a6 100644 --- a/app/femr/ui/views/manager/index.scala.html +++ b/app/femr/ui/views/manager/index.scala.html @@ -16,16 +16,9 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = @currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { diff --git a/app/femr/ui/views/medical/index.scala.html b/app/femr/ui/views/medical/index.scala.html index 16c693a83..c258e294b 100644 --- a/app/femr/ui/views/medical/index.scala.html +++ b/app/femr/ui/views/medical/index.scala.html @@ -13,16 +13,9 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = @currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { diff --git a/app/femr/ui/views/partials/authenticated.scala.html b/app/femr/ui/views/partials/authenticated.scala.html index f471d8935..0a1b6f2b5 100644 --- a/app/femr/ui/views/partials/authenticated.scala.html +++ b/app/femr/ui/views/partials/authenticated.scala.html @@ -20,16 +20,9 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { @@ -37,7 +30,7 @@ } } - function updateLanguage(languageCode = "en") { + function updateLanguage(languageCode) { localStorage.setItem('languageCode', languageCode); updateTextContent("langCode_triage", languageData[languageCode].langCode_triage); updateTextContent("langCode_medical", languageData[languageCode].langCode_medical); diff --git a/app/femr/ui/views/partials/footer.scala.html b/app/femr/ui/views/partials/footer.scala.html index ae3edef15..e3f32d1d3 100644 --- a/app/femr/ui/views/partials/footer.scala.html +++ b/app/femr/ui/views/partials/footer.scala.html @@ -2,20 +2,19 @@ diff --git a/app/femr/ui/views/settings/index.scala.html b/app/femr/ui/views/settings/index.scala.html index aa85c1ae2..13150a8af 100644 --- a/app/femr/ui/views/settings/index.scala.html +++ b/app/femr/ui/views/settings/index.scala.html @@ -17,15 +17,13 @@ .then(response => response.json()) .then(data => { languageData = data; - const initialLanguage = localStorage.getItem('languageCode') || 'en'; - //const initialLanguage = currentUser.getLanguageCode(); - updateLanguage(initialLanguage); - document.getElementById('languageSelect').value = initialLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); + //document.getElementById('languageSelect').value = initialLanguage; }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); + //document.getElementById('languageSelect').addEventListener('change', function() { + //updateLanguage(this.value); + //}); function updateTextContent(elementId, value) { const element = document.getElementById(elementId); diff --git a/app/femr/ui/views/triage/index.scala.html b/app/femr/ui/views/triage/index.scala.html index bfa6419d6..094284c02 100644 --- a/app/femr/ui/views/triage/index.scala.html +++ b/app/femr/ui/views/triage/index.scala.html @@ -29,15 +29,9 @@ .then(response => response.json()) .then(data => { languageData = data; - const storedLanguage = localStorage.getItem('languageCode') || 'en'; - updateLanguage(storedLanguage); - document.getElementById('languageSelect').value = storedLanguage; + updateLanguage("@{currentUser.getLanguageCode()}"); }); - document.getElementById('languageSelect').addEventListener('change', function() { - updateLanguage(this.value); - }); - function updateTextContent(elementId, value) { const element = document.getElementById(elementId); if (element) { diff --git a/conf/routes b/conf/routes index 2b0ae74f5..822301168 100644 --- a/conf/routes +++ b/conf/routes @@ -73,7 +73,7 @@ GET /search/typeahead/medicationAdministrations @femr.ui.controll #Settings GET /settings @femr.ui.controllers.SettingsController.index() -POST /settings/update @femr.ui.controllers.SettingsController.update() +POST /settings/update @femr.ui.controllers.SettingsController.update(languageCode: String) #Photo