    with curDateTime as (select localtimestamp as curDateTime)
    SELECT
        count(ds.DocumentsSigning_id) as cnt
    FROM
        dbo.DocumentsSigning ds
    WHERE
        ds.EMDDocumentTypeLocal_id in (9,12,27,40,49,56,57,58,69,71,76,81,88,90,91,96,106,111,119,122,142,160,161,170,171,172,173,174,175,371,374,382,383,384,385,386,393,100067,100068)
        AND coalesce(ds.DocumentsSigning_IsSigned, 1) = 1
        AND coalesce(ds.DocumentsSigning_deleted, 1) = 1
        AND ds.DocumentsSigning_isNotice = 2
        AND ds.DocumentsSigning_MinCount > 0
        AND dateadd('month', 15, ds.DocumentsSigning_setDT) > (select curDateTime from curDateTime)
         AND ds.Lpu_id = 43  AND ds.MedPersonal_id = '450101000012681' 
