Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<BenWithDoAndPncCache>>

@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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down