From ff87f08f3c4880014191d64b3f7f26749f0bcfb0 Mon Sep 17 00:00:00 2001 From: Brendan <105313389+bholt13@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:36:44 -0800 Subject: [PATCH 01/10] Brendan (#741) * Triage image upload now uploads image properly for patient profile photo * updated iPhotoService javadoc --- app/femr/business/helpers/LogicDoer.java | 7 ++++--- .../business/services/core/IPhotoService.java | 5 ++--- .../services/system/PatientService.java | 2 +- .../business/services/system/PhotoService.java | 17 +++++++++++++++-- app/femr/data/DataModelMapper.java | 1 + app/femr/ui/controllers/HistoryController.java | 5 ++++- app/femr/ui/controllers/TriageController.java | 8 ++++++-- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/app/femr/business/helpers/LogicDoer.java b/app/femr/business/helpers/LogicDoer.java index b9618ed48..0afdf2a3a 100644 --- a/app/femr/business/helpers/LogicDoer.java +++ b/app/femr/business/helpers/LogicDoer.java @@ -116,9 +116,10 @@ public static boolean isEncounterClosed(IPatientEncounter patientEncounter) { if (dateOfPharmacyVisit != null) { isClosed = true; - } else if (dateOfMedicalVisit != null) { - //give 1 day before closing - DateTime dayAfterMedicalVisit = dateOfMedicalVisit.plusDays(1); + } else + if (dateOfMedicalVisit != null) { + //give 1 day before closing + DateTime dayAfterMedicalVisit = dateOfMedicalVisit.plusDays(1); if (dateNow.isAfter(dayAfterMedicalVisit)) { isClosed = true; } diff --git a/app/femr/business/services/core/IPhotoService.java b/app/femr/business/services/core/IPhotoService.java index 4b3cb67e5..8f2049393 100644 --- a/app/femr/business/services/core/IPhotoService.java +++ b/app/femr/business/services/core/IPhotoService.java @@ -53,14 +53,13 @@ public interface IPhotoService { * Saves a patient's photo and updates the patients photoId field to point * to the updated photo. * - * @param imageString image to save as a base64 encoded string, TODO: make not null + * @param image image to be uploaded * @param patientId id of the patient, not null * @param deleteFlag true if photo is being deleted instead of saved, not null * @return a service response that contains true if creation successful, false if not * and/or errors if they exist. */ - ServiceResponse createPatientPhoto(String imageString, int patientId, Boolean deleteFlag); - + ServiceResponse createPatientPhoto(File image, int patientId, Boolean deleteFlag); /** * Returns patient photo in binary form. Will determine where to fetch the photo (file system or blob) diff --git a/app/femr/business/services/system/PatientService.java b/app/femr/business/services/system/PatientService.java index 326507879..674daa129 100644 --- a/app/femr/business/services/system/PatientService.java +++ b/app/femr/business/services/system/PatientService.java @@ -428,7 +428,7 @@ private Integer getPatientPhotoIdOrNull(IPatient patient){ Integer photoId = null; if (patient.getPhoto() != null){ - photoId = patient.getPhoto().getId(); + photoId = patient.getPhoto().getId(); } return photoId; diff --git a/app/femr/business/services/system/PhotoService.java b/app/femr/business/services/system/PhotoService.java index 16c757836..ac2e667a5 100644 --- a/app/femr/business/services/system/PhotoService.java +++ b/app/femr/business/services/system/PhotoService.java @@ -105,12 +105,14 @@ private byte[] convertBufferedImageToByteArray(BufferedImage img) { * {@inheritDoc} */ @Override - public ServiceResponse createPatientPhoto(String imageString, int patientId, Boolean deleteFlag) { + public ServiceResponse createPatientPhoto(File image, int patientId, Boolean deleteFlag) { ServiceResponse response = new ServiceResponse<>(); try { IPatient patient = patientRepository.retrievePatientById(patientId); + String imageString = encodePhoto(image); + if (StringUtils.isNotNullOrWhiteSpace(imageString)) { //Decode image, save as BufferedImage: @@ -214,7 +216,6 @@ public ServiceResponse retrievePatientPhotoData(int patientId) { } - /** * {@inheritDoc} */ @@ -414,5 +415,17 @@ private static BufferedImage decodeToImage(String imageString) { return image; } + private static String encodePhoto(File file){ + try { + byte[] bytes = Files.readAllBytes(file.toPath()); + return Base64.encodeBase64String(bytes); + } catch (IOException e) { + e.printStackTrace(); + } + + return ""; + + } + } diff --git a/app/femr/data/DataModelMapper.java b/app/femr/data/DataModelMapper.java index 8c2196703..8fa6fe3cf 100644 --- a/app/femr/data/DataModelMapper.java +++ b/app/femr/data/DataModelMapper.java @@ -344,6 +344,7 @@ public IPatient createPatient(int userID, String firstName, String lastName, Str patient.setSex(sex); patient.setAddress(address); patient.setCity(city); + if (photoID != null) patient.setPhoto(Ebean.getReference(photoProvider.get().getClass(), photoID)); diff --git a/app/femr/ui/controllers/HistoryController.java b/app/femr/ui/controllers/HistoryController.java index f6ec81b0a..3549ca6df 100644 --- a/app/femr/ui/controllers/HistoryController.java +++ b/app/femr/ui/controllers/HistoryController.java @@ -107,7 +107,10 @@ public Result indexPatientGet(String query) { //too much logic - move patient photo finding up to the service layer for (PatientItem patientItem : patientItems) - patientItem.setPathToPhoto(routes.PhotoController.GetPatientPhoto(patientItem.getId(), true).toString()); + if(patientItem.getPhotoId() != null) + patientItem.setPathToPhoto(routes.PhotoController.GetPatientPhoto(patientItem.getId(), false).toString()); + else + patientItem.setPathToPhoto(routes.PhotoController.GetPatientPhoto(patientItem.getId(), true).toString()); viewModel.setPatientItems(patientItems); viewModel.setRankedPatientItems(new ArrayList<>()); viewModel.setPatientItem(patientItems.get(0)); diff --git a/app/femr/ui/controllers/TriageController.java b/app/femr/ui/controllers/TriageController.java index 1e9fed0d4..1f328b09c 100644 --- a/app/femr/ui/controllers/TriageController.java +++ b/app/femr/ui/controllers/TriageController.java @@ -19,6 +19,7 @@ import play.data.FormFactory; import play.mvc.*; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -200,14 +201,17 @@ public Result indexPost(int id) { patientItem = patientServiceResponse.getResponseObject(); - photoService.createPatientPhoto(viewModel.getPatientPhotoCropped(), patientItem.getId(), viewModel.getDeletePhoto()); + //photoService.createPatientPhoto(viewModel.getPatientPhotoCropped(), patientItem.getId(), viewModel.getDeletePhoto()); //V code for saving photo without javascript //currently javascript is required - //Http.MultipartFormData.FilePart fpPhoto = request().body().asMultipartFormData().getFile("patientPhoto"); + Http.MultipartFormData body = request().body().asMultipartFormData(); + Http.MultipartFormData.FilePart filePart = body.getFile("patientPhoto"); + photoService.createPatientPhoto(filePart.getFile(), patientItem.getId(), viewModel.getDeletePhoto()); List chiefComplaints = parseChiefComplaintsJSON(viewModel.getChiefComplaint(), viewModel.getChiefComplaintsJSON()); ServiceResponse patientEncounterServiceResponse = encounterService.createPatientEncounter(patientItem.getId(), currentUser.getId(), currentUser.getTripId(), viewModel.getAgeClassification(), chiefComplaints); + PatientEncounterItem patientEncounterItem; if (patientEncounterServiceResponse.hasErrors()) { From 735c14bc7134930e22399a843700e9532e42a179 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 5 Nov 2024 09:36:19 -0800 Subject: [PATCH 02/10] Added translation for managing teams, trips, and cities --- .../ui/views/admin/trips/cities.scala.html | 47 +++++++++++-- .../ui/views/admin/trips/manage.scala.html | 69 +++++++++++++++---- .../ui/views/admin/trips/teams.scala.html | 54 ++++++++++++--- app/femr/ui/views/home/index.scala.html | 2 +- app/femr/ui/views/partials/footer.scala.html | 3 - .../ui/views/superuser/tabs/fields.scala.html | 1 + .../ui/views/superuser/tabs/manage.scala.html | 1 + .../util/translation/TranslationServer.java | 2 +- public/json/languages.json | 2 +- 9 files changed, 148 insertions(+), 33 deletions(-) diff --git a/app/femr/ui/views/admin/trips/cities.scala.html b/app/femr/ui/views/admin/trips/cities.scala.html index c52863b37..56f349994 100644 --- a/app/femr/ui/views/admin/trips/cities.scala.html +++ b/app/femr/ui/views/admin/trips/cities.scala.html @@ -12,6 +12,38 @@ @additionalScripts = { + } @admin("Trips - Manage Cities", currentUser, scripts = additionalScripts, styles = additionalStyles, assets = assets) { @@ -24,15 +56,18 @@ @helper.form(action = TripController.citiesPost()) {
-

Add City:

+

Add City

-
-
-
-
-
- +
} @@ -77,12 +120,12 @@

