Skip to content

Commit

Permalink
feat: add external access to data submission form
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Oct 30, 2023
1 parent 647d255 commit d5a29b2
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 32 deletions.
7 changes: 3 additions & 4 deletions src/pages/data_submission/DataAccessGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ export const DataAccessGovernance = (props) => {
const prefillConsentGroups = useCallback(async () => {
var consentGroups = await Promise.all(datasets?.map(async (dataset, idx) => {
const dataUse = await normalizeDataUse(dataset?.dataUse);
// DAC is required if openAccess is false
const openAccess = extract('Open Access', dataset);
const dac = openAccess ? undefined : await DAC.get(dataset?.dacId);
const accessManagement = extract('Access Management', dataset);
const dac = 'dacId' in dataset ? await DAC.get(dataset.dacId) : undefined;

return {
consentGroup: {
Expand All @@ -130,7 +129,7 @@ export const DataAccessGovernance = (props) => {
hmb: dataUse.hmbResearch,
diseaseSpecificUse: dataUse.diseaseRestrictions,
poa: dataUse.populationOriginsAncestry,
openAccess: openAccess,
accessManagement: accessManagement,
otherPrimary: dataUse.other,

// secondary
Expand Down
2 changes: 1 addition & 1 deletion src/pages/data_submission/RegistrationValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const updateValidation = (existingValidation, validationError) => {
};
}
// if the field is required and empty, we shouldn't also error on, e.g., that it isn't a date format
if (existingValidation.failed.includes('required') || validationError === 'required') {
if ((existingValidation.failed && existingValidation.failed.includes('required')) || validationError === 'required') {
return {
valid: false,
failed: ['required']
Expand Down
8 changes: 6 additions & 2 deletions src/pages/data_submission/consent_group/ConsentGroupErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const invalidFormatError = (format) => {
export const computeConsentGroupValidationErrors = (consentGroup, datasetNames = []) => {
const validation = {};

if (isNil(selectedPrimaryGroup(consentGroup))) {
if (isNil(consentGroup.accessManagement)) {
validation.accessManagement = requiredError;
}

if (isNil(selectedPrimaryGroup(consentGroup)) && consentGroup.accessManagement !== 'open') {
validation.primaryConsent = requiredError;
}

Expand Down Expand Up @@ -61,7 +65,7 @@ export const computeConsentGroupValidationErrors = (consentGroup, datasetNames =
validation.otherPrimary = requiredError;
}

if (isNil(consentGroup.dataAccessCommitteeId) && consentGroup.openAccess !== true) {
if (isNil(consentGroup.dataAccessCommitteeId) && consentGroup.accessManagement === 'controlled') {
validation.dataAccessCommitteeId = requiredError;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/data_submission/consent_group/ConsentGroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ export const ConsentGroupForm = (props) => {
datasetId: curConsentGroup.datasetId || null,
consentGroupName: curConsentGroup.consentGroupName || '',

// access management is one of: "controlled", "open", "external"
accessManagement: curConsentGroup.accessManagement || undefined, // string

// primary:
generalResearchUse: curConsentGroup.generalResearchUse || undefined,
hmb: curConsentGroup.hmb || undefined,
diseaseSpecificUse: curConsentGroup.diseaseSpecificUse || undefined, // string
poa: curConsentGroup.poa || undefined,
openAccess: curConsentGroup.openAccess || undefined,
otherPrimary: curConsentGroup.otherPrimary || undefined, // string

// secondary:
Expand Down
81 changes: 57 additions & 24 deletions src/pages/data_submission/consent_group/EditConsentGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const selectedPrimaryGroup = (consentGroup) => {
return 'diseaseSpecificUse';
} else if (!isNil(consentGroup.poa) && consentGroup.poa) {
return 'poa';
} else if (!isNil(consentGroup.openAccess) && consentGroup.openAccess) {
return 'openAccess';
} else if (!isNil(consentGroup.otherPrimary) && isString(consentGroup.otherPrimary)) {
return 'otherPrimary';
}
Expand Down Expand Up @@ -119,8 +117,60 @@ export const EditConsentGroup = (props) => {
onValidationChange,
}),

// primary
// controlled, open and external access
div({}, [
h(FormField, {
title: 'Data Access Management',
description: 'Select a data access management strategy',
id: idx + '_accessManagement_controlled',
name: 'accessManagement',
value: 'controlled',
type: FormFieldTypes.RADIOBUTTON,
toggleText: 'Controlled Access (managed by a DAC in DUOS)',
disabled: disableFields,
defaultValue: consentGroup.accessManagement,
onChange,
validation: validation.accessManagement,
onValidationChange: ({ validation }) => {
onValidationChange({ key: 'accessManagement', validation });
},
}),

h(FormField, {
id: idx + '_accessManagement_open',
name: 'accessManagement',
value: 'open',
type: FormFieldTypes.RADIOBUTTON,
toggleText: 'Open Access (does not need DAC approval)',
disabled: disableFields,
defaultValue: consentGroup.accessManagement,
onChange,
validation: validation.accessManagement,
onValidationChange: ({ validation }) => {
onValidationChange({ key: 'accessManagement', validation });
},
}),

h(FormField, {
id: idx + '_accessManagement_external',
name: 'accessManagement',
value: 'external',
type: FormFieldTypes.RADIOBUTTON,
toggleText: 'External Access (managed by a DAC external to DUOS)',
disabled: disableFields,
defaultValue: consentGroup.accessManagement,
onChange,
validation: validation.accessManagement,
onValidationChange: ({ validation }) => {
onValidationChange({ key: 'accessManagement', validation });
},
}),
]),

// primary
div({
isRendered: consentGroup.accessManagement !== 'open',
}, [
h(FormField, {
title: 'Primary Data Use Terms*',
description: 'Please select one of the following data use permissions for your dataset',
Expand Down Expand Up @@ -229,23 +279,6 @@ export const EditConsentGroup = (props) => {
},
}),

h(FormField, {
type: FormFieldTypes.RADIOBUTTON,
id: idx + '_primaryConsent_openAccess',
name: 'primaryConsent',
value: 'openAccess',
toggleText: 'No Restrictions (Open Access Data)',
disabled: disableFields,
defaultValue: selectedPrimaryGroup(consentGroup),
onChange: ({ value }) => {
onPrimaryChange({ key: value, value: true });
},
validation: validation.primaryConsent,
onValidationChange: ({ validation }) => {
onValidationChange({ key: 'primaryConsent', validation });
},
}),

h(FormField, {
type: FormFieldTypes.RADIOBUTTON,
id: idx + '_primaryConsent_otherPrimary',
Expand Down Expand Up @@ -284,7 +317,7 @@ export const EditConsentGroup = (props) => {

// secondary
div({
isRendered: consentGroup.openAccess !== true,
isRendered: consentGroup.accessManagement !== 'open',
}, [
h(FormField, {
title: 'Secondary Data Use Terms',
Expand Down Expand Up @@ -460,10 +493,10 @@ export const EditConsentGroup = (props) => {

// data access committee
h(FormField, {
isRendered: consentGroup.openAccess !== true,
isRendered: consentGroup.accessManagement === 'controlled',
id: idx + 'dataAccessCommitteeId',
name: 'dataAccessCommitteeId',
title: 'Data Access Committee',
title: 'Data Access Committee (DAC)',
description: 'Please select which DAC should govern requests for this dataset',
type: FormFieldTypes.SELECT,
selectOptions: dacs.map((dac) => {
Expand All @@ -472,7 +505,7 @@ export const EditConsentGroup = (props) => {
onChange: ({ key, value }) => {
onChange({ key, value: value?.dacId });
},
validators: [FormValidators.REQUIRED],
//validators: consentGroup.accessManagement === 'controlled' ? [FormValidators.REQUIRED] : undefined,
validation: validation.dataAccessCommitteeId,
disabled: disableFields,
defaultValue: dacs.map((dac) => {
Expand Down

0 comments on commit d5a29b2

Please sign in to comment.