78 lines
3.6 KiB
Markdown
78 lines
3.6 KiB
Markdown
# 1. Goal
|
|
A home care service plans the visits of its carers. Before the dispatcher
|
|
confirms a visit, the system must check the visit. The check raises a
|
|
class-based exception. The exception gives one reason code for each rule that
|
|
fails.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- All objects are in package $TMP.
|
|
- The interface {{P}}IF_CARE_REASON exists in package $TMP. It is active. It has
|
|
the type TY_REASON (type C, length 20) and the constant structure C_REASON.
|
|
Each component of C_REASON has the type TY_REASON and a value that is equal to
|
|
its name: NO_VISIT_ID, NO_CLIENT, NO_CARER, OUTSIDE_HOURS, BAD_DURATION,
|
|
TOO_LONG, CARER_OVERLAP, CLIENT_OVERLAP.
|
|
- The exception class {{P}}CX_CARE_VISIT exists in package $TMP. It is active.
|
|
It inherits from CX_STATIC_CHECK. It has the public read-only attribute
|
|
MV_REASON (type C, length 20) and the public read-only attribute MV_VISIT_ID
|
|
(type STRING). Its public constructor has the importing parameters IV_REASON
|
|
(type C, length 20) and IV_VISIT_ID (type STRING).
|
|
- A visit has a visit ID, a client ID, a carer ID, a start hour and an end hour.
|
|
The hours are whole numbers from 0 to 23.
|
|
- The dispatcher calls the check for one planned visit. The dispatcher also
|
|
passes the visits that are already planned for the same day.
|
|
- Other programs call the check and catch the exception. They show the reason
|
|
and the visit ID to the dispatcher.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CARE_VISIT_CHECKER in package $TMP.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- Public type TY_VISIT: a structure with these components:
|
|
VISIT_ID (type STRING), CLIENT_ID (type STRING), CARER_ID (type STRING),
|
|
START_HOUR (type I), END_HOUR (type I).
|
|
- Public type TT_VISIT: a standard table of TY_VISIT with an empty key.
|
|
- Public method CHECK_VISIT:
|
|
IMPORTING is_visit TYPE ty_visit
|
|
it_plan TYPE tt_visit
|
|
RAISING {{P}}cx_care_visit.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
CHECK_VISIT applies the rules below in this sequence. The first rule that fails
|
|
raises the exception {{P}}CX_CARE_VISIT with the reason of that rule and with the
|
|
visit ID of the checked visit. If no rule fails, the method returns without an
|
|
exception.
|
|
|
|
1. VISIT_ID must not be empty. Else the reason is NO_VISIT_ID.
|
|
2. CLIENT_ID must not be empty. Else the reason is NO_CLIENT.
|
|
3. CARER_ID must not be empty. Else the reason is NO_CARER.
|
|
4. START_HOUR must be 7 or more. END_HOUR must be 20 or less. Else the reason
|
|
is OUTSIDE_HOURS.
|
|
5. END_HOUR must be greater than START_HOUR. Else the reason is BAD_DURATION.
|
|
6. END_HOUR minus START_HOUR must be 4 or less. Else the reason is TOO_LONG.
|
|
7. The visit must not overlap a visit of IT_PLAN with the same CARER_ID. Else
|
|
the reason is CARER_OVERLAP.
|
|
8. The visit must not overlap a visit of IT_PLAN with the same CLIENT_ID. Else
|
|
the reason is CLIENT_OVERLAP.
|
|
|
|
Two visits overlap when the start hour of the first visit is less than the end
|
|
hour of the second visit and the start hour of the second visit is less than the
|
|
end hour of the first visit. A visit that starts at the hour when another visit
|
|
ends does not overlap that visit.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816.
|
|
- Coding standards: Clean ABAP. Methods below 40 statements. No global
|
|
variables. No comment that restates the code. Use the reason codes of
|
|
{{P}}IF_CARE_REASON.
|
|
- Out of scope: do not change {{P}}IF_CARE_REASON or {{P}}CX_CARE_VISIT. No
|
|
database table, no CDS view, no report, no function module, no object outside
|
|
package $TMP.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the checker class.
|