Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Table of Contents

...

Table of Contents

Purpose

This WS is designed to review and update assign merge_request.


Specification

Page Properties
idAPI_Specification

Link

API paragraph not found

Resource

API paragraph not found

Scope

merge_request:review

Components

API paragraph not found

Microservices

API paragraph not found

Protocol type

API paragraph not found

Request type

API paragraph not found

Sync/Async

API paragraph not found

Public/Private/Internal

Private

GraphQL schema
Expand
titleRequest example
Code Block
"""
Methods to use when ordering `Merge Request`.
"""
enum MergeRequestOrderBy {
  "Sort Person by inserted at in ascending order."
  INSERTED_AT_ASC
  "Sort Person by inserted at in descending order."
  INSERTED_AT_DESC
  "Sort Person by birth date in ascending order."
  STATUS_ASC
  "Sort Person by birth date in descending order."
  STATUS_DESC
}

"""
A connection to a list of `MergeRequest` values.
"""
type MergeRequestConnection {
  "Information to aid in pagination."
  pageInfo: PageInfo!
  "Flag which shows whether NEW merge candidate can be assigned to the User"
  canAssignNew: Boolean!
  "A list of nodes."
  nodes: [MergeRequest]
  "A list of edges."
  edges: [MergeRequestEdge]
}

"""
Reads and enables pagination through a set of `MergeRequest`.
"""
type MergeRequestEdge {
  "The item at the end of the edge."
  node: MergeRequest!
  "A cursor for use in pagination."
  cursor: String!
}

"""
Return type for `assignMergeCandidate` mutation.
"""
type AssignMergeCandidatePayload {
  "Information of pair of persons which can be same."
  mergeRequest: MergeRequest!
}

"""
Input for `updateMergeRequest` mutation.
In order to update status user must have a scope `merge_request:write`
"""
input UpdateMergeRequestInput {
  "Primary key identifier from the database"
  id: ID!
  "next status of merge request"
  status: MergeRequestStatus!
  "comment which user can leave"
  comment: String
}

"""
Return type for `updateMergeRequest` mutation.
"""
type UpdateMergeRequestPayload {
  "Information of pair of persons which can be same."
  mergeRequest: MergeRequest!
}

"""
This is Merge Request details. In order to obtain details user must have a scope **merge_request:read**
"""
type MergeRequest implements Node {
  "The ID of an object"
  id: ID!
  "Primary key identifier from the database"
  databaseId: UUID!
  "The pair of persons which is considerated to be the same person"
  manualMergeCandidate: ManualMergeCandidate!
  "status of merge request"
  status: MergeRequestStatus!
  "comment which user can leave"
  comment: String
  "Technical information when the patient was inserted into the DB."
  insertedAt: DateTime!
  "Technical information when the patient was updated in the DB."
  updatedAt: DateTime!
}

"""
List of MergeRequest statuses.
"""
enum MergeRequestStatus {
  "Status `MERGE` for a merge request"
  MERGE
  "Status `NEW` for a merge request"
  NEW
  "Status `POSTPONE` for a merge request"
  POSTPONE
  "Status `SPLIT` for a merge request"
  SPLIT
  "Status `TRASH` for a merge request"
  TRASH
}

"""
Information about Manual Merge Candidate.
"""
type ManualMergeCandidate {
  "The ID of an object"
  id: ID!
  "Primary key identifier from the database"
  databaseId: UUID!
  "The pair of persons which is considerated to be the same person"
  mergeCandidate: MergeCandidate!
  "status of merge candidate"
  status: ManualMergeCandidateStatus
  "Technical information when the patient was inserted into the DB."
  insertedAt: DateTime!
  "Technical information when the patient was updated in the DB."
  updatedAt: DateTime!
}

"""
Information about Merge Candidate.
"""
type MergeCandidate {
  "The ID of an object"
  id: ID!
  "Primary key identifier from the database"
  databaseId: UUID!
  "The person wich will be deactivated"
  person: Person!
  "The person wich will remain"
  masterPerson: Person!
}

"""
List of Merge candidate statuses
"""
enum ManualMergeCandidateStatus {
  "Status `NEW` for a merge request"
  NEW
  "Status `PROCESSED` for a merge request"
  PROCESSED
}

Purpose

This WS is designed to review and update assign merge_request.

Statements 

Logic

  1. Assignee can postpone merge_request change its status to POSTPONE

  2. POSTPONE is not final status and must be changed to one of MERGE, SPLIT, TRASH

  3. MERGE, SPLIT, TRASH are final statuses

  4. In case one of MERGE, SPLIT, TRASH for one merge_request reached decision_amount value this request must be processed

    1. Decisions with status SPLIT and TRASH changes Merge Candidates to PROCESSED

    2. Decisions with status MERGE changes Merge Candidates to PROCESSED and creates Merge Job

Request structure

API paragraph not found

Authorize

    1. Verify the validity of access token

      1. in case of error return 401 ('Access denied')

    2. Check user scope merge_request:review in order to perform this action

      1. in case of error generate 401 response ('Invalid scopes')

Headers

API paragraph not found

Request data validation

Verify user and role

Extract from token:

  1. Validate client_id (is_blocked=false)

    1. in case of error return 403 Error ('Client is blocked')

  2. Check user_roles by client_id 

    1. check whether exist role NHS_REVIEWER 

      1. in case of error return 403 Error ('User doesn't have required role')

  3. Validate client_id is NHS

    1. check client type is NHS

      1. in case of error rerun forbidden error (Client is not allowed to the action')

Validate request

  1. Check allowed status transitions: 

    1. from NEW to POSTPONE/SPLIT/MERGE/TRASH

    2. from POSTPONE to SPLIT/MERGE/TRASH

      1. in case of other transitions return CONFLICT error - 'Incorrect transition status'

  2. Check id exists. In case if error return 404 'Merge request doesn't exist'

  3. Check assignee_id = $user_id

    1. in case of error return FORBIDDEN 'Current client is not allowed to access this resource'

...

Processing

Update  manual_merge_requests record by ID

column

value

updated_at

now()

status

$status

comment

$comment

Add a record to audit log

After status was changed  add new record to audit_log

field

value

id

generate UUID

actor_id

$user_id

resource

'manual_merge_process'

resource_id

$manual_merge_process.id

changeset

{status:$status}

inserted_at

DATETIME

Update  manual_merge_

...

candidates 

Update assignee_id

Fetch the record from manual_merge_candidates by manual_merge_candidate_id=dedup.manual_merge_candidates.id

column

value

assignee_id

null

updated_at

now()

Check amount of decisions

In case status was changed to final  SPLIT/MERGE/TRASH recalculate how many decisions on this merge_request was made by each status (qty).

Compare calculated qty to decision_amount. If qty=decision_amount:

  1. update manual_merge_candidates by manual_merge_candidate_id=dedup.manual_merge_candidates.id

Field 

Value

status

$PROCESSED

updated_at

now()

decision

$status (by calculated qty)

in case final decision is MERGE it should be checked whether deactivated person is a slave/master person in  any other merge candidate.

a) fetch all records from manual_merge_candidates where person_id or master_person_id=$person_id 

b) for such record update

...


Field 

Value

status

$PROCESSED

updated_at

now()

decision

$MERGE

status_reason

auto_merge

2. Add event to terminate declaration with reason manual_merge and deactivate person by person_id to Kafka in case final decision is MERGE

Response structure

API paragraph not found

Post-processing processes

API paragraph not found

HTTP status codes

API paragraph not found