Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public EncounterSaveAdvice() throws SQLException {

@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object emrEncounterService) throws Throwable {
if (method.getName().equals(SAVE_METHOD)) {
if (method.getName().equals(SAVE_METHOD) && isAtomFeedPublishEnabled()) {
Object encounterUuid = PropertyUtils.getProperty(returnValue, "encounterUuid");
String url = String.format(ENCOUNTER_REST_URL, encounterUuid);
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, url, CATEGORY);
Expand All @@ -65,6 +65,10 @@ public PropagationDefinition getTxPropagationDefinition() {
}
}

private boolean isAtomFeedPublishEnabled() {
return Boolean.parseBoolean(Context.getAdministrationService().getGlobalProperty("atomfeed.enable.publish"));
}

private static String getEncounterFeedUrl() {
return Context.getAdministrationService().getGlobalProperty("encounter.feed.publish.url");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public EncounterServiceSaveAdvice() throws SQLException {

@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object encounterService) throws Throwable {
if (method.getName().equals(SAVE_METHOD)) {
if (method.getName().equals(SAVE_METHOD) && isAtomFeedPublishEnabled()) {
Encounter encounter = (Encounter) args[0]; // Assuming encounter is the first argument
String encounterType = encounter.getEncounterType().getName(); // Assuming encounterType is a string
if (ENCOUNTER_TYPE_INVESTIGATION.equals(encounterType)) {
Expand All @@ -69,6 +69,10 @@ public PropagationDefinition getTxPropagationDefinition() {
}
}

private boolean isAtomFeedPublishEnabled() {
return Boolean.parseBoolean(Context.getAdministrationService().getGlobalProperty("atomfeed.enable.publish"));
}

private static String getEncounterFeedUrl() {
return Context.getAdministrationService().getGlobalProperty("encounter.feed.publish.url");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public PatientAdvice() throws SQLException {

@Override
public void afterReturning(Object returnValue, Method method, Object[] arguments, Object target) throws Throwable {
if (method.getName().equals(SAVE_PATIENT_METHOD)) {
if (method.getName().equals(SAVE_PATIENT_METHOD) && isAtomFeedPublishEnabled()) {
String contents = String.format(TEMPLATE, ((Patient) returnValue).getUuid());
final Event event = new Event(UUID.randomUUID().toString(), TITLE, LocalDateTime.now(), (URI) null, contents, CATEGORY);

Expand All @@ -56,6 +56,10 @@ public PropagationDefinition getTxPropagationDefinition() {
}
}

private boolean isAtomFeedPublishEnabled() {
return Boolean.parseBoolean(Context.getAdministrationService().getGlobalProperty("atomfeed.enable.publish"));
}

private PlatformTransactionManager getSpringPlatformTransactionManager() {
List<PlatformTransactionManager> platformTransactionManagers = Context.getRegisteredComponents(PlatformTransactionManager.class);
return platformTransactionManagers.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ private AtomFeedSpringTransactionManager getAFTxManager() {
}

private boolean shouldRaiseRelationshipEvent() {
String masterSwitch = Context.getAdministrationService().getGlobalProperty("atomfeed.enable.publish");
if (!Boolean.parseBoolean(masterSwitch)) return false;
String raiseEvent = Context.getAdministrationService().getGlobalProperty(RAISE_PATIENT_PROGRAM_EVENT_GLOBAL_PROPERTY);
return Boolean.valueOf(raiseEvent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public PropagationDefinition getTxPropagationDefinition() {
}

private boolean shouldRaiseRelationshipEvent() {
String masterSwitch = Context.getAdministrationService().getGlobalProperty("atomfeed.enable.publish");
if (!Boolean.parseBoolean(masterSwitch)) return false;
String raiseEvent = Context.getAdministrationService().getGlobalProperty(RAISE_RELATIONSHIP_EVENT_GLOBAL_PROPERTY);
return Boolean.valueOf(raiseEvent);
}
Expand Down
16 changes: 16 additions & 0 deletions openmrs-atomfeed-api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,20 @@
</insert>
</changeSet>


<changeSet id="atomfeed-master-publish-switch-20260327" author="Lingeswaran,aishwarya">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM global_property where property = 'atomfeed.enable.publish'
</sqlCheck>
</preConditions>
<comment>Adding master switch global property to enable or disable all atomfeed event publishing in atomfeed module</comment>
<insert tableName="global_property">
<column name="property" value="atomfeed.enable.publish"/>
<column name="property_value" value="false"/>
<column name="uuid" valueComputed="UUID()"/>
<column name="description" value="Master switch to enable or disable all atomfeed event publishing. Set to false to stop all events from being published."/>
</insert>
</changeSet>

</databaseChangeLog>