Skip to content

Commit

Permalink
picklist field (single and multivalued) silent validation and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ddooley committed Dec 20, 2024
1 parent 43c6a41 commit b19ecbc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 20 deletions.
29 changes: 18 additions & 11 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1597,17 +1597,22 @@ class DataHarmonizer {

if (field.sources) {
const options = field.sources.flatMap((source) => {
return Object.values(field.permissible_values[source]).reduce(
(acc, item) => {
acc.push({
label: titleOverText(item),
value: titleOverText(item),
_id: item.text,
});
return acc;
},
[]
);
if (field.permissible_values[source])
return Object.values(field.permissible_values[source]).reduce(
(acc, item) => {
acc.push({
label: titleOverText(item),
value: titleOverText(item),
_id: item.text,
});
return acc;
},
[]
);
else {
alert("Schema Error: Slot mentions enumeration " + source + " but this was not found in enumeration dictionary, or it has no selections");
return [];
}
});

col.source = options;
Expand Down Expand Up @@ -2780,11 +2785,13 @@ class DataHarmonizer {
if (field.multivalued === true) {
const [, update] = validateValsAgainstVocab(cellVal, field);
if (update) {
data[row][col] = update;
cellChanges.push([row, col, update, 'thisChange']);
}
} else {
const [, update] = validateValAgainstVocab(cellVal, field);
if (update) {
data[row][col] = update;
cellChanges.push([row, col, update, 'thisChange']);
}
}
Expand Down
14 changes: 11 additions & 3 deletions web/templates/influenza/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@
"title": "umbrella bioproject accession menu",
"from_schema": "https://example.com/Influenza"
},
"null value menu": {
"name": "null value menu",
"NullValueMenu": {
"name": "NullValueMenu",
"title": "null value menu",
"from_schema": "https://example.com/Influenza",
"permissible_values": {
Expand Down Expand Up @@ -531,7 +531,15 @@
"PresamplingActivityMenu": {
"name": "PresamplingActivityMenu",
"title": "presampling activity menu",
"from_schema": "https://example.com/Influenza"
"from_schema": "https://example.com/Influenza",
"permissible_values": {
"Post-infection convalescence": {
"text": "Post-infection convalescence"
},
"Vaccination": {
"text": "Vaccination"
}
}
},
"VaccineNameMenu": {
"name": "VaccineNameMenu",
Expand Down
10 changes: 7 additions & 3 deletions web/templates/influenza/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1716,8 +1716,8 @@ enums:
name: UmbrellaBioprojectAccessionMenu
title: umbrella bioproject accession menu
permissible_values: {}
null value menu:
name: null value menu
NullValueMenu:
name: NullValueMenu
title: null value menu
permissible_values:
Not Applicable:
Expand Down Expand Up @@ -1878,7 +1878,11 @@ enums:
PresamplingActivityMenu:
name: PresamplingActivityMenu
title: presampling activity menu
permissible_values: {}
permissible_values:
Post-infection convalescence:
text: Post-infection convalescence
Vaccination:
text: Vaccination
VaccineNameMenu:
name: VaccineNameMenu
title: vaccine name menu
Expand Down
6 changes: 3 additions & 3 deletions web/templates/influenza/schema_enums.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ title name meaning menu_1 menu_2 menu_3 menu_4 menu_5 description EXPORT_GISAID

umbrella bioproject accession menu UmbrellaBioprojectAccessionMenu

null value menu GENEPIO:0001619 Not Applicable
null value menu NullValueMenu GENEPIO:0001619 Not Applicable
GENEPIO:0001618 Missing
GENEPIO:0001620 Not Collected
GENEPIO:0001668 Not Provided
Expand Down Expand Up @@ -60,8 +60,8 @@ Related specimen relationship type menu RelatedSpecimenRelationshipTypeMenu HP:0
Sequencing/bioinformatics methods development/validation
Specimen sampling methods testing

presampling activity menu PresamplingActivityMenu Post-infection convalescence
Vaccination
presampling activity menu PresamplingActivityMenu Post-infection convalescence
Vaccination



Expand Down

0 comments on commit b19ecbc

Please sign in to comment.