USE [Clinica]
GO
/****** Object:  Table [Clinica].[PacienteSistemaSalud]    Script Date: 18-08-2025 21:40:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Clinica].[PacienteSistemaSalud](
	[IdPacienteSistemaSalud] [int] IDENTITY(1,1) NOT NULL,
	[IdPaciente] [int] NOT NULL,
	[IdSistemaSalud] [int] NOT NULL,
	[IdIsapre] [int] NULL,
	[FechaInicioVigencia] [date] NOT NULL,
	[FechaFinVigencia] [date] NULL,
	[IndVigente] [tinyint] NOT NULL,
	[IndEliminado] [tinyint] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[IdPacienteSistemaSalud] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud] ADD  DEFAULT ((1)) FOR [IndVigente]
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud] ADD  DEFAULT ((0)) FOR [IndEliminado]
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud]  WITH CHECK ADD FOREIGN KEY([IdIsapre])
REFERENCES [Clinica].[Isapre] ([IdIsapre])
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud]  WITH CHECK ADD  CONSTRAINT [FK__PacienteS__IdPac__25DB9BFC] FOREIGN KEY([IdPaciente])
REFERENCES [Clinica].[Paciente] ([IdPaciente])
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud] CHECK CONSTRAINT [FK__PacienteS__IdPac__25DB9BFC]
GO
ALTER TABLE [Clinica].[PacienteSistemaSalud]  WITH CHECK ADD FOREIGN KEY([IdSistemaSalud])
REFERENCES [Clinica].[SistemaSalud] ([IdSistemaSalud])
GO
