diff --git a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js index 81f33468c7ce291af8d1117a347cb264ee13b4aa..d9bd763c59280c845e6922e84ff592d2f7d7de2b 100644 --- a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js @@ -192,12 +192,20 @@ if(idValues == false) .from("VISITPLANENTRY") .where(newWhere("VISITPLANENTRY.CONTACT_ID", tmpData[0]) .or("VISITPLANENTRY.ORGANISATION_CONTACT_ID", tmpData[0])) - .and(newWhere("VISITPLANENTRY.ENTRYDATE", eMath.subInt(vars.get("$sys.today"), datetime.ONE_DAY * 7), SqlBuilder.LESS_OR_EQUAL()) - .and("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.NOT_EQUAL())) - .cell(); - if(!manualRec || visitEntry) - recommendationData.push(tmpData); + var visitEntryExists = visitEntry.cell(); + + visitEntry = visitEntry.and(newWhere("VISITPLANENTRY.ENTRYDATE", eMath.subInt(vars.get("$sys.today"), datetime.ONE_DAY * 7), SqlBuilder.LESS_OR_EQUAL()) + .and("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.NOT_EQUAL())) + .or("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.EQUAL()).cell() + + if(!manualRec) + { + if(!visitEntryExists || visitEntry) + { + recommendationData.push(tmpData); + } + } } }