Before starting, I'd look into what 'respective endpoint' means. If that's 2 years for one group and half a year for the other, I don't see how any meaningful comparison can be made.
First test. This can be run as a test of equality of two proportions. Results from Minitab statistical software are shown below. The P-value 0.109
is based on a normal approximation. The P-value 0.144 is from Fisher's
exact test, which is based on a hypergeometric distribution. Neither
P-value is sufficiently small to reject the null hypothesis, so there
is no significant difference between groups.
Test and CI for Two Proportions
Sample X N Sample p
1 6 157 0.038217
2 12 146 0.082192
Difference = p (1) - p (2)
Estimate for difference: -0.0439752
95% CI for difference: (-0.0976797, 0.00972929)
Test for difference = 0 (vs ≠ 0): Z = -1.60 P-Value = 0.109
Fisher’s exact test: P-Value = 0.144
[Before looking at the data, if you expected the latter death rate to be larger, you might test
against a one-sided alternative. (The wording of the question might suggest this approach.) In that case, both of the above P-values would be cut
approximately in half---still not small enough for statistical significance at the 5% level.]
Second test, accounting for risk. It is unclear how you might deal with the categorical variable
for three levels of pre-existing risk.
(a) If you can justify putting all 303 subjects together into one group, then you might try a chi-squared test of independence to see if death rates differ by category. The null hypothesis might be that 'risk' makes no difference.
(b) If you need to keep the two time groups separate, then you might consider looking at
a three-way contingency table with 2(times) by 3(risks) by 2(outcomes); that's 12 cells in the table. However, with 18 deaths spread somehow
among six cells, I don't see how you could run a valid chi-squared analysis.