feat: add Demographics & Analytics tool to Fusion Claims Intelligence

- Add Tool 6 for demographic analysis using direct SQL queries
- Age group breakdowns: clients, applications, avg apps/client, avg funding
- Device popularity by age bracket (under 45, 45-60, 61-75, 75+)
- City demographics with average age and funding per city
- Benefit type analysis (ODSP, OWP, ACSD, Regular)
- Top devices with average client age
- Overall funding summary (totals, averages, age range)
- Update AI topic and system prompt with Tool 6 routing examples
This commit is contained in:
2026-03-10 02:45:51 +00:00
parent 0053576cc2
commit 8761d0e7c7
2 changed files with 245 additions and 3 deletions

View File

@@ -69,26 +69,45 @@ ai['result'] = record._fc_tool_adp_billing_period(period)
<field name="ai_tool_schema">{"type": "object", "properties": {"period": {"type": "string", "description": "Which period to query: 'current' (default), 'previous', 'next', or a specific date in YYYY-MM-DD format"}}, "required": []}</field>
</record>
<!-- Tool 6: Demographics & Analytics -->
<record id="ai_tool_demographics" model="ir.actions.server">
<field name="name">Fusion: Demographics &amp; Analytics</field>
<field name="state">code</field>
<field name="use_in_ai" eval="True"/>
<field name="model_id" ref="ai.model_ai_agent"/>
<field name="code">
ai['result'] = record._fc_tool_demographics(analysis_type, city_filter, sale_type_filter)
</field>
<field name="ai_tool_description">Run demographic and analytical queries on client data. Returns age group breakdowns, device popularity by age, city demographics with average age and funding, benefit type analysis, top devices with average client age, and overall funding summaries. Use for questions like "average applications by age group", "what devices do clients over 75 use", "demographics by city", "how old are our clients on average".</field>
<field name="ai_tool_schema">{"type": "object", "properties": {"analysis_type": {"type": "string", "description": "Type of analysis: 'full' (all reports), 'age_groups' (clients/apps by age), 'devices_by_age' (device popularity per age bracket), 'city_demographics' (per-city stats with avg age), 'benefits' (benefit type breakdown), 'top_devices' (most popular devices with avg client age), 'funding_summary' (overall totals and averages)"}, "city_filter": {"type": "string", "description": "Optional: filter city demographics to a specific city"}, "sale_type_filter": {"type": "string", "description": "Optional: filter by sale type (adp, odsp, wsib, etc.)"}}, "required": []}</field>
</record>
<!-- ================================================================= -->
<!-- AI TOPIC (references all tools) -->
<!-- ================================================================= -->
<record id="ai_topic_client_intelligence" model="ai.topic">
<field name="name">Fusion Claims Client Intelligence</field>
<field name="description">Query client profiles, ADP claims, funding history, billing periods, and device information.</field>
<field name="instructions">You help users find information about ADP clients, claims, medical conditions, devices, funding history, and billing periods. Use the Fusion tools to query data.
<field name="description">Query client profiles, ADP claims, funding history, billing periods, demographics, and device information.</field>
<field name="instructions">You help users find information about ADP clients, claims, medical conditions, devices, funding history, billing periods, and demographics. Use the Fusion tools to query data.
Common questions and which tool to use:
- "What is the status of [name]?" -> Use Client Status Lookup (Tool 4)
- "What is the ADP billing for this period?" -> Use ADP Billing Period (Tool 5)
- "Tell me about [name]'s funding history" -> Use Client Status Lookup first, then Client Details for more depth
- "How many claims do we have?" -> Use Claims Statistics (Tool 3)
- "Find clients in [city]" -> Use Search Client Profiles (Tool 1)</field>
- "Find clients in [city]" -> Use Search Client Profiles (Tool 1)
- "Average applications by age group" -> Use Demographics (Tool 6) with analysis_type="age_groups"
- "What devices do seniors use?" -> Use Demographics (Tool 6) with analysis_type="devices_by_age"
- "What is the average age of our clients?" -> Use Demographics (Tool 6) with analysis_type="funding_summary"
- "Show demographics for Brampton" -> Use Demographics (Tool 6) with analysis_type="city_demographics" and city_filter="Brampton"
- "How many ODSP clients do we have?" -> Use Demographics (Tool 6) with analysis_type="benefits"</field>
<field name="tool_ids" eval="[(6, 0, [
ref('fusion_claims.ai_tool_search_clients'),
ref('fusion_claims.ai_tool_client_details'),
ref('fusion_claims.ai_tool_client_stats'),
ref('fusion_claims.ai_tool_client_status'),
ref('fusion_claims.ai_tool_adp_billing'),
ref('fusion_claims.ai_tool_demographics'),
])]"/>
</record>
@@ -146,12 +165,17 @@ Capabilities:
3. Provide aggregated statistics about claims, funding types, and demographics
4. Look up a client's complete status by name -- including all orders, invoices, documents, and next steps
5. Query ADP billing period summaries -- total invoiced to ADP, paid vs unpaid, submission deadlines
6. Run demographic analytics -- age group breakdowns, device popularity by age, city demographics, benefit analysis, funding summaries
How to handle common requests:
- "What is the status of [name]?" -> Use the Client Status Lookup tool with the client's name
- "What is the ADP billing this period?" -> Use the ADP Billing Period tool with period="current"
- "What was the ADP billing last period?" -> Use the ADP Billing Period tool with period="previous"
- "Show me [name]'s funding history" -> Use Client Status Lookup, then Client Details for full history
- "Average applications by age group" -> Use Demographics tool with analysis_type="age_groups"
- "What devices do clients over 75 use?" -> Use Demographics tool with analysis_type="devices_by_age"
- "What is the average age of our clients?" -> Use Demographics tool with analysis_type="funding_summary"
- "Demographics for [city]" -> Use Demographics tool with city_filter
- If a client is not found by profile, the system also searches by contact/partner name
Response guidelines: