varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""TpaId"") FROM ""Tpa"" WHERE Lower(""Name"") = '{model.Name.ToLower()}'");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""TpaId"") FROM ""Tpa"" WHERE Lower(""Name"") = '{model.Name.ToLower()}'");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UnitTypeId"") FROM ""UnitType"" WHERE TRIM(UPPER(""Name"")) = '{model.Name.ToUpper().Trim()}'");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UnitTypeId"") FROM ""UnitType"" WHERE TRIM(UPPER(""Name"")) = '{model.Name.ToUpper().Trim()}' AND ""UnitTypeId"" <> {model.UnitTypeId}");
varquery=$@" Select count(EUH.*) over() as ""TotalItems"",EUH.*, A.""FullName"" as ""UploadedByName"", l.""Name"" as ""LocationName"" from ""ExcelUploadHistory"" EUH
join ""Account"" A on A.""AccountId"" = EUH.""UploadedBy""
left join ""Location"" l on l.""LocationId"" = EUH.""LocationId""
varquery=$@" Select count(UEH.*) over() as ""TotalItems"",UEH.*, A.""FullName"" as ""UploadedByName"", l.""Name"" as ""LocationName"" from ""UserExcelHistory"" UEH
join ""Account"" A on A.""AccountId"" = UEH.""UploadedBy""
left join ""Location"" l on l.""LocationId"" = UEH.""LocationId""
(CASE WHEN usr.""ThumbnailUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}','/', usr.""Guid"", '/', usr.""ThumbnailUrl"") ELSE NULL END) AS ""ThumbnailUrl"",
(CASE WHEN usr.""ProfileImageUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}', '/', usr.""Guid"", '/', usr.""ProfileImageUrl"") ELSE NULL END) AS ""ProfileImageUrl"",
where+=$@" AND usr.""FullName"" ILIKE '%{model.FullName}%'";
}
if(model.ProviderId!=null)
{
where+=$@" AND pr.""ProviderId"" = {model.ProviderId}";
}
if(!string.IsNullOrEmpty(model.Email))
{
where+=$@" AND usr.""Email"" ILIKE '%{model.Email}%'";
}
if(!string.IsNullOrEmpty(model.Mobile))
{
where+=$@" AND usr.""Mobile"" ILIKE '%{model.Mobile}%'";
}
if(!string.IsNullOrEmpty(model.Username))
{
where+=$@" AND act.""UserName"" ILIKE '%{model.Username}%'";
}
if(!string.IsNullOrEmpty(model.CreatedDate))
{
where+=$@" AND usr.""CreatedDate""::DATE = '{model.CreatedDate}'::DATE ";
}
if(model.ProviderLocationId!=null)
{
where+=$@" AND usr.""ProviderLocationId"" = '{model.ProviderLocationId}'";
}
if(model.RoleId!=null)
{
where+=$@" AND usr.""RoleId"" = '{model.RoleId}'";
}
if(model.CountryId!=null)
{
where+=$@" AND usr.""CountryId"" = '{model.CountryId}'";
}
if(model.Active!=null)
{
where+=$@" AND usr.""Active"" IS {((bool)model.Active?"TRUE":"FALSE")}";
}
if(model.LocationIds!=null)
{
where+=$@" AND LAM.""LocationId"" = {model.LocationIds}";
}
if(!string.IsNullOrEmpty(model.BulkUserIds))
{
where+=$@" and usr.""UserId"" in ({model.BulkUserIds})";
}
varquery=$@"Select COUNT(*) OVER () AS ""TotalItems"",* from (SELECT distinct usr.""UserId"",act.""UserName"", usr.""FullName"", usr.""CreatedDate"",usr.""ModifiedDate"", usr.""CountryId"",
usr.""ProviderLocationId"", pra.""FullName"" AS ""PracticeName"",
(CASE WHEN usr.""ThumbnailUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}','/', usr.""Guid"", '/', usr.""ThumbnailUrl"") ELSE NULL END) AS ""ThumbnailUrl"",
(CASE WHEN usr.""ProfileImageUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}', '/', usr.""Guid"", '/', usr.""ProfileImageUrl"") ELSE NULL END) AS ""ProfileImageUrl"",
(Select string_agg(R.""RetailPharmacyId""::character varying, ',') as ""RetailIds""
from ""RetailPharmacy"" S
join ""PharmacyRetailUser"" R ON R.""RetailPharmacyId"" = S.""RetailPharmacyId"" and R.""AccountId"" = act.""AccountId"")
,(Select string_agg(S.""RetailName"", ',') as ""RetailNames""
from ""RetailPharmacy"" S
join ""PharmacyRetailUser"" R ON R.""RetailPharmacyId"" = S.""RetailPharmacyId"" and R.""AccountId"" = act.""AccountId"")
,(Select string_agg(l.""NameLoc"", ', ') as ""LocationNames""
from ""LocationAccountMap"" la
join ""Location"" l ON l.""LocationId"" = la.""LocationId"" WHERE la.""AccountId"" = act.""AccountId""),
(Select string_agg(l.""LocationId""::text, ', ') as ""LocationIdentifiers""
from ""LocationAccountMap"" la
join ""Location"" l ON l.""LocationId"" = la.""LocationId"" WHERE la.""AccountId"" = act.""AccountId"")
FROM ""User"" usr
JOIN ""Account"" act ON act.""ReferenceId"" = usr.""UserId"" AND act.""RoleId"" IN ( select ""RoleId"" from ""Role"" where ""RoleId"" not in ({(int)Roles.Provider},{(int)Roles.Patient}))
JOIN ""LocationAccountMap"" LAM ON LAM.""AccountId"" = act.""AccountId""
LEFT JOIN ""Country"" cun ON cun.""CountryId"" = usr.""CountryId"" AND cun.""Active"" IS TRUE
LEFT JOIN ""ProviderLocation"" prl ON prl.""ProviderLocationId"" = usr.""ProviderLocationId"" AND prl.""Active"" IS true
left join ""Location"" L on L.""LocationId"" = prl.""LocationId""
LEFT JOIN ""Practice"" pra ON pra.""PracticeId"" = L.""PracticeId"" AND pra.""Active"" IS TRUE
LEFT JOIN ""Provider"" pr ON pr.""ProviderId"" = prl.""ProviderId"" AND pr.""Active"" IS TRUE
LEFT JOIN ""Role"" rl ON rl.""RoleId"" = usr.""RoleId"" AND rl.""Active"" IS TRUE
JOIN ""Account"" CA on CA.""AccountId"" = usr.""CreatedBy""
JOIN ""Role"" CR on CR.""RoleId"" = CA.""RoleId""
LEFT JOIN ""Account"" MA on MA.""AccountId"" = usr.""ModifiedBy""
LEFT JOIN ""Role"" MR on MR.""RoleId"" = MA.""RoleId""
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}'",null,transaction);
if(checkIf>0)
{
returnnewTuple<int,Guid?>(-1,null);
}
}
}
if(!string.IsNullOrEmpty(model.Mobile))
{
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE ""Mobile"" = '{model.Mobile}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE ""Mobile"" = '{model.Mobile}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}' AND ""UserId"" <> '{model.UserId}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}'",null,transaction);
if(checkIf>0)
{
return-1;
}
}
}
if(!string.IsNullOrEmpty(model.Mobile))
{
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE ""Mobile"" = '{model.Mobile}' AND ""UserId"" <> '{model.UserId}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE ""Mobile"" = '{model.Mobile}'",null,transaction);
varquery=$@"UPDATE ""User"" SET ""Active"" = {status}, ""ModifiedBy"" = {modifiedBy}, ""ModifiedDate"" = NOW() AT TIME ZONE 'UTC' WHERE ""UserId"" = {userId}";
query=$@"UPDATE ""Account"" SET ""Active"" = {status}, ""ModifiedBy"" = {modifiedBy}, ""ModifiedDate"" = NOW() AT TIME ZONE 'UTC' WHERE ""ReferenceId"" = {userId} AND ""RoleId"" Not IN ({(int)Roles.Patient}) ;";
varquery=$@"SELECT * FROM ""Account"" WHERE ""RoleId"" IN (Select ""RoleId"" from ""Role"" where ""RoleId"" not in ({(int)Roles.Provider},{(int)Roles.Patient})) AND ""ReferenceId"" = {model.UserId} ";
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE UPPER(""Email"") = '{model.Email.ToUpper()}'",null,transaction);
if(checkIf>0)
{
returnnewTuple<int,int,Guid?>(-1,checkIf,null);
}
}
}
if(!string.IsNullOrEmpty(model.Mobile))
{
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE ""Mobile"" = '{model.Mobile}'",null,transaction);
checkIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE ""Mobile"" = '{model.Mobile}'",null,transaction);
where+=$@" and usr.""UserId"" in ({model.BulkUserIds})";
}
varquery=$@"Select COUNT(*) OVER () AS ""TotalItems"",* from (SELECT distinct usr.""UserId"",act.""UserName"", usr.""FullName"", usr.""CreatedDate"",usr.""ModifiedDate"", usr.""CountryId"",
usr.""ProviderLocationId"", pra.""FullName"" AS ""PracticeName"",
(CASE WHEN usr.""ThumbnailUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}','/', usr.""Guid"", '/', usr.""ThumbnailUrl"") ELSE NULL END) AS ""ThumbnailUrl"",
(CASE WHEN usr.""ProfileImageUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}', '/', usr.""Guid"", '/', usr.""ProfileImageUrl"") ELSE NULL END) AS ""ProfileImageUrl"",
vargetOrder=awaitthis.unitOfWork.Current.QuerySingleOrDefaultAsync<int?>($@"select ""Order"" from ""VaccineMaster"" order by ""Order"" desc limit 1 ");
STRING_AGG (vm.""VaccineName"",',') as ""GroupedVaccines"",
pp.""ProductName"" ,pp.""GenericName"" , c.""Name"" as ""CompanyName"", pp.""PharmacyProductId""
from ""VaccinePharmacyLinkDetail"" vd
join ""VaccinePharmacyLinkHeader"" vh on vh.""VaccinePharmacyLinkHeaderId"" = vd.""VaccinePharmacyLinkHeaderId""
join ""VaccineMaster"" vm on vm.""VaccineMasterId"" = vd.""VaccineMasterId""
join ""PharmacyProduct"" pp on pp.""PharmacyProductId"" = vh.""PharmacyProductId""
join ""Company"" c on c.""CompanyId"" = pp.""CompanyId""
where vd.""VaccinePharmacyLinkHeaderId"" in (select ""VaccinePharmacyLinkHeaderId"" from ""VaccinePharmacyLinkDetail"" where ""VaccineMasterId"" = {vaccineMasterId})
group by vd.""VaccinePharmacyLinkHeaderId"" , pp.""ProductName"" ,pp.""GenericName"" , c.""Name"", pp.""PharmacyProductId""";
varaccountCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"select count(""AccountId"") from ""Account"" where LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) and ""ReferenceId"" <> '{referenceId}' AND ""Email"" != ''");
switch(type)
{
case"Patient":
returnawaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""PatientId"") FROM ""Patient"" WHERE LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) AND ""PatientId"" <> '{referenceId}' AND ""Email"" != '' ");
case"User":
varuserResponse=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) AND ""UserId"" <> '{referenceId}'");
returnaccountCount+userResponse;
case"Provider":
varprovidersCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) AND ""ProviderId"" <> '{referenceId}' AND ""Email"" != ''");
varusersCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) AND ""UserId"" <> '{referenceId}' AND ""RoleId"" IN ({(int)Roles.Nurse},{(int)Roles.Receptionist})");
varaccountCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"select count(""AccountId"") from ""Account"" where ""Mobile"" = '{query}' AND ""CountryId"" = '{countryId}' and ""Mobile"" != '' and ""ReferenceId"" <> '{referenceId}' ");
switch(type)
{
case"Patient":
returnawaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""PatientId"") FROM ""Patient"" WHERE ""Mobile"" = '{query}' AND ""CountryId"" = '{countryId}' AND ""PatientId"" <> '{referenceId}'");
case"User":
varuserCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE ""Mobile"" = '{query}' AND ""CountryId"" = '{countryId}' AND ""UserId"" <> '{referenceId}'");
returnuserCount+accountCount;
case"Provider":
varprovidersCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE ""Mobile"" = '{query}' AND ""CountryId"" = '{countryId}' AND ""ProviderId"" <> '{referenceId}' AND ""Mobile"" != ''");
varusersCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE ""Mobile"" = '{query}' AND ""CountryId"" = '{countryId}' AND ""UserId"" <> '{referenceId}' AND ""RoleId"" IN ({(int)Roles.Nurse},{(int)Roles.Receptionist}) ");
varaccountCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"select count(""AccountId"") from ""Account"" where LOWER(TRIM(""UserName"")) = LOWER(TRIM('{query}')) and ""ReferenceId"" <> '{referenceId}' AND ""UserName"" != ''");
switch(type)
{
case"Patient":
returnawaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""PatientId"") FROM ""Patient"" WHERE LOWER(TRIM(""UserName"")) = LOWER(TRIM('{query}')) AND ""PatientId"" <> '{referenceId}' AND ""UserName"" != '' ");
case"User":
varuserResponse=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(ad.""ReferenceId"") FROM ""Account"" ad LEFT JOIN ""User"" usr on usr.""UserId"" = ad.""ReferenceId"" WHERE LOWER(TRIM(ad.""Email"")) = LOWER(TRIM('{query}')) AND usr.""UserId"" <> '{referenceId}' ");
returnaccountCount+userResponse;
case"Provider":
///var providersCount = await this.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""ProviderId"") FROM ""Provider"" WHERE LOWER(TRIM(""Email"")) = LOWER(TRIM('{query}')) AND ""ProviderId"" <> '{referenceId}' AND ""UserName"" != ''");
varprovidersCount=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(ad.""ReferenceId"") FROM ""Account"" ad LEFT JOIN ""User"" usr on usr.""UserId"" = ad.""ReferenceId"" WHERE LOWER(TRIM(ad.""Email"")) = LOWER(TRIM('{query}')) AND usr.""UserId"" <> '{referenceId}' ");
///var usersCount = await this.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""UserId"") FROM ""User"" WHERE LOWER(TRIM(""UserName"")) = LOWER(TRIM('{query}')) AND ""UserId"" <> '{referenceId}' AND ""RoleId"" IN ({(int)Roles.Nurse},{(int)Roles.Receptionist})");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""VisitTypeId"") FROM ""VisitType"" WHERE TRIM(UPPER(""VisitorName"")) = '{model.VisitorName.ToUpper().Trim()}'");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""VisitTypeId"") FROM ""VisitType"" WHERE TRIM(UPPER(""VisitorName"")) = '{model.VisitorName.ToUpper().Trim()}' AND ""VisitTypeId"" <> {model.VisitTypeId}");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""VitalTypeId"") FROM ""VitalType"" WHERE TRIM(UPPER(""Name"")) = '{model.Name.ToUpper().Trim()}'");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""VitalTypeId"") FROM ""VitalType"" WHERE TRIM(UPPER(""Name"")) = '{model.Name.ToUpper().Trim()}' AND ""VitalTypeId"" <> {model.VitalTypeId}");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""WardId"") FROM ""Ward"" WHERE TRIM(UPPER(""WardName"")) = '{model.WardName.ToUpper().Trim()}' and ""FloorId"" ={model.FloorId}");
varcheckIf=awaitthis.unitOfWork.Current.QueryFirstOrDefaultAsync<int>($@"SELECT COUNT(""WardId"") FROM ""Ward"" WHERE TRIM(UPPER(""WardName"")) = '{model.WardName.ToUpper().Trim()}' and ""FloorId"" ={model.FloorId}");
varquery1=$@"select count(""BedId"") from ""Admission"" where ""IsDischarged"" is false and ""Active"" is true and ""BedId"" in (select b.""BedId"" from ""Bed"" b join ""Room"" r on r.""RoomId"" = b.""RoomId"" where r.""WardId"" = {wardId}) ";
varquery=$@"select count(""BedId"") from ""Admission"" where ""IsDischarged"" is false and ""Active"" is true and ""BedId"" in (select b.""BedId"" from ""Bed"" b join ""Room"" r on r.""RoomId"" = b.""RoomId"" where r.""WardId"" = {model.WardId}) ";
varwhere=$@"Where 1=1 and WB.""IsRead"" is false";
varextraCondition=string.Empty;
varextraConditionScan=string.Empty;
varextraColumn=string.Empty;
varfilterPatient=string.Empty;
if(model.ShowRead)
{
where=$@" Where 1=1 ";
}
if(model.RoleId>0)
{
where+=$@" and R.""RoleId"" = {model.RoleId} ";
}
if(model.PatientId!=null)
{
where+=$@" and WB.""PatientId"" = {model.PatientId} ";
}
if(!string.IsNullOrEmpty(model.FilterPatient))
{
filterPatient+=$@" Where (TRIM(UPPER(m.""PatientName"")) ILIKE '%{model.FilterPatient.Trim().ToUpper()}%' OR m.""PatientMobile"" ILIKE '%{model.FilterPatient.Trim().ToUpper()}%' OR m.""UMRNo"" ILIKE '%{model.FilterPatient.Trim().ToUpper()}%')";
}
if(model.FromDate!=null)
{
where+=$@" and WB.""CreatedDate""::date >= '{model.FromDate?.ToString("yyyy-MM-dd")}'::date ";
}
if(model.ToDate!=null)
{
where+=$@" and WB.""CreatedDate""::date <= '{model.ToDate?.ToString("yyyy-MM-dd")}'::date ";
}
if(model.ProviderId!=null)
{
where+=$@" and APT.""ProviderId"" = {model.ProviderId} ";
}
if(model.ModuleType!=null)
{
where+=$@" and MM.""ModuleName"" ilike '{model.ModuleType}%'";
}
if(model.LocationId!=null)// Only applicable if this is for appointment/Scans
{
where+=$@" and (APT.""LocationId"" = {model.LocationId} or BSA.""LocationId"" = {model.LocationId})";
extraColumn+=$@" , BSA.""PaymentStatus"" AS ""ScanPaymentStatus""";
extraConditionScan+=$@" left join ""BookScanAppointment"" BSA on BSA.""BookScanAppointmentId"" = WB.""ReferenceId"" AND BSA.""PaymentStatus"" IS FALSE AND BSA.""Active"" IS TRUE AND BSA.""Status"" != 'C'";
}
if(model.ModuleIdNotToDisplay!=null)
{
where+=$@" and MM.""ModulesMasterId"" != {model.ModuleIdNotToDisplay}";
WNP.""Priority"",WNL.""LogType"",P.""FullName"" as ""PatientName"", P.""Age"" as ""PatientAge"",P.""Gender"" as ""PatientGender"",P.""Mobile"" as ""PatientMobile"",
P.""UMRNo"",WB.""ModulesMasterId"" as ""WebNotificationTypeId"",MM.""ModuleName"" as ""ModuleType"",
(CASE WHEN P.""ThumbnailUrl"" IS NOT NULL THEN CONCAT('{this.runningEnvironment.CurrentEnvironment}', '/', P.""Guid"", '/', P.""ThumbnailUrl"") ELSE '' END) AS ""PatientThumbnailUrl""
{extraColumn}
FROM ""WebNotification"" WB
join ""WebNotificationPriority"" WNP on WNP.""WebNotificationPriorityId"" = WB.""WebNotificationPriorityId""
join ""WebNotificationLogType"" WNL on WNL.""WebNotificationLogTypeId"" = WB.""WebNotificationLogTypeId""
join ""ModulesMaster"" MM on MM.""ModulesMasterId"" = WB.""ModulesMasterId""
join ""Role"" R on R.""RoleId"" = any(string_to_array(WB.""AllowedRoles"",',')::int[])
left join ""Patient"" P on P.""PatientId"" = WB.""PatientId""
{extraCondition}
{extraConditionScan}
{where}
order by WB.""CreatedDate"" desc)
Select count(m.*) over() as ""TotalItems"",m.* from mainData m
varquery=$@"SELECT ""AppointmentNo"" from ""Appointment"" WHERE ""PatientId"" = '{patientId}' AND ""AppointmentDate""::date = '{DateTime.Today:yyyy/MM/dd}'::date ";
query=$@"SELECT DISTINCT ac.""AccountId"",'Dr.' || ac.""FullName"" ""FullName"", ac.""RoleId"" FROM ""Provider"" p
JOIN ""Account"" ac on ac.""ReferenceId"" = p.""ProviderId"" AND ac.""Active"" IS TRUE {and}
WHERE ac.""RoleId"" = 3 AND ac.""ReferenceId"" IN (SELECT ""ProviderId"" FROM ""Provider"" WHERE ""ProviderId"" IN (
SELECT ""ProviderId"" FROM ""ProviderLocation"" WHERE ""PracticeLocationId"" IN (
SELECT ""PracticeLocationId"" FROM ""PracticeLocation"" WHERE ""PracticeId"" IN (
SELECT ""PracticeId"" FROM ""PracticeLocation"" WHERE ""PracticeLocationId"" IN (
SELECT ""PracticeLocationId"" FROM ""ProviderLocation"" WHERE ""ProviderLocationId"" IN (
SELECT ""ProviderLocationId"" FROM ""Appointment"" WHERE ""AppointmentNo"" = '{appointmentNo}' ))) AND ""Active"" IS TRUE ) AND ""Active"" IS TRUE) AND ""Active"" IS TRUE )";
varquery=$@"select w.""WebTelemedicineId"", a.""AppointmentNo"" as ""RoomName"" from ""WebTelemedicine"" w
LEFT JOIN ""Appointment"" a on a.""AppointmentId"" = w.""AppointmentId""
LEFT JOIN ""Account"" ac on ac.""ReferenceId"" = a.""ProviderId""
WHERE w.""AppointmentId"" IN ({string.Join(',',appointmentIds)}) AND w.""Status"" <> 2 AND ac.""RoleId"" = 3 AND w.""CreatedDate"" >= NOW() - INTERVAL '2 minutes'";
varcheckIf=awaitthis.unitOfWork.Current.QuerySingleOrDefaultAsync<int>($@"select count(*) from ""WorkingHour"" where ""StartDate"" ilike'{model.StartDate}' and ""EndDate"" ilike '{model.EndDate}' and ""StartTime"" ilike '{model.StartTime}' and ""EndTime"" ilike '{model.EndTime}'");