Versions Compared

Key

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

Table of Contents

Related information

...

  1. Verify the validity of access token

    1. Return 401 in case validation fails

  2. Check scopes in order to perform this action (scope = 'declaration_request:sign')

    1. Return 403 in case invalid scope(s)

Digital signature

Digital signature validation is different depending on channel

  • for channel PIS and status APPROVED there must be 2 signatures - one for patient and one for doctor

  • for channel MIS and status APPROVED there must be only 1 doctor’s signature

Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature(s) and returns result.
See service specification

Validate patient’s signature

This validation must be done in different ways depending on context:

  • if request is done by person itself (There is no confidant person in data_to_be_signed data_to_be_signed.person.confidant_person (or is nil)) - we must check that signer DRFO matches with person tax_id or document

  • if request is done by confidant person (There is confidant person in data_to_be_signed data_to_be_signed.person.confidant_person) - we must check that signer DRFO matches with confidant person tax_id or document

Request is done by person

  1. Check that DRFO in Certificate details exists and not empty

  2. Check that DRFO in Certificate details is equal to Person’s tax_id

    1. Get person_id from token

    2. Get Person details using person_id

    3. Compare DRFO in Certificate with person.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

    4. In case validation fails - generate 422 error

Request is done by confidant person

  1. Check that DRFO in Certificate details exists and not empty

  2. Check that DRFO in Certificate details is equal to Confidant Person’s tax_id

    1. Get confidant_person from data_to_be_signed.person

    2. Compare DRFO in Certificate with person.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 doctor’s signature

...

  1. Change entity status in IL_DB.declaration_request to SIGNED

  2. Set status_reason:

    1. If channel = MIS - set status_reason to doctor_signed

    2. If channel = PIS - set status_reason to doctor_approved_over_limit

  3. Set updated_at - now() (Get current date-time)

  4. Set updated_by - user_id (Extract user from token)

...

  1. Check authentication_method_current

    Code Block
    SELECT authentication_method_current
    FROM declaration_requests
    WHERE id = {:id}
    
    1. If "type" = "OFFLINE"

      1.  set declaration status to "PENDING_VERIFICATION" “active”

      2. set reason to 'offline'

    2. if "type" = "OTP" - set declaration status to "ACTIVE" “active” 

    3. if "type" = "NA" - check parent_declaration_id, if not null than set declaration status to "ACTIVE" “active”

  2. Check persons 'no_tax_id' flag

    1. if 'no_tax_id'=true and parent_declaration_id is null

      1. set declaration status to "PENDING_VERIFICATION" “active”

      2. set reason to 'no_tax_id'

    2. if ‘no_tax_id’=true and parent_declaration_id is not null - set declaration status to "ACTIVE"“active”

  3. Create a new declaration by adding a new entity to the declarations table ops_db without declaration_id.

    1. if there is existing record in the declarations table with the same id and declaration_request_id, return ok to IL