From 37a70a2463561f3b504c3769d3b10505e7f3dac3 Mon Sep 17 00:00:00 2001 From: Warren Lu Date: Tue, 2 Apr 2024 15:32:16 -0400 Subject: [PATCH 01/22] fix failed conceptId parsing. cleanups --- siteManagerDashboard/participantHeader.js | 139 ++++++---------------- 1 file changed, 39 insertions(+), 100 deletions(-) diff --git a/siteManagerDashboard/participantHeader.js b/siteManagerDashboard/participantHeader.js index 313347d..5d7eb84 100644 --- a/siteManagerDashboard/participantHeader.js +++ b/siteManagerDashboard/participantHeader.js @@ -2,82 +2,39 @@ import fieldMapping from './fieldToConceptIdMapping.js'; import { humanReadableMDY } from './utils.js'; import { keyToNameObj } from './idsToName.js'; -export const headerImportantColumns = [ - { field: 'Connect_ID' }, - { field: fieldMapping.fName }, - { field: fieldMapping.lName }, - { field: fieldMapping.birthYear }, - { field: fieldMapping.consentFlag }, - { field: fieldMapping.verifiedFlag }, - { field: 'Site' }, - { field: 'Year(s) in Connect' }, - { field: 'Participation Status'}, - { field: 'Suspended Contact'} -]; - - export const renderParticipantHeader = (participant) => { - - let conceptIdMapping = JSON.parse(localStorage.getItem('conceptIdMapping')); - let template = `' - - return template; -} + const readableVerificationDate = humanReadableMDY(participant[fieldMapping.verficationDate]); + let verificationHtmlStr = ""; + if (participant[fieldMapping.verifiedFlag] === fieldMapping.verified) { + verificationHtmlStr = `Verified: ${readableVerificationDate}`; + } else if (participant[fieldMapping.verifiedFlag] === fieldMapping.cannotBeVerified) { + verificationHtmlStr = `Can't Be Verified: ${readableVerificationDate}`; + } else if (participant[fieldMapping.verifiedFlag] === fieldMapping.notYetVerified) { + verificationHtmlStr = `Not Yet Verified: N/A`; + } else if (participant[fieldMapping.verifiedFlag] === fieldMapping.duplicate) { + verificationHtmlStr = `Duplicate: ${readableVerificationDate}`; + } else { + verificationHtmlStr = `Outreach Timed Out: ${readableVerificationDate}`; + } + + return ` + `; +}; // Year(s) in Connect : 1 const getYearsInConnect = (participant) => { @@ -92,22 +49,12 @@ const getYearsInConnect = (participant) => { totalYears <= 0 ? totalYears = '< 1' : totalYears; let yearsInConnect = totalYears; return typeof(yearsInConnect) !== 'string' && isNaN(yearsInConnect) ? 'N/A' : yearsInConnect; -} - - - -const concatDOB = (participant) => { - const participantBirthMonth = participant[fieldMapping.birthMonth]; - const participantBirthDate = participant[fieldMapping.birthDay]; - const participantBirthYear = participant[fieldMapping.birthYear]; - return participantBirthMonth && participantBirthDate && participantBirthYear ? participantBirthMonth + '/' + participantBirthDate + '/' + participantBirthYear : 'data deleted'; // 07/02/1966 or 'data deleted' - -} +}; const renderSiteLocation = (participant) => { const siteHealthcareProvider = participant[fieldMapping.healthcareProvider]; return keyToNameObj[siteHealthcareProvider]; -} +}; export const getParticipantStatus = (participant) => { if (typeof participant !== "string") { @@ -120,20 +67,12 @@ export const getParticipantStatus = (participant) => { } }; -const getEnrollmentStatus = (participant) => { - if (typeof participant !== "string") { - const statusValue = participant[fieldMapping.enrollmentStatus]; - if (statusValue !== undefined && statusValue !== `` ) return fieldMapping[statusValue]; - else return `Error`; - } -} - export const getParticipantSuspendedDate = (participant) => { if (participant[fieldMapping.suspendContact] !== "" && participant[fieldMapping.suspendContact] !== undefined ) { let suspendContactRequestedFrom = humanReadableMDY(participant[fieldMapping.startDateSuspendedContact]); - let suspendedDate = participant[fieldMapping.suspendContact] - return `Suspended Contact : From: ${suspendContactRequestedFrom} To: ${suspendedDate}` - } else { - return `` + let suspendedDate = participant[fieldMapping.suspendContact]; + return `Suspended Contact : From: ${suspendContactRequestedFrom} To: ${suspendedDate}`; } -} \ No newline at end of file + + return ""; +}; From b7aa054f6f0a606a37f5dea14c3094bf803834c4 Mon Sep 17 00:00:00 2001 From: Warren Lu Date: Tue, 2 Apr 2024 16:34:43 -0400 Subject: [PATCH 02/22] fix errors of null and undefined --- .../notifications/storeNotifications.js | 2 +- siteManagerDashboard/participantCommons.js | 4 +- .../participantDetailsHelpers.js | 2 +- siteManagerDashboard/participantHeader.js | 2 +- siteManagerDashboard/participantWithdrawal.js | 46 +++++++++++-------- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/siteManagerDashboard/notifications/storeNotifications.js b/siteManagerDashboard/notifications/storeNotifications.js index 6fdda92..35146dd 100644 --- a/siteManagerDashboard/notifications/storeNotifications.js +++ b/siteManagerDashboard/notifications/storeNotifications.js @@ -187,7 +187,7 @@ export const mapSchemaNotificaiton = (updateSchemaNotification, concepts, flag) if (i === "sms") { document.getElementById('smsCheckBox').checked = true; renderDivs("sms", flag); - document.getElementById('smsBody').value = updateSchemaNotification.sms.body; + document.getElementById('smsBody').value = updateSchemaNotification.sms.body; // handle null document.getElementById('characterCounts').innerText = `${updateSchemaNotification.sms.body.length}/160 characters`; localStorage.setItem("smsCheck", true); } diff --git a/siteManagerDashboard/participantCommons.js b/siteManagerDashboard/participantCommons.js index 48ad16e..ee12a13 100644 --- a/siteManagerDashboard/participantCommons.js +++ b/siteManagerDashboard/participantCommons.js @@ -938,14 +938,14 @@ export const activeColumns = (data, showButtons) => { } if (appState.getState().filterHolder.type === "passive") { let passiveButton = document.getElementById('passiveFilter'); - if ([...passiveButton.classList].includes('btn-outline-info')) { + if (passiveButton && [...passiveButton.classList].includes('btn-outline-info')) { passiveButton.classList.remove('btn-outline-info'); passiveButton.classList.add('btn-info'); } } if (appState.getState().filterHolder.type === "active") { let activeButton = document.getElementById('activeFilter'); - if ([...activeButton.classList].includes('btn-outline-info')) { + if (activeButton && [...activeButton.classList].includes('btn-outline-info')) { activeButton.classList.remove('btn-outline-info'); activeButton.classList.add('btn-info'); } diff --git a/siteManagerDashboard/participantDetailsHelpers.js b/siteManagerDashboard/participantDetailsHelpers.js index eb80447..1ca60f5 100644 --- a/siteManagerDashboard/participantDetailsHelpers.js +++ b/siteManagerDashboard/participantDetailsHelpers.js @@ -790,7 +790,7 @@ export const saveResponses = (participant, changedOption, editedElement, concept changedOption[currentConceptId] = newValueElement.value; // if a changed field is a date of birth field then we need to update full date of birth if (fieldMapping.birthDay in changedOption || fieldMapping.birthMonth in changedOption || fieldMapping.birthYear in changedOption) { - const day = changedOption[fieldMapping.birthDay] || participant[fieldMapping.birthDay]; + const day = changedOption[fieldMapping.birthDay] || participant[fieldMapping.birthDay] || '01'; // Not ideal here const month = changedOption[fieldMapping.birthMonth] || participant[fieldMapping.birthMonth]; const year = changedOption[fieldMapping.birthYear] || participant[fieldMapping.birthYear]; const dateOfBirthComplete = fieldMapping.dateOfBirthComplete; diff --git a/siteManagerDashboard/participantHeader.js b/siteManagerDashboard/participantHeader.js index 5d7eb84..71e7ee1 100644 --- a/siteManagerDashboard/participantHeader.js +++ b/siteManagerDashboard/participantHeader.js @@ -26,7 +26,7 @@ export const renderParticipantHeader = (participant) => { ${ participant[fieldMapping.consentFlag] === fieldMapping.yes ? `Consented: ${humanReadableMDY(participant[fieldMapping.consentDate])}` - : "Not Consented: N/A " + : "Not Consented: N/A" }   ${verificationHtmlStr}   Site: ${renderSiteLocation(participant)}   diff --git a/siteManagerDashboard/participantWithdrawal.js b/siteManagerDashboard/participantWithdrawal.js index 6305f32..1aabf9a 100644 --- a/siteManagerDashboard/participantWithdrawal.js +++ b/siteManagerDashboard/participantWithdrawal.js @@ -68,25 +68,33 @@ const checkPreviousWithdrawalStatus = (participant) => { } const getParticipantSelectedRefusals = (participant) => { - let template = `` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedSurvey] === fieldMapping.yes ) template += `Initial Survey​, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedBlood] === fieldMapping.yes ) template += `Baseline Blood Donation, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedUrine] === fieldMapping.yes ) template += `Baseline Urine Donation, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedMouthwash] === fieldMapping.yes ) template += `Baseline Mouthwash (Saliva) Donation, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedSpecimenSurveys] === fieldMapping.yes ) template += `Baseline Specimen Surveys, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedFutureSamples] === fieldMapping.yes ) template += `All future specimens (willing to do surveys)​​, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedQualityOfLifeSurvey] === fieldMapping.yes ) template += `Refused QOL survey 3-mo (but willing to do other future surveys)​, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedAllFutureQualityOfLifeSurveys] === fieldMapping.yes ) template += `Refused all future QOL surveys (but willing to do other future surveys)​, ` - if (participant[fieldMapping.refusalOptions][fieldMapping.refusedFutureSurveys] === fieldMapping.yes ) template += `All future surveys (willing to do specimens)​, ` - if (participant[fieldMapping.refusedAllFutureActivities] === fieldMapping.yes ) template += `All Future Study Activities, ` - if (participant[fieldMapping.revokeHIPAA] === fieldMapping.yes ) template += `Revoke HIPAA Authorization, ` - if (participant[fieldMapping.withdrawConsent] === fieldMapping.yes ) template += `Withdraw Consent​, ` - if (participant[fieldMapping.destroyData] === fieldMapping.yes ) template += `Destroy Data​, ` - if (participant[fieldMapping.participantDeceased] === fieldMapping.yes ) template += `Participant Deceased, ` + let strArray = []; + const refusalOptions = participant[fieldMapping.refusalOptions]; - template = template.replace(/,\s*$/, "") // removes comma from the end + if (refusalOptions) { + if (refusalOptions[fieldMapping.refusedSurvey] === fieldMapping.yes) strArray.push("Initial Survey"); + if (refusalOptions[fieldMapping.refusedBlood] === fieldMapping.yes) strArray.push("Baseline Blood Donation"); + if (refusalOptions[fieldMapping.refusedUrine] === fieldMapping.yes) strArray.push("Baseline Urine Donation"); + if (refusalOptions[fieldMapping.refusedMouthwash] === fieldMapping.yes) + strArray.push("Baseline Mouthwash (Saliva) Donation"); + if (refusalOptions[fieldMapping.refusedSpecimenSurveys] === fieldMapping.yes) + strArray.push("Baseline Specimen Surveys"); + if (refusalOptions[fieldMapping.refusedFutureSamples] === fieldMapping.yes) + strArray.push("All future specimens (willing to do surveys)"); + if (refusalOptions[fieldMapping.refusedQualityOfLifeSurvey] === fieldMapping.yes) + strArray.push("Refused QOL survey 3-mo (but willing to do other future surveys)"); + if (refusalOptions[fieldMapping.refusedAllFutureQualityOfLifeSurveys] === fieldMapping.yes) + strArray.push("Refused all future QOL surveys (but willing to do other future surveys)"); + if (refusalOptions[fieldMapping.refusedFutureSurveys] === fieldMapping.yes) + strArray.push("All future surveys (willing to do specimens)"); + } - return template - -} + if (participant[fieldMapping.refusedAllFutureActivities] === fieldMapping.yes) + strArray.push("All Future Study Activities"); + if (participant[fieldMapping.revokeHIPAA] === fieldMapping.yes) strArray.push("Revoke HIPAA Authorization"); + if (participant[fieldMapping.withdrawConsent] === fieldMapping.yes) strArray.push("Withdraw Consent"); + if (participant[fieldMapping.destroyData] === fieldMapping.yes) strArray.push("Destroy Data"); + if (participant[fieldMapping.participantDeceased] === fieldMapping.yes) strArray.push("Participant Deceased"); + return strArray.join(", "); +}; From 3c543d7c20e93671553942087d1f6f30b1ffcc7f Mon Sep 17 00:00:00 2001 From: Warren Lu Date: Tue, 2 Apr 2024 16:40:40 -0400 Subject: [PATCH 03/22] fix missing sms --- siteManagerDashboard/notifications/storeNotifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siteManagerDashboard/notifications/storeNotifications.js b/siteManagerDashboard/notifications/storeNotifications.js index 35146dd..d2edce4 100644 --- a/siteManagerDashboard/notifications/storeNotifications.js +++ b/siteManagerDashboard/notifications/storeNotifications.js @@ -187,7 +187,7 @@ export const mapSchemaNotificaiton = (updateSchemaNotification, concepts, flag) if (i === "sms") { document.getElementById('smsCheckBox').checked = true; renderDivs("sms", flag); - document.getElementById('smsBody').value = updateSchemaNotification.sms.body; // handle null + document.getElementById('smsBody').value = updateSchemaNotification.sms?.body ?? ""; document.getElementById('characterCounts').innerText = `${updateSchemaNotification.sms.body.length}/160 characters`; localStorage.setItem("smsCheck", true); } From 331790bf193a7f4416d32aa833075e9b59205bcd Mon Sep 17 00:00:00 2001 From: Warren Lu Date: Wed, 3 Apr 2024 15:00:20 -0400 Subject: [PATCH 04/22] get birthDay from dateOfBirthComplete --- siteManagerDashboard/participantDetailsHelpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/siteManagerDashboard/participantDetailsHelpers.js b/siteManagerDashboard/participantDetailsHelpers.js index 1ca60f5..b541a7f 100644 --- a/siteManagerDashboard/participantDetailsHelpers.js +++ b/siteManagerDashboard/participantDetailsHelpers.js @@ -790,7 +790,7 @@ export const saveResponses = (participant, changedOption, editedElement, concept changedOption[currentConceptId] = newValueElement.value; // if a changed field is a date of birth field then we need to update full date of birth if (fieldMapping.birthDay in changedOption || fieldMapping.birthMonth in changedOption || fieldMapping.birthYear in changedOption) { - const day = changedOption[fieldMapping.birthDay] || participant[fieldMapping.birthDay] || '01'; // Not ideal here + const day = changedOption[fieldMapping.birthDay] || participant[fieldMapping.birthDay] || participant[fieldMapping.dateOfBirthComplete]?.slice(6,8) || "01"; const month = changedOption[fieldMapping.birthMonth] || participant[fieldMapping.birthMonth]; const year = changedOption[fieldMapping.birthYear] || participant[fieldMapping.birthYear]; const dateOfBirthComplete = fieldMapping.dateOfBirthComplete; @@ -801,7 +801,7 @@ export const saveResponses = (participant, changedOption, editedElement, concept updateUIValues(editedElement, newValueElement.value, conceptIdArray); changedOption = forceDataTypesForFirestore(changedOption); closeModal(); - }; + } } else { showAlreadyExistsNoteInModal(); } From b2907754c4b244e2847821a44f1195fc6f00bee8 Mon Sep 17 00:00:00 2001 From: Warren Lu Date: Wed, 3 Apr 2024 15:19:28 -0400 Subject: [PATCH 05/22] minor adjustments --- siteManagerDashboard/participantHeader.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/siteManagerDashboard/participantHeader.js b/siteManagerDashboard/participantHeader.js index 71e7ee1..bd8abc9 100644 --- a/siteManagerDashboard/participantHeader.js +++ b/siteManagerDashboard/participantHeader.js @@ -18,15 +18,15 @@ export const renderParticipantHeader = (participant) => { } return ` -