Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancer screening history and other updates #865

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,36 @@ import { renderVerifiedPage } from "./js/pages/verifiedPage.js";
import { firebaseConfig as devFirebaseConfig } from "./dev/config.js";
import { firebaseConfig as stageFirebaseConfig } from "./stage/config.js";
import { firebaseConfig as prodFirebaseConfig } from "./prod/config.js";
// When doing local development, uncomment this.
// Get the API key file from Box or the DevOps team
// Do not accept PRs with the localDevFirebaseConfig import uncommented
// import { firebaseConfig as localDevFirebaseConfig} from "./local-dev/config.js";

import conceptIdMap from "./js/fieldToConceptIdMapping.js";

if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("./serviceWorker.js").catch((error) => {
console.error("Service worker registration failed.", error);
return;
});

navigator.serviceWorker
.register("./serviceWorker.js")
.then((registration) => {
registration.onupdatefound = () => {
const sw = registration.installing;
if (sw) {
sw.onstatechange = () => sw.state === "activated" && sw.postMessage({ action: "getAppVersion" });
}
};
})
.catch((err) => {
console.error("Service worker registration failed.", err);
});

navigator.serviceWorker.ready.then(() => {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" });
}
const sw = navigator.serviceWorker.controller;
sw && sw.postMessage({ action: "getAppVersion" });
});

navigator.serviceWorker.addEventListener("message", (event) => {
if (event.data.action === "sendAppVersion") {
document.getElementById("appVersion").textContent = event.data.payload;
}
if (event.data.action === "sendAppVersion") {
document.getElementById("appVersion").textContent = event.data.payload;
}
});

}
}

let auth = '';
// DataDog session management -> tie Connect_ID to DataDog sessions
let isDataDogUserSessionSet = false;

const datadogConfig = {
Expand Down Expand Up @@ -93,8 +94,9 @@ window.onload = async () => {
window.DD_RUM && window.DD_RUM.init({ ...datadogConfig, env: 'stage' });
}
else if (isLocalDev) {
if (typeof localDevFirebaseConfig === 'undefined') {
console.error('Local development requires a localDevFirebaseConfig function to be defined in ./local-dev/config.js.');
const { firebaseConfig: localDevFirebaseConfig } = await import("./local-dev/config.js");
if (!localDevFirebaseConfig) {
console.error('Local development requires a firebaseConfig variable defined in ./local-dev/config.js.');
return;
}
!firebase.apps.length ? firebase.initializeApp(localDevFirebaseConfig) : firebase.app();
Expand Down
5 changes: 4 additions & 1 deletion i18n/en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion i18n/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -1353,17 +1353,6 @@ export const addEventCancerFollowUp = () => {
});
}


export const addEventHideNotification = (element) => {
const hideNotification = element.querySelectorAll('.hideNotification');
Array.from(hideNotification).forEach(btn => {
btn.addEventListener('click', () => {
btn.parentNode.parentNode.parentNode.parentNode.removeChild(btn.parentNode.parentNode.parentNode);
});
// setTimeout(() => { btn.dispatchEvent(new Event('click')) }, 5000);
});
}

export const addEventRetrieveNotifications = () => {
const btn = document.getElementById('retrieveNotifications');
if(!btn) return;
Expand Down
13 changes: 12 additions & 1 deletion js/fieldToConceptIdMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export default
"D_793330426": "ModuleCovid19",
"D_390351864": "Mouthwash",
"D_601305072": "PROMIS",
"D_506648060": "Experience2024"
"D_506648060": "Experience2024",
"D_369168474": "CancerScreeningHistory"
},

"Module1_OLD": {
Expand Down Expand Up @@ -248,6 +249,16 @@ export default
"version": "905236593"
},

CancerScreeningHistory: {
"conceptId": "D_369168474",
"startTs": "609630315",
"completeTs": "389890053",
"statusFlag": "176068627",
"standaloneSurvey": true,
"version": "350996955",
"questVersion": "562804752",
},

// @deprecated. Retain until migration to Quest2 is complete. External variables passed into Quest that require extra async/await handling.
delayedParameterArray: [
"D_761310265",
Expand Down
44 changes: 31 additions & 13 deletions js/pages/myToDoList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML, translateText} from "../shared.js";
import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML, translateText, getAdjustedTime } from "../shared.js";
import { blockParticipant, questionnaire } from "./questionnaire.js";
import { renderUserProfile } from "../components/form.js";
import { consentTemplate } from "./consent.js";
Expand Down Expand Up @@ -310,18 +310,14 @@ export const myToDoList = async (data, fromUserProfile, collections) => {
}

