diff --git a/bahmnicore-api/pom.xml b/bahmnicore-api/pom.xml
index 2b447e3a7e..4aaf0cf22a 100644
--- a/bahmnicore-api/pom.xml
+++ b/bahmnicore-api/pom.xml
@@ -83,6 +83,10 @@
joda-time
2.0
+
+ org.bahmni.module
+ communication-api
+
org.bahmni.module
bahmni-emr-api
diff --git a/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEvent.java b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEvent.java
new file mode 100644
index 0000000000..1681c1e017
--- /dev/null
+++ b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEvent.java
@@ -0,0 +1,26 @@
+package org.bahmni.module.bahmnicore.events;
+
+import org.openmrs.api.context.Context;
+import org.openmrs.api.context.UserContext;
+
+import java.time.LocalDateTime;
+import java.util.UUID;
+
+public class BahmniEvent {
+
+ private static final long version = 1L;
+ public UserContext userContext;
+ public String eventId;
+ public BahmniEventType eventType;
+ public String payloadId;
+ public LocalDateTime publishedDateTime;
+
+ public BahmniEvent(BahmniEventType bahmniEventType) {
+ this.eventType = bahmniEventType;
+ this.eventId = UUID.randomUUID().toString();
+ this.publishedDateTime = LocalDateTime.now();
+ this.userContext= Context.getUserContext();
+ this.payloadId="";
+ }
+}
+
diff --git a/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEventType.java b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEventType.java
new file mode 100644
index 0000000000..0f2dd642ce
--- /dev/null
+++ b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/BahmniEventType.java
@@ -0,0 +1,16 @@
+package org.bahmni.module.bahmnicore.events;
+
+public enum BahmniEventType {
+ BAHMNI_PATIENT_CREATED("bahmni-patient"),
+ BAHMNI_PATIENT_UPDATED("bahmni-patient"),
+ BAHMNI_ENCOUNTER_CREATED("bahmni-encounter"),
+ BAHMNI_ENCOUNTER_UPDATED("bahmni-encounter");
+
+ private final String topic;
+ BahmniEventType(String topic) {
+ this.topic = topic;
+ }
+ public String topic() {
+ return topic;
+ }
+}
\ No newline at end of file
diff --git a/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/EncounterEvent.java b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/EncounterEvent.java
new file mode 100644
index 0000000000..a3b0107902
--- /dev/null
+++ b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/EncounterEvent.java
@@ -0,0 +1,19 @@
+package org.bahmni.module.bahmnicore.events;
+
+import org.openmrs.Encounter;
+
+public class EncounterEvent extends BahmniEvent {
+
+ private Encounter encounter;
+
+ public EncounterEvent(BahmniEventType bahmniEventType, Encounter encounter) {
+ super(bahmniEventType);
+ this.encounter = encounter;
+ this.payloadId=encounter.getUuid();
+ }
+
+ public Encounter getEncounter() {
+ return encounter;
+ }
+}
+
diff --git a/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/PatientEvent.java b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/PatientEvent.java
new file mode 100644
index 0000000000..dba79af640
--- /dev/null
+++ b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/PatientEvent.java
@@ -0,0 +1,24 @@
+package org.bahmni.module.bahmnicore.events;
+
+import org.openmrs.Patient;
+import org.openmrs.api.context.Context;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.util.UUID;
+
+public class PatientEvent extends BahmniEvent {
+
+ private Patient patient;
+
+ public PatientEvent(BahmniEventType bahmniEventType, Patient patient) {
+ super(bahmniEventType);
+ this.patient = patient;
+ this.payloadId=patient.getUuid();
+ }
+
+ public Patient getPatient() {
+ return patient;
+ }
+}
+
diff --git a/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/advice/EncounterAdvice.java b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/advice/EncounterAdvice.java
new file mode 100644
index 0000000000..649a21f563
--- /dev/null
+++ b/bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/events/advice/EncounterAdvice.java
@@ -0,0 +1,61 @@
+package org.bahmni.module.bahmnicore.events.advice;
+
+import com.google.common.collect.Sets;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bahmni.module.bahmnicore.events.BahmniEventType;
+import org.bahmni.module.bahmnicore.events.EncounterEvent;
+import org.bahmni.module.bahmnicore.events.eventPublisher.BahmniEventPublisher;
+import org.openmrs.Encounter;
+import org.openmrs.api.context.Context;
+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.bahmni.module.bahmnicore.events.BahmniEventType.BAHMNI_ENCOUNTER_CREATED;
+import static org.bahmni.module.bahmnicore.events.BahmniEventType.BAHMNI_ENCOUNTER_UPDATED;
+
+
+public class EncounterAdvice implements AfterReturningAdvice, MethodBeforeAdvice {
+
+ private final Logger log = LogManager.getLogger(this.getClass());
+ private final BahmniEventPublisher eventPublisher;
+ private final ThreadLocal