Skip to content

Commit

Permalink
Merge pull request #1805 from data-team-uhn/CARDS-2575-unsubmitted-cl…
Browse files Browse the repository at this point in the history
…eanup-data-loss

CARDS-2575: Submitted IP/ED forms will be deleted if the clinic switches to Integrated Care
  • Loading branch information
sdumitriu authored Sep 6, 2024
2 parents abb3c7f + 9cb410c commit aeef21c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected void activate(final ComponentContext componentContext) throws Exceptio
{
try {
// Every night at midnight
final ScheduleOptions options = this.scheduler.EXPR("0 0 0 * * ? *");
final ScheduleOptions options = this.scheduler.EXPR("0 0 1 * * ? *");
options.name(SCHEDULER_JOB_NAME);
options.canRunConcurrently(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public void run()
(String) resolver.getResource("/Questionnaires/Visit information").getValueMap().get("jcr:uuid");
final String time =
(String) resolver.getResource("/Questionnaires/Visit information/time").getValueMap().get("jcr:uuid");
final String submitted = (String) resolver
.getResource("/Questionnaires/Visit information/surveys_submitted").getValueMap().get("jcr:uuid");
final int patientTokenLifetime = this.patientAccessConfiguration.getDaysRelativeToEventWhileSurveyIsValid();

// Find all clinics to iterate over
Expand All @@ -114,23 +112,20 @@ public void run()
+ " on clinic.form = visitInformation.[jcr:uuid]"
+ " inner join [cards:DateAnswer] as visitDate"
+ " on visitDate.form=visitInformation.[jcr:uuid]"
+ " inner join [cards:BooleanAnswer] as submitted"
+ " on submitted.form = visitInformation.[jcr:uuid]"
+ " where"
// link to the correct Visit Information questionnaire
+ " visitInformation.questionnaire = '%1$s'"
// link to the exact clinic in Visit Information form
+ " and clinic.value = '%5$s'"
+ " and clinic.value = '%4$s'"
// the visit date is in the past
+ " and visitDate.question = '%2$s'"
+ " and visitDate.value < '%4$s'"
// the visit is not submitted
+ " and submitted.question = '%3$s'"
+ " and (submitted.value <> 1 OR submitted.value IS NULL)"
+ " and visitDate.value < '%3$s'"
// the form is not submitted
+ " and not dataForm.statusFlags = 'SUBMITTED'"
// exclude the Visit Information form itself
+ " and dataForm.questionnaire <> '%1$s'"
+ " option (index tag cards)",
visitInformationQuestionnaire, time, submitted,
visitInformationQuestionnaire, time,
ZonedDateTime.now().minusDays(delay)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSxxx")), clinicPath),
Query.JCR_SQL2);
Expand Down

0 comments on commit aeef21c

Please sign in to comment.