-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Schedule un-activate patients not updated in the last year.
- Loading branch information
1 parent
6c9284e
commit fba3987
Showing
5 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/systelab/seed/service/PatientMaintenanceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.systelab.seed.service; | ||
|
||
import com.systelab.seed.repository.PatientRepository; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Calendar; | ||
|
||
@Service | ||
public class PatientMaintenanceService { | ||
|
||
private Logger logger = LoggerFactory.getLogger(PatientMaintenanceService.class); | ||
|
||
@Autowired | ||
private PatientRepository patientRepository; | ||
|
||
@Scheduled(cron = "${patient.maintenance.cron.expression}") | ||
public void schedulePurgeOlderRecordsTask() { | ||
Calendar cal = Calendar.getInstance(); | ||
cal.add(Calendar.YEAR, -1); | ||
this.patientRepository.setActiveForUpdatedBefore(cal.getTime()); | ||
logger.info("Patients DB purged!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters