Repository: PolicyEngine/policyengine-us

Issue:
Replace is_aca_eshi_eligible with separate variables for has / offered ESI
Following https://github.com/PolicyEngine/policyengine-us/issues/5963 and outreach to API customers (since this will be backwards-incompatible) let's create variables for:
- has_esi
- offered_aca_disqualifying_esi

Then replace `is_aca_eshi_eligible` with these.

Discussion:

Solution patch:
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb2..a9ab30db09 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,4 @@
+- bump: minor
+  changes:
+    added:
+    - Populate is_aca_eshi_eligible formula from ASEC inputs.
diff --git a/policyengine_us/variables/gov/aca/__init__.py b/policyengine_us/variables/gov/aca/__init__.py
new file mode 100644
index 0000000000..664644e4d0
--- /dev/null
+++ b/policyengine_us/variables/gov/aca/__init__.py
@@ -0,0 +1 @@
+# ACA employer-sponsored-insurance (ESI) variables
diff --git a/policyengine_us/variables/gov/aca/eligibility/has_esi.py b/policyengine_us/variables/gov/aca/eligibility/has_esi.py
new file mode 100644
index 0000000000..77d070eb04
--- /dev/null
+++ b/policyengine_us/variables/gov/aca/eligibility/has_esi.py
@@ -0,0 +1,8 @@
+from policyengine_us.model_api import *
+
+
+class has_esi(Variable):
+    value_type = bool
+    entity = Person
+    label = "Person currently has ESI"
+    definition_period = YEAR
diff --git a/policyengine_us/variables/gov/aca/eligibility/is_aca_eshi_eligible.py b/policyengine_us/variables/gov/aca/eligibility/is_aca_eshi_eligible.py
index 0be0ff1ff0..e734365d34 100644
--- a/policyengine_us/variables/gov/aca/eligibility/is_aca_eshi_eligible.py
+++ b/policyengine_us/variables/gov/aca/eligibility/is_aca_eshi_eligible.py
@@ -6,7 +6,14 @@ class is_aca_eshi_eligible(Variable):
     entity = Person
     label = (
         "Person is eligible for employer-sponsored health insurance "
-        "under ACA rules"
+        "under ACA rules"  # if this is true, person is ineligible for ACA PTC
     )
     definition_period = YEAR
-    default_value = False
+
+    def formula(person, period, parameters):
+
+        has = person("has_esi", period)  # has ESI
+        offered = person(
+            "offered_aca_disqualifying_esi", period
+        )  # being offered disqualifying ESI
+        return has | offered
diff --git a/policyengine_us/variables/gov/aca/eligibility/offered_aca_disqualifying_esi.py b/policyengine_us/variables/gov/aca/eligibility/offered_aca_disqualifying_esi.py
new file mode 100644
index 0000000000..f3a2592553
--- /dev/null
+++ b/policyengine_us/variables/gov/aca/eligibility/offered_aca_disqualifying_esi.py
@@ -0,0 +1,8 @@
+from policyengine_us.model_api import *
+
+
+class offered_aca_disqualifying_esi(Variable):
+    value_type = bool
+    entity = Person
+    label = "Person is offered ACA disqualifying esi"
+    definition_period = YEAR


Test patch:
diff --git a/policyengine_us/tests/policy/baseline/gov/aca/eligibility/is_aca_eshi_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/aca/eligibility/is_aca_eshi_eligible.yaml
new file mode 100644
index 0000000000..dd25160011
--- /dev/null
+++ b/policyengine_us/tests/policy/baseline/gov/aca/eligibility/is_aca_eshi_eligible.yaml
@@ -0,0 +1,23 @@
+- name: is_aca_eshi_eligible unit test 1
+  period: 2025
+  input:
+    has_esi: true
+    offered_aca_disqualifying_esi: false
+  output:
+    is_aca_eshi_eligible: true
+
+- name: is_aca_eshi_eligible unit test 2
+  period: 2025
+  input:
+    has_esi: false
+    offered_aca_disqualifying_esi: false #no esi, can get aca
+  output:
+    is_aca_eshi_eligible: false
+
+- name: is_aca_eshi_eligible unit test 3
+  period: 2025
+  input:
+    has_esi: false
+    offered_aca_disqualifying_esi: false  # doesn’t matter
+  output:
+    is_aca_eshi_eligible: false