IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0V1EHRWELFAREDOCUMENTTYPES')
BEGIN
DROP VIEW LD0V1EHRWELFAREDOCUMENTTYPES
END
;
CREATE VIEW LD0V1EHRWELFAREDOCUMENTTYPES          
AS          
SELECT           
 D.DOCUMENTTYPEOID,          
 D.DOCUMENTTYPEDESCRIPTION,           
 S.PROCESSID,          
 C.COMPONENTMANIFESTID AS PROCESSCOMPONENTNAME,          
 CM.ID COMPONENTMAPPINGID,           
 D.EHRDOCUMENTNAME, 
 D.EHRDOCUMENTANNOTATION,         
 D.ID as COMPONENTDOCUMENTTYPEMAPPINGID,          
 D.ISDOCUMENTTYPEUSED          
FROM LD0V0PROCESSSTEPS S             
INNER JOIN LD0V0PROCESSSTEPCOMPONENTMAPPING CM ON S.ID = CM.STEPID             
INNER JOIN LD0V0COMPONENTDOCUMENTTYPEMAPPING D ON CM.ID = D.STEPCOMPONENTMAPPINGID            
INNER JOIN LD0V0PROCESSCOMPONENTS C  ON C.ID = CM.COMPONENTID
;