Spaces:
Sleeping
Sleeping
| import time | |
| def simulate_claude_api_call(prompt): | |
| """Simulate a call to Anthropic's Claude API""" | |
| # In a real implementation, this would make an actual API call | |
| # For demo purposes, we'll return predefined responses based on the prompt | |
| # Mock waiting time for API call to seem realistic | |
| time.sleep(1.5) | |
| if "primary care" in prompt.lower() and "diabetes" in prompt.lower(): | |
| return """Based on the digital twin simulation for Primary Care Physicians treating diabetes: | |
| 1. 72% would prescribe XenoGlip as a second-line therapy after metformin failure for patients with an A1C between 7.5-8.5% | |
| 2. Key drivers include: perceived cardiovascular safety profile (83%), once-daily dosing (76%), and favorable formulary status (68%) | |
| 3. Main barriers to adoption are: concerns about pancreatitis risk (41%), patient cost concerns (37%), and preference for newer GLP-1 options (29%) | |
| 4. When comparing to competitors, physicians rate XenoGlip higher on "ease of use" and "patient adherence" but lower on "glycemic efficacy" and "weight management" | |
| This microsegment shows high receptivity to messages focused on cardiovascular outcomes data and patient support programs.""" | |
| elif "endocrinologist" in prompt.lower(): | |
| return """Based on the digital twin simulation for Endocrinologists: | |
| 1. Only 38% would prescribe XenoGlip as a second-line therapy, preferring GLP-1 agonists (47%) or SGLT2 inhibitors (15%) | |
| 2. Key considerations include: comprehensive glycemic control (91%), weight effects (87%), and cardiorenal protection (83%) | |
| 3. This segment is highly influenced by recent clinical trial data and guideline updates | |
| 4. They express specific concerns about XenoGlip's efficacy in patients with A1C >9.0% and its neutral effect on weight | |
| Messages emphasizing XenoGlip's role in a comprehensive treatment approach and compatibility with other agents would resonate better than positioning it as monotherapy.""" | |
| elif "messaging" in prompt.lower(): | |
| return """Based on digital twin simulations, the following messaging approaches would be most effective for XenoGlip: | |
| 1. For Primary Care: "XenoGlip provides reliable A1C reduction with once-daily dosing and proven cardiovascular safety" (estimated 76% receptivity) | |
| 2. For Endocrinologists: "XenoGlip offers flexible integration into treatment regimens with minimal drug-drug interactions and established safety profile" (estimated 64% receptivity) | |
| 3. For Cardiologists: "XenoGlip demonstrated no increased cardiovascular risk in patients with established heart disease, with neutral effects on weight and blood pressure" (estimated 71% receptivity) | |
| 4. Messaging around patient support programs shows 2.3x higher engagement across all specialties compared to clinical data messaging alone.""" | |
| elif "formulary" in prompt.lower() or "payer" in prompt.lower(): | |
| return """The digital twin simulation predicts the following impact of formulary changes for XenoGlip: | |
| 1. If moved from Tier 3 to Tier 2 status on major commercial plans: | |
| - 43% increase in new prescriptions among PCPs | |
| - 26% increase among endocrinologists | |
| - Overall market share would likely increase by 2.3 percentage points within 6 months | |
| 2. If prior authorization requirements were removed: | |
| - 38% of physicians who currently prescribe competitors would consider XenoGlip | |
| - Time to first prescription would decrease by approximately 22 days | |
| 3. The most impactful coverage improvement would be reducing patient out-of-pocket costs below $30/month, which would influence 79% of prescribers.""" | |
| elif "patient profile" in prompt.lower(): | |
| return """For the described patient profile (58-year-old male, A1C 8.2%, on metformin 1000mg BID, obese with hypertension): | |
| 1. 64% of PCPs would add XenoGlip | |
| 2. 22% would add a GLP-1 agonist | |
| 3. 14% would add an SGLT2 inhibitor | |
| Key factors influencing this decision include: | |
| - Patient's commercial insurance status and formulary positioning | |
| - Moderate A1C elevation (suggesting DPP-4 could be sufficient) | |
| - Presence of obesity (though many physicians still consider XenoGlip weight-neutral) | |
| - Comorbid hypertension (some physicians believe SGLT2s might offer better overall benefit) | |
| If the patient profile included CKD or established cardiovascular disease, XenoGlip selection would drop to approximately 31%.""" | |
| elif "sales" in prompt.lower() or "uptake" in prompt.lower(): | |
| return """The digital twin model predicts the following regarding XenoGlip uptake: | |
| 1. Near-term projection (6 months): | |
| - 11.2% growth in total prescriptions | |
| - Highest growth among PCPs practicing in group settings (17.4%) | |
| - Limited growth among specialists (5.1%) | |
| 2. Key drivers of adoption: | |
| - Recent label update regarding renal dosing (influencing 43% of providers) | |
| - New cardiovascular safety data (influencing 58% of providers) | |
| - Competitor supply constraints (temporary advantage) | |
| 3. Regional variations show strongest growth in the Midwest and Southeast regions, with more challenging uptake in the Northeast where formulary positions are less favorable. | |
| 4. The model forecasts peak market share of approximately 14.3% within the DPP-4 class, dependent on maintaining current access.""" | |
| elif "barriers" in prompt.lower(): | |
| return """The digital twin analysis identifies the following key barriers to XenoGlip adoption: | |
| 1. Perceived efficacy limitations: | |
| - 68% of non-prescribers cite concerns about efficacy relative to newer classes | |
| - This is particularly pronounced among physicians who see patients with higher baseline A1C values (>8.5%) | |
| - This perception persists despite head-to-head trials showing non-inferiority in certain patient populations | |
| 2. Formulary and access issues: | |
| - 72% indicate tier positioning as a significant barrier | |
| - Prior authorization requirements delay initiation by an average of 18.4 days | |
| - Patient abandonment rates of 31% when out-of-pocket costs exceed $50/month | |
| 3. Competition from newer therapeutic classes: | |
| - Growing preference for GLP-1s and SGLT2s due to extra-glycemic benefits | |
| - Decreasing comfort with initiating DPP-4 inhibitors in patients with cardiovascular disease | |
| - Perception gap between clinical trial results and real-world expectations | |
| 4. Knowledge gaps in specific areas: | |
| - 41% of physicians uncertain about long-term safety profile | |
| - 36% unfamiliar with newest data on cardiovascular outcomes | |
| - 28% unclear on appropriate patient selection criteria | |
| The simulation suggests that addressing the perception gap around efficacy and improving formulary positioning would have the greatest impact on adoption rates.""" | |
| elif "competitive" in prompt.lower(): | |
| return """Based on the digital twin simulations, XenoGlip's competitive positioning reveals: | |
| 1. Relative to other DPP-4 inhibitors: | |
| - Perceived as therapeutically similar by 76% of physicians | |
| - Differentiated primarily on formulary status rather than clinical attributes | |
| - Slight preference (53%) for XenoGlip among physicians who express a DPP-4 class preference | |
| 2. Compared to GLP-1 receptor agonists: | |
| - Positioned as less efficacious for A1C reduction (average perceived difference of 0.4-0.6%) | |
| - Significantly preferred for ease of administration (oral vs. injectable) | |
| - Viewed as more appropriate for earlier stage patients and the elderly | |
| - Cost advantage perceived by 82% of physicians, though this varies by plan | |
| 3. Against SGLT2 inhibitors: | |
| - Lower perception of cardiorenal benefit (cited by 89% of physicians) | |
| - Higher perceived safety in patients with renal impairment | |
| - Fewer concerns about genitourinary side effects (important for 64% of PCPs) | |
| - Similar formulary positioning in most regions | |
| 4. Across all diabetes treatments: | |
| - Ranked 4th in overall prescriber preference for second-line therapy | |
| - Highest ranked for "ease of initiation" and "minimal monitoring requirements" | |
| - Lowest ranked for "weight management" and "impact beyond glycemic control" | |
| The digital twin analysis suggests that XenoGlip could strengthen its competitive position by emphasizing its role in specific patient types (elderly, renally impaired) and by more effectively communicating recent data on cardiovascular safety.""" | |
| else: | |
| return """Based on the digital twin simulation for physicians regarding XenoGlip: | |
| The analysis indicates 68% of physicians in this microsegment would prescribe XenoGlip for appropriate patients with Type 2 Diabetes. Key decision factors include efficacy data (cited by 72%), tolerability profile (68%), and formulary status (84%). | |
| The simulation identified specific knowledge gaps around XenoGlip's cardiovascular safety data, with 37% of physicians uncertain about the CAROLINA trial results. | |
| For this microsegment, educational messaging focused on simplified patient selection criteria and step-by-step initiation protocols would likely increase confidence in prescribing by approximately 23%. | |
| When comparing promotional channels, virtual detailing with targeted clinical content shows 1.6x higher engagement than traditional sales visits for this specific physician group.""" | |
| def simulate_anthropic_api_call(model, prompt, max_tokens=1000): | |
| """ | |
| Simulate a call to Anthropic API with Claude | |
| In a real implementation, this would use: | |
| import anthropic | |
| client = anthropic.Client(api_key="your-api-key") | |
| response = client.completions.create( | |
| model=model, | |
| prompt=prompt, | |
| max_tokens_to_sample=max_tokens, | |
| ) | |
| return response.completion | |
| """ | |
| # Mock API call with delay for realism | |
| time.sleep(2) | |
| # For demo purposes, just delegate to our existing simulator | |
| return simulate_claude_api_call(prompt) | |
| def make_claude_api_call(prompt, model="claude-3-haiku-20240307"): | |
| """ | |
| Wrapper function for Claude API calls | |
| This function can be modified to use the real API in production | |
| or the simulator for the demo | |
| """ | |
| try: | |
| # For demo, use the simulator | |
| return simulate_anthropic_api_call(model, prompt) | |
| # For production with real API, uncomment the following: | |
| # import anthropic | |
| # import os | |
| # client = anthropic.Client(api_key=os.environ.get("ANTHROPIC_API_KEY")) | |
| # response = client.completions.create( | |
| # model=model, | |
| # prompt=prompt, | |
| # max_tokens_to_sample=1000, | |
| # ) | |
| # return response.completion | |
| except Exception as e: | |
| return f"Error calling Claude API: {str(e)}" |