File size: 1,617 Bytes
05cb41b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import requests
import json

# Target URL for your local running FastAPI instance
URL = "http://127.0.0.1:8000/api/claims/adjudicate"

# Pick one of the sample images available in your folder
IMAGE_FILE = "111.jpg"  # You can swap this with '111.jpg', '115.jpg', or 'handwriting.png'

def run_test():
    if not os.path.exists(IMAGE_FILE):
        print(f"❌ Error: Test image '{IMAGE_FILE}' not found in the root folder.")
        return

    print(f"🚀 Sending claim adjudication request for document: {IMAGE_FILE}...")
    
    # Form fields required by our FastAPI route
    form_data = {
        "member_id": "Sudhan P",
        "claim_amount": "4500.00",
        "cashless_request": "false",
        "hospital_name": "Apollo Hospital"
    }

    # Open and attach the document image
    with open(IMAGE_FILE, "rb") as f:
        files = {
            "document": (IMAGE_FILE, f, "image/jpeg")
        }
        
        try:
            # Fire the multi-part form POST request
            response = requests.post(URL, data=form_data, files=files)
            
            print(f"Status Code: {response.status_code}\n")
            if response.status_code == 200:
                print("✅ Adjudication Success Response:")
                print(json.dumps(response.json(), indent=2))
            else:
                print("❌ Server Error Response:")
                print(response.text)
                
        except requests.exceptions.ConnectionError:
            print("❌ Connection Error: Is your uvicorn server still running on port 8000?")

if __name__ == "__main__":
    run_test()