Skip to content

Commit

Permalink
Taking {UPPER_CASE} out of Mpox pattern field
Browse files Browse the repository at this point in the history
And fix to "host vaccination status menu" range to     "HostVaccinationStatusMenu"
  • Loading branch information
ddooley committed Dec 24, 2024
1 parent b19ecbc commit 1690b59
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 72 deletions.
48 changes: 24 additions & 24 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2468,45 +2468,49 @@ class DataHarmonizer {
let matrixRow = matrix[row];
matrixRow[col] = change[3]; // prime changed value

const prevName = col > 0 ? fields[col - 1].title : null;
const nextName = fields.length > col + 1 ? fields[col + 1].title : null;
const prevName = col > 0 ? fields[col - 1].name : null;
const nextName = fields.length > col + 1 ? fields[col + 1].name : null;

// Match <field>[field unit]
if (nextName === field.title + ' unit') {
// On [field] where next field is [field unit]
if (nextName === field.name + '_unit') {
if (field.datatype === 'xsd:date') {
// Transform ISO 8601 date to bin year / month granularity.
// This literally resets day or month to /01/ value based on
// granularity, for information accuracy or obfuscation purposes.
// "day" granularity is taken care of by regular date validation.
// Don't attempt to reformat x/y/z dates here.
const dateGranularity = this.hot.getDataAtCell(row, col + 1);
const dateGranularity = this.hot.getDataAtCell(row, col + 1).split(' ')[0];
// previously had to block x/y/z with change[3].indexOf('/') === -1 &&
if (dateGranularity === 'year' || dateGranularity === 'month') {
change[3] = this.setDateChange(dateGranularity, change[3]);
}
return;
}

// Match <field>[field unit][field bin]
/* Deprecating this. Users need to change unit to trigger bin
// Match <field> [field]_unit [field]_bin
const nextNextName =
fields.length > col + 2 ? fields[col + 2].title : null;
if (nextNextName === field.title + ' bin') {
fields.length > col + 2 ? fields[col + 2].name : null;
if (nextNextName === field.name + '_bin') {
matrixRow[col + 1] = this.hot.getDataAtCell(row, col + 1); //prime unit
matrixRow[col + 2] = this.hot.getDataAtCell(row, col + 2); //prime bin
this.binChangeTest(matrix, col, fields, 2, triggered_changes);
return;
}
*/
}

// Match <field>[field bin]
if (nextName === field.title + ' bin') {
// On [field] here, where next column is "[field]_bin".
if (nextName === field.name + '_bin') {
matrixRow[col + 1] = this.hot.getDataAtCell(row, col + 1); //prime bin
this.binChangeTest(matrix, col, fields, 1, triggered_changes);
return;
}

// Match [field]<field unit>
if (field.title === prevName + ' unit') {
// Match [field]<field unit>[field bin]
if (prevName + ' bin' === nextName) {
// On "[field] unit" here, where next column is [field]_bin.
if (field.name === prevName + '_unit') {
if (prevName + '_bin' === nextName) {
console.log("on", prevName + '_unit')
// trigger reevaluation of bin from field
matrixRow[col - 1] = this.hot.getDataAtCell(row, col - 1);
matrixRow[col] = this.hot.getDataAtCell(row, col);
Expand Down Expand Up @@ -2563,20 +2567,20 @@ class DataHarmonizer {

// Rules that require a column or two following current one.
if (fields.length > col + 1) {
const nexttitle = fields[col + 1].title;
const nexttitle = fields[col + 1].name;

// Rule: for any <x>[x bin] pattern of field names,
// find and set appropriate bin selection.
if (nexttitle === field.title + ' bin') {
if (nexttitle === field.name + '_bin') {
this.binChangeTest(matrix, col, fields, 1, triggered_changes);
}
// Rule: for any [x], [x unit], [x bin] series of fields
else if (nexttitle === field.title + ' unit') {
else if (nexttitle === field.name + '_unit') {
if (fields[col].datatype === 'xsd:date') {
//Validate
for (let row = 0; row < matrix.length; row++) {
if (!matrix[row][col]) continue;
const dateGranularity = matrix[row][col + 1];
const dateGranularity = matrix[row][col + 1].split(' ')[0];
if (dateGranularity === 'year' || dateGranularity === 'month') {
matrix[row][col] = this.setDateChange(
dateGranularity,
Expand Down Expand Up @@ -2666,15 +2670,12 @@ class DataHarmonizer {
// Host age unit is interpreted by default to be year.
// If user selects month, value is converted into years for binning.
// Future solution won't hardcode month / year assumption
// ENGLISH ONLY: value might be suffixed with ontology id.
if (unit) {
if (unit === 'month') {
if (unit.split(' ',1)[0] === 'month') {
number = number / 12;
}
}
// Force unit to be year if empty.
//else {
// triggered_changes.push([rowOffset + parseInt(row), col+1, undefined, 'year']);
//}
}
// .flatVocabulary is an array of string bin ranges e.g. "10 - 19"
// if (typeof fields[hotRowBinCol].flatVocabulary !== 'undefined') {
Expand All @@ -2699,7 +2700,6 @@ class DataHarmonizer {
const bin_values = fields[hotRowBinCol].flatVocabulary;
if (value in bin_values && (!bin_value || bin_value === '')) {
selection = value;
console.log('no bin value', value);
}
// If a unit field exists, then set that to metadata too.
if (binOffset == 2) {
Expand Down
4 changes: 2 additions & 2 deletions web/templates/canada_covid19/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7382,7 +7382,7 @@
],
"any_of": [
{
"range": "host vaccination status menu"
"range": "HostVaccinationStatusMenu"
},
{
"range": "NullValueMenu"
Expand Down Expand Up @@ -12338,7 +12338,7 @@
"slot_group": "Host vaccination information",
"any_of": [
{
"range": "host vaccination status menu"
"range": "HostVaccinationStatusMenu"
},
{
"range": "NullValueMenu"
Expand Down
2 changes: 1 addition & 1 deletion web/templates/canada_covid19/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ slots:
comments: Select the vaccination status of the host from the pick list.
slot_uri: GENEPIO:0001404
any_of:
- range: host vaccination status menu
- range: HostVaccinationStatusMenu
- range: NullValueMenu
examples:
- value: Fully Vaccinated
Expand Down
2 changes: 1 addition & 1 deletion web/templates/canada_covid19/schema_slots.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CanCOGeNCovid19 GENEPIO:0001122 Database Identifiers
Host Information Informations sur l'hôte GENEPIO:0001401 pre-existing conditions and risk factors preexisting_conditions_and_risk_factors Conditions préexistantes et facteurs de risque PreExistingConditionsAndRiskFactorsMenu NullValueMenu TRUE Patient pre-existing conditions and risk factors. <li>Pre-existing condition: A medical condition that existed prior to the current infection. <li>Risk Factor: A variable associated with an increased risk of disease or infection. Conditions préexistantes et facteurs de risque du patient <li>Condition préexistante : Condition médicale qui existait avant l’infection actuelle <li>Facteur de risque : Variable associée à un risque accru de maladie ou d’infection  Select all of the pre-existing conditions and risk factors experienced by the host from the pick list. If the desired term is missing, contact the curation team. Sélectionnez toutes les conditions préexistantes et tous les facteurs de risque de l’hôte à partir de la liste de sélection. S’il manque le terme souhaité, veuillez communiquer avec l’équipe de conservation des données. Asthma; Pregnancy; Smoking Asthme; grossesse; tabagisme pre-existing conditions and risk factors
Host Information Informations sur l'hôte GENEPIO:0001402 complications complications Complications ComplicationsMenu NullValueMenu TRUE Patient medical complications that are believed to have occurred as a result of host disease. Complications médicales du patient qui seraient dues à une maladie de l’hôte Select all of the complications experienced by the host from the pick list. If the desired term is missing, contact the curation team. Sélectionnez toutes les complications éprouvées par l’hôte à partir de la liste de sélection. S’il manque le terme souhaité, veuillez communiquer avec l’équipe de conservation des données. Acute Respiratory Failure; Coma; Septicemia Insuffisance respiratoire aiguë; coma; septicémie complications
GENEPIO:0001403 Host vaccination information
Host vaccination information Informations sur la vaccination de l'hôte GENEPIO:0001404 host vaccination status host_vaccination_status Statut de vaccination de l’hôte host vaccination status menu NullValueMenu The vaccination status of the host (fully vaccinated, partially vaccinated, or not vaccinated). Statut de vaccination de l’hôte (entièrement vacciné, partiellement vacciné ou non vacciné) Select the vaccination status of the host from the pick list. Sélectionnez le statut de vaccination de l’hôte à partir de la liste de sélection. Fully Vaccinated Entièrement vacciné PH_VACCINATION_HISTORY
Host vaccination information Informations sur la vaccination de l'hôte GENEPIO:0001404 host vaccination status host_vaccination_status Statut de vaccination de l’hôte HostVaccinationStatusMenu NullValueMenu The vaccination status of the host (fully vaccinated, partially vaccinated, or not vaccinated). Statut de vaccination de l’hôte (entièrement vacciné, partiellement vacciné ou non vacciné) Select the vaccination status of the host from the pick list. Sélectionnez le statut de vaccination de l’hôte à partir de la liste de sélection. Fully Vaccinated Entièrement vacciné PH_VACCINATION_HISTORY
Host vaccination information Informations sur la vaccination de l'hôte GENEPIO:0001406 number of vaccine doses received number_of_vaccine_doses_received Nombre de doses du vaccin reçues integer The number of doses of the vaccine recived by the host. Nombre de doses du vaccin reçues par l’hôte Record how many doses of the vaccine the host has received. Enregistrez le nombre de doses du vaccin que l’hôte a reçues. 2 2
Host vaccination information Informations sur la vaccination de l'hôte GENEPIO:0100313 vaccination dose 1 vaccine name vaccination_dose_1_vaccine_name Dose du vaccin 1 – Nom du vaccin VaccineNameMenu NullValueMenu The name of the vaccine administered as the first dose of a vaccine regimen. Nom du vaccin administré comme première dose d’un schéma vaccinal Provide the name and the corresponding manufacturer of the COVID-19 vaccine administered as the first dose by selecting a value from the pick list Fournissez le nom et le fabricant correspondant du vaccin contre la COVID-19 administré comme première dose en sélectionnant une valeur à partir de la liste de sélection. Pfizer-BioNTech (Comirnaty) Pfizer-BioNTech (Comirnaty) PH_VACCINATION_HISTORY
Host vaccination information Informations sur la vaccination de l'hôte GENEPIO:0100314 vaccination dose 1 vaccination date vaccination_dose_1_vaccination_date Dose du vaccin 1 – Date du vaccin date NullValueMenu {today} The date the first dose of a vaccine was administered. Date à laquelle la première dose d’un vaccin a été administrée Provide the date the first dose of COVID-19 vaccine was administered. The date should be provided in ISO 8601 standard format "YYYY-MM-DD". Indiquez la date à laquelle la première dose du vaccin contre la COVID-19 a été administrée. La date doit être fournie selon le format standard ISO 8601 « AAAA-MM-DD ». 2021-03-01 2021-03-01 PH_VACCINATION_HISTORY
Expand Down
35 changes: 7 additions & 28 deletions web/templates/mpox/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9909,7 +9909,6 @@
"MpoxInternational"
],
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -9939,7 +9938,6 @@
"MpoxInternational"
],
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -10009,7 +10007,7 @@
],
"examples": [
{
"value": "BC Centre for Disease Control"
"value": "BCCDC Public Health Laboratory"
}
],
"from_schema": "https://example.com/mpox",
Expand Down Expand Up @@ -10535,7 +10533,7 @@
},
"collection_method": {
"name": "collection_method",
"description": "The process used to collect the sample e.g. phlebotamy, necropsy.",
"description": "The process used to collect the sample e.g. phlebotomy, necropsy.",
"title": "collection method",
"comments": [
"Provide a descriptor if a collection method was used for sampling. Use the picklist provided in the template. If a desired term is missing from the picklist, contact [email protected]. If not applicable, do not leave blank. Choose a null value."
Expand Down Expand Up @@ -10907,12 +10905,7 @@
"domain_of": [
"Mpox",
"MpoxInternational"
],
"structured_pattern": {
"syntax": "{Title_Case}",
"interpolated": true,
"partial_match": false
}
]
},
"host_residence_geo_loc_name_country": {
"name": "host_residence_geo_loc_name_country",
Expand Down Expand Up @@ -15091,7 +15084,6 @@
],
"slot_group": "Database Identifiers",
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -15125,7 +15117,6 @@
],
"slot_group": "Database Identifiers",
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -15176,7 +15167,7 @@
],
"examples": [
{
"value": "BC Centre for Disease Control"
"value": "BCCDC Public Health Laboratory"
}
],
"from_schema": "https://example.com/mpox",
Expand Down Expand Up @@ -15839,7 +15830,7 @@
},
"collection_method": {
"name": "collection_method",
"description": "The process used to collect the sample e.g. phlebotamy, necropsy.",
"description": "The process used to collect the sample e.g. phlebotomy, necropsy.",
"title": "collection method",
"comments": [
"Provide a descriptor if a collection method was used for sampling. Use the picklist provided in the template. If a desired term is missing from the picklist, contact [email protected]. If not applicable, do not leave blank. Choose a null value."
Expand Down Expand Up @@ -16350,11 +16341,6 @@
],
"slot_group": "Host Information",
"required": true,
"structured_pattern": {
"syntax": "{Title_Case}",
"interpolated": true,
"partial_match": false
},
"any_of": [
{
"range": "HostGenderMenu"
Expand Down Expand Up @@ -20233,7 +20219,6 @@
],
"slot_group": "Database Identifiers",
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -20267,7 +20252,6 @@
],
"slot_group": "Database Identifiers",
"range": "WhitespaceMinimizedString",
"pattern": "{UPPER_CASE}",
"structured_pattern": {
"syntax": "{UPPER_CASE}",
"interpolated": true,
Expand Down Expand Up @@ -20345,7 +20329,7 @@
],
"examples": [
{
"value": "BC Centre for Disease Control"
"value": "BCCDC Public Health Laboratory"
}
],
"from_schema": "https://example.com/mpox",
Expand Down Expand Up @@ -20990,7 +20974,7 @@
},
"collection_method": {
"name": "collection_method",
"description": "The process used to collect the sample e.g. phlebotamy, necropsy.",
"description": "The process used to collect the sample e.g. phlebotomy, necropsy.",
"title": "collection method",
"comments": [
"Provide a descriptor if a collection method was used for sampling. Use the picklist provided in the template. If a desired term is missing from the picklist, contact [email protected]. If not applicable, do not leave blank. Choose a null value."
Expand Down Expand Up @@ -21611,11 +21595,6 @@
],
"slot_group": "Host Information",
"recommended": true,
"structured_pattern": {
"syntax": "{Title_Case}",
"interpolated": true,
"partial_match": false
},
"any_of": [
{
"range": "HostGenderInternationalMenu"
Expand Down
10 changes: 2 additions & 8 deletions web/templates/mpox/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,6 @@ slots:
Sequence Archive (GSA) accessions start with CRR.
slot_uri: GENEPIO:0101203
range: WhitespaceMinimizedString
pattern: '{UPPER_CASE}'
structured_pattern:
syntax: '{UPPER_CASE}'
partial_match: false
Expand All @@ -1773,7 +1772,6 @@ slots:
the GenBank accession version.
slot_uri: GENEPIO:0101204
range: WhitespaceMinimizedString
pattern: '{UPPER_CASE}'
structured_pattern:
syntax: '{UPPER_CASE}'
partial_match: false
Expand Down Expand Up @@ -1828,7 +1826,7 @@ slots:
slot_uri: GENEPIO:0001153
required: true
examples:
- value: BC Centre for Disease Control
- value: BCCDC Public Health Laboratory
sample_collector_contact_email:
name: sample_collector_contact_email
title: sample collector contact email
Expand Down Expand Up @@ -2155,7 +2153,7 @@ slots:
collection_method:
name: collection_method
title: collection method
description: The process used to collect the sample e.g. phlebotamy, necropsy.
description: The process used to collect the sample e.g. phlebotomy, necropsy.
comments: Provide a descriptor if a collection method was used for sampling. Use
the picklist provided in the template. If a desired term is missing from the
picklist, contact [email protected]. If not applicable, do not leave blank.
Expand Down Expand Up @@ -2355,10 +2353,6 @@ slots:
description: The gender of the host at the time of sample collection.
comments: If known, select a value from the pick list.
slot_uri: GENEPIO:0001395
structured_pattern:
syntax: '{Title_Case}'
partial_match: false
interpolated: true
host_residence_geo_loc_name_country:
name: host_residence_geo_loc_name_country
title: host residence geo_loc name (country)
Expand Down
Loading

0 comments on commit 1690b59

Please sign in to comment.