Fixed issues creating visits and appointments

When creating a visit or appointment outside of the patient screen,
appointments and visits were getting lost or not tied to the patient.
Fixed display of appointments and visits

Also, added capability of viewing visit/appointment by clicking on the
row
Cleaned up purchase delete dialog
Added logic to verify inventory total