Skip to content

Commit 62a626d

Browse files
authored
Merge pull request #13590 from SORMAS-Foundation/bugfix-13555-phone_dd_save_error
#13555 - Fix editing Notifier in phone DD
2 parents 19af2d3 + b541947 commit 62a626d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

sormas-backend/src/main/java/de/symeda/sormas/backend/person/notifier/NotifierService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ public Notifier getByUuidAndTime(String uuid, Instant time) {
9191

9292
final Timestamp timestamp = Timestamp.from(time);
9393

94-
final String sql = "SELECT * FROM ("
95-
+ "SELECT * FROM (SELECT * FROM notifier_history b WHERE b.uuid = :uuid AND changedate <= CAST(:changeDate AS TIMESTAMP) ORDER BY changedate DESC LIMIT 1) "
96-
+ "UNION SELECT * FROM notifier a WHERE a.uuid = :uuid) "
97-
+ "WHERE uuid = :uuid AND changedate <= CAST(:changeDate AS TIMESTAMP) ORDER BY changedate DESC LIMIT 1;";
94+
final String sql = "SELECT " + "a.id AS id, a.uuid AS uuid," + "COALESCE(b.changedate, a.changedate) AS changedate,"
95+
+ "a.creationdate AS creationdate, a.change_user_id AS change_user_id,"
96+
+ "COALESCE(b.registrationnumber, a.registrationnumber) AS registrationnumber," + "COALESCE(b.firstname, a.firstname) AS firstname,"
97+
+ "COALESCE(b.lastname, a.lastname) AS lastname," + "COALESCE(b.address, a.address) AS address," + "COALESCE(b.email, a.email) AS email,"
98+
+ "COALESCE(b.phone, a.phone) AS phone, "+ "COALESCE(b.agentfirstname, a.agentfirstname) AS agentfirstname, "
99+
+ "COALESCE(b.agentlastname, a.agentlastname) AS agentlastname "+ "FROM notifier a " + "LEFT JOIN " + "(SELECT * FROM notifier_history "
100+
+ "WHERE uuid = :uuid AND changedate <= CAST(:changeDate AS TIMESTAMP) " + "ORDER BY changedate DESC LIMIT 1" + ") b ON a.uuid = b.uuid "
101+
+ "WHERE a.uuid = :uuid";
98102

99103
Query query = em.createNativeQuery(sql, Notifier.class);
100104
query.setParameter("uuid", uuid);

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/notifier/CaseNotifierSideViewController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ public void editNotifier(CaseDataDto caze, Runnable callback, boolean isEditAllo
144144
return;
145145
}
146146

147+
// We only edit the current version
147148
NotifierDto notifier =
148-
FacadeProvider.getNotifierFacade().getByUuidAndTime(caze.getNotifier().getUuid(), caze.getNotifier().getVersionDate().toInstant());
149+
FacadeProvider.getNotifierFacade().getByUuid(caze.getNotifier().getUuid());
149150
TherapyDto therapy = caze.getTherapy();
150151

151152
openEditWindow(

0 commit comments

Comments
 (0)