Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
84
tasks_gen/eval/G0130/spec.md
Normal file
84
tasks_gen/eval/G0130/spec.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# 1. Goal
|
||||
A pharmacy dispenses prescription items. Before the pharmacy dispenses a
|
||||
prescription, it validates the prescription. The validation raises a class-based
|
||||
exception with one reason and one message for each problem. The pharmacy program
|
||||
needs the validation class and the exception class.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}DRUG_MASTER is in package $TMP. It is active. It is the drug
|
||||
master data of the pharmacy. Do not change it.
|
||||
- Public type TY_DRUG_ID: character, length 10.
|
||||
- Public structure TY_DRUG with the components DRUG_ID (TY_DRUG_ID) and
|
||||
MAX_DAILY_DOSE (integer, milligram).
|
||||
- Public method GET_DRUG with the importing parameter IV_DRUG_ID (TY_DRUG_ID)
|
||||
and the returning parameter RS_DRUG (TY_DRUG). If the drug is not in the
|
||||
master data, RS_DRUG is initial.
|
||||
- The drug master data contains these drugs and maximum daily doses:
|
||||
PARA500 4000, IBU400 1200, AMOX500 1500, META50 200, SALB100 800.
|
||||
- A prescription has an issue date, a number of valid days and items. Each item
|
||||
has a drug, a quantity and a daily dose.
|
||||
|
||||
# 4. Contract
|
||||
## 4.1 Exception class {{P}}CX_PRESC_ERROR
|
||||
- Create the class in package $TMP.
|
||||
- The class inherits from CX_ROOT.
|
||||
- Public type TY_REASON: character, length 12.
|
||||
- Public constant structure C_REASON with the components EMPTY, EXPIRED,
|
||||
QUANTITY, UNKNOWN, DOSE and DUPLICATE. Each component has the type TY_REASON
|
||||
and the value of its own name.
|
||||
- Public constructor with the importing parameter IV_REASON (TY_REASON).
|
||||
- Public method GET_REASON with the returning parameter RV_REASON (TY_REASON).
|
||||
- Public method GET_MESSAGE_TEXT with the returning parameter RV_TEXT (string).
|
||||
GET_MESSAGE_TEXT returns the message of the reason:
|
||||
- EMPTY: The prescription has no items
|
||||
- EXPIRED: The prescription is expired
|
||||
- QUANTITY: The quantity is not positive
|
||||
- UNKNOWN: The drug is not in the drug master
|
||||
- DOSE: The daily dose is not allowed
|
||||
- DUPLICATE: The drug appears more than once
|
||||
|
||||
## 4.2 Check class {{P}}PRESCRIPTION_CHECK
|
||||
- Create the class in package $TMP.
|
||||
- The class is public and final. It has a public constructor without parameters.
|
||||
- Public type TY_DRUG_ID: character, length 10.
|
||||
- Public structure TY_ITEM with the components DRUG_ID (TY_DRUG_ID), QUANTITY
|
||||
(integer) and DAILY_DOSE (integer).
|
||||
- Public table type TT_ITEM: standard table of TY_ITEM with empty key.
|
||||
- Public method VALIDATE with these importing parameters:
|
||||
- IV_ISSUE_DATE (type d)
|
||||
- IV_VALID_DAYS (integer)
|
||||
- IV_AS_OF_DATE (type d)
|
||||
- IT_ITEM (TT_ITEM)
|
||||
and the addition RAISING {{P}}CX_PRESC_ERROR.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
VALIDATE applies the rules in this sequence. It raises {{P}}CX_PRESC_ERROR with
|
||||
the reason of the first rule that fails.
|
||||
1. If IT_ITEM is empty, the reason is EMPTY.
|
||||
2. If IV_AS_OF_DATE is later than IV_ISSUE_DATE plus IV_VALID_DAYS days, the
|
||||
reason is EXPIRED.
|
||||
3. Process the items in the sequence of the table. For each item:
|
||||
3.1 If QUANTITY is less than 1, the reason is QUANTITY.
|
||||
3.2 If DRUG_ID is not in the drug master data, the reason is UNKNOWN.
|
||||
3.3 If DAILY_DOSE is less than 1, or if DAILY_DOSE is greater than the
|
||||
maximum daily dose of the drug, the reason is DOSE.
|
||||
4. If one DRUG_ID occurs in more than one item, the reason is DUPLICATE.
|
||||
5. Else VALIDATE returns without an exception.
|
||||
The dates are always valid dates.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Package: $TMP. Do not use a transport request.
|
||||
- Coding standards: Clean ABAP. Methods below 40 statements. No global
|
||||
variables. Pass large parameters by reference. No comment that restates the
|
||||
code.
|
||||
- Out of scope: do not change {{P}}DRUG_MASTER.
|
||||
|
||||
# 7. Acceptance
|
||||
- Both classes are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for {{P}}PRESCRIPTION_CHECK.
|
||||
Reference in New Issue
Block a user