Case study

On-Premises Clinical Decision Support APIs for Insurance and Drug Checks

A health-technology company in Saudi Arabia needed its clinic software to check treatment plans against insurance rules and resolve drug brand names to scientific names, with the language models hosted on-premises so patient data stays inside its environment.
  • Client: A health-technology company in Saudi Arabia
  • Industry: Health & Fitness
  • AI capability: Generative AI & Intelligent Document Processing
Architecture diagram in four stages: inputs (treatment plans, policies, CHI formulary, SFDA GTIN, Nphies code sets), extraction (EasyOCR, Excel ingestion), AI and matching (on-premises LLM compliance check, fuzzy drug matching, Llama 3 SQL agent) and delivery (authenticated FastAPI endpoints)
AI modules built: insurance alignment and pharmacy benefit APIs
2
Endpoints in the pharmacy benefit API
4
Closest matches returned for a misspelled drug name
Top 5

The challenge

Insurance rules and drug naming checks, at the point of care

Doctors must write treatment plans that comply with each insurer's rules, which are mostly long if-then guidelines, and by law they must prescribe drugs by scientific name rather than brand. With thousands of drugs and many insurance plans, both checks are slow and error-prone at the point of care. The language models had to be hosted on-premises so patient data stays inside the client's environment, and the drug data had to stay in step with official Saudi sources: the CHI drug formulary, SFDA GTIN lists and Nphies code sets.

What we built

Two clinical APIs, with the models on the client's own servers

Patient data stays inside the client's environment.

  1. Stage 1

    Data assembly

    We compiled the CHI drug formulary, SFDA GTIN registry and Nphies codeable concepts, and profiled about 5,000 rows of the client's historical claims data.
  2. Stage 2

    Insurance alignment

    Treatment plans and policy documents are read with EasyOCR, and an on-premises LLM checks whether the plan complies with the selected insurance policy.
  3. Stage 3

    Drug lookup

    A drug index maps brand names, scientific names, GTINs and registration numbers to the full drug record, with fuzzy matching that returns the top five suggestions for misspelled names.
  4. Stage 4

    Drug Q&A agent

    A follow-on module lets staff ask questions about the formulary in plain English, using a local Llama 3 model with a SQL agent over the drug database.
  5. Stage 5

    API delivery

    Everything is exposed through authenticated FastAPI endpoints, including one that replaces the drug database from a new Excel upload.
  • The pharmacy benefit API's four endpoints, from authentication to drug lookup.

The impact

Compliance and drug checks behind a REST call

  • Insurance alignment API
  • Pharmacy benefit API with four endpoints
  • Five closest matches for a misspelled drug name

The insurance policy alignment API takes a treatment plan and an insurance policy and returns whether the plan is compliant. The pharmacy benefit API has four endpoints: authentication, database update from Excel, database export, and drug lookup and validation by brand name, scientific name, GTIN or registration number. Invalid or misspelled drug names return the five closest matches with a validation status, and a formulary Q&A module answers questions such as a drug's registration year from the CHI formulary.

Project showcase

More from the project

Discuss a similar project
  • Test interface for the drug index: a scientific-name search returns the matching formulary records.

Book a strategy session

Talk to an AI engineer about your project

Tell us what you want to automate. The first call is a 30-minute working session with an engineer, not a sales pitch.

  • Send the form, it takes 2 minutes
  • We reply within 1 business day, under NDA if you need it
  • A 30-minute call to scope feasibility and next steps

Tell us about your project

By submitting, you agree to our Privacy Policy. We never share your details.