DECLARE @ResourceLocalizedValues TABLE (
    [LanguageId]     INT            NOT NULL,
    [EntityType]     INT            NOT NULL,
    [ResourceKey]    NVARCHAR (200) NOT NULL,
    [LocalizedValue] NVARCHAR (MAX) NOT NULL,
    [Description]    NVARCHAR (200) NULL
)

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 14, 'MailBody',N'<p>Your account password was successfully changed.<br />If you did not authorize this action, then please reset your password.<br />For more information, please contact customer support.</p>')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 14, 'MailSubject',N'Care@Home Password Changed')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 14, 'MailSender',N'')


INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_At_Home_Alert','Resident has not left home for too long ')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'E_ALERT_TYPE_At_Home_Alert','Resident has not left home for too long ')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES ( 1, 7, N'E_ALERT_TYPE_NoActivityDetected', N'No activity detected in {0}')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES ( 1, 8, N'E_ALERT_TYPE_NoActivityDetected', N'No activity detected in {0}')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_SMOKE', N'Smoke was detected in the {3} sensor')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 10, 'GAS_SENSOR',N'Gas Sensor')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'Honorific_Male',N'Mr.')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'Honorific_Female',N'Mrs.')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'Honorific_Male',N'Mr.')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'Honorific_Female',N'Mrs.')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'BLE_CPU_software',N'BLE processor')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'BLE_CPU_software',N'BLE processor')


INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'FILE_TYPE_BleCpuSoftware',N'BLE Software')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'FILE_TYPE_BleCpuSoftware',N'BLE Software')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthCaregiverNotificationMailBody'        ,'Dear {0},<br/><br/>Patient {1} did not take a scheduled measurement.<br/> Enter <a href=''{2}''>{3}</a> to check on the patient.')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthCaregiverNotificationMailSubject'    ,'Patient {0} Missed a measurement')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthCaregiverNotificationMailSender'     ,'default email')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthCaregiverNotificationSiteUrl'        ,'default site')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthCaregiverNotificationSiteDisplayName','telehealth Site default name')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthDoctorReminderMailBody'        ,'Dear {0},<br/><br/>Please sign in to the <a href=''{1}''>{2}</a> and review the latest activities.')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthDoctorReminderMailSubject'    ,'Review RPM Activities')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'TelehealthDoctorReminderMailSender'     ,'default email')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'TelehealthResidentReminderTextMessage','It is time for your daily measurement')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 10, 'CarbonMonoxideDetector',N'Carbon Monoxide Detector')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 10, 'EpilepsyDetector',N'Epilepsy Detector')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 10, 'EnuresisDetector',N'Enuresis Detector')


INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_CaregiverPresence','A caregiver is on site')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'E_ALERT_TYPE_CaregiverPresence','A caregiver is on site')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_ActivityAlarmCancelled','Activity alarm cancelled by reset button')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'E_ALERT_TYPE_ActivityAlarmCancelled','Activity alarm cancelled by reset button')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_Missed_Reminder','Patient missed reminder')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'E_ALERT_TYPE_Missed_Reminder','Patient missed reminder')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES ( 1, 7, N'E_ALERT_TYPE_LONG_TOTAL_SUSTAINED_ACTIVITY_DURATION_V2', N'Resident stayed in the {0} for longer than {3} minutes since {1}')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES ( 1, 8, N'E_ALERT_TYPE_LONG_TOTAL_SUSTAINED_ACTIVITY_DURATION_V2', N'Resident stayed in the {0} for longer than {3} minutes since {1}')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 15, 'MailBody',N'<div>Account {0} took {1}({2}) measurement at {3:dd/MM/yyyy HH:mm:ss} <br/>severity : {4}<br/><br/>To view the values and other details they will have to open CVH.<br/>Measurements include also invalid measurements. Historical measurements are out of scope for this project</div>')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 15, 'MailSubject',N'Account {0} sent a Measurement')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 15, 'MailSender',N'')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'Voice_File',N'Voice File')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'Voice_File',N'Voice File')

INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 7, 'FILE_TYPE_ADHOC_VOICE_FILE',N'Ad-hoc announcements')
INSERT @ResourceLocalizedValues([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) VALUES (1, 8, 'FILE_TYPE_ADHOC_VOICE_FILE',N'Ad-hoc announcements')


INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue],[Description]) values (1,10,'BED_SENSOR','Bed','default device label for Bed Sensor')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'Medication','Medication')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'Medication','Medication')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'Alarm','Health Check')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'Alarm','Health Check')

INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'E_ALERT_TYPE_ReminderStatus','{2} reminder was handled successfully')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'E_ALERT_TYPE_ReminderStatus','{2} reminder was handled successfully')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,7,'PendantTest','Pendant Test')
INSERT @ResourceLocalizedValues ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue]) values (1,8,'PendantTest','Pendant Test')


MERGE INTO [dbo].[ResourceLocalizedValues] AS TARGET  
USING @ResourceLocalizedValues AS SOURCE  
ON TARGET.[LanguageId] = SOURCE.[LanguageId]
	AND TARGET.[EntityType] = SOURCE.[EntityType]
	AND TARGET.[ResourceKey] = SOURCE.[ResourceKey]
WHEN NOT MATCHED BY TARGET THEN
INSERT ([LanguageId], [EntityType], [ResourceKey], [LocalizedValue])
VALUES (SOURCE.[LanguageId], SOURCE.[EntityType], SOURCE.[ResourceKey], SOURCE.[LocalizedValue])
WHEN MATCHED THEN    
UPDATE SET	TARGET.[LocalizedValue] = SOURCE.[LocalizedValue]
OUTPUT $ACTION, SOURCE.*;
