   ,c.from_case_id::boolean as "Split_Check"
   ,split_case.laa_reference as "Split_Link_Case"
   -- /SPLIT FIELDS. --
-  ,COALESCE(trim((log.context->'provider')::text, '"'), provider.name) as "Provider_ID" -- need to convert to LAA provider ID
+  ,COALESCE(assigned_provider.name, trim((log.context->'provider')::text, '"'), provider.name) as "Provider_ID" -- need to convert to LAA provider ID
   ,category.code as "Category_Name"
   ,c.created as "Date_Case_Created"
   ,c.modified as "Last_Modified_Date"
   ,log.code as "Outcome_Code_Child"
-  ,ceil(EXTRACT(EPOCH FROM (timer.stopped - timer.created))) as "Billable_Time"
+  ,CASE WHEN log.code = 'NCOE' THEN 0 ELSE ceil(EXTRACT(EPOCH FROM (timer.stopped - timer.created))) END as "Billable_Time"
   ,CASE WHEN latest_outcome.id = log.id THEN c.billable_time ELSE null END as "Cumulative_Time"
   ,mt1.code as "Matter_Type_1"
   ,mt2.code as "Matter_Type_2"

  ,ceil(EXTRACT(SECOND FROM provider_first_view.created-provider_first_assign.created))  as "Time_to_SP_Access"
  ,'PASS' as "Residency_Test"
  ,null as "Repeat_Contact"
  ,CASE WHEN log.code in ('COSPF', 'IRKB', 'SPFN', 'SPFM') THEN log.notes END as "Referral_Agencies"
  ,null as "Complaint_Type"
  ,null as "Complaint_Date"
  ,null as "Complaint_Owner"

  ,adapt.language as "Language"
  ,log.created as "Outcome_Created_At"
  ,u.username as "Username"
  ,c.thirdparty_details_id::bool as "Has_Third_Party"
from cla_eventlog_log as log
  JOIN legalaid_case as c on c.id = log.case_id
  LEFT OUTER JOIN legalaid_personaldetails as pd on c.personal_details_id = pd.id
