Skip to main content

Section 5-1 : Case Study openEMR

AI Case Study

This tutorial is based on case study, where AI data solution is used as in a real-world example of a customer using it.

Please review important aspects and key considerations on How To Use AI Data Solutions in previous chapter.

Healthcare App openEMR Case Study

Of: openEMR App for healthcare

Summary Highlights

The case study sought to leverage the power of AI models to unlock the full potential of openEMR health system data with EasyManage help.

Successfully achieved key objectives:

1.Get Data modeling suggestions from AI
2.Ask AI For Sensitive Data Analysis
3.Make openEMR data AI-Ready in 10 Min
4.Build, deploy and Customize MCP Server
5.AI Model Analysis performed on openEMR data
6.Ask AI What Insights and Trends Can Get
7.Ask AI What AI Workflows Can Implement

Brief Synopsis

Leverage opportunities for AI data solutions such as AI-driven insights & trends and AI workflow automation for healthcare App openEMR as demo installation.

Steps

Following steps were taken towards implementing solutions using EasyManage AI.

Import Tables And Download Schema

  • Import Tables

    • App Tables from MySQL/mariaDB cloud database imported into EasyManage.
  • Search tables, listed

import_tables_list.png

  • Tables Imported

import_tables_imported.png

  • Search metadata, search tables for field patient_id

metadata_srh_field.png

  • Download Table Schema from EasyManage.

table_schema_download.png

Get Data modeling suggestions from AI

  • Open Cursor and start new project workspace at e.g. C:\openEMR
  • Copy TableSchemaDnld_openEMR.sql to project root.
  • Using above table schema SQL file as context, Ask AI model
Give suggestions for data modeling i.e. table joins up to 4 nested levels, specify one-to-many or one-to-one
  • Context given

dm_suggest_give_context.png

  • Asked for data modeling suggestions

dm_suggest_chat_input.png

  • Response for data modeling suggestions

dm_suggest_response.png

Configure Data Modeling

  • Define and configure data modeling, table joins in EasyManage Builder Studio for

    • Medication and Prescription Data Model
      • Level 1: Patient Medications
      • patient_data | 1:M | prescriptions | 1:M | drugs
      • Refer to tutorial on Data Modeling
  • Data modeling configured for Patient Medications

    • patient_data ←→ prescriptions (via patient_id)
    • prescriptions ←→ drugs (via drug_id)
  • In this order: 1. prescriptions ←→ drugs

data_modeling_01.png

  • Then: 2. patient_data ←→ prescriptions

data_modeling_02.png

Ask AI For Sensitive Data Analysis

  • Giving as context TableSchemaDnld_openEMR.sql, Ask AI model
Study columns and mark columns , put comment on right side, for columns that come under Sensitive data, PII (Personally Identifiable Information), Confidential Business Information, Data revealing sensitive personal informatio

OR

Analyze the OpenEMR database schema to identify columns that contain sensitive data, PII, confidential business information, or data revealing sensitive personal information
  • Tip: For healthcare databases also check for PHI fields i.e. sensitive PHI identifiers under HIPAA.
  • Chat input

ask_sensitive_data_01.png

  • Chat Response Progress

ask_sensitive_data_02.png

NOTE: Using the 1st prompt, AI was not able to edit file, but decided to create a new file:

info
  • How to implement the sensitive data recommendations?
    • Before generating code, use EasyManage field hide option to exclude columns, having sensitive data, from API and MCP Layers, so that AI models will not have access to them. Use via menu links:
      • Data Table Explorer navigate to folder having table Select option on right side of table listed Field Prop - Hide Set for required columns Field Prompt Properties Hide [Yes] and Data Display Properties Hide [Yes]

EasyManage Builder Studio Project Configure Settings

proj_configure_settings_01.png

proj_configure_settings_02.png

MCP Server Module Bundling for V1

It is recommended to keep 5-10 tables in one MCP Server module. Along with data modeling of those tables.

  • Select 16 tables for AI solution module building.
  • Bookmarked tables for generating code
  • Build Selection

build_selected_tables.png

  • Build/Generate : Included will be MCP Server REST with APIs REST.
    • This will be version V1.

