icgc-argo / argo-clinical

Clinical data submission for ARGO programs.
GNU Affero General Public License v3.0
2 stars 0 forks source link

Exception Manifest - 1 - Function to generate exception records for donors #1142

Closed joneubank closed 2 months ago

joneubank commented 4 months ago

Create a function that will collect all exceptions related to a clinical data request and return the collection of those exception records sorted and ready to be converted into an exception manifest file.

Implementation Details

Types for ExceptionRecords

type ExceptionType = 'MissingEntity'| 'ProgramProperty' | 'EntityProperty'
type MissingEntityExceptionRecord = {
    exceptionType: 'MissingEntity';
    programId: string;
    donorId: string;
    submitterDonorId: string;
}
type ProgramPropertyExceptionRecord = {
    exceptionType: 'ProgramProperty';
    programId: string;
    donorId: string;
    submitterDonorId: string;
    schemaName: string;
    propertyName: string;
    exceptionValue: string;
}
type EntityPropertyExceptionRecord = {
    exceptionType: 'EntityProperty';
    programId: string;
    donorId: string;
    submitterDonorId: string;
    entityId: string;
    submitterEntityId: string;
    schemaName: string;
    propertyName: string;
    exceptionValue: string;

}
type ExceptionRecord = MissingEntityExceptionRecord | ProgramPropertyExceptionRecord | EntityPropertyExceptionRecord;

Function Inputs

The filter for donor data could be provided by any combination of donorIDs or submitterDonorIDs. This function will need to have an input for each type of IDs.

function (filters: { donorIDs: number[], submitterDonorIDs: string[] })

Return

Sorted array of ExceptionRecords.

Sorting rules:

  1. Program ID
  2. Submitter Donor ID (all program level exceptions have empty donor id, sort these above all other exceptions)
  3. Exception Type
  4. Schema Name
  5. Submitter Entity ID (could be submitter's followup id, treatment id, specimen id)

Process

image

demariadaniel commented 3 months ago

Sorting will be finalized in https://app.zenhub.com/workspaces/icgc-argo-platform-dk-production-board-5e542d38415f5034e9fed89d/issues/gh/icgc-argo/argo-clinical/1143

Records are already generally sorted as specified. See output of unit test below:

Screenshot 2024-03-05 at 3.17.00 PM.png