Mainframe modernization · Part 3

How coding agents turn mainframe facts into modernized code

By Ergane IO · · 4 min read

Moving the filing date on a Medicare home health test claim from June 6 to June 7 changed the late-filing penalty from $0 to $336.22. Both runs of the published CMS Java Pricer returned the same completion code. A coding agent could generate an implementation that passes a check on that code and still gets the payment wrong. CMS Home Health Java Pricer

Rebuilding the late-filing rule
  1. COBOL date and waiver checks
  2. Target rule
  3. Replay late and on-time notices

What the sixth day costs

In 2021, a home health agency submitted a request for anticipated payment. For the type of claim examined here, CMS allowed five calendar days from the start of the service period. Once the filing was late, the reduction counted the elapsed days back to the start of the period. For a period starting June 1, a June 7 receipt could cost six days of payment. CMS’s 2021 instructions, p. 3

Give the agent the original program and ask it to locate both the decision and the calculation. In the CMS 2021.3 mainframe release, paragraph 9100-LATE-SUB-PENALTY in hhcal213.txt checks for a positive payment for the home health resource group and a receipt date. It calls the calculation when more than five days have elapsed and the waiver field is N. Paragraph 9110-COMPUTE-LATE-SUB-PENALTY caps the count at 30, calculates the reduction separately for the group payment and any outlier payment, and rounds each to cents. The release notes specifically identify that 30-day cap as a change. CMS COBOL program and release notes, ZIP

Here is the call site in the COBOL. The waiver field will matter again when we test the Java interface.

IF WS-DAYS-DIFFERENCE > +5 AND H-HHA-OVERRIDE-IND = 'N'
   PERFORM 9110-COMPUTE-LATE-SUB-PENALTY
      THRU 9110-EXIT.

That gives an agent a small piece of target code to write. This Python version takes one payment component in decimal dollars after the caller has checked the waiver and the dates.

from decimal import Decimal, ROUND_HALF_UP

def component_penalty(amount, elapsed_days):
    if elapsed_days <= 5:
        return Decimal("0.00")
    chargeable_days = min(elapsed_days, 30)
    return (amount * chargeable_days / 30).quantize(
        Decimal("0.01"), rounding=ROUND_HALF_UP
    )

amount = Decimal("1681.11")
assert component_penalty(amount, 5) == Decimal("0.00")
assert component_penalty(amount, 6) == Decimal("336.22")

Give the workflow an independent answer

For the replay, we used the 1AA11 request in the linked case file. It has four covered nursing visits, a June 1 service start, a $1,681.11 group payment before the penalty, and zero outlier payment. We changed only claimData.noticeReceiptDate and claimData.lateFilingPenaltyWaiverIndicator, then sent each request to the CMS Java 2.6.0 executable. The amounts below are its outputs for the 2021 calculation. Requests, runner instructions and baseline response

Receipt date (2021) Waiver field Late-filing penalty Total payment
June 6 N $0.00 $1,681.11
June 7 N $336.22 $1,344.89
June 7 Y $0.00 $1,681.11
July 1 N $1,681.11 $0.00
July 2 N $1,681.11 $0.00

A repeatable workflow can retrieve the two COBOL paragraphs, run the cases against the CMS executable, and save its responses before the agent writes the replacement. Compare the fields lateSubmissionPenaltyAmount and totalPayment. The return code was 00 in every row, even when the entire payment disappeared. If a proposed patch charges $56.04 on June 7, the amount tells the reviewer exactly where to look. That is one day’s reduction on this claim. The five days determined when to start charging, then the program counted all six.

When the agent needs to investigate

We also sent the June 7 request with the waiver field omitted. Java accepted it and returned the same $336.22 penalty as an explicit N. The rule in LateSubmissionPenalty.shouldExecute calls this method in HhaPricerContext to find out whether a waiver was granted. CMS Java rule and context, ZIP

public boolean isLateFilingPenaltyWaiverIndicator() {
  return StringUtils.equals(
      getInput().getClaimData()
          .getLateFilingPenaltyWaiverIndicator(),
      "Y");
}

Only Y satisfies that comparison. The COBOL branch above requires an explicit N to apply the penalty, and its input layout lists Y and N as valid. The Java run establishes what its interface accepts. Whether the old claims system could send a blank is a question about the caller. CMS COBOL field definition and decision, ZIP

Have the agent trace where the old caller populated the field and look for a recorded input that exercised the blank case. If the team is designing a new interface, the owner can then decide whether omission should trigger a penalty, produce an error or be impossible. Keeping that decision beside the six replay cases gives the next engineer the reason for the code. Part 4 on dividing a rebuild into independently verifiable units.

← All parts in this series