Add Trip:

- - - - - - + + + + + + diff --git a/app/femr/ui/views/admin/trips/teams.scala.html b/app/femr/ui/views/admin/trips/teams.scala.html index 25ca8ef40..4bcfa7c91 100644 --- a/app/femr/ui/views/admin/trips/teams.scala.html +++ b/app/femr/ui/views/admin/trips/teams.scala.html @@ -12,6 +12,41 @@ @additionalScripts = { + } @admin("Trips - Manage Teams", currentUser, styles = additionalStyles, scripts = additionalScripts, assets = assets) { @@ -25,21 +60,24 @@ @helper.form(action = TripController.teamsPost()) {
-

Add Team:

+

Add Team:

-
-
-
@@ -49,7 +87,7 @@

Add Team:

- +
} @@ -58,9 +96,9 @@

Add Team:

EditTeam NameCountryCityStart DateEnd DateEditTeam NameCountryCityStart DateEnd Date
- - - + + + diff --git a/app/femr/ui/views/home/index.scala.html b/app/femr/ui/views/home/index.scala.html index 504fc0220..300d65095 100644 --- a/app/femr/ui/views/home/index.scala.html +++ b/app/femr/ui/views/home/index.scala.html @@ -56,7 +56,7 @@ } - + @*Sample texts. Content is pulled from the languages json in the public directory.*@ @top = {
diff --git a/app/femr/ui/views/partials/footer.scala.html b/app/femr/ui/views/partials/footer.scala.html index 4a1790bad..1543c673d 100644 --- a/app/femr/ui/views/partials/footer.scala.html +++ b/app/femr/ui/views/partials/footer.scala.html @@ -2,15 +2,12 @@ } @@ -56,6 +56,8 @@

