Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Create Contract request - Release Candidate of Insulin reimbursement project _EN

Specification

Apiary

Table of Contents

Create Contract request - Release Candidate of Insulin reimbursement project _EN

Specification

Apiary

Purpose

This WS is designed to create contract request from Legal Entity side by Owner or Admin. Before the request is created the documents must have been uploaded. Then request can be approved or declined by NHS side.

...

  1. Validate contract_type

    1. legal entities with types in (MSP,PRIMARY_CARE) can create only capitation contracts, legal entities with types in (PHARMACY) can create only reimbursement contracts

      1. in case of error 409 - "Contract type "{contract_type}" is not allowed for legal_entity with type "{legal_entity_type}" "

  2. Validate previous_request_id 

    1. select id from contract_request where id=$.previous_request_id

      1. in case no data found return 422 ("previous_request does not exist")

    2. Check previous_request status not in ('SIGNED')

      1. in case error return 422 ('In case contract exists new contract request should be created')

    3. Check that contractor_legal_entity_id of previous request is equal to contractor_legal_entity_id of current request

      1. in case of error return 422 ('Previous request doesn't belong to legal entity')

    4. For reimbursement contracts: Check that medical_program_id id_form from $that id_form from $.previous_request_id equal to idto id_form from form from request

      1. in case of error return 422 ('Id_form from previous request is not equal to id_form from request')

  3. Validate contractor_divisions

    1. Check divisions belongs to legal_entity and divisions.status='active'

      1. in case of error return 422  error view $divisions ('Division must be active and within current legal_entity')

    2. Validate each division in array present exactly one time

      1. in case of error return 422  error view $divisions ('Division duplicates')

  4. Validate start_date

    1. validate that start_date in a date format (^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$)

      1. in case of error return 422 error $start_date ('"expected \"<start_date>" to be a valid ISO 8601 date"')

    2. the year in start_date must be equal to current or next year (current+1).

      1. in case of error return 422 error $start_date ('Start date must be within this or next year')

  5. Validate end_date (Note. These validations are applied for cases when the contract_number isn't passed in the request. If the contract_number is passed, validations from 10.g are applied)

    1. validate that end_date in a date format (^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$)

      1. in case of error return 422 error $end_date ('"expected \"<end_date>" to be a valid ISO 8601 date"')

    2. the year in $end_date can be next year after 'start_date' if the total period of the contract doesn't exceed 1 year.

    3. the $end_date must be greater or equal than the $start_date

      1. in case of error return 422 ('The end_date should be greater or equal than the start_date')

    4. the different between $end_date and $start_date should be no more than one year old (365 or 366 days)

      1. in case of error return 422 ('The difference between end_date and start_date is more than one year')

  6. Validate contractor_owner_id

    1. Check employees.employee_id=contractor_owner_id and client_id=employee.legal_entity_id and employee_type in('OWNER', 'ADMIN') and status='APPROVED' and is_active=true

      1. In case of error return 422 Error ('Contractor owner must be an active OWNER or ADMIN and within current legal entity in contract request')

  7. If in request was sent contract_number:

    Validate id_from is from dictionary CONTRACT_TYPE:
    1. check contract request number structure XXXX-1234-5678-C , where:

      1. XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X)

      2. 1234-5678 - randomly generated numbers and letters A, E, H, K, M, P, T, X.

    2. check there is a contract with such contract_number 

      1. in case of error return 422 error ('Contract with such contract number does not exist')

    3. check if contract is not in status 'TERMINATED'

      1. in case of error return 409 error ('Can not update terminated contract')

    4. employee_divisions, start_date, end_date can't be updated. If there is an active contract with such contract_number copy start_date, end_date and contractor_legal_entity_id from existing contract. It's not allowed in response.

      1. in case of error return 422 error

    5. check submitted contract_type is the same as in existing contract with number =contract_number

      1. in case of error 409 ('Submitted contract_type does not correspond to previously created content`)

    6. for capitation and reimbursement contract requests:

      1. if $contract_number and $end_date is passed in request:

        1. the $end_date must be greater or equal then the $start_datethe $start_date

          1. in case of error return 422 ('The year of end_date should be one year greater or equal to start_date')

        2. the $end_date should be less than $end_date from the previous contract and less than or equal to three month

          1. in case of error return 422 ('The year of end_date should be one year greater greater than of the previous contract and less than or equal to start_datethree months')

          the $end_date should be less than $end_date from the previous contract and less than or equal to three month
      2. if $contract_number w/o $end_date is passed in request:

        1. $end_date is taken from the previous contract.

    7. in case it is reimbursement contract:

      1. check id_form is the same

        1. in case of error

          return 422

          409 ('

          The end_date should be greater than of the previous contract and less than or equal to three months')
      2. if $contract_number w/o $end_date is passed in request:

        1. $end_date is taken from the previous contract.

    8. in case it is reimbursement contract, check medical_program_id id_form is the same

      1. in case of error 409 ('Submitted id_form does not correspond to previously created content`)

  8. Validate contractor_payment_details:

    1. if payer_account not like ^UA[0-9]{22}$ or ^UA[0-9]{27}$ -> MFO must be required

        1. Submitted id_form does not correspond to previously created content`)

      1. if medical_programs passed - validate them as described at p.13 below

  9. Validate contractor_payment_details:

    1. if payer_account not like ^UA[0-9]{22}$ or ^UA[0-9]{27}$ -> MFO must be required

  10. Validate id_from is from dictionary CONTRACT_TYPE:

    1. in case of error return 422 error ('value is not allowed in enum')

  11.  Validate there is no other active (VERIFIED) contract created by this legal_entity_id in this period(contract_request.start_date <= contract.end_date and contract_request.end_date => contract.start_date) by same contract_type and id_form (in case of reimbursement contract)

    1. in case of error return 422 error ('value is not allowed in enum')

     Validate there is no other active (VERIFIED) contract created by this legal_entity_id in this period(contract_request.start_date <= contract.end_date and contract_request.end_date => contract.start_date) by same contract_type and medical_program_id id_form (in case of reimbursement contract)

    1. in case of error return 422 error ('Active contract is found. Contract number must be sent in request')Active contract is found. Contract number must be sent in request')

  12. For capitation contract: Validate external_contractors

    1. Check external_contractors.divisions.id is present in contractor_divisions.id

      1. in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')

    2. Check external_contractors.contract.expires_at>start_date

      1. in case of error return 422 error $contract.expires_at ('Expires date must be greater than contract start_date')

    3. Set external_contractors.legal_entity_id='client_id'

    4. division_id from the external_contractors block must be a part of the legal entity that enters into the capitation contract. In the external_contractors.legal_entity_id must be specify the legal entity that is the counter-party of this division_id.

  13. For capitation contract: Validate external_contractors

  14. Check external_contractors.divisions.id is present in contractor_divisions.id

    1. in case of error return 422 error $divisions ('The division is not belong to contractor_divisions')

  15. Check external_contractors.contract.expires_at>start_date

    contractor_flag:

    1. If external_contractors is not null then external_contractor_flag must be true

    2. If external_contractors is null then external_contractor_flag must be set to false 

      1. in case of error return 422 error $contract.expires_at ('Expires date must be greater than contract start_date$external_contractor_flag ('Invalid external_contractor_flag')

    3. Set externalIf external_contractors .legal_entity_id='client_id'

    4. division_id from the external_contractors block must be a part of the legal entity that enters into the capitation contract. In the external_contractors.legal_entity_id must be specify the legal entity that is the counter-party of this division_id.

    For capitation contract: Validate external_contractor_flag:

    1. If external_contractors is not null then external_contractor_flag must be true

    2. If external_contractors is null then external_contractor_flag must be set to false wasn't sent in request then set external_contractor_flag to false.

  16. For reimbursement contracts: Validate medical_programs:

    1. Validate that all medical_programs with submitted ids exists

      1. in case of error return 422 error view $medical_programs[...] ('Reimbursement program with such id does not exist')

    2. Validate that medical_programs with submitted id is an active program

      1. in case of error return 422 error view $medical_programs[...] ('Reimbursement program is not active')

    3. Validate that all medical program and with MEDICATION type:

      1. in case of error return 422 error $external_contractor_flag ('Invalid external_contractor_flag')

    4. If external_contractors wasn't sent in request then set external_contractor_flag to false.

    For reimbursement contracts: Validate medical_programs:

    1. Validate that all medical_programs with submitted ids exists
      1. view $medical_programs[...] (‘Program with such id is not a reimbursement program')

    2. Check that medical_programs with submitted id correspond to id_form is in the allowed list:

      1. in case of error return 422 error view $medical_programs[...] ('Reimbursement program with such id does not exist')

      Validate that medical_programs with submitted id is an active program
      1. Medical program is not allowed for this action')
        Note. For id_form=INSULIN_1 and PSYCHIATRY two medical programs must be present.

        1. in case of error return

        422
        1. 409 error view $medical_

        programs[...] ('Reimbursement program is not active
        1. programs ('The composition of medical programs does not correspond to the allowed composition')

    3. Validate that all medical program and with MEDICATION typelist of medical programs in array doesn't contain duplicates ids:

      1. in case of error return 422 409 error view $medical_programs [...] (‘Program with such id is not a reimbursement program(‘The list of medical programs contains duplicates')

      Check that medical_programs with submitted

id

...

_form

...

 

id_form

medical_programs

PMD_1

REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_ID_DOSTUPNI_LIKY

INSULIN_1

REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_IDS_INSULIN

ND_1

REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_ID_NETSUKROVYY_DIABET

PSYCHIATRY

REIMBURSEMENT_CONTRACT_REQUEST_MEDICAL_PROGRAM_IDS_PSYCHIATRY

e. Validate that list of medical programs in array doesn't contain duplicates ids:

  1. in case of error return 409 error view $medical_programs (‘The list of medical programs contains duplicates')

Determine parent contract (optional)

...