-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BAH 2962 | SMS functionality of appointment booking and reminder moved to backend #117
Merged
Merged
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
5640079
BAH-2181 | added sms reminder for appointments
atishbeehyv123 8407919
[Rahul] | Fix. teleconsultation-api Version Upgrade
rahu1ramesh c76b466
BAH-2181 | ConnectionDetails refratored with null check
atishbeehyv123 bfaf187
BAH-2181 | refractored patientid and clinicName
atishbeehyv123 12a517d
BAH-2181 | Refractored the process of fetching Clinic name
atishbeehyv123 0c641e9
BAH-2181 | Moving appointment booking sms to backend
atishbeehyv123 29857ba
refractored user and template key
atishbeehyv123 63d0d6f
sms uri to be fetched from global properties now
atishbeehyv123 a31cef2
refractored the code acc to comments
atishbeehyv123 4395f39
teleconsultation-api version changed because build failed
atishbeehyv123 d8900aa
refractored clinic to facility and used sms-user
atishbeehyv123 aee3b64
refractored code
atishbeehyv123 1246c0a
refractored code
atishbeehyv123 4c379be
added tests because of build failure with less coverage
atishbeehyv123 d88975b
added tests because of build failure with less coverage
atishbeehyv123 09bc9f7
decreased minimum required branch coverage ratio
atishbeehyv123 6718e62
Merge remote-tracking branch 'origin/master' into BAH-2181
atishbeehyv123 e5ee037
Merge remote-tracking branch 'origin/BAH-2181' into BAH-2962
atishbeehyv123 bd89818
Refractored test for SMSServiceTest
atishbeehyv123 a8e6d06
Refractored test for SMSServiceTest
atishbeehyv123 ade2221
Merge remote-tracking branch 'origin/BAH-2962' into BAH-2962
atishbeehyv123 0f6a3c6
BAH-2962 | refractored sms api to be different api altogether for asy…
atishbeehyv123 2b8f041
BAH-2962 | used single line imports
atishbeehyv123 d06a6e3
Added required privileges condition check for appointments sms
atishbeehyv123 43ee6c8
Added required privileges condition check for appointments sms.
atishbeehyv123 dfb9347
Merge remote-tracking branch 'origin/BAH-2962' into BAH-2962
atishbeehyv123 7762a23
Changed condition of privilege for reminder
atishbeehyv123 7ebe69c
Refactored token sending process
atishbeehyv123 b19d36e
Removed usage of appointments module to send sms now working as part …
anubhavBeehyv 52d572f
Merge remote-tracking branch 'origin/master' into BAH-2962
anubhavBeehyv 9cbf697
Merge remote-tracking branch 'origin/master' into BAH-2962
anubhavBeehyv efc4a7e
Event Publisher moved to specific modules.
anubhavBeehyv cd829d4
Event Publisher moved to specific modules.
anubhavBeehyv fcc423b
Event publisher now added in appointments module itself.
anubhavBeehyv ac2b2f3
Removed bahmni-commons dependency
anubhavBeehyv ede9471
Added communications-module dependency as aware_of.
anubhavBeehyv 86bfd69
Update PrivilegeConstants.java
anubhavBeehyv d6f376b
Changes to resolve git comments
anubhavBeehyv 551a8f0
Merge remote-tracking branch 'origin/BAH-2962' into BAH-2962
anubhavBeehyv ae5683c
Changes to resolve git comments
anubhavBeehyv ce8c9a0
Merge remote-tracking branch 'origin/master' into BAH-2962
anubhavBeehyv 5edc04c
Update AppointmentArgumentsMapperImpl.java
anubhavBeehyv d608863
Update AppointmentArgumentsMapperImpl.java
anubhavBeehyv 94114bf
Changes to reslove comments
anubhavBeehyv d68b46c
Merge remote-tracking branch 'origin/BAH-2962' into BAH-2962
anubhavBeehyv 58f3d69
Removed global property clinic timings.
anubhavBeehyv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
api/src/main/java/org/openmrs/module/appointments/connection/ConnectionDetails.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
api/src/main/java/org/openmrs/module/appointments/connection/OpenmrsLogin.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
api/src/main/java/org/openmrs/module/appointments/connection/WebClientFactory.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
api/src/main/java/org/openmrs/module/appointments/events/AppointmentBookingEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.openmrs.module.appointments.events; | ||
|
||
import org.openmrs.module.appointments.model.Appointment; | ||
|
||
public class AppointmentBookingEvent extends AppointmentEvent { | ||
|
||
private Appointment appointment; | ||
|
||
public AppointmentBookingEvent(AppointmentEventType eventType, Appointment appointment) { | ||
super(eventType); | ||
this.appointment=appointment; | ||
this.payloadId=appointment.getUuid(); | ||
} | ||
|
||
public Appointment getAppointment() { | ||
return appointment; | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
api/src/main/java/org/openmrs/module/appointments/events/AppointmentEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openmrs.module.appointments.events; | ||
|
||
import org.openmrs.api.context.Context; | ||
import org.openmrs.api.context.UserContext; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
public class AppointmentEvent { | ||
private static final long version = 1L; | ||
public UserContext userContext; | ||
public final String eventId; | ||
public final AppointmentEventType eventType; | ||
public String payloadId; | ||
public LocalDateTime publishedDateTime; | ||
public AppointmentEvent(AppointmentEventType eventType) { | ||
this.eventType = eventType; | ||
this.eventId = UUID.randomUUID().toString(); | ||
this.publishedDateTime = LocalDateTime.now(); | ||
this.userContext= Context.getUserContext(); | ||
this.payloadId=""; | ||
} | ||
} | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
api/src/main/java/org/openmrs/module/appointments/events/AppointmentEventType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.openmrs.module.appointments.events; | ||
|
||
public enum AppointmentEventType { | ||
BAHMNI_APPOINTMENT_CREATED("bahmni-appointment"), | ||
BAHMNI_APPOINTMENT_UPDATED("bahmni-appointment"), | ||
BAHMNI_RECURRING_APPOINTMENT_CREATED("bahmni-recurring-appointment"), | ||
BAHMNI_RECURRING_APPOINTMENT_UPDATED("bahmni-recurring-appointment"); | ||
|
||
private final String topic; | ||
AppointmentEventType(String topic) { | ||
this.topic = topic; | ||
} | ||
|
||
public String topic() { | ||
return topic; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
api/src/main/java/org/openmrs/module/appointments/events/RecurringAppointmentEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.openmrs.module.appointments.events; | ||
import org.openmrs.module.appointments.model.AppointmentRecurringPattern; | ||
|
||
public class RecurringAppointmentEvent extends AppointmentEvent { | ||
private AppointmentRecurringPattern appointmentRecurringPattern; | ||
|
||
public RecurringAppointmentEvent(AppointmentEventType eventType,AppointmentRecurringPattern appointmentRecurringPattern) { | ||
super(eventType); | ||
this.appointmentRecurringPattern=appointmentRecurringPattern; | ||
this.payloadId=appointmentRecurringPattern.getAppointments().iterator().next().getUuid(); | ||
} | ||
public AppointmentRecurringPattern getAppointmentRecurringPattern() { | ||
return appointmentRecurringPattern; | ||
} | ||
|
||
} | ||
|
59 changes: 59 additions & 0 deletions
59
api/src/main/java/org/openmrs/module/appointments/events/advice/AppointmentEventsAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.openmrs.module.appointments.events.advice; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.openmrs.api.context.Context; | ||
import org.openmrs.module.appointments.events.AppointmentEvent; | ||
import org.openmrs.module.appointments.events.publisher.AppointmentEventPublisher; | ||
import org.openmrs.module.appointments.model.Appointment; | ||
import org.openmrs.module.appointments.events.AppointmentBookingEvent; | ||
import org.openmrs.module.appointments.events.AppointmentEventType; | ||
import org.springframework.aop.AfterReturningAdvice; | ||
import org.springframework.aop.MethodBeforeAdvice; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
import static org.openmrs.module.appointments.events.AppointmentEventType.BAHMNI_APPOINTMENT_CREATED; | ||
import static org.openmrs.module.appointments.events.AppointmentEventType.BAHMNI_APPOINTMENT_UPDATED; | ||
|
||
public class AppointmentEventsAdvice implements AfterReturningAdvice, MethodBeforeAdvice { | ||
|
||
private final Logger log = LogManager.getLogger(AppointmentEventsAdvice.class); | ||
private final AppointmentEventPublisher eventPublisher; | ||
private final ThreadLocal<Map<String,Integer>> threadLocal = new ThreadLocal<>(); | ||
private final String APPOINTMENT_ID_KEY = "appointmentId"; | ||
private final Set<String> adviceMethodNames = Sets.newHashSet("validateAndSave"); | ||
|
||
public AppointmentEventsAdvice() { | ||
this.eventPublisher=Context.getRegisteredComponent("appointmentEventPublisher",AppointmentEventPublisher.class); | ||
} | ||
|
||
@Override | ||
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) { | ||
if (adviceMethodNames.contains(method.getName())) { | ||
Map<String, Integer> patientInfo = threadLocal.get(); | ||
if (patientInfo != null) { | ||
AppointmentEventType eventType = patientInfo.get(APPOINTMENT_ID_KEY) == null ? BAHMNI_APPOINTMENT_CREATED : BAHMNI_APPOINTMENT_UPDATED; | ||
threadLocal.remove(); | ||
|
||
Appointment appointment = (Appointment) returnValue; | ||
AppointmentBookingEvent appointmentEvent =new AppointmentBookingEvent(eventType,appointment); | ||
eventPublisher.publishEvent(appointmentEvent); | ||
log.info("Successfully published event with uuid : " + appointmentEvent.payloadId); | ||
} | ||
} | ||
} | ||
@Override | ||
public void before(Method method, Object[] objects, Object o) { | ||
if (adviceMethodNames.contains(method.getName())) { | ||
Appointment appointment = ((Supplier<Appointment>) objects[0]).get(); | ||
Map<String, Integer> appointmentInfo = new HashMap<>(1); | ||
appointmentInfo.put(APPOINTMENT_ID_KEY, appointment.getId()); | ||
threadLocal.set(appointmentInfo); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
.../java/org/openmrs/module/appointments/events/advice/RecurringAppointmentEventsAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.openmrs.module.appointments.events.advice; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.openmrs.api.context.Context; | ||
import org.openmrs.module.appointments.events.publisher.AppointmentEventPublisher; | ||
import org.openmrs.module.appointments.events.AppointmentEventType; | ||
import org.openmrs.module.appointments.model.AppointmentRecurringPattern; | ||
import org.openmrs.module.appointments.events.RecurringAppointmentEvent; | ||
import org.springframework.aop.AfterReturningAdvice; | ||
import org.springframework.aop.MethodBeforeAdvice; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.openmrs.module.appointments.events.AppointmentEventType.BAHMNI_RECURRING_APPOINTMENT_CREATED; | ||
import static org.openmrs.module.appointments.events.AppointmentEventType.BAHMNI_RECURRING_APPOINTMENT_UPDATED; | ||
|
||
public class RecurringAppointmentEventsAdvice implements AfterReturningAdvice, MethodBeforeAdvice { | ||
|
||
private final Logger log = LogManager.getLogger(RecurringAppointmentEventsAdvice.class); | ||
private final AppointmentEventPublisher eventPublisher; | ||
private final ThreadLocal<Map<String, Integer>> threadLocal = new ThreadLocal<>(); | ||
private final String RECURRING_APPOINTMENT_ID_KEY = "recurringAppointmentId"; | ||
private final Set<String> adviceMethodNames = Sets.newHashSet("validateAndSave"); | ||
|
||
public RecurringAppointmentEventsAdvice() { | ||
this.eventPublisher = Context.getRegisteredComponent("appointmentEventPublisher", AppointmentEventPublisher.class); | ||
} | ||
|
||
@Override | ||
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) { | ||
if (adviceMethodNames.contains(method.getName())) { | ||
Map<String, Integer> appointmentInfo = threadLocal.get(); | ||
if (appointmentInfo != null) { | ||
AppointmentEventType eventType = appointmentInfo.get(RECURRING_APPOINTMENT_ID_KEY) == null ? BAHMNI_RECURRING_APPOINTMENT_CREATED : BAHMNI_RECURRING_APPOINTMENT_UPDATED; | ||
threadLocal.remove(); | ||
AppointmentRecurringPattern appointmentRecurringPattern = (AppointmentRecurringPattern) returnValue; | ||
RecurringAppointmentEvent recurringAppointmentEvent = new RecurringAppointmentEvent(eventType, appointmentRecurringPattern); | ||
eventPublisher.publishEvent(recurringAppointmentEvent); | ||
log.info("Successfully published event with uuid : " + recurringAppointmentEvent.payloadId); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void before(Method method, Object[] objects, Object o) { | ||
if (adviceMethodNames.contains(method.getName())) { | ||
AppointmentRecurringPattern appointmentRecurringPattern = (AppointmentRecurringPattern) objects[0]; | ||
Map<String, Integer> appointmentInfo = new HashMap<>(1); | ||
appointmentInfo.put(RECURRING_APPOINTMENT_ID_KEY, appointmentRecurringPattern.getId()); | ||
threadLocal.set(appointmentInfo); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't be mixing event with the topic here.
if any mapping needs to be done regarding which topic it must be sent to, then the listener to the spring application event (e.g. bahmni events module) - should use some mapping to identify the topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binduak ^