© 2024 IQVIA - All Rights Reserved

Incomplete/Partial DateTime Logic Check

Summary

This edit check interrogates Incomplete DateTime and Partial DateTime items to ensure that the entered timing components are logical.

Logic

This edit check will elicit an alert if a ‘lower level’ timing component is specified without the the full hierarchy of ‘higher level’ components also specified. For example:

  • Seconds are specified; but not Minutes, Hours, Day, Month, and Year

  • Minutes are specified; but not Hours, Day, Month, and Year

  • Hours are specified; but not Day, Month, and Year

  • Day is specified; but not Month and Year

  • Month is specified; but not Year

Formal Expression

function isLogicalIncompleteDatetime(value) { // Split the datetime into date and time parts var parts = value.split('T'); var datePart = parts[0].split('-'); var timePart = parts.length > 1 ? parts[1].split(':') : []; // Define helper function to check if an array has any missing parts function hasMissingParts(arr) { return arr.some(function (part) { return part === null || part.trim() === ''; }); } // Check for logical date parts if (datePart.length === 3) { // Year should not be missing if (datePart[0].trim() === '') { customErrorMessage('Year is missing, but month or day is present.'); return false; } // If month is present, year should be present if (datePart[1].trim() !== '' && datePart[0].trim() === '') { customErrorMessage('Month is present, but year is missing.'); return false; } // If day is present, both year and month should be present if (datePart[2].trim() !== '' && (datePart[0].trim() === '' || datePart[1].trim() === '')) { customErrorMessage('Day is present, but year or month is missing.'); return false; } } // Check for logical time parts if (timePart.length > 0) { // Hour should not be missing if minutes or seconds are present if (timePart[0].trim() === '' && (timePart[1].trim() !== '' || timePart.length > 2 && timePart[2].trim() !== '')) { customErrorMessage('Hour is missing, but minute or second is present.'); return false; } // If minutes are present, hour should be present if (timePart[1].trim() !== '' && timePart[0].trim() === '') { customErrorMessage('Minute is present, but hour is missing.'); return false; } // If seconds are present, both hour and minute should be present if (timePart.length > 2 && timePart[2].trim() !== '' && (timePart[0].trim() === '' || timePart[1].trim() === '')) { customErrorMessage('Second is present, but hour or minute is missing.'); return false; } } // If all checks pass, the datetime is logically consistent return true; } // Execute the check on the item's value var isValid = isLogicalIncompleteDatetime(itemJson.item.value); return isValid;

Edit Check Walkthrough

https://www.loom.com/share/61d2a1a125f44ceeb2b041b50c89fa46?sid=49af9bf5-c9d1-4e04-b77b-73e4de741426

 

Exported and Printed Copies Are Uncontrolled