Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jonatan-leal/ia-proyecto-sustituto/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Patient model is a Pydantic BaseModel that defines the structure and validation rules for patient health data used in diabetes predictions.Schema Definition
The Patient model is defined inpatient.py and contains 8 required fields representing key health metrics.
Fields
gender
Patient’s genderAllowed values:
FemaleMaleOther
"Female"age
Patient’s age in yearsType: IntegerExample:
45Typical range: 0-120Clinical note: Diabetes risk generally increases with age, particularly after age 45.hypertension
Whether the patient has hypertension (high blood pressure)Allowed values:
0: No hypertension1: Has hypertension
0Clinical note: Hypertension and diabetes often co-occur. People with hypertension are at higher risk for developing diabetes.heart_disease
Whether the patient has heart diseaseAllowed values:
0: No heart disease1: Has heart disease
0Clinical note: Cardiovascular disease and diabetes share many risk factors. Having heart disease increases diabetes risk.smoking_history
Patient’s smoking historyAllowed values:
never: Never smokedformer: Former smoker (quit smoking)current: Current smokernot current: Not currently smoking (may have smoked in the past)ever: Has smoked at some pointNo Info: No information available
"never"Clinical note: Smoking increases the risk of type 2 diabetes by 30-40%.bmi
Body Mass Index (BMI) of the patientType: FloatExample:
27.5Calculation: weight (kg) / height (m)²BMI Categories:- Underweight: < 18.5
- Normal weight: 18.5 - 24.9
- Overweight: 25.0 - 29.9
- Obese: ≥ 30.0
HbA1c_level
Hemoglobin A1c level - a measure of average blood glucose levels over the past 2-3 monthsType: FloatExample:
5.7Unit: Percentage (%)Reference ranges:- Normal: < 5.7%
- Prediabetes: 5.7% - 6.4%
- Diabetes: ≥ 6.5%
blood_glucose_level
Blood glucose (sugar) levelType: IntegerExample:
140Unit: mg/dL (milligrams per deciliter)Fasting glucose ranges:- Normal: 70-100 mg/dL
- Prediabetes: 100-125 mg/dL
- Diabetes: ≥ 126 mg/dL
- Normal: < 140 mg/dL
- Prediabetes: 140-199 mg/dL
- Diabetes: ≥ 200 mg/dL
Complete Example
Here’s a complete Patient object with realistic values:Sample Patient Profiles
Low Risk Profile
Moderate Risk Profile
High Risk Profile
Validation
Pydantic automatically validates all fields when creating a Patient object:Type Validation
Required Field Validation
API Validation Response
When sending invalid data to the API, you’ll receive a 422 error:Best Practices
Use exact values for categorical fields
Use exact values for categorical fields
For
gender and smoking_history, use the exact string values specified (case-sensitive):✅ Correct: "Female"❌ Incorrect: "female", "FEMALE", "F"Ensure numeric fields have correct types
Ensure numeric fields have correct types
- Use integers (no decimals) for: age, hypertension, heart_disease, blood_glucose_level
- Use floats (can have decimals) for: bmi, HbA1c_level
"age": 45, "bmi": 27.5❌ Incorrect: "age": 45.0 (should be int), "bmi": "27.5" (should be number)Validate data before sending to API
Validate data before sending to API
Implement client-side validation to catch errors before making API calls:
Use realistic medical values
Use realistic medical values
Ensure values are within realistic medical ranges:
- Age: 0-120 years
- BMI: 10-80 (typical range)
- HbA1c: 3.0-15.0% (typical range)
- Blood glucose: 20-600 mg/dL (typical range)
Common Validation Errors
One or more required fields are missing from the request.Solution: Include all 8 required fields in your request.
A field that expects an integer received a different type.Solution: Ensure age, hypertension, heart_disease, and blood_glucose_level are integers.
A field that expects a float received a different type.Solution: Ensure bmi and HbA1c_level are numeric (can be int or float).
A field that expects a string received a different type.Solution: Ensure gender and smoking_history are strings.
Using the Patient Model
In Python Applications
In Web Applications
Related Resources
Make Predictions
Use the Patient model to make diabetes predictions
API Overview
Complete API documentation and examples