Skip to content

Commit b19ecbc

Browse files
committed
picklist field (single and multivalued) silent validation and fix
1 parent 43c6a41 commit b19ecbc

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

lib/DataHarmonizer.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -1597,17 +1597,22 @@ class DataHarmonizer {
15971597

15981598
if (field.sources) {
15991599
const options = field.sources.flatMap((source) => {
1600-
return Object.values(field.permissible_values[source]).reduce(
1601-
(acc, item) => {
1602-
acc.push({
1603-
label: titleOverText(item),
1604-
value: titleOverText(item),
1605-
_id: item.text,
1606-
});
1607-
return acc;
1608-
},
1609-
[]
1610-
);
1600+
if (field.permissible_values[source])
1601+
return Object.values(field.permissible_values[source]).reduce(
1602+
(acc, item) => {
1603+
acc.push({
1604+
label: titleOverText(item),
1605+
value: titleOverText(item),
1606+
_id: item.text,
1607+
});
1608+
return acc;
1609+
},
1610+
[]
1611+
);
1612+
else {
1613+
alert("Schema Error: Slot mentions enumeration " + source + " but this was not found in enumeration dictionary, or it has no selections");
1614+
return [];
1615+
}
16111616
});
16121617

16131618
col.source = options;
@@ -2780,11 +2785,13 @@ class DataHarmonizer {
27802785
if (field.multivalued === true) {
27812786
const [, update] = validateValsAgainstVocab(cellVal, field);
27822787
if (update) {
2788+
data[row][col] = update;
27832789
cellChanges.push([row, col, update, 'thisChange']);
27842790
}
27852791
} else {
27862792
const [, update] = validateValAgainstVocab(cellVal, field);
27872793
if (update) {
2794+
data[row][col] = update;
27882795
cellChanges.push([row, col, update, 'thisChange']);
27892796
}
27902797
}

web/templates/influenza/schema.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@
301301
"title": "umbrella bioproject accession menu",
302302
"from_schema": "https://example.com/Influenza"
303303
},
304-
"null value menu": {
305-
"name": "null value menu",
304+
"NullValueMenu": {
305+
"name": "NullValueMenu",
306306
"title": "null value menu",
307307
"from_schema": "https://example.com/Influenza",
308308
"permissible_values": {
@@ -531,7 +531,15 @@
531531
"PresamplingActivityMenu": {
532532
"name": "PresamplingActivityMenu",
533533
"title": "presampling activity menu",
534-
"from_schema": "https://example.com/Influenza"
534+
"from_schema": "https://example.com/Influenza",
535+
"permissible_values": {
536+
"Post-infection convalescence": {
537+
"text": "Post-infection convalescence"
538+
},
539+
"Vaccination": {
540+
"text": "Vaccination"
541+
}
542+
}
535543
},
536544
"VaccineNameMenu": {
537545
"name": "VaccineNameMenu",

web/templates/influenza/schema.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1716,8 +1716,8 @@ enums:
17161716
name: UmbrellaBioprojectAccessionMenu
17171717
title: umbrella bioproject accession menu
17181718
permissible_values: {}
1719-
null value menu:
1720-
name: null value menu
1719+
NullValueMenu:
1720+
name: NullValueMenu
17211721
title: null value menu
17221722
permissible_values:
17231723
Not Applicable:
@@ -1878,7 +1878,11 @@ enums:
18781878
PresamplingActivityMenu:
18791879
name: PresamplingActivityMenu
18801880
title: presampling activity menu
1881-
permissible_values: {}
1881+
permissible_values:
1882+
Post-infection convalescence:
1883+
text: Post-infection convalescence
1884+
Vaccination:
1885+
text: Vaccination
18821886
VaccineNameMenu:
18831887
name: VaccineNameMenu
18841888
title: vaccine name menu

web/templates/influenza/schema_enums.tsv

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ title name meaning menu_1 menu_2 menu_3 menu_4 menu_5 description EXPORT_GISAID
22

33
umbrella bioproject accession menu UmbrellaBioprojectAccessionMenu
44

5-
null value menu GENEPIO:0001619 Not Applicable
5+
null value menu NullValueMenu GENEPIO:0001619 Not Applicable
66
GENEPIO:0001618 Missing
77
GENEPIO:0001620 Not Collected
88
GENEPIO:0001668 Not Provided
@@ -60,8 +60,8 @@ Related specimen relationship type menu RelatedSpecimenRelationshipTypeMenu HP:0
6060
Sequencing/bioinformatics methods development/validation
6161
Specimen sampling methods testing
6262

63-
presampling activity menu PresamplingActivityMenu Post-infection convalescence
64-
Vaccination
63+
presampling activity menu PresamplingActivityMenu Post-infection convalescence
64+
Vaccination
6565

6666

6767

0 commit comments

Comments
 (0)