Refactor and chage if for foreach in template show appointment

Signed-off-by: Atanas Kerezov <kerezov.atanas@gmail.com>