from simplex import (
CaremarkGlobalPaFormQuestions,
ClinicalAnswers,
FillPaResponse,
PatientInfo,
PrescriberInfo,
SimplexClient,
SimplexError,
)
client = SimplexClient()
PATIENT: PatientInfo = {
"first_name": "Jordan",
"last_name": "WHITAKER",
"dob": "1987-08-22",
"id": "PSHP8839241076",
"address": "4412 SE STEELE ST",
"city": "PORTLAND",
"state": "OR",
"zip": "97206",
"home_phone": "5035550142",
"gender": "F",
}
PRESCRIBER: PrescriberInfo = {
"first_name": "Evelyn",
"last_name": "Harper",
"npi": "1427389056",
"address": "2130 NW Lovejoy St, Suite 400",
"city": "Portland",
"state": "OR",
"zip": "97210",
"office_phone": "5035550318",
}
FORM_SPECIFIC_QUESTIONS: CaremarkGlobalPaFormQuestions = {
"prescription_date": "04/24/2026",
}
# Wrapped {answers, resolved} payload from the clinical-question UI.
# `answers` drives form-fill decisions; `resolved` is preserved for audit.
CLINICAL_ANSWERS: ClinicalAnswers = {
"answers": {
"indication_selector": "wm_adult_injection",
"wm_adult_injection_phase": "initiation",
"wm_adult_init_age_18_or_older": "18",
"wm_adult_init_diet_and_activity": "yes",
"wm_adult_init_6mo_wm_program": "yes",
"wm_adult_init_bmi_branch": "bmi_ge_30",
"wm_adult_init_bmi_value": "30",
},
"resolved": [
{
"question_id": "indication_selector",
"prompt": "Which indication is this prior authorization for?",
"answer_value": "wm_adult_injection",
"answer_label": "Weight management (Adult) — Wegovy Injection",
},
{
"question_id": "wm_adult_init_bmi_value",
"prompt": "What is the patient's baseline BMI (kg/m²)?",
"answer_value": "30",
"answer_label": "30 kg/m²",
},
],
}
# 1. Resolve drug_slug.
match = client.search_drugs("wegovy 2.4mg auto-injectors")["matches"][0]
# 2. Fill the PA.
try:
response: FillPaResponse = client.fill_pa(
bin="004336",
pcn="ADV",
state="OR",
member_id="PSHP8839241076",
drug_slug=match["slug"],
icd10_diagnosis="E66.9",
patient=PATIENT,
prescriber=PRESCRIBER,
form_specific_questions=FORM_SPECIFIC_QUESTIONS,
clinical_questions=CLINICAL_ANSWERS,
documents=["chart_notes.pdf"],
)
print(response["signed_url"])
except SimplexError as e:
print(f"error: {e}")