Versions Compared

Key

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

...

  1. Extract legal_entity_id (client_id) from token. Take contract_request_id.

  2. Check client_id=contractor_legal_entity_id (contractor_side)

  3. Validate that contract_request hasn't been signed by  contractor_side already

    1. Check status<>'SIGNED'.

    2. In case of error return 422 error ('The contract was already signed by contractor')

...

Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.

Validations

Validate DRFO or EDRPOU

...

  1. Get parties.tax_id using party_users.party_id by user_id.

  2. Compare DRFO in Certificate with party.tax_id

    1. Convert DRFO and TAX_ID to uppercase

    2. Compare DRFO and TAX_ID as Cyrillic letters

    3. Convert DRFO to Cyrillic and compare as Cyrillic letters

  3. In case validation fails - generate 422 error

Validate Status

  1. Check contract_request.status='NHS_SIGNED'

    1. in case of error return 422 Error 'Incorrect status for signing'

...

In case if they are not equal - generate 422 error (message: "Signed content does not match the previously created content")

2. Actualize data:

Invoke service 'Get Contract Reqeust by ID'. In the response will be received printout form and json. Compare it with previously created on IL.db

In case if they are not equal - generate 422 error (message: "Signed content does not match the previously created content")

Validate 1st Signature

  1. Get client_id from token

  2. Find prm.legal_entities by  nhs_signer_id → prm.employee→ legal_entity

  3. Check EDRPOU or DRFO matches prn.legal_entities.EDRPOU

    1. Check if  EDRPOU in Certificate details exists and not empty

      1. Check if  Certificate_details.EDRPOU=prm.legal_entities.EDRPOU

    2. in case validation from a. didn't pass - Check that DRFO in Certificate details exists and not empty

      1. Convert DRFO and prn.legal_entities.EDRPOU to uppercase

      2. Compare DRFO and prn.legal_entities.EDRPOU as Cyrillic letters

      3. Convert DRFO to Cyrillic and compare as Cyrillic letters

      4. Check if  Certificate_details.DRFO=prn.legal_entities.EDRPOU 

    3. In case validation fails - generate 422 error

  4. Check that SURNAME in Certificate details is equal to LAST_NAME in Party

    1. Get party.last_name using nhs_signer_id from contract_request (employees.employee_id=nhs_signer_id –> parties.id)

      1. Convert prm.parties.LAST_NAME and Certificate details.SURNAME to uppercase

      2. Compare prm.parties.LAST_NAME and Certificate details.SURNAME as Cyrillic letters

      3. In case validation fails - generate 422 error

  5. Validate DRFO

    1. Get parties.tax_id using party_users.party_id by user_id.

    2. Compare DRFO in Certificate with party.tax_id

      1. Convert DRFO and TAX_ID to uppercase

      2. Compare DRFO and TAX_ID as Cyrillic letters

      3. Convert DRFO to Cyrillic and compare as Cyrillic letters

    3. In case validation fails - generate 422 error

...

  1. Validate request using JSON schema

    1. In case validation fails - generate 422 error

  2. Check contract request status

    1. If status is not APPROVED - returned error 'Incorrect status'

  3. Capitation only: Validate contractor_employee_divisions

    1. Employees from employee_divisions has employee_type='DOCTOR', status='APPROVED', division is not null

      1. in case of error return 422  error view $employee ('Employee must be an active DOCTOR with linked division')

    2. 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')

    3. Check employee belongs to division

      1.  in case of error return 422  error view $employee  ('Employee must be within current division')

  4. Validate start_date

    1. start_date>now()

      1. in case of error return 422 error $start_date ('Start date must be greater than create date')

  5. Check whether all id is resolved and valid. For
     - contractor_legal_entity_id and nhs_legal_entity_id in status='active'  and nhs_verified = true (prm.legal_entities)
     - contractor_owner_id and nhs_signer_id in status = 'APPROVED' (prm.employees)

  6. Search contract_number in contracts.contract_number. if found none or one contract in status='VERIFIED' - validation passed.

    1. In case found contract(s), but in status='TERMINATED' show an error 422 ('There is no active contract with such contract_number')

  7. Reimbursement only: validate that medical_program_id is a valid ID of an ACTIVE medical_program with type 'medication'

    1. in case of error return "Medical program is not active"


Save signed contract to media storage

...

Parameter

Source

action

'GET'

bucket

'CONTRACTS'

resource_id

: CONTRACT_ID

resource_name

: CONTRACT_NAME

timestamp

:TIMESTAMP

Update contract request

  1. update contract_request.status='SIGNED'

  2. update contract_request.contract_id=contract.id

    Code Block
    UPDATE contract_requests
    SET status = 'SIGNED'
    WHERE id = {:id}


Create Contract

If status='SIGNED'

  • Create a new record in PRM.contracts with status='VERIFIED'

  • set is_suspended=false, is_active=true

  • for each division from array contract_divisions create a new row in contract_divisions

  • capitation only: for each employee from array create a new row in PRM.contract_employees

Check parent_contract_id

Search parent_contract_id in contracts.id.

  1. Get contract.id by parent_contract_id and status='VERIFIED'

    1. fetch all records in contract_employees by contract_id and end_date is null

      1. set for those records end_date=$contract_request.start_date

  2. In case active contract found - terminate by changing status to TERMINATED.

...

field

value

event_type

StatusChangeEvent

entity_type

Contract_request

entity_id

$.id

properties.status.new_value

$.status

event_time

$.update_at

changed_by

$.changed_by


Deactivate Medical Program Provision

If contract update operation (Sign Contract Request by MSP api with contract_number) (according to link):

  • define medical programs that are not present in the new contract.

  • deactivate all active medical program provision for defined programs within contract number and current legal entity: 

    • set is_active = false

    • set deactivate_reason = AUTO_CONTRACT_TERMINATION

    • set updated_at, updated by
      Note: Status of medical program provision entities for the programs remained in the new contract should not be changed.