Amazon Pharmacy Improved Prescription Processing Time by 90% with Gen AI
Generative AI is becoming a central component of success in nearly every industry. We have the unique opportunity to see how different businesses within Amazon are using generative AI to create transformative customer experiences—with nearly 1,000 generative AI applications in motion inside Amazon.
This blog post is the first in a series that will explore how Amazon is innovating in various industries from healthcare to advertising, powered by Amazon Web Services (AWS) generative AI (gen AI), and the best practices and learnings we can unpack from the experience.
Generative AI at Amazon Pharmacy
Having spent over a decade working with AI, it’s clear to me that gen AI has the ability to speed up engineering and transform customer experiences. In my current role as Senior Principal Engineer at Amazon Pharmacy, it has been my team’s responsibility to facilitate a faster and smoother pharmacy experience for clinical teams and customers. To do so, we used AWS gen AI services to create a HIPAA-compliant digital platform. It can process high prescription intake volumes, at scale, while delivering an excellent customer experience surpassing that of an in-person pharmacy.
Accomplishing this required a fundamental change to not only the way we developed software, but also how we interacted and communicated with team members. In this blog, I’d like to discuss some of my learnings from this experience and give some advice for other engineers building healthcare platforms with gen AI.
Integrating gen AI into the customer journey
The journey of placing an order for a medication, interacting with the pharmacist, picking up the medication, and administering it is really an extension of the healthcare process. The customer is accustomed to communicating directly with a medical professional for highly personalized care. This ease of communication and personalization is one aspect that is difficult to transfer to a digital experience, particularly at scale.
So, building Amazon Pharmacy required creating a digital customer journey that would be on par with the in-store, human process. First and foremost, it was necessary for us to excel at data management, as using high quality data is fundamental to the success of gen AI and machine learning (ML). It was also important to remember that each pharmacy customer has their own set of protected identifiable information (PII). A patient health profile can include current conditions and allergies, prescription information, and related queries. As we were building Amazon Pharmacy, we knew that protecting our patients’ data would need to be a major priority. Using AI to automate the processing of information like this would make it possible to provide personalized communications to the customer, while minimizing risk to their data.
Today, gen AI and ML are embedded throughout the entire customer experience at Amazon Pharmacy. When a customer first enrolls, AI makes the often-cumbersome process of insurance capture and validation seamless. When their prescription is sent to the pharmacy, AI handles the typical bottleneck of prescription ingestion, transfer, OCR (optical character recognition), and document classification.
As the prescription is processed, AI speeds up data entry and validation while providing clear medication education to the customer. For order fulfillment, AI is used to sequence orders, optimizing techniques, and handle batching. In addition, AI is used to improve testing by facilitating real-world simulations.
Throughout this process, customers can ask any other questions using the Amazon Pharmacy chatbot, which is HIPAA compliant and supports personalized queries. Amazon Pharmacists, of course, oversee these interactions and are available for escalations as needed.
Integrating gen AI so completely into the customer journey provided the necessary speed-at-scale and bottleneck resolution without sacrificing the customer’s personalized experience. We believe this will apply to all digitized aspects of healthcare going forward, from digital pharmacies to online doctor’s appointments to lab processing.
Flexibility with tools and models is the key to speed
While we managed to keep the process simple and seamless for the customer, embedding gen AI into the software was complicated. Speed was a priority—adopting any new technology requires countless rounds of time-consuming testing.
The Amazon Pharmacy gen AI implementation started upstream, where prescriptions flow into the system. This was also the biggest bottleneck for incoming data during the lifecycle of a prescription order. Starting upstream gave the scientists and developers leverage to ensure that implementing and using AI for the remaining process would fall into a better, more natural flow. Then, one-by-one, gen AI and machine learning techniques were employed downstream at each piece of the customer’s journey, from prescription ingestion to processing to order fulfillment. One of the key ways of achieving this is to use a “bookshelf end” design, where the bookends are “data” and “test”; if you set up both of these well, then you can easily replace the software in the middle.
Throughout the development process, one of our most important learnings was to remain flexible around the tools and models we chose to use. We prioritized tools and services that we could implement quickly and continuously iterate with until we secured a great fit. For prescription ingestion and OCR, we started with existing AWS services. For prescription processing and validation, we needed named-entity recognition to be able to extract entities of the prescription such as the medicine name, cadence, and method of ingestion (oral, nasal, and so on).
To customize the technology as closely as possible to our needs, we developed custom models using Amazon SageMaker and Amazon SageMaker JumpStart. We then went on to onboard Amazon Bedrock. When dealing with new and rapidly evolving technology like gen AI, having the flexibility to choose and change tools, services, and models enables health tech engineers to customize, test, and upgrade quickly.
Gen AI is an extension of the engineering process
To integrate gen AI firmly into the customer journey and prescription lifecycle requires embedding it into the software development process as well. It’s important to approach it as an extension of the engineering process rather than create a separate, siloed process for gen AI functions. Silos not only make the engineering process difficult; they are also likely to affect the final customer journey. My advice is to invest in tools, services, and frameworks that allow your teams to improve data management and quality, model evaluation, and application testing.
Evaluating new technology quickly
Ten years ago, ML engineers would spend the first six months just training and evaluating a model to see if it was good enough. Now, with modern tools and foundation models, they can do that in just a day. There’s a lot of power in this ability to experiment quickly and move with the technology as it evolves, instead of catching up. Foundation models have really democratized AI. All developers can now be machine learning developers.
Prioritizing data management
The most challenging part of adapting the engineering process, while building Amazon Pharmacy, was figuring out how to access and process high-quality data. Gen AI requires significant customization, tailoring, and training to do its job well and does so by learning from massive amounts of data. Finding the correct data, and enough of it, needs to be incorporated into the software development process. Without data, the final product will simply not have the relevancy and accuracy required to deliver a bar raising customer experience.
Many engineers tend to focus on imperative code over data, but it should be the opposite for gen AI. While most engineering processes focus on managing code, the inclusion of gen AI requires being able to manage both code and data. Versioning code becomes versioning code and data. Verifying the quality of code now includes verifying the quality of data as well.
Services like AWS Glue and Amazon Redshift made this easier for us at first, but ultimately, we changed the engineering process entirely to refocus on data.
The importance of testing
As Amazon Pharmacy scaled, my team discovered that testing and data validation needed to be automated wherever possible. Testing is more complicated with gen AI, because answers are more complex and there can be multiple correct ones. Every time engineers receive more data, or context, they have an additional opportunity to improve their model. This refinement makes the extra time and effort worth it.
For organizations that require specialized knowledge in their data (like healthcare companies), it is also important to have experts who can help the system recalibrate and ensure data quality. Such companies must always have domain experts who validate that the data is following the correct patterns. For Amazon Pharmacy, we used in-house pharmacists to verify responses from AI.
People silos can be a major roadblock
Adopting gen AI requires a more integrated approach that brings together teams of people traditionally belonging to different parts of the company. With these diverse teams, challenges such as handovers and communication must be addressed. How do you coordinate handovers? How do you speak the same “language”? We learned quickly we needed to adapt to accelerate innovation and progress.
This involved clearer communication with explicit definitions of machine learning models, roles, and handoffs. While the larger group was originally siloed into a smaller “science team” and an “engineering team”, it now has a single team that we, at Amazon, call a two-pizza team. This is a single team that is self-sustainable but not too large. In short, just right for two pizzas. It brings together scientists, engineers, and business people to help understand problems and come up with solutions.
Success with gen AI
The process of integrating gen AI, like any other transformative technology is challenging and time-consuming, but also has significant benefits. For Amazon Pharmacy, the amount of time it takes to process prescriptions has improved by 90 percent. The development timeline has decreased from nine months to three. The most validating piece is that patients exhibit trust in the HIPAA compliant chatbot, which gives them the information they need in a fraction of the time that going to an in-person pharmacy would require. Using AI, we have been able to elevate the full Amazon Pharmacy customer experience.
From CEOs to their companies’ newest employees, everyone is aware of the scale of opportunity that gen AI offers. The main learning to take away from our experience adopting gen AI at Amazon Pharmacy is to recognize that it will fundamentally change the way software is built. Engineering teams will need to redesign their order of operations around data, experimenting, and testing. However, as seen from our results, this is a small hurdle for the doors that gen AI opens.
Learn how other industries are using gen AI to provide an excellent customer experience at scale and quickly.