From 8568dc88eb16ef2ec24225ec6ea4b32865e037a2 Mon Sep 17 00:00:00 2001 From: ritik-bizbrolly Date: Thu, 2 Jul 2026 15:44:21 +0530 Subject: [PATCH] PNC . change logic 42 days to 60 days --- .../org/piramalswasthya/sakhi/database/room/dao/BenDao.kt | 5 +++-- .../org/piramalswasthya/sakhi/repositories/RecordsRepo.kt | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/piramalswasthya/sakhi/database/room/dao/BenDao.kt b/app/src/main/java/org/piramalswasthya/sakhi/database/room/dao/BenDao.kt index 7e233497c..f9f474b26 100644 --- a/app/src/main/java/org/piramalswasthya/sakhi/database/room/dao/BenDao.kt +++ b/app/src/main/java/org/piramalswasthya/sakhi/database/room/dao/BenDao.kt @@ -799,11 +799,12 @@ interface BenDao { //@Query("SELECT ben.* FROM BEN_BASIC_CACHE ben left outer join delivery_outcome del on ben.benId = del.benId left outer join pnc_visit pnc on pnc.benId = ben.benId WHERE reproductiveStatusId = 3 and (pnc.isActive is null or pnc.isActive == 1) and CAST((strftime('%s','now') - del.dateOfDelivery/1000)/60/60/24 AS INTEGER) BETWEEN :minPncDate and :maxPncDate and villageId=:selectedVillage group by ben.benId") //@Query("SELECT ben.* FROM BEN_BASIC_CACHE ben LEFT OUTER JOIN delivery_outcome del ON ben.benId = del.benId LEFT OUTER JOIN pnc_visit pnc ON pnc.benId = ben.benId WHERE reproductiveStatusId = 3 AND (pnc.isActive IS NULL OR pnc.isActive == 1) AND ( del.dateOfDelivery IS NULL OR CAST((strftime('%s','now') - COALESCE(del.dateOfDelivery, 0)/1000)/60/60/24 AS INTEGER) BETWEEN :minPncDate AND :maxPncDate) AND (:selectedVillage IS NULL OR villageId = :selectedVillage) GROUP BY ben.benId") - @Query("SELECT ben.* FROM BEN_BASIC_CACHE ben LEFT OUTER JOIN delivery_outcome del ON ben.benId = del.benId LEFT OUTER JOIN pnc_visit pnc ON pnc.benId = ben.benId WHERE reproductiveStatusId = 3 AND (pnc.isActive IS NULL OR pnc.isActive = 1) AND (pnc.pncPeriod IS NULL OR pnc.pncPeriod != 42) AND (ben.isDeath IS NULL OR ben.isDeath = 0 OR ben.isDeath = 'undefined' ) AND ben.isDeactivate = 0 AND (:selectedVillage IS NULL OR villageId = :selectedVillage) GROUP BY ben.benId") + @Query("SELECT ben.* FROM BEN_BASIC_CACHE ben LEFT OUTER JOIN delivery_outcome del ON ben.benId = del.benId LEFT OUTER JOIN pnc_visit pnc ON pnc.benId = ben.benId WHERE reproductiveStatusId = 3 AND (pnc.isActive IS NULL OR pnc.isActive = 1) AND (del.dateOfDelivery IS NULL OR del.dateOfDelivery >= :sixtyDaysAgo) AND (ben.isDeath IS NULL OR ben.isDeath = 0 OR ben.isDeath = 'undefined' ) AND ben.isDeactivate = 0 AND (:selectedVillage IS NULL OR villageId = :selectedVillage) GROUP BY ben.benId") fun getAllPNCMotherList( - selectedVillage: Int + selectedVillage: Int, // minPncDate: Long = 0, // maxPncDate: Long = Konstants.pncEcGap + sixtyDaysAgo: Long ): Flow> @Query("SELECT * FROM BEN_BASIC_CACHE WHERE CAST(((strftime('%s','now') - dob/1000)/60/60/24) AS INTEGER) <= :max and villageId=:selectedVillage and isDeactivate=0") diff --git a/app/src/main/java/org/piramalswasthya/sakhi/repositories/RecordsRepo.kt b/app/src/main/java/org/piramalswasthya/sakhi/repositories/RecordsRepo.kt index e00580005..862143053 100644 --- a/app/src/main/java/org/piramalswasthya/sakhi/repositories/RecordsRepo.kt +++ b/app/src/main/java/org/piramalswasthya/sakhi/repositories/RecordsRepo.kt @@ -229,11 +229,13 @@ class RecordsRepo @Inject constructor( .map { list -> list.map { it.asBasicDomainModel() } } val hrpListCount = menopauseList.map { it.size } - val pncMotherList = benDao.getAllPNCMotherList(selectedVillage) + val sixtyDaysAgo = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60) + + val pncMotherList = benDao.getAllPNCMotherList(selectedVillage,sixtyDaysAgo) .map { list -> list.map { it.asBasicDomainModelForPNC() } } val pncMotherListCount = pncMotherList.map { it.size } - val pncMotherNonFollowUpList = benDao.getAllPNCMotherList(selectedVillage) + val pncMotherNonFollowUpList = benDao.getAllPNCMotherList(selectedVillage,sixtyDaysAgo) .map { list -> list.filter { if (!it.savedPncRecords.isNullOrEmpty()) {