@message

}
+

Please note: Before you can log in your account must be approved by an admin.

+ @helper.form(action = SessionsController.createAccountPost(), 'class -> "form-horizontal createWrap", 'name -> "createForm") { @helper.inputText(createForm("email"), @@ -84,6 +86,8 @@

@message

+ + @helper.inputText(createForm("firstName"), 'class -> "fInput", 'placeholder -> "First Name", From 6c59d79bff234646444d21bdb53d4b087e123a05 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:54:44 -0800 Subject: [PATCH 05/10] removed char --- app/femr/ui/views/sessions/create.scala.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/femr/ui/views/sessions/create.scala.html b/app/femr/ui/views/sessions/create.scala.html index 4c96e753a..9586bfd28 100644 --- a/app/femr/ui/views/sessions/create.scala.html +++ b/app/femr/ui/views/sessions/create.scala.html @@ -86,8 +86,6 @@

Please note: Before you can log in your account must be approved by an admin - - @helper.inputText(createForm("firstName"), 'class -> "fInput", 'placeholder -> "First Name", From 0a3dd7372b6ee42716fe3b36a4a7f694b6154a6e Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:31:25 -0800 Subject: [PATCH 06/10] removed char --- app/femr/ui/views/sessions/create.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/femr/ui/views/sessions/create.scala.html b/app/femr/ui/views/sessions/create.scala.html index 9586bfd28..4040828b0 100644 --- a/app/femr/ui/views/sessions/create.scala.html +++ b/app/femr/ui/views/sessions/create.scala.html @@ -17,7 +17,7 @@ @additionalStyles = { } -` + @additionalScripts = { } From 5502f7ed327a2e16c100231b1d04167822eb52aa Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Wed, 6 Nov 2024 17:20:58 -0800 Subject: [PATCH 07/10] Updated workflow to represent buildilng and testing --- .github/workflows/scala.yml | 2 +- app/femr/ui/views/admin/updates/manage.scala.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index 07a2cc43e..d4b20044e 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - build: + build_and_test: runs-on: ubuntu-latest diff --git a/app/femr/ui/views/admin/updates/manage.scala.html b/app/femr/ui/views/admin/updates/manage.scala.html index 78a1f10c8..2c94b47c0 100644 --- a/app/femr/ui/views/admin/updates/manage.scala.html +++ b/app/femr/ui/views/admin/updates/manage.scala.html @@ -23,7 +23,7 @@

Network Status

-

Team NameDescriptionOriginTeam NameDescriptionOrigin
+
`
@helper.form(action = UpdatesController.refreshInternetStatus()) { From 7e4d9e99587b0f089125c86b6fc8e3d1f0415cd5 Mon Sep 17 00:00:00 2001 From: JLpro-cd <75441530+JLpro-cd@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:16:31 -0800 Subject: [PATCH 08/10] Update ReferenceController.java to allow Admin to access reference page. --- app/femr/ui/controllers/ReferenceController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/femr/ui/controllers/ReferenceController.java b/app/femr/ui/controllers/ReferenceController.java index 6b48e0ce1..3e679980c 100644 --- a/app/femr/ui/controllers/ReferenceController.java +++ b/app/femr/ui/controllers/ReferenceController.java @@ -11,7 +11,7 @@ import femr.ui.views.html.reference.index; @Security.Authenticated(FEMRAuthenticated.class) -@AllowedRoles({Roles.PHYSICIAN, Roles.PHARMACIST, Roles.NURSE, Roles.SUPERUSER}) +@AllowedRoles({Roles.PHYSICIAN, Roles.PHARMACIST, Roles.NURSE, Roles.SUPERUSER, Roles.ADMINISTRATOR}) public class ReferenceController extends Controller { private final AssetsFinder assetsFinder; From 21e63e854bd7ca11831343818fc9694b36ccd805 Mon Sep 17 00:00:00 2001 From: JLpro-cd <75441530+JLpro-cd@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:50:52 -0800 Subject: [PATCH 09/10] Update retrieveAllRoles() in UserRepository.java to include SuperUser role when retrieving all roles from the database --- app/femr/data/daos/system/UserRepository.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/femr/data/daos/system/UserRepository.java b/app/femr/data/daos/system/UserRepository.java index b68c489cf..14028907a 100644 --- a/app/femr/data/daos/system/UserRepository.java +++ b/app/femr/data/daos/system/UserRepository.java @@ -237,9 +237,12 @@ public List retrieveUsersByTripId(Integer tripId){ @Override public List retrieveAllRoles(){ - ExpressionList roleQuery = QueryProvider.getRoleQuery() - .where() + ExpressionList roleQuery = QueryProvider.getRoleQuery().where(); + + /* .ne("name", "SuperUser"); + Why remove SuperUser from role list? Caused bug where updating SuperUser removed its role... + */ List allRoles; try{ From a997b37e78527bcb502124a9c3290b3bf42fc953 Mon Sep 17 00:00:00 2001 From: JLpro-cd <75441530+JLpro-cd@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:05:45 -0800 Subject: [PATCH 10/10] Update main.scala.html favicon to femr logo --- app/femr/ui/views/layouts/main.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/femr/ui/views/layouts/main.scala.html b/app/femr/ui/views/layouts/main.scala.html index 69edd3d9a..5a8e94d84 100644 --- a/app/femr/ui/views/layouts/main.scala.html +++ b/app/femr/ui/views/layouts/main.scala.html @@ -15,7 +15,7 @@ - +