if exists ( select * from sys.indexes i where i.object_id = object_id('AKUZ.T_DOCTOR_INSPECTION_RE', 'U') and i.name = 'IX_T_DOCTOR_INSPECTION_RE_DOCTORINSPECTION')
DROP INDEX [IX_T_DOCTOR_INSPECTION_RE_DOCTORINSPECTION] ON [AKUZ].[T_DOCTOR_INSPECTION_RE];
go
CREATE INDEX [IX_T_DOCTOR_INSPECTION_RE_DOCTORINSPECTION] ON [AKUZ].[T_DOCTOR_INSPECTION_RE] ([DoctorInspection])  WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);

if exists ( select * from sys.indexes i where i.object_id = object_id('AKUZ.T_HOSPITALISATION_ACTIVE_CALL', 'U') and i.name = 'IX_HospitalisationActiveCall_AmbulanceEvent')
DROP INDEX IX_HospitalisationActiveCall_AmbulanceEvent ON [AKUZ].[T_HOSPITALISATION_ACTIVE_CALL];
go
CREATE NONCLUSTERED INDEX [IX_HospitalisationActiveCall_AmbulanceEvent] ON [AKUZ].[T_HOSPITALISATION_ACTIVE_CALL] ([AmbulanceEvent]) WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);

if exists ( select * from sys.indexes i where i.object_id = object_id('AKUZ.T_VISIT', 'U') and i.name = 'IX_T_VISIT_PaymentType')
	DROP INDEX [IX_T_VISIT_PaymentType] ON [AKUZ].[T_VISIT];
go
CREATE INDEX [IX_T_VISIT_PaymentType] ON [AKUZ].[T_VISIT] ([type_], [PaymentType]) INCLUDE ([AmbulanceEvent], [OutcomeRecord]) WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);

if exists ( select * from sys.indexes i where i.object_id = object_id('AKUZ.T_VISIT', 'U') and i.name = 'IX_T_VISIT_DATE')
		DROP INDEX [IX_T_VISIT_DATE] ON [AKUZ].[T_VISIT];
go
CREATE INDEX [IX_T_VISIT_DATE] ON [AKUZ].[T_VISIT] ([VisitDate], [type_]) INCLUDE ([OutcomeRecord]) WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);	



