Analysis & Recommendations
Overview of Analysis & Recommendations
The HCG AI application provides an automated medical risk assessment engine designed for the first trimester of pregnancy. By combining quantitative data from $\beta$-hCG blood tests and qualitative measurements from ultrasound scans, the system generates standardized diagnosis summaries, calculates Z-scores, and assigns a clinical risk level.
Clinical Risk Levels
The system categorizes all analysis results into three distinct risk tiers:
- LOW: Measurements are within expected physiological ranges for the reported gestational age.
- MEDIUM: Minor deviations detected or inconsistent data points that require closer monitoring.
- HIGH: Significant deviations from standard growth curves (e.g., abnormal HCG doubling times or discordant ultrasound measurements) that suggest a potential clinical complication.
Automated Analysis Types
1. HCG Trend Analysis
This module tracks the progression of $\beta$-hCG levels over time. Users can provide "Advanced Details" to increase the accuracy of the analysis.
- Standard Inputs: HCG value (mIU/mL) and test date.
- Advanced Inputs: Last Menstrual Period (LMP), average cycle length, and known ovulation dates.
- Output: The system calculates doubling times and compares results against standardized growth curves to generate a Z-Score.
2. Ultrasound Scan Analysis
This module interprets measurements from early pregnancy scans to determine if fetal development is synchronous with gestational age.
- Key Measurements:
- GS Size: Gestational Sac diameter (mm).
- YS Size: Yolk Sac diameter (mm).
- CRL: Crown-Rump Length (mm).
- Heart Rate: Fetal heart tones (BPM).
- Multiple Sac Support: The system allows for individual measurement entries for multiple gestational sacs (twins/triplets), storing this in a structured JSON format.
AI Chatbot Support
The application integrates with the OpenAI API to provide an interactive "AI Chat" tab. This feature allows users to:
- Ask clarifying questions about their analysis results.
- Understand medical terminology used in the recommendations.
- Receive general guidance on first-trimester symptoms.
Note: The AI Chatbot is an informational tool and does not replace professional medical consultation. It utilizes the
OPENAI_API_KEYconfigured in your.envfile.
API Reference: Analysis Results
If you are extending the application or querying the backend directly, the analysis data is managed via the following schema and endpoints.
Analysis Data Object
The analysis_results table stores the processed interpretation of user entries:
| Field | Type | Description |
| :--- | :--- | :--- |
| entryType | text | Either 'hcg' or 'ultrasound'. |
| diagnosis | text | A plain-language summary of the findings. |
| riskLevel | text | LOW, MEDIUM, or HIGH. |
| recommendations | jsonb | A list of suggested next steps (e.g., "Repeat HCG in 48 hours"). |
| zScores | jsonb | Statistical deviation markers for HCG values. |
Fetching Analysis
To retrieve the analysis for a specific user, the frontend interacts with the authenticated data routes:
// Example: Fetching the analysis for the current user
async function getAnalysis() {
const response = await fetch('/api/hcg-entries', {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
});
const data = await response.json();
// Results include associated analysisResults via the Drizzle ORM relations
console.log(data);
}
Usage Guidelines
- Toggle Advanced Details: For the most accurate risk assessment, users should enable the "Advanced Details" toggle in the UI and provide their LMP (Last Menstrual Period).
- Sequential Entries: Analysis is most effective when multiple HCG entries are recorded, allowing the system to calculate the rate of change (doubling time) rather than a single static value.
- Viewing Recommendations: Recommendations are displayed in the Analysis Tab immediately after data is synchronized with the PostgreSQL database.