Table of Contents |
---|
...
Capitation report starts periodically based on the value of configuration parameter CAPITATION_REPORT_SCHEDULE
Configuration
Parameter | Description | Value |
---|---|---|
CAPITATION_REPORT_SCHEDULE | (Cron Format) How often to run capitation report | `* 1 * * *` for prod
|
CAPITATION_REPORT_VALIDATE_SIGNATURE | true |
Specification
Prepare dataset
...
Info | ||||
---|---|---|---|---|
| ||||
Report execution date is June 5, 2018 So the billing date should be June 1, 2018 |
2. Generate report_id
Report_id - unique report identifier generated for each report execution
3. Find active contracts
Active contract - contract that meets the following conditions:
Attribute | Condition |
---|---|
contract.start_date | < billing_date |
contract.end_date | >= billing_date |
contract.status | in (ACTIVE) |
contract.type | in (capitation) |
34. Find active employees declared in Active contract's
...
Attribute | Condition |
---|---|
contract_employees.start_date | < billing_date |
contract_employees.end_date | >= billing_date |
45. Find active declarations signed with Active employee
Active Declarations - declaration that meets the following conditions and is signed with active employee
Attribute | Condition |
---|---|
declarations.employee_id | = contract_employees.employee_id |
declarations.division_id | = contract_employees.division_id |
declaration_status_hstr.status = active declaration_status_hstr.inserted_at | Declaration was active on billing_date |
56. Determine age_group for each declaration
There are following age groups right now:
Group | Condition |
---|---|
0 - 5 | EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 0 and |
5 | |
6 - 17 | EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 6 and 17 where persons.id = declarations.person_id |
18 - 39 | EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 18 and 39 where persons.id = declarations.person_id |
40 - 65 | EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 40 and 65 where persons.id = declarations.person_id |
65 + | EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) > 65 where persons.id = declarations.person_id |
67. (Optional) Validate signed content
In case of error during signed content 7validation - add record to capitation_report_errors
Attribute | Description |
---|---|
id | Unique record identifier |
capitation_report_id | Capitation report id generated on step 2 |
declaration_id | Declaration id that caused error during signed content validation |
action | Const: SIGNED_CONTENT_VALIDATION |
message | Error message |
inserted_at | Inserted at date time |
8. Aggregate and save data to DBSave data to DB
Create report record in capitation_reports. Result with zero values are also saved to report.
- For each contract in billing prepare temporary dataset with zero values for each key (age group | mountain group)
- Update this dataset with real number of declarations for each key
Attribute | Description |
---|---|
id | Generated on Step 2 report_id |
billing_date | Determined on Step 1 billing_date |
created_at | Created at date time |
Aggregate result data by:
- legal_entity_id
- capitation_contract_id
- mountain_group
- age_group
Attribute | Description |
---|---|
id | Unique record identifier |
capitation_report_id | Generated on Step 2 report_id |
legal_entity_id | contract.legal_entity_id |
capitation_contract_id | contract.id |
mountain_group | divisions.mountain_group where division.legal_entity_id = contract.legal_entity_id |
age_group | Determined on Step 6 age group |
declarations_count | Number of declaration grouped by legal_entity_id, capitation_contract_id, mountain_group, age_group |