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 18, 2023
1 parent 2d7bc9e commit 374eb39
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/components/data_submission/DataAccessGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export const DataAccessGovernance = (props) => {
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 externalAccess = extract('External Access', dataset);
const dac = (openAccess || externalAccess) ? undefined : await DAC.get(dataset?.dacId);
const controlledAccess = dac !== undefined;

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

// secondary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const ConsentGroupForm = (props) => {
hmb: curConsentGroup.hmb || undefined,
diseaseSpecificUse: curConsentGroup.diseaseSpecificUse || undefined, // string
poa: curConsentGroup.poa || undefined,
controlledAccess: curConsentGroup.controlledAccess || undefined,
openAccess: curConsentGroup.openAccess || undefined,
externalAccess: curConsentGroup.externalAccess || undefined,
otherPrimary: curConsentGroup.otherPrimary || undefined, // string

// secondary:
Expand Down
99 changes: 81 additions & 18 deletions src/components/data_submission/consent_group/EditConsentGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import { FormFieldTypes, FormField, FormTable, FormValidators, FormFieldTitle }
import { DAR } from '../../../libs/ajax';
import { cloneDeep } from 'lodash';

export const selectedAccessManagementGroup = (consentGroup) => {
if(!isNil(consentGroup.controlledAccess) && consentGroup.controlledAccess) {
return 'controlledAccess';
} else if(!isNil(consentGroup.openAccess) && consentGroup.openAccess) {
return 'openAccess';
} else if(!isNil(consentGroup.externalAccess) && consentGroup.externalAccess) {
return 'externalAccess';
}
}

export const selectedPrimaryGroup = (consentGroup) => {
if (!isNil(consentGroup.generalResearchUse) && consentGroup.generalResearchUse) {
return 'generalResearchUse';
Expand Down Expand Up @@ -83,6 +93,20 @@ export const EditConsentGroup = (props) => {
});
};

const onAccessManagementChange = ({ key, value }) => {
setConsentGroup({
...consentGroup,
...{
controlledAccess: false,
openAccess: false,
externalAccess: false,
},
...{
[key]: value,
}
})
};

const onPrimaryChange = ({ key, value }) => {
setConsentGroup({
...consentGroup,
Expand Down Expand Up @@ -119,6 +143,62 @@ export const EditConsentGroup = (props) => {
onValidationChange,
}),

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

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

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

// primary
div({}, [
h(FormField, {
Expand Down Expand Up @@ -229,23 +309,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 @@ -463,7 +526,7 @@ export const EditConsentGroup = (props) => {
isRendered: consentGroup.openAccess !== true,
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 Down

0 comments on commit 374eb39

Please sign in to comment.