Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

Capitation report starts periodically based on the value of configuration parameter CAPITATION_REPORT_SCHEDULE

Configuration

ParameterDescriptionValue
CAPITATION_REPORT_SCHEDULE(Cron Format) How often to run capitation report`* 1 * * *`
CAPITATION_REPORT_VALIDATE_SIGNATURE
true

Specification

Prepare dataset

...

Active Declarations - declaration that meets the following conditions and is signed with active employee

AttributeCondition
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

6. Determine age_group for each declaration

There are following age groups right now:

GroupCondition
0 - 5
EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 0 and 6
where persons.id = declarations.person_id
6 - 17EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 6 and 17
where persons.id = declarations.person_id
18 - 39EXTRACT(YEAR FROM AGE(now(), persons.birth_date)) between 18 and 39
where persons.id = declarations.person_id
40 - 65EXTRACT(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

7. (Optional) Validate signed content

In case of error during signed content validation - add record to capitation_report_errors

AttributeDescription
idUnique record identifier
capitation_report_idCapitation report id generated on step 2
declaration_idDeclaration id that caused error during signed content validation
actionConst: SIGNED_CONTENT_VALIDATION
messageError message
inserted_atInserted at date time

8. Aggregate and save data to DB

Create report record in capitation_reports

AttributeDescription
idGenerated on Step 2 report_id
billing_dateDetermined on Step 1 billing_date
created_atCreated at date time

Aggregate result data by: 

  • legal_entity_id
  • capitation_contract_id
  • mountain_group
  • age_group
AttributeDescription
idUnique record identifier
capitation_report_idGenerated on Step 2 report_id
legal_entity_idcontract.legal_entity_id
capitation_contract_idcontract.id
mountain_group

divisions.mountain_group

where division.legal_entity_id = contract.legal_entity_id

age_groupDetermined on Step 6 age group
declarations_countNumber of declaration grouped by legal_entity_id, capitation_contract_id, mountain_group, age_group