diff --git a/hub-prime/lib/techbd-udi-jooq-ingress.auto.jar b/hub-prime/lib/techbd-udi-jooq-ingress.auto.jar index a120d93066b..424a039c7f5 100644 Binary files a/hub-prime/lib/techbd-udi-jooq-ingress.auto.jar and b/hub-prime/lib/techbd-udi-jooq-ingress.auto.jar differ diff --git a/udi-prime/src/main/postgres/ingestion-center/001_idempotent_interaction.psql b/udi-prime/src/main/postgres/ingestion-center/001_idempotent_interaction.psql index 3c88c194cdb..b038859d925 100644 --- a/udi-prime/src/main/postgres/ingestion-center/001_idempotent_interaction.psql +++ b/udi-prime/src/main/postgres/ingestion-center/001_idempotent_interaction.psql @@ -234,7 +234,7 @@ DROP FUNCTION IF EXISTS techbd_udi_ingress.register_interaction_http_request(tex DROP FUNCTION IF EXISTS techbd_udi_ingress.register_interaction_http_request(text, text, jsonb, text, text, jsonb, jsonb, text, text, text, text, text, text, text, text, timestamptz, text, text, bool, text, bytea, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text); -CREATE OR REPLACE FUNCTION techbd_udi_ingress.register_interaction_http_request(interaction_id text, interaction_key text, payload jsonb DEFAULT NULL::jsonb, payload_text text DEFAULT NULL::text, rule_namespace text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, nature jsonb DEFAULT NULL::jsonb, content_type text DEFAULT NULL::text, from_state text DEFAULT NULL::text, to_state text DEFAULT NULL::text, state_transition_reason text DEFAULT NULL::text, user_id text DEFAULT NULL::text, user_name text DEFAULT NULL::text, user_session text DEFAULT NULL::text, user_role text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, hub_upsert_behavior boolean DEFAULT true, csv_zip_file_name text DEFAULT NULL::text, csv_zip_file_content bytea DEFAULT NULL::bytea, csv_group_id text DEFAULT NULL::text, csv_status text DEFAULT NULL::text, csv_screening_observation_data_payload_text text DEFAULT NULL::text, csv_screening_profile_data_payload_text text DEFAULT NULL::text, csv_demographic_data_payload_text text DEFAULT NULL::text, csv_qe_admin_data_payload_text text DEFAULT NULL::text, csv_screening_observation_data_file_name text DEFAULT NULL::text, csv_screening_profile_data_file_name text DEFAULT NULL::text, csv_demographic_data_file_name text DEFAULT NULL::text, csv_qe_admin_data_file_name text DEFAULT NULL::text, source_hub_interaction_id text DEFAULT NULL::text, client_ip_address text DEFAULT NULL::text, user_agent text DEFAULT NULL::text, origin text DEFAULT 'http'::text, source_type text DEFAULT 'fhir'::text, group_hub_interaction_id text DEFAULT NULL::text) +CREATE OR REPLACE FUNCTION techbd_udi_ingress.register_interaction_http_request(interaction_id text, interaction_key text, payload jsonb DEFAULT NULL::jsonb, payload_text text DEFAULT NULL::text, rule_namespace text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, nature jsonb DEFAULT NULL::jsonb, content_type text DEFAULT NULL::text, from_state text DEFAULT NULL::text, to_state text DEFAULT NULL::text, state_transition_reason text DEFAULT NULL::text, user_id text DEFAULT NULL::text, user_name text DEFAULT NULL::text, user_session text DEFAULT NULL::text, user_role text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, hub_upsert_behavior boolean DEFAULT true, csv_zip_file_name text DEFAULT NULL::text, csv_zip_file_content bytea DEFAULT NULL::bytea, csv_group_id text DEFAULT NULL::text, csv_status text DEFAULT NULL::text, csv_screening_observation_data_payload_text text DEFAULT NULL::text, csv_screening_profile_data_payload_text text DEFAULT NULL::text, csv_demographic_data_payload_text text DEFAULT NULL::text, csv_qe_admin_data_payload_text text DEFAULT NULL::text, csv_screening_observation_data_file_name text DEFAULT NULL::text, csv_screening_profile_data_file_name text DEFAULT NULL::text, csv_demographic_data_file_name text DEFAULT NULL::text, csv_qe_admin_data_file_name text DEFAULT NULL::text, source_hub_interaction_id text DEFAULT NULL::text, client_ip_address text DEFAULT NULL::text, user_agent text DEFAULT NULL::text, origin text DEFAULT NULL::text, source_type text DEFAULT NULL::text, group_hub_interaction_id text DEFAULT NULL::text) RETURNS jsonb LANGUAGE plpgsql AS $function$ @@ -1527,7 +1527,7 @@ DROP FUNCTION IF EXISTS techbd_udi_ingress.sat_interaction_fhir_request_upserted DROP FUNCTION IF EXISTS techbd_udi_ingress.sat_interaction_fhir_request_upserted(text, text, text, text, text, text, jsonb, text, timestamptz, text, text, jsonb, text, text); -CREATE OR REPLACE FUNCTION techbd_udi_ingress.sat_interaction_fhir_request_upserted(hub_interaction_id text, tenant_id text, uri text, nature text, from_state text, to_state text, payload jsonb, state_transition_reason text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, source_type text DEFAULT 'fhir', source_hub_interaction_id text DEFAULT NULL::TEXT, group_hub_interaction_id text DEFAULT NULL::TEXT) +CREATE OR REPLACE FUNCTION techbd_udi_ingress.sat_interaction_fhir_request_upserted(hub_interaction_id text, tenant_id text, uri text, nature text, from_state text, to_state text, payload jsonb, state_transition_reason text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, source_type text DEFAULT NULL::text, source_hub_interaction_id text DEFAULT NULL::text, group_hub_interaction_id text DEFAULT NULL::text) RETURNS text LANGUAGE plpgsql AS $function$ @@ -1833,7 +1833,7 @@ BEGIN COALESCE(v_interaction_end_time::TIMESTAMPTZ,NULL), v_techbd_disposition_action, v_patient_mrn_source_system, - COALESCE(source_type, 'fhir'), + source_type, source_hub_interaction_id, group_hub_interaction_id ) RETURNING sat_interaction_fhir_request_id INTO v_return; -- Return the generated UUID @@ -3269,7 +3269,8 @@ DROP FUNCTION IF EXISTS techbd_udi_ingress.sat_interaction_csv_request_upserted( DROP FUNCTION IF EXISTS techbd_udi_ingress.sat_interaction_csv_request_upserted(text, text, text, text, text, bytea, text, text, text, text, text, text, text, text, text, text, jsonb, text, text, text, timestamptz, text, text, jsonb, text, text, text, text); -CREATE OR REPLACE FUNCTION techbd_udi_ingress.sat_interaction_csv_request_upserted(interaction_id text, uri text, nature text, tenant_id text DEFAULT NULL::text, csv_zip_file_name text DEFAULT NULL::text, csv_zip_file_content bytea DEFAULT NULL::bytea, group_id text DEFAULT NULL::text, status text DEFAULT NULL::text, csv_screening_observation_data_payload_text text DEFAULT NULL::text, csv_screening_profile_data_payload_text text DEFAULT NULL::text, csv_demographic_data_payload_text text DEFAULT NULL::text, csv_qe_admin_data_payload_text text DEFAULT NULL::text, csv_screening_observation_data_file_name text DEFAULT NULL::text, csv_screening_profile_data_file_name text DEFAULT NULL::text, csv_demographic_data_file_name text DEFAULT NULL::text, csv_qe_admin_data_file_name text DEFAULT NULL::text, validation_result_payload jsonb DEFAULT NULL::jsonb, from_state text DEFAULT NULL::text, to_state text DEFAULT NULL::text, state_transition_reason text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, zip_file_hub_interaction_id text DEFAULT NULL::text, client_ip_address text DEFAULT NULL::text, user_agent text DEFAULT NULL::text, origin text DEFAULT 'http'::text) +CREATE OR REPLACE FUNCTION techbd_udi_ingress.sat_interaction_csv_request_upserted(interaction_id text, uri text, nature text, tenant_id text DEFAULT NULL::text, csv_zip_file_name text DEFAULT NULL::text, csv_zip_file_content bytea DEFAULT NULL::bytea, group_id text DEFAULT NULL::text, status text DEFAULT NULL::text, csv_screening_observation_data_payload_text text DEFAULT NULL::text, csv_screening_profile_data_payload_text text DEFAULT NULL::text, csv_demographic_data_payload_text text DEFAULT NULL::text, csv_qe_admin_data_payload_text text DEFAULT NULL::text, csv_screening_observation_data_file_name text DEFAULT NULL::text, csv_screening_profile_data_file_name text DEFAULT NULL::text, csv_demographic_data_file_name text DEFAULT NULL::text, csv_qe_admin_data_file_name text DEFAULT NULL::text, validation_result_payload jsonb DEFAULT NULL::jsonb, from_state text DEFAULT NULL::text, to_state text DEFAULT NULL::text, state_transition_reason text DEFAULT NULL::text, created_at timestamp with time zone DEFAULT NULL::timestamp with time zone, created_by text DEFAULT NULL::text, provenance text DEFAULT NULL::text, elaboration jsonb DEFAULT NULL::jsonb, zip_file_hub_interaction_id text DEFAULT NULL::text, client_ip_address text DEFAULT NULL::text, user_agent text DEFAULT NULL::text, origin text DEFAULT NULL::text) + RETURNS text LANGUAGE plpgsql AS $function$ @@ -3767,4 +3768,30 @@ BEGIN recently_created_at DESC' ) USING organization_id_param, start_date, end_date; -- Pass all parameters END; -$$ LANGUAGE plpgsql; \ No newline at end of file +$$ LANGUAGE plpgsql; + +DROP VIEW IF EXISTS techbd_udi_ingress.interaction_csv_http_stat CASCADE; +CREATE OR REPLACE VIEW techbd_udi_ingress.interaction_csv_http_stat AS +SELECT + sizfr.hub_interaction_id, + sizfr.created_at, + SUM(CASE WHEN siffcr.demographic_data_file_name IS NOT NULL THEN 1 ELSE 0 END) + + SUM(CASE WHEN siffcr.qe_admin_data_file_name IS NOT NULL THEN 1 ELSE 0 END) + + SUM(CASE WHEN siffcr.screening_observation_data_file_name IS NOT NULL THEN 1 ELSE 0 END) + + SUM(CASE WHEN siffcr.screening_profile_data_file_name IS NOT NULL THEN 1 ELSE 0 END) + AS file_count, + count(sifr.hub_interaction_id) as fhir_count, + SUM(CASE WHEN sifr.nature = 'Forwarded HTTP Response' THEN 1 ELSE 0 END) AS fhir_count_success, + SUM(CASE WHEN sifr.nature = 'Forwarded HTTP Response Error' THEN 1 ELSE 0 END) AS fhir_count_failed +FROM + techbd_udi_ingress.sat_interaction_zip_file_request sizfr +JOIN + techbd_udi_ingress.sat_interaction_flat_file_csv_request siffcr + ON sizfr.hub_interaction_id = siffcr.zip_file_hub_interaction_id +LEFT JOIN + techbd_udi_ingress.sat_interaction_fhir_request sifr + ON sizfr.hub_interaction_id = sifr.source_hub_interaction_id AND (sifr.nature ='Forwarded HTTP Response' or sifr.nature='Forwarded HTTP Response Error') AND sifr.source_type ='CSV' +GROUP BY + sizfr.hub_interaction_id, + sizfr.created_at +ORDER BY sizfr.created_at DESC; \ No newline at end of file