Versions Compared

Key

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

...

Expand
titleRequest example
Code Block
{
  "medication_id": "59781de0-2e64-4359-b716-bcc05a32c10f",
  "medical_program_id": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
  "reimbursement": {
    "type": "fixed",
    "reimbursement_amount": 450
  },
  "wholesale_price": "148.50",
  "consumer_price": "150.00",
  "daily_dosage": "200",
  "wholesalereimbursement_daily_pricedosage": "14810.504858",
  "consumerestimated_payment_priceamount": "150.00",
  "daily_dosage": "200",
  "reimbursement_daily_dosage": "10.4858",
  "estimated_payment_amount": "34.50"
}

Authorize

...

Verify the validity of access token

  • in case of error - return 401 (“Invalid access token”) in case of validation fails.

...

Verify that token is not expired

  • in case of error - return 401 (“Invalid access token”).

...

34.50"
}

Authorize

  • Verify the validity of access token

    • in case of error - return 401 (“Invalid access token”) in case of validation fails.

  • Verify that token is not expired

    • in case of error - return 401 (“Invalid access token”).

  • Check user scopes in order to perform this action (scope = 'program_medication:write')

    • return 403 (“Your scope does not allow to access this resource. Missing allowances: program_medication:read”) in case of invalid scope(s).

Request to process the request using a token in the headers

Headers

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

Request data validation

Validate legal entity

  • Extract client_id from token.

  • Check client scopes in order to perform this action (scope = 'program_medication:write')

    • in case of error - return 403 (“Your scope does not allow to access this resource. Missing allowances: program_medication:read”) in case of invalid scope(s).

Request to process the request using a token in the headers

Headers

  • Content-Type:application/json

  • Authorization:Bearer c2778f3064753ea70de870a53795f5c9

Request data validation

Validate legal entity

  • Extract client_id from token.

  • Check client scopes in order to perform this action (scope = 'program_medication:write')
    • write”).

Validate request

  1. Check medicalProgramId:

    1. exists in DB

      1. in case of error - return 404 ('not_found')

    2. has type = MEDICATION

      1. in case of error - return 409 ('MedicalProgram type should be MEDICATION')

    3. is_active = true

      1. in case of error - return

...

Validate request

  1. Check medicalProgramId:

    1. exists in DB

      1. in 409 ('Medical program is not active')

  2. Check start_date < end_date

    1. in case of error - return

      404

      422 ('

      not_found')

      has type = MEDICATIONmust be earlier than the end date')

  3. Validate reimbursement:

    1. If reimbursement type = FIXED, than reimbursementAmount field required

    2. If reimbursement type = PERCENTAGE, percentageDiscount field required

      1. in case of error - return 409 422 ('MedicalProgram type should be MEDICATIONcan't be blank')

    3. is_active = true

      1. in case of error - return 409 ('Medical program is not active')

  4. Check start_date < end_dateIf percentageDiscount submitted in the reimbursement structure:

    1. Check it’s value in range from 0 to 100

      1. in case of error - return 422 ('

      must be earlier than the end date
      1. expected the value to be <= 100')

  5. Validate reimbursementmedicationId:

    1. If reimbursement type = FIXED, than reimbursementAmount field required

    2. If reimbursement type = PERCENTAGE, percentageDiscount field required

      Check it is active and it’s type is BRAND

      1. in case of error - return 422 409 ('can't be blank')

    If percentageDiscount submitted in the reimbursement structure:

    1. Check it’s value in range from 0 to 100
      1. Medication is not active')

  6. Validate compliance of INNM_DOSAGE.mr_blank_type:

    1. in case when $.medication.type is BRAND:

      Check it
      1. Check INNM_DOSAGE

        1. There is link of a BRAND to INNM_DOSAGE (in prm.ingredients table) and INNM_DOSAGE exists

          1. in case of error - return

        422 ('expected the value to be <= 100
          1. 404 ('INNM_DOSAGE of a BRAND not_found')

    Validate medicationId:

        1. is

      active and it’s type is BRAND
        1. _active = true

          1. in case of error - return 409 ('

        Medication
          1. INNM_DOSAGE of a BRAND is not active')

    Validate compliance of
    1. in case when $.medication.type is INNM_DOSAGE

    .mr_blank_type of a BRAND to medicalProgram.mr_blank_type
    1. :

      1. Check INNM_DOSAGEThere is link of a BRAND to INNM_DOSAGE (in prm.ingredients table) and

        1. INNM_DOSAGE exists

          1. in case of error - return 404 ('INNM_DOSAGE

          of a BRAND
          1. not_found')

        2. is_active = true

          1. in case of error - return 409 ('INNM_DOSAGE

          of a BRAND
          1. is not active')

    2. Check compliance of INNM_DOSAGEof a BRANDto medicalProgram

      1. if INNM_DOSAGE.mr_blank_type = medicalProgram.mr_blank_type
        (i.e prm.medications.mr_blank_type = prm.medical_programs.mr_blank_type)

        1. in case of error - return 422 ('Dosage form of selected Medication does not comply with mr_blank_type requirement of Medical Program')

Processing

...

Response structure

See on Apiary

...