Case Study: How EBH uses Kafka to manage Lab Booking Journey

Bajaj Finserv Health Limited (BFHL), a distinguished member of the Bajaj Group, extends a range of healthcare services encompassing Doctor’s Appointments, Wellness Programs, Health Articles, and Lab Bookings.

Aatif Bandey
Engineering at Bajaj Health

--

In the dynamic landscape of healthcare, the advent of digital platforms has transformed the way individuals access medical services. Lab bookings, a critical aspect of preventive healthcare, have also undergone a significant evolution.

Through the BFHL app, you can seamlessly schedule Lab tests by leveraging our Labs platform.
Visit this link to conveniently book Lab tests for yourself and your family.

Moving on, Lab bookings involve a complex ecosystem, with multiple stakeholders, events, and states. BFHL has developed a robust platform that seamlessly connects users, labs, and healthcare providers, ensuring a hassle-free experience. We are partnered with India’s largest labs Thyrocare, Redcliffe, Metropolis, and many more.

Understanding the Lab Booking Ecosystem

The Lab Booking journey stands as a cornerstone of our platform, managing an impressive volume of 30,000+ bookings monthly.
Bajaj Health collaborates with a diverse array of Lab Partners, categorized into Online and Offline Providers.
The fundamental Lab Journey unfolds as follows

The aforementioned four processes are inherently complex, intricately interlinked with various third-party systems. Let’s delve into each of these processes and highlight the key actors involved.

Catalogue Manage System:

At the heart of the lab booking journey is an extensive catalogue management system. Our app maintains an internal Lab Catalogue Management System, offering a comprehensive list of tests and packages with pricing details. Users can effortlessly browse and book lab tests from our partner labs

Order States and Events:

Post-payment completion, lab orders transition through various states. These states, such as ‘Appointment Booked,’ ‘Phlebo Assigned,’ and ‘Report Generated,’ are events triggered by our provider partners’ APIs. Each provider may have a unique set of states, and our app efficiently manages this diversity.

Role of Kafka in Lab Bookings:

After payment confirmation, we send the order to the provider for fulfillment. However, lab booking is more complex than a typical e-commerce order. To manage the various order events from the provider, we utilize the Kafka system.

The backbone of our lab booking system is Kafka, a powerful queue management system. When an order is confirmed, Kafka ensures seamless communication between our platform and provider APIs. It plays a pivotal role in handling real-time data, facilitating smooth transitions between order states

Phlebotomist Assignment and Customer Communication

When an order is entered into our eco-system and payment is received from the customer, we receive an event from the provider called ‘provider order success,’ indicating that the provider is ready to fulfill our order.

After some time, we receive a new state from the provider, ‘Phlebo Assigned,’ for lab bookings that involve home collection.

Phlebo Assigned: a phlebotomist is assigned to visit the customer’s place and collect a blood sample.

After the phlebotomist is assigned, our platform takes the initiative to keep the customer informed about the order status. This involves notifying them that a phlebotomist is scheduled to visit their home at a specified time and date.

It’s important to note that we receive various asynchronous events from the providers’ end, and to seamlessly process these events, we leverage Kafka, a efficient messaging system.
This ensures that our customers stay well-informed about the progress of their lab booking in real-time, contributing to an enhanced and transparent user experience, let’s delve into the engineering behind managing these states with a flow diagram:

As illustrated in the aforementioned flow diagram, our system initiates the transmission of messages to Azure Service Bus following provider order success events.
Simultaneously, Azure Service Bus is configured to dispatch these messages to Kafka, specifying a designated partition. Upon receipt, Kafka interprets and processes the messages, executing various operations to update the order status. Let’s delve into the intricacies of an example scenario for a comprehensive understanding

The Dance of Messages

Explore how messages, representing different order states, move between Azure Service Bus and Kafka. This dance of messages ensures that the order status is consistently updated based on the latest information from the lab service provider.

Consider a scenario where a customer initiates an order at 09:00 AM. After a lapse of 2 hours, a message is dispatched to Azure Service Bus. This message follows a publish-subscribe model, where Azure Service Bus actively listens for specific events related to the order, such as order success. Concurrently, the same message is transmitted to Kafka for processing.

In the Kafka partition, the incoming message triggers a call to the provider’s API to retrieve the latest order status. For instance, if the current status is “Provider Order Success” and the API indicates a transition to the “Phlebo-Assigned” state, we promptly update the order status in our Labs database. This update is then reflected on our application.

After processing the message and updating the status, the information is pushed back to the Azure Service Bus. Subsequently, the same message re-enters the Kafka system after a 2-hour interval to fetch any new status updates from the provider’s end.
This iterative process continues until a final state is achieved, such as the generation of the user’s report or the order being moved to a “Cancelled” state.
This back-and-forth communication ensures that our platform stays synchronized with real-time events and maintains accurate order statuses for a seamless user experience

Conclusion:

By adopting Kafka and Azure Service Bus in the lab booking journey, our healthcare platform can enhance the reliability, efficiency, and real-time nature of the services. The seamless integration of these technologies empowers providers to deliver a superior experience to users, ensuring that their lab bookings are processed accurately and efficiently.

As we conclude this case study, I want to express my appreciation to my dedicated team members who crafted this architecture, Shubham Jhangir and Kajal Rana. Their tireless efforts and commitment were instrumental in implementing this robust design pattern

If you enjoyed this case-study, don’t forget to follow me on Twitter and subscribe here for more captivating articles.
Show your appreciation with a round of applause 👏 👏 before you leave

--

--