Digital Transformation: Claims Management System

In the traditional world, claims management often involves manual entry, paperwork, and slow processing times. With digital transformation, we can improve:

  • Claims submission via web forms.
  • Automatic database storage for claims data.
  • Status tracking for claims.
  • Notifications to clients when claims are updated.

Project Structure

sqlCopy code/claims-management-system
  |-- app.py
  |-- templates/
      |-- index.html
      |-- claim_status.html
      |-- claim_detail.html
  |-- static/
      |-- style.css
  |-- claims.db

Step 1: Set up Environment

Make sure to install Flask and SQLite (SQLite comes built-in with Python, but other DB systems can also be used). You can install Flask using pip:

bashCopy codepip install flask

Step 2: Create the Backend (Flask Application)

Create a file named app.py in your project directory. The backend will include routes to submit claims, view claim statuses, and see individual claim details.

app.py:

pythonCopy codefrom flask import Flask, render_template, request, redirect, url_for
import sqlite3

app = Flask(__name__)

# Initialize database connection
def init_db():
    conn = sqlite3.connect('claims.db')
    c = conn.cursor()
    c.execute('''CREATE TABLE IF NOT EXISTS claims 
                 (id INTEGER PRIMARY KEY, 
                  customer_name TEXT, 
                  claim_type TEXT, 
                  claim_amount REAL, 
                  status TEXT, 
                  description TEXT)''')
    conn.commit()
    conn.close()

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/submit_claim', methods=['POST'])
def submit_claim():
    customer_name = request.form['customer_name']
    claim_type = request.form['claim_type']
    claim_amount = float(request.form['claim_amount'])
    description = request.form['description']

    conn = sqlite3.connect('claims.db')
    c = conn.cursor()
    c.execute("INSERT INTO claims (customer_name, claim_type, claim_amount, status, description) VALUES (?, ?, ?, ?, ?)",
              (customer_name, claim_type, claim_amount, 'Pending', description))
    conn.commit()
    conn.close()

    return redirect(url_for('claim_status'))

@app.route('/claim_status')
def claim_status():
    conn = sqlite3.connect('claims.db')
    c = conn.cursor()
    c.execute("SELECT * FROM claims")
    claims = c.fetchall()
    conn.close()
    return render_template('claim_status.html', claims=claims)

@app.route('/claim_detail/<int:id>')
def claim_detail(id):
    conn = sqlite3.connect('claims.db')
    c = conn.cursor()
    c.execute("SELECT * FROM claims WHERE id=?", (id,))
    claim = c.fetchone()
    conn.close()
    return render_template('claim_detail.html', claim=claim)

if __name__ == '__main__':
    init_db()  # Initialize the database if it doesn't exist
    app.run(debug=True)

Explanation of Routes:

  • / (index route): This is the homepage where users can submit claims.
  • /submit_claim (POST method): This route processes the claim submission form and saves it into the database.
  • /claim_status: This route displays a list of all claims in the system, showing their current status.
  • /claim_detail/<id>: This route allows viewing the details of a specific claim, including the status and description.

Step 3: Create the Frontend (HTML Pages)

Now, let’s create the HTML templates for the user interface.

index.html (Submit Claim Form):

htmlCopy code<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Submit Claim</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        <h1>Submit a Claim</h1>
        <form action="/submit_claim" method="POST">
            <label for="customer_name">Name:</label>
            <input type="text" id="customer_name" name="customer_name" required>

            <label for="claim_type">Claim Type:</label>
            <input type="text" id="claim_type" name="claim_type" required>

            <label for="claim_amount">Claim Amount:</label>
            <input type="number" id="claim_amount" name="claim_amount" required>

            <label for="description">Description:</label>
            <textarea id="description" name="description" required></textarea>

            <button type="submit">Submit Claim</button>
        </form>
    </div>
</body>
</html>

claim_status.html (List All Claims):

htmlCopy code<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Claims Status</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        <h1>Claims Status</h1>
        <table>
            <tr>
                <th>ID</th>
                <th>Customer Name</th>
                <th>Claim Type</th>
                <th>Claim Amount</th>
                <th>Status</th>
                <th>Details</th>
            </tr>
            {% for claim in claims %}
            <tr>
                <td>{{ claim[0] }}</td>
                <td>{{ claim[1] }}</td>
                <td>{{ claim[2] }}</td>
                <td>{{ claim[3] }}</td>
                <td>{{ claim[4] }}</td>
                <td><a href="/claim_detail/{{ claim[0] }}">View Details</a></td>
            </tr>
            {% endfor %}
        </table>
    </div>
</body>
</html>

claim_detail.html (View Claim Details):

htmlCopy code<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Claim Details</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        <h1>Claim Details</h1>
        <p><strong>Customer Name:</strong> {{ claim[1] }}</p>
        <p><strong>Claim Type:</strong> {{ claim[2] }}</p>
        <p><strong>Claim Amount:</strong> ${{ claim[3] }}</p>
        <p><strong>Status:</strong> {{ claim[4] }}</p>
        <p><strong>Description:</strong> {{ claim[5] }}</p>
        <a href="/claim_status">Back to Claims List</a>
    </div>
</body>
</html>

Step 4: Add Styling (CSS)

style.css (Styling the Web Pages):

cssCopy codebody {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
}

.container {
    width: 70%;
    margin: auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 50px;
}

h1 {
    text-align: center;
}

form input, form textarea, form button {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background-color: #45a049;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table, th, td {
    border: 1px solid #ddd;
}

th, td {
    padding: 12px;
    text-align: left;
}

tr:nth-child(even) {
    background-color: #f2f2f2;
}

a {
    color: #4CAF50;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

Step 5: Run the Application

To run the application, use the following command:

bashCopy codepython app.py

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *