Versions Compared

Key

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

Required parameters are marked with "*"

...

Purpose

...

This WS allows to create medical program provision by divisions of user’s legal entity. It shows what divisions provides medical program according to legal entity contractprogram.

Key points

  1. This is a REST method.

  2. Only authenticated and authorized pharmacy owner with appropriate scope can create a Medical program provision.

  3. Request should be signed with DS.

  4. User can add multiple divisions at once to provide a medical program.

Specification

...

Page Properties

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-contracts/medical-program-provision/create-medical-program-provision

Resource

/api/medical_program_provision

Scope

medical_program_provision:write

Components

Medical program provision

Microservices

API paragraph not found

Protocol type

REST

Request type

POST

Sync/Async

Sync

Logic*

This method allows to create medical program provision by divisions of user’s legal entity. It shows what divisions provide medical program according to legal entity contract. Method receives signed message (pkcs7) that consists of signed content, digital signature and signer public key. All signature fields will be validated (including signer certificate authority). Service will store signed copy of the request in Media Content Storage if all checks is passed.

Key points

  1. This is a REST method.

  2. Only authenticated and authorized legal entity owner with appropriate scope can create a Medical program provision.

  3. Request should be signed with DS.

  4. User can add multiple divisions at once to provide a medical program.

...

Public/Private/Internal

Public

Preconditions

MSP/Pharmacy contracts should be created and signed with NHS

Logic

  1. Save signed content to media storage. Look at Bucket structure for details.

  2. Save records to the database according to Data model

Request structure

See on Apiary

Example:

Expand
titleRequest example
Code Block
{
  "signed_content": "ew0KICAicGVyaW9kIjogew0KIC...",
  "signed_content_encoding": "base64"
}

Dummy example:

Expand
Code Block
{
  "contract_number": "0000-PAP5-M000",
  "medical_program_id": "04d5ea65-d6e7-44f8-9eef-f0d3c1121d2b",
  "divisions": [
    "15caea3f-cac3-483c-a3da-5875eba96430",
    "6d07bdb0-59c0-4b54-8a90-bada3e232877"
  ]
}

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 = 'medical_program_provision:write')

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

Request to process the request using a token in the headers

Headers

...

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer F3GF124Df565FDS234SDF34

  • api-key:aDGFDFGT46S5gFGD

Request data validation

...

Validate Digital Sign

  • Validate request is signed

    • in case of error - return 422 “document must be signed by 1 signer but contains 0 signatures”

  • Check DS is valid and not expired

  • Validate that DS belongs to the user

    • Check that DRFO from DS and party.tax_id matches

      • in case of error - return 409 “Signer DRFO doesn't match with requester tax_id“422 “Does not match the signer drfo“

Validate legal entity

  • Extract client_id from token.

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

    • in case of error - return 403 “Your scope does not allow to access this resource. Missing allowances: medical_program_provision:write”

  • Check legal entity status (status = ACTIVE,  SUSPENDEDSUSPENDED)

    • In case of error - return 422 “Legal entity is not active”

Validate request

...

  1. Validate contract_number, if submitted:

    1. Select contract_number from contracts where:

      1. type = REIMBURSEMENT

      2. is_active=true

      3. status =

...

      1. VERIFIED

      2. contractor_legal_entity = client_id (from token)

        1. in case of error - return 422 “Your legal entity has no reimbursement contract with number <contract_number> or it is not active”

...

  1. Validate medical_program_id:

    1. Сheck program exists and active

      1. in case of error - return 422 “Medical program not found”

    2. If medical program has funding_source is in ('NHS', 'LOCAL')

      1. in case of error - return 422 “Medical program not found“

    3. If medical program has funding_source = NHS:

      1. Validate contract_number submitted:

        1. in case of error - return 422 “Contract number should be submitted for medical program with NHS funding source“

      2. Check medical program belongs to the contract

        1. in case of error - return 422 “Medical program does not belong to contract”

...

    1. If medical program has funding_source = LOCAL:

      1. Validate msp_legal_entity_id submitted:

        1. in case of error - return 422 “MSP legal entity should be submitted for medical program with LOCAL funding source“

  1. Validate divisions :

    1. Check divisions are not duplicated in the array

      1. in case of error - return 422 “Division list has duplicated identifiers in the request”

    2. For each division in the array:

      1. Validate it exists and active (is_active = true and status = ACTIVE):

        1. in case of error - return 422 “Division

...

        1. does not exist or not active”

      1. If chart

...

      1. parameter DISPENSE_DIVISION_DLS_VERIFY

...

      1. is on,

...

      1. then validate it DLS verified (dls_verified=true)

        1. in case of error - return 422 “Division with id <id> is not verified in DLS”

      2. Validate it belongs to the legal entity (client_id from token)

        1. in case of error - return 422 “Division

...

        1. does not belong to legal entity”

      1. Validate there is no existing active records with the same division, medical program

...

      1. , contract number or msp_legal_entity_id

        1. in case of error - return 422 “The medical program has already been provided by division according to the contract or MSP legal entity“

      2. Validate it is DLS verified by one of the params (if both params are on, check that at least one of checks passes):

        1. If chart parameter DISPENSE_DIVISION_DLS_VERIFY is on, check that division.dls_verified=true

        2. If chart parameter DISPENSE_DIVISION_HEALTHCARE_SERVICE_DLS_VERIFY is on, check that exists healthcare service with division

...

        1. _id = $.divisions.[*], category = ‘PHARMACY’, status = ‘ACTIVE’ and licensed_healthcare_service.status = ‘ACTIVE’

          1. in case of error - return 422 “Division with id <id> is not verified in DLS”

  1. Validate msp_legal_entity_id , if submitted:

    1. Check legal entity exists and is_active:

      1. in case of error - return 422 “MSP legal entity not found”

    2. Check legal entity status (status = ACTIVE, SUSPENDED)

      1. In case of error - return 422 “Invalid status of MSP legal entity”

    3. Check legal entity type (type = PRIMARY_CARE, OUTPATIENT, EMERGENCY)

      1. In case of error - return 422 “Legal entity type should be of PRIMARY_CARE, OUTPATIENT or EMERGENCY”

Processing

  1. Save signed content to media storage. Look at Bucket structure for details.

  2. Save records to the database according to Data model

Response structure

...

See on Apiary

Example:

Expand
titleResponse example
Code Block
{
  "meta": {
    "code": 201,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  },
  "data": [
    {
      "id": "3e34da3d-9b8c-4aaf-be8e-24a161279b6a",
      "contract_number": "0000-PAP5-M000",
      "medical_program_id": "04d5ea65-d6e7-44f8-9eef-f0d3c1121d2b",
      "division_id": "15caea3f-cac3-483c-a3da-5875eba96430",
      "is_active": true,
      "deactivate_reason": null,
      "inserted_at": "2017-04-20T19:14:13Z",
      "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e",
      "updated_at": "2017-04-20T19:14:13Z",
      "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd"
    }
  ]
}

...

API paragraph not found

HTTP status codes

...

HTTP status code

Message

What caused the error

 201

Response

  

401

Invalid access token

403

Your scope does not allow to access this resource. Missing allowances: medical_program_provision:write

422

Validation error