--DEL103_DBSS_ESPL_DON_IN_TC14
create
or replace view del103_dbss_espl_don_in_tc14
(unique_id, id_richiesta, codice_richiesta, inbound_outbound, sistema_in_out, cod_tipo_comunicazione, desc_tipo_comunicazione, delibera, esito_notifica, data_inv_not_da_dbcfx, data_ric_not_su_dbcfx, data_notifica, codice_ordine_olo, data_ordine_olo, codice_ordine_ti, data_ordine_ti, dn, id_risorsa, nome_file_inviato_a_now, nome_file_ricevuto_da_now, cod_operatore_recipient, cod_operatore_donor, cod_operatore_donating, dac, des, dac_rimodulata, bid, unique_id_now, unique_id_crm_notify, unique_id_crm, unique_id_now_notify, data_filtro)
as
select SYS_GUID()                                           as UNIQUE_ID,
       null                                                 AS ID_RICHIESTA,
       CAST(cs.id_richiesta AS varchar2(100))               AS CODICE_RICHIESTA,
       'INBOUND'                                            AS INBOUND_OUTBOUND,
       'D'                                                  AS SISTEMA_IN_OUT,
       '14'                                                 AS TIPO_COMUNICAZIONE,
       CAST('ESPLETAMENTO' AS varchar2(100))                AS DESC_TIPO_COMUNICAZIONE,
       'Del.103'                                            AS DELIBERA,
       null                                                 AS ESITO_NOTIFICA,
       null                                                 AS DATA_INV_NOT_DA_DBCFX,
       null                                                 AS DATA_RIC_NOT_SU_DBCFX,
       CAST(GFRI.DATA_INVIO_RICHIESTA AS varchar2(100))     AS DATA_NOTIFICA,
       CAST(gfri.codice_ordine AS varchar2(100))            as CODICE_ORDINE_OLO,
       CAST(gfri.data_ordine AS varchar2(100))              as DATA_ORDINE_OLO,
       null                                                 as CODICE_ORDINE_TI,
       null                                                 as DATA_ORDINE_TI,
       CAST(gfri.dn AS varchar2(100))                       as DN,
       null                                                 as ID_RISORSA,
       fo.NOME_FILE                                         as NOME_FILE_INVIATO_A_NOW,
       null                                                 as NOME_FILE_RICEVUTO_DA_NOW,
       cs.COD_OP_RECIPIENT                                  as COD_OPERATORE_RECIPIENT,
       cs.COD_OP_DONOR                                      as COD_OPERATORE_DONOR,
       cs.COD_OP_DONATING                                   as COD_OPERATORE_DONATING,
       CAST(gfri.DAC AS varchar2(100))                      as DAC,
       CAST(gfri.DATA_ESPLETAMENTO_ORDINE AS varchar2(100)) AS DES,
       null                                                 AS DAC_RIMODULATA,
       null                                                 AS BID,
       null                                                 AS UNIQUE_ID_NOW,
       null                                                    UNIQUE_ID_CRM_NOTIFY,
       null                                                    UNIQUE_ID_CRM,
       null                                                    UNIQUE_ID_NOW_NOTIFY,
       null                                                 AS DATA_FILTRO
from GNP_DBSS_ESPL_DONATING_IN GFRI
         JOIN GNP_RICHIESTE_CS_NPG103 cs
              ON GFRI.CODICE_ORDINE = CS.CODICE_ORDINE
         JOIN GNP_FENP_RICHIESTE_OUT fo ON fo.CODICE_ORDINE = cs.CODICE_ORDINE
WHERE fo.TIPO_COMUNICAZIONE = '14';