const addEventToDoList = () => {
const modules = document.getElementsByClassName('questionnaire-module');

Array.from(modules).forEach(module => {
module.addEventListener('click',() => {

if (!module.classList.contains("btn-disabled")) {
const moduleId = module.getAttribute("module_id");
questionnaire(moduleId);
}
});
const enabledButtons = document.querySelectorAll("button.questionnaire-module:not(.btn-disabled)");
enabledButtons.forEach((btn) => {
if (!btn.hasClickListener) {
btn.addEventListener("click", () => questionnaire(btn.getAttribute("module_id")));
btn.hasClickListener = true;
}
});
}
};

const renderMainBody = (data, collections, tab) => {
let template = `<ul class="questionnaire-module-list" role="list">`;
Expand Down Expand Up @@ -382,6 +378,8 @@ const renderMainBody = (data, collections, tab) => {
toDisplaySystem.unshift({'body':['Connect Experience 2024']});
}

modules["Cancer Screening History"].enabled && toDisplaySystem.unshift({ body: ["Cancer Screening History"] });

if(tab === 'todo'){
for(let obj of toDisplaySystem){
let started = false;
Expand Down Expand Up @@ -648,7 +646,7 @@ const checkForNewSurveys = async (data, collections) => {

if(newSurvey) {
template += `
<div class="alert alert-warning" id="verificationMessage" style="margin-top:10px;" data-i18n="mytodolist.newSurvey">>
<div class="alert alert-warning" id="verificationMessage" style="margin-top:10px;" data-i18n="mytodolist.newSurvey">
You have a new survey to complete.
</div>
`;
Expand Down Expand Up @@ -734,6 +732,12 @@ const setModuleAttributes = (data, modules, collections) => {
modules['Connect Experience 2024'].header = '2024 Connect Experience Survey';
modules['Connect Experience 2024'].description = 'mytodolist.mainBodyExperience2024Description';
modules['Connect Experience 2024'].estimatedTime = 'mytodolist.15_20minutes';

modules['Cancer Screening History'].header = 'Cancer Screening History Survey';
modules['Cancer Screening History'].description = 'mytodolist.mainBodyCancerScreeningHistoryDescription';
modules['Cancer Screening History'].estimatedTime = 'mytodolist.15_20minutes';

const currentTime = new Date();

if(data['331584571']?.['266600170']?.['840048338']) {
modules['Biospecimen Survey'].enabled = true;
Expand Down Expand Up @@ -861,5 +865,19 @@ const setModuleAttributes = (data, modules, collections) => {
modules['Connect Experience 2024'].completed = true;
}

if (
data[fieldMapping.verification] === fieldMapping.verified &&
data[fieldMapping.verifiedDate] &&
currentTime > getAdjustedTime(data[fieldMapping.verifiedDate], 270)
) {
if (data[fieldMapping.CancerScreeningHistory.statusFlag]) {
modules["Cancer Screening History"].enabled = true;
}

if (data[fieldMapping.CancerScreeningHistory.statusFlag] === fieldMapping.moduleStatus.submitted) {
modules["Cancer Screening History"].completed = true;
}
}

return modules;
};
Loading