Using Large Language Models for Generating Smart Contracts for Health Insurance from Textual Policies

Inwon Kang, William Van Woensel, Oshani SeneviratnearXiv 2024

Here is a concise, engaging summary of the research paper.

TL;DR

This paper investigates whether Large Language Models (LLMs) can automate health insurance claims by translating dense, natural-language policies into blockchain-based smart contracts and declarative decision logic. While LLMs excel at summarizing policies and generating basic code, the study reveals critical vulnerabilities in conceptual modeling and handling complex logic, underscoring that human oversight remains essential.

What Problem Does This Paper Address?

Health insurance processing is notoriously manual, labor-intensive, and error-prone, often requiring human operators to cross-reference dense "legalese" policies against patient records. Automating this via blockchain-based smart contracts offers a compelling solution—providing immutability, transparency, and a trustless environment for patients, providers, and insurers.

However, bridging the gap between natural language policies (like Medicare guidelines) and executable code requires specialized domain and technical expertise that software developers rarely possess. The authors explore whether LLMs can bridge this gap by automatically translating textual policies into structured summaries, formal decision logic, and smart contracts.

Methods

The authors designed a multi-step prompt engineering workflow to evaluate LLMs across four distinct tasks with increasing technical detail:

  1. Structured Text Summarization: Condensing natural text into a clear, numbered list of decision criteria.
  2. Extracting High-Level Decision Logic: Translating text into formal declarative languages, specifically Notation3 (N3, a domain-agnostic rule language) and Clinical Quality Language (CQL, a healthcare-specific standard).
  3. Generating Unit Tests: Creating tests using the Remix IDE plugin format to validate contract behavior.
  4. Generating Smart Contract Code: Producing executable Solidity code for deployment on Ethereum-compatible blockchains.

They evaluated five models (GPT-3.5 Turbo, GPT-3.5 Turbo 16K, GPT-4, GPT-4 Turbo, and CodeLLaMA-instruct-34B) using zero/near-zero temperature settings to ensure reproducibility.

Datasets

The evaluation uses three real-world health insurance scenarios extracted and paraphrased from the official Medicare benefits booklet, selected for their increasing levels of logical complexity:

  • Scenario 1 (Moderate): Coverage criteria for injectable osteoporosis drugs.
  • Scenario 2 (Moderate): Coverage for home-based Intravenous Immune Globulin (IVIG).
  • Scenario 3 (High): Highly complex rules governing transplant drug therapy, involving Medicare Parts A, B, and D, specific timelines (36-month limits), and special immunosuppressive benefits.

Key Insights and Ideas

  • The Training Data Popularity Trap: LLMs performed significantly worse on CQL syntax than N3 or Solidity. Even though CQL is an international healthcare standard, its scarcity on the open web (e.g., GitHub) leads to severe syntax errors, highlighting that domain-specific formalisms need better representation in LLM training data.
  • The "Fan Trap" Vulnerability: LLMs frequently violate basic conceptual modeling principles. For example, a model might correctly identify that a patient has a fracture and that a doctor treats osteoporosis, but fail to explicitly link the fracture to the osteoporosis, creating logical gaps that would cause false positives or negatives in real-world deployments.
  • Complexity Overload: When faced with long, intricate policies (Scenario 3), LLMs tend to group unrelated conditions together or hallucinate non-existent terms (like fake SNOMED codes or co-insurance clauses) to cope with the cognitive load.

Key Results

The authors evaluated the outputs based on completeness, soundness, clarity, syntax, and functionality:

  • Task 1 (Summaries): Highly successful. GPT-4 variants generated complete, sound, and exceptionally clear summaries, even automatically creating helpful sub-lists not requested in the prompt.
  • Tasks 2 & 4 (Logic & Code): For simpler scenarios (1 & 2), GPT-4 Turbo generated syntactically correct and functioning N3 and Solidity code, though minor conceptual modeling issues remained. For Scenario 3, it failed completely to generate valid N3 rules and missed critical conditions in Solidity.
  • Task 3 (Unit Tests): LLMs successfully generated runnable tests for explicit "if-then" conditions but consistently overlooked implicit failure cases (e.g., failing to test what happens if a patient doesn't have a required diagnosis).

Limitations and Future Work

The authors note that LLMs struggle with complex, multi-layered logic, frequently hallucinate when overwhelmed, and lack an inherent understanding of conceptual modeling principles.

To address these limitations, future work will focus on:

  • Exploring multi-prompt pipelines, such as Chain-of-Thought reasoning, rather than single-shot prompts.
  • Fine-tuning LLMs on specific coding styles, industry standards, and conceptual modeling guidelines.
  • Integrating advanced language techniques like multi-hop reasoning and knowledge graphs to better capture intricate healthcare logic.

Summary updated

Abstract

We explore using Large Language Models (LLMs) to generate application code that automates health insurance processes from text-based policies. We target blockchain-based smart contracts as they offer immutability, verifiability, scalability, and a trustless setting: any number of parties can use the smart contracts, and they need not have previously established trust relationships with each other. Our methodology generates outputs at increasing levels of technical detail: (1) textual summaries, (2) declarative decision logic, and (3) smart contract code with unit tests. We ascertain LLMs are good at the task (1), and the structured output is useful to validate tasks (2) and (3). Declarative languages (task 2) are often used to formalize healthcare policies, but their execution on blockchain is non-trivial. Hence, task (3) attempts to directly automate the process using smart contracts. To assess the LLM output, we propose completeness, soundness, clarity, syntax, and functioning code as metrics. Our evaluation employs three health insurance policies (scenarios) with increasing difficulty from Medicare's official booklet. Our evaluation uses GPT-3.5 Turbo, GPT-3.5 Turbo 16K, GPT-4, GPT-4 Turbo and CodeLLaMA. Our findings confirm that LLMs perform quite well in generating textual summaries. Although outputs from tasks (2)-(3) are useful starting points, they require human oversight: in multiple cases, even "runnable" code will not yield sound results; the popularity of the target language affects the output quality; and more complex scenarios still seem a bridge too far. Nevertheless, our experiments demonstrate the promise of LLMs for translating textual process descriptions into smart contracts.
BibTeX
@misc{kang2024using,
  author = {Inwon Kang and William Van Woensel and Oshani Seneviratne},
  title = {{Using Large Language Models for Generating Smart Contracts for Health Insurance from Textual Policies}},
  year = {2024},
  eprint = {2407.07019},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.07019},
}
Figure