CareShield Life 派款:Python 一條規則重現 CPF 表全部 111 個數值
CareShield Life payouts in Python: one rule reproduces all 111 cells of CPF's table
CareShield Life 計算器以一條 Python 規則重現 CPF 派款表全部 111 個數值,並以斷言核對 CPF 和 MOH 發佈的例子。派款按申領年份每年增加 2%,2026 至 2030 年每年增加 4%,只在最後按整數金額四捨五入;逐年取整會令 2023 年派款少算 S$1。CPF 派款表只列至 2030 年,計算器則按 MOH 假設把 4% 增幅延伸至其後年份。
CareShield Life is Singapore's long-term care insurance. If you become severely disabled (you can't do 3 of 6 daily activities, such as washing or dressing), it pays a monthly sum for as long as the disability lasts. For a claim made in 2026, that's S$689 a month.
CPF Board publishes the payouts as a PDF table: birth year down the side, the year you claim across the top. You could type it into a lookup and be done. But the table stops at 2030, and anyone who claims later needs a number too. So for our CareShield Life calculator I wrote the rule the table comes from. The build then asserts that the rule reproduces every cell, plus every worked example MOH and CPF publish, before it writes the data file.
This post covers the rule, the 111 checks, and the rounding mistake that gets three of them wrong.
The table
Here's CPF's table (updated 1 January 2026), simplified:
| Born | Claim in 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | 2027 | 2028 | 2029 | 2030 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1954 or earlier | n/a | 612 | 612 | 612 | 612 | 612 | 612 | 612 | 612 | 612 | 612 |
| 1955 | n/a | 612 | 624 | 624 | 624 | ... | 624 | ||||
| ... | |||||||||||
| 1962 | n/a | 612 | 624 | 637 | 649 | 662 | 689 | 717 | 745 | 775 | 775 |
| 1963 to 1979 | n/a | 612 | 624 | 637 | 649 | 662 | 689 | 717 | 745 | 775 | 806 |
| 1980 and later | 600 | 612 | 624 | 637 | 649 | 662 | 689 | 717 | 745 | 775 | 806 |
That's 11 rows by 11 years, less the 10 "n/a" cells: people born in 1979 or earlier could only join from 6 November 2021, so they have no 2020 claims. 111 cells.
The PDF draws the table with merged cells, so text extraction scrambles it: one row's figures land on another row's line. I typed it by hand. That's the other reason for a rule: a typo in a hand-typed table is invisible, but a typo that contradicts a rule fails the build.
The rule
From CPF and MOH's descriptions:
- S$600 a month for a claim in 2020.
- Up 2% a year to 2025, then up 4% a year from 2026 to 2030.
- Rounded to the dollar.
- The level is fixed in the year you claim or turn 67, whichever is first.
- Anyone born in 1954 or earlier gets S$612, whatever the year.
import math
def r0(v):
# half up to the dollar; Python's round() rounds half to even
return int(math.floor(v + 0.5 + 1e-9))
def level(year, g2=0.04):
v = 600.0
for yr in range(2021, year + 1):
v *= 1.02 if yr <= 2025 else (1 + g2)
return v
def payout(born, claim_year, g2=0.04):
if born <= 1954:
return 612
return r0(level(min(claim_year, born + 67), g2))
min(claim_year, born + 67) handles the age-67 freeze. Someone born in 1962 turns 67 in 2029, so a claim in 2030 still pays the 2029 level: S$775, not S$806. That diagonal is the staircase you can see in the table.
The 111 assertions
cpf_year = {2020: 600, 2021: 612, 2022: 624, 2023: 637, 2024: 649, 2025: 662,
2026: 689, 2027: 717, 2028: 745, 2029: 775, 2030: 806}
cpf_rows = {1955: 624, 1956: 637, 1957: 649, 1958: 662, # frozen at 67
1959: 689, 1960: 717, 1961: 745, 1962: 775}
n = 0
for y, v in cpf_year.items(): # 1980 and later: 11 cells
assert payout(1985, y) == v; n += 1
if y >= 2021: # 1963 to 1979: 10 cells
assert payout(1970, y) == v; n += 1
for b, v in cpf_rows.items(): # 1955 to 1962: 80 cells
for y in range(2021, 2031):
expected = v if y >= b + 67 else cpf_year[y]
assert payout(b, y) == expected, (b, y); n += 1
for y in range(2021, 2031): # 1954 or earlier: 10 cells
assert payout(1950, y) == 612; n += 1
assert n == 111
All 111 pass. Then the build checks CPF's two worked examples (born 1980: S$624 for a 2022 claim, S$689 for 2026), and the build stops if any of them fails.
The rounding mistake that breaks three cells
The obvious way to code "up 2% a year, rounded to the dollar" is to round each year and grow from the rounded figure:
v = 600
for yr in range(2021, 2031):
v = r0(v * (1.02 if yr <= 2025 else 1.04))
It looks fine for two years and then drifts:
| Claim year | Round each year | Round once (CPF) |
|---|---|---|
| 2022 | 624 | 624 |
| 2023 | 636 | 637 |
| 2024 | 649 | 649 |
| 2026 | 688 | 689 |
| 2027 | 716 | 717 |
| 2030 | 806 | 806 |
612 × 1.02 = 624.24, which rounds to 624. But CPF grows the unrounded level: 624.24 × 1.02 = 636.72, which rounds to 637. Growing the rounded 624 gives 636.48, which rounds to 636. A dollar a month, paid for years, to everyone who claims in 2023.
The 111 cells caught it. A spot check of 2021, 2022 and 2030 wouldn't have: all three agree.
(The same lesson came up in our CPF contribution rounding post: round once, at the end.)
Past 2030: test the projection too
CPF has only set payouts to 2030. For later claims, MOH's 2025 review assumes 4% a year continues, and it prints worked illustrations. The same function, run past 2030, has to match them:
assert payout(1990, 2045) == 1452 # MOH's Ms A, born 1990, claiming at 55
assert payout(1990, 2057) == 2324 # Ms A at 67
assert payout(1975, 2042) == 1290 # MOH's Mr B at 67
They match to the dollar. So does the old scheme MOH compares against (2% a year throughout: S$984, S$1,248 and S$928). On the page, a claim after 2030 shows the 2030 level first, then MOH's 4% assumption, labelled as an assumption the next review decides.
Premiums: assert the worked examples
Premiums are personal (they depend on gender, the age you joined and earlier cover), and CPF's own checker needs a Singpass login. So the calculator doesn't guess a base premium. You type it from your CPF notice, and the tool applies the subsidy and the participation incentive.
MOH prints two six-year examples of exactly that arithmetic, and the build reproduces every year of both:
# Mr B, 2025-2030: gross premium, transitional support, 20% subsidy, S$50 incentive
gross = [424, 559, 582, 605, 629, 654]
ts = [0, 89, 66, 43, 21, 0]
pay = [289, 326, 363, 400, 436, 473]
for g, t, p in zip(gross, ts, pay):
net = g - t
assert net - r0(net * 20 / 100) - 50 == p
One more assertion checks the policy's shape. MOH says the transitional support spreads the 2025-to-2030 rise evenly, so each year's net premium should sit on a straight line between the two ends. In both examples every year is within S$1 of that line.
When CPF updates the table
The checks only help if someone re-reads the source. The site keeps an update schedule, and one of its rows says: each January, re-read CPF's payout table, re-type it, and re-run the build. If CPF changes the rule (say, 4% becomes 3% from 2028), the re-typed cells disagree with the function and the build stops before a wrong number reaches the page.
That's the pattern I'd recommend for any government table you republish:
- Find the rule behind the table, and write it as a function.
- Assert the function against every cell, not a sample.
- Assert every worked example the agency prints, including projections.
- Book a date to re-read the source.
Try it
The CareShield Life page works out your payout by birth year and claim year, the total over a chosen number of years, your premium after subsidies, and how it compares with ElderShield. Every figure links to the CPF or MOH document it came from.
I'm Jeremiah Say, editor of Numbers.sg. AI assistants helped build the page and draft this post. CPF's table and MOH's examples were read on 20 November 2026.
來源:DEV Community · dev.to