SELECT EXISTS (
	-- substance check
	SELECT 1 FROM clin.v_substance_intakes WHERE
		pk_patient = ID_ACTIVE_PATIENT
			AND
		-- on Sartan or ACEI
		(
			substance ~* '.*sartan.*'
				OR
			substance ~* '.*angiotensin.*'
				OR
			substance ~ '.*ACE.*'
				OR
			-- might result in false positives (.Prilocarpin)
			substance ~* '.+pril.*'
				OR
			atc_brand ~* '^C09.*'
				OR
			atc_substance ~* '^C09.*'
	)
) AND EXISTS (
	-- pregnancy check
	SELECT 1 FROM clin.patient WHERE
		fk_identity = ID_ACTIVE_PATIENT
			AND
		coalesce(edc BETWEEN now() - '1 month'::interval AND now() + '11 months'::interval, FALSE)
);