
DECLARE @TelehealthPrimaryDXCodeTypes TABLE (
    [Code]    NVARCHAR (50) NOT NULL,
    [Description]    NVARCHAR (200) NULL,
    vendorid    int null
)

INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W19.XXXA','Unspecified fall, initial encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W19.XXXD','Unspecified fall, subsequent encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W19.XXXS','Unspecified fall, sequela',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W06.XXXA','Fall from bed, initial encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W06.XXXD','Fall from bed, subsequent encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W06.XXXS','Fall from bed, sequela',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W07.XXXA','Fall from chair, initial encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W07.XXXD','Fall from chair, subsequent encounter',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('W07.XXXS','Fall from chair, sequela',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('R03.0','Elevated blood-pressure reading, without diagnosis of hypertension',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('R03.1','Nonspecific low blood-pressure reading',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('E10.21','Type 1 diabetes mellitus with diabetic nephropathy',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('I11.0','Hypertensive heart disease with heart failure',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('I11.9','Hypertensive heart disease without heart failure',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('N19','Unspecified kidney failure',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('E66.9','Obesity, unspecified',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('R78.4','Finding of other drugs of addictive potential in blood',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('Z63.72','Alcoholism and drug addiction in family',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('F40.10','Social phobia, unspecified',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('F40.298','Other specified phobia',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('Z13.31','Encounter for screening for depression',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('I99.9','Unspecified disorder of circulatory system',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('D70.1','Agranulocytosis secondary to cancer chemotherapy',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('R97.1','Elevated cancer antigen 125 [CA 125]',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('R06.89','Other abnormalities of breathing',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('G30.0','Alzheimer''s disease with early onset',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('G30.1','Alzheimer''s disease with late onset',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('G30.8','Other Alzheimer''s disease',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('I69.311','Memory deficit following cerebral infarction',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('H53.11','Day blindness',2)
INSERT INTO @TelehealthPrimaryDXCodeTypes(Code,Description,vendorid) VALUES('NA','NA',2)


MERGE INTO [dbo].TelehealthPrimaryDXCodeTypes AS TARGET  
USING @TelehealthPrimaryDXCodeTypes AS SOURCE  
ON TARGET.code = SOURCE.code
	AND TARGET.[Description] = SOURCE.[Description]
    and target.vendorid=source.vendorid
WHEN NOT MATCHED BY TARGET THEN
INSERT (code,[Description],vendorid)
VALUES (SOURCE.code, SOURCE.[Description],source.vendorid)
WHEN MATCHED THEN    
UPDATE SET	TARGET.[Description] = SOURCE.[Description], Target.Code=source.Code;