USE [BDHIS_MINSA]
GO
PRINT '=================>>>>>>>>> INICIO DE PROCESO MJM_0_SCRIPT_LIMPIAR <<<<<<<<<================='
GO
PRINT '=================>>>>>>>>> INICIO LIMPIEZA DE MJM_1_SCRIPT_MAESTROS_ARCHIVOS_PLANOS <<<<<<<<<================='
GO
IF OBJECT_ID('[dbo].[TBM_ANIOS_MES_ARCHIVO_PLANO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE TBM_ANIOS_MES_ARCHIVO_PLANO
	PRINT 'SE ELIMINO LA TABLA TBM_ANIOS_MES_ARCHIVO_PLANO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_PROFESION]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_PROFESION
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_PROFESION'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='    
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_COLEGIO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_COLEGIO
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_COLEGIO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_PAIS]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_PAIS
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_PAIS'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_ETNIA]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_ETNIA
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_ETNIA'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_CONDICION_CONTRATO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_CONDICION_CONTRATO
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_CONDICION_CONTRATO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='    
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_TIPO_DOC]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_TIPO_DOC
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_TIPO_DOC'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_UPS]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_UPS
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_UPS'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='    
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_FINANCIADOR]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_FINANCIADOR
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_FINANCIADOR'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_OTRA_CONDICION]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_OTRA_CONDICION
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_OTRA_CONDICION'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_UBIGEO_INEI_RENIEC]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_UBIGEO_INEI_RENIEC
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_UBIGEO_INEI_RENIEC'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_ESTABLECIMIENTO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_ESTABLECIMIENTO
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_ESTABLECIMIENTO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_HIS_CIE_CPMS]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_HIS_CIE_CPMS
	PRINT 'SE ELIMINO LA TABLA MAESTRO_HIS_CIE_CPMS'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
PRINT '=================>>>>>>>>> INICIO LIMPIEZA DE MJM_2_SCRIPT_IMPORTAR_ARCHIVOS_PLANOS <<<<<<<<<================='
GO
IF OBJECT_ID('[dbo].[TBM_ANIOS_MES_ARCHIVO_PLANO_TMP]', 'U') IS NOT NULL
BEGIN
	DROP TABLE TBM_ANIOS_MES_ARCHIVO_PLANO_TMP
	PRINT 'SE ELIMINO LA TABLA TBM_ANIOS_MES_ARCHIVO_PLANO_TMP'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='	
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_REGISTRADOR]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_REGISTRADOR
	PRINT 'SE ELIMINO LA TABLA MAESTRO_REGISTRADOR'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='	
END
GO
IF OBJECT_ID('[dbo].[MAESTRO_PERSONAL]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_PERSONAL
	PRINT 'SE ELIMINO LA TABLA MAESTRO_PERSONAL'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='	
END  
GO
IF OBJECT_ID('[dbo].[MAESTRO_PACIENTE]', 'U') IS NOT NULL
BEGIN
	DROP TABLE MAESTRO_PACIENTE
	PRINT 'SE ELIMINO LA TABLA MAESTRO_PACIENTE'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='		
END
GO
IF OBJECT_ID('[dbo].[NOMINAL_TRAMA_NUEVO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE NOMINAL_TRAMA_NUEVO
	PRINT 'SE ELIMINO LA TABLA NOMINAL_TRAMA_NUEVO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='			
END
GO
PRINT '=================>>>>>>>>> INICIO LIMPIEZA DE MJM_3_SCRIPT_VISTAS_TABLAS_MAESTRAS_ARCHIVOS_PLANOS_DETALLADO <<<<<<<<<================='
GO
IF OBJECT_ID('[dbo].[V_CONSOLIDADO_NUEVA_TRAMA_HISMINSA]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_CONSOLIDADO_NUEVA_TRAMA_HISMINSA
	PRINT 'SE ELIMINO V_CONSOLIDADO_NUEVA_TRAMA_HISMINSA'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[T_CONSOLIDADO_NUEVA_TRAMA_HISMINSA]', 'U') IS NOT NULL
BEGIN
	DROP TABLE T_CONSOLIDADO_NUEVA_TRAMA_HISMINSA
	PRINT 'SE ELIMINO T_CONSOLIDADO_NUEVA_TRAMA_HISMINSA'
    PRINT '=================>>>>>>>>>'	
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_ATENCIONES_ATENDIDOS_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_ATENCIONES_ATENDIDOS_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_ATENCIONES_ATENDIDOS_DETALLADO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_PRODUCCION_ATENCION_DIARIO_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_PRODUCCION_ATENCION_DIARIO_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_PRODUCCION_ATENCION_DIARIO_DETALLADO'
    PRINT '=================>>>>>>>>> <<<<<<<<<================='	
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_PRODUCCION_ATENCION_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_PRODUCCION_ATENCION_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_PRODUCCION_ATENCION_DETALLADO'
	PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_PRODUCCION_DIGITADOR_DIARIO_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_PRODUCCION_DIGITADOR_DIARIO_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_PRODUCCION_DIGITADOR_DIARIO_DETALLADO'
	PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_PRODUCCION_DIGITADOR_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_PRODUCCION_DIGITADOR_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_PRODUCCION_DIGITADOR_DETALLADO'
	PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
IF OBJECT_ID('[dbo].[V_REPORTE_REPORTE40A_DETALLADO]', 'V') IS NOT NULL
BEGIN
	DROP VIEW V_REPORTE_REPORTE40A_DETALLADO
	PRINT 'SE ELIMINO V_REPORTE_REPORTE40A_DETALLADO'
	PRINT '=================>>>>>>>>> <<<<<<<<<================='
END
GO
PRINT '=================>>>>>>>>> INICIO LIMPIEZA DE MJM_5_SCRIPT_REPORTES_OPERACIONALES <<<<<<<<<================='
GO
IF OBJECT_ID('[dbo].[TRAMA_BASE_GENERALES_RPT_02_MORBILIDAD_CONSOLIDADO]', 'U') IS NOT NULL
BEGIN
	DROP TABLE TRAMA_BASE_GENERALES_RPT_02_MORBILIDAD_CONSOLIDADO
	PRINT 'SE ELIMINO LA TABLA TRAMA_BASE_GENERALES_RPT_02_MORBILIDAD_CONSOLIDADO'
END
GO
PRINT '=================>>>>>>>>> FIN DE PROCESO MJM_0_SCRIPT_LIMPIAR <<<<<<<<<================='