-- Tables

-- Alters

ALTER TABLE [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] ADD [PalliativeRegistry] uniqueidentifier NULL
GO

UPDATE e
	SET e.[PalliativeRegistry] = r.PallieativeRegistry
from [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] e
	join AKUZ.T_PALLIATIVE_CARE_RECORD r on r.PalliativeCareRecordID = e.PalliativeCareRecord
GO

ALTER TABLE [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] ALTER COLUMN [PalliativeRegistry] uniqueidentifier NOT NULL
GO

ALTER TABLE [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] ADD CONSTRAINT [FK_T_PALLIATIVE_REGISTRY_T_PALLIATIVE_USED_MEDICAL_EQUIPMENT_PalliativeRegistry]
FOREIGN KEY([PalliativeRegistry]) REFERENCES [AKUZ].[T_PALLIATIVE_REGISTRY] ([PalliativeRegistryID])
GO

ALTER TABLE [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] DROP CONSTRAINT [FK_T_PALLIATIVE_CARE_RECORD_T_PALLIATIVE_USED_MEDICAL_EQUIPMENT_PalliativeCareRecord]
GO

ALTER TABLE [AKUZ].[T_PALLIATIVE_USED_MEDICAL_EQUIPMENT] DROP COLUMN [PalliativeCareRecord]
GO