build_generate_code.png

  • Download generated code.

download_gen_code.png

  • Create Folder structure for easymanage and cursor workspace.

openEMR_workspace.png

  • Copy below projects from extracted code to workspace openEMR_workspace.

    • backend\spring-java\emapi
    • mcp\spring-java\emmcp
  • APIs REST : Open project, Build

emapi_proj_01.png

  • Run APIs - CMD Prompt
    • cd openEMR_workspace
    • java -jar emapi\app\dbrest\target\dbrest-1.0-SNAPSHOT.jar

emapi_run.png

  • Run APIs - Check Swagger Home

emapi_swagger_01.png

  • Run APIs - Check Swagger Data Modeling endpoint

emapi_swagger_02.png

  • MCP Server REST : Open project, Build

emmcp_proj_01.png

Use MCP Server V1

  • Configure and Use MCP Server V1 in Cursor.

  • Sample mcp.json

{
"mcpServers": {
"easymanage": {
"command": "C:/ProgFiles/Java/jdk-17/bin/java.exe",
"args":
["-jar",
"path_to_workspace/openEMR_workspace/emmcp/app/mcprest/target/mcprest-1.0-SNAPSHOT.jar"
],
"env": {
"em.mcp.apiUrl": "http://127.0.0.1:9080/emdbrest",
"em.mcp.authType": "None",
"em.mcp.authToken": ""
}
}
}
}

Exceeding Total Tools Limit

  • Warning is displayed as total tools 102 are exceeding 40.

emmcp_tools_exceed_issue.png

Try chat input:

easymanage get and study all table schema and suggest what insights and trends can be derived from tables
  • AI model sees no relevant tool call available and tries to suggest insights from static SQL file available in workspace:

  • Please see response doc:

  • Now delete TableSchemaDnld_openEMR.sql from project root

    • We want AI model to call tool get_all_table_schema once available later.

Customize MCP Server as V2

  • Customize MCP Server REST V1, disable some table level tools globally.

    • Please see section: How to Enable/Disable Tools in README-mcprest.md
  • Verify and Disable Tools as indicated below and try out.

    • Table Level - Disable
      • TOOL-ViewAll
      • TOOL-ViewAllPaged
    • Table Level - Keep
      • TOOL-SelectWhere
      • TOOL-Query
    • AI Transactions - Disable All
      • AI-TRAN-ADD
      • AI-TRAN-EDIT
      • AI-TRAN-DEL
    • Table Joins Data Modeling Level - Disable
      • TOOL-DM-ViewAll
      • TOOL-DM-ViewAllPaged
    • Table Joins Data Modeling Level - Keep
      • TOOL-DM-SelectWhere
      • TOOL-DM-Query
  • Disable Tools using VS Code

emmcp_tools_disable.png

  • Build/Generate MCP Server REST.
    • This will be version V2.
  • Configure MCP Server in Cursor.
    • Shows: Found 40 Tools

AI Model Analysis

Results from AI analysis is given in response docs below.

Presented below and listed are few analysis and solutions being recommended by AI models.

easymanage get and study all table schema and suggest what insights and trends can be derived from tables
  • Chat input

emmcp_tools_reduced_ask_insights.png

  • Chat Response Progress 1

emmcp_tools_got_match_01.png

  • Chat Response Progress 2

emmcp_tools_got_match_02.png

Please refer to response doc

Ask AI What AI Workflows Can Implement

easymanage get and study all table schema and suggest what AI workflows can be implemented based on tables
  • Chat input

emmcp_ask_workflows_01.png

  • Chat Response Progress 1

emmcp_ask_workflows_02.png

  • Chat Response Progress 2

emmcp_ask_workflows_03.png

  • Chat Response Progress 3

emmcp_ask_workflows_04.png

Please refer to response doc

Next Steps

After AI Transaction Tools enabled, can ask AI What AI Transactions Can Implement.

Enable AI Transaction Tools

  • Customize MCP Server REST V2 to build V3, where in enable AI transaction table level tools globally.
    • Please see section: How to Enable/Disable Tools in README-mcprest.md

Ask AI What AI Transactions Can Implement

easymanage get and study all table schema and suggest what AI transactions can be implemented