Skip to content

Commit

Permalink
Merge pull request #935 from alan-francis/main
Browse files Browse the repository at this point in the history
feat: create 2 views for FHIR Interactions details with CSV #910
  • Loading branch information
alan-francis authored Dec 20, 2024
2 parents 84989be + e2d03be commit a0227a0
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 2 deletions.
Binary file modified hub-prime/lib/techbd-udi-jooq-ingress.auto.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,14 @@ AS SELECT sat_interaction_fhir_request_id,
payload,
patient_mrn,
concat_ws('-'::text, tenant_id, organization_id, patient_mrn) AS source_mrn,
(SELECT string_agg(concat_ws(': ', key, COALESCE(value, 'NULL')), ', ') FROM jsonb_each_text((payload->>'responseBody')::jsonb) AS json_data(key, value)) AS response_body_details
(SELECT string_agg(concat_ws(': ', key, COALESCE(value, 'NULL')), ', ') FROM jsonb_each_text((payload->>'responseBody')::jsonb) AS json_data(key, value)) AS response_body_details,
case
when (source_type = 'CSV') then 'CSV'
when (source_type = 'fhir') then 'FHIR'
when (source_type = 'FHIR') then 'FHIR'
else 'FHIR'
end as source_type,
source_hub_interaction_id
FROM techbd_udi_ingress.sat_interaction_fhir_request intr_hreq
WHERE to_state = 'FAIL'::text;

Expand Down Expand Up @@ -3819,4 +3826,88 @@ GROUP BY
fhir_summary.fhir_count_success,
fhir_summary.fhir_count_failed
ORDER BY
sizfr.created_at DESC;
sizfr.created_at DESC;


/*******************************************************************************************
This view takes data from sat_interaction_fhir_request table to
provide a consolidated view of HTTP FHIR requests via CSV, including resource types,
interaction details, request attributes, and validation issues.
******************************************************************************************/
DROP VIEW IF EXISTS techbd_udi_ingress.interaction_csv_http_fhir_request CASCADE;
CREATE OR REPLACE VIEW techbd_udi_ingress.interaction_csv_http_fhir_request
AS SELECT hub_interaction_id AS interaction_id,
uri,
bundle_id,
created_at AS interaction_created_at,
created_by AS interaction_created_by,
provenance AS interaction_provenance,
sat_interaction_fhir_request_id AS sat_interaction_http_request_id,
nature,
tenant_id,
user_agent,
client_ip_address,
'application/json'::text AS content_type,
payload,
elaboration,
from_state,
to_state,
state_transition_reason,
created_at AS request_created_at,
created_by AS request_created_by,
provenance AS request_provenance,
issues_count,
resource_type_set AS resource_types,
interaction_start_time::text AS start_time,
interaction_end_time::text AS finish_time,
EXTRACT(epoch FROM interaction_end_time::timestamp without time zone - interaction_start_time::timestamp without time zone) * 1000::numeric AS duration_millisecs,
patient_id,
patient_mrn,
patient_mrn_source_system,
organization_id,
organization_name,
concat_ws('-'::text, tenant_id, organization_id, patient_mrn) AS source_mrn,
CASE
WHEN 'ServiceRequest' = ANY(string_to_array(resource_type_set, ', ')) OR 'Task' = ANY(string_to_array(resource_type_set, ', '))
THEN 'Referral'
WHEN 'Consent' = ANY(string_to_array(resource_type_set, ', '))
THEN 'Screening'
WHEN 'Condition' = ANY(string_to_array(resource_type_set, ', '))
THEN 'Assessment'
ELSE NULL
END AS bundle_resource_type,
source_hub_interaction_id
FROM techbd_udi_ingress.sat_interaction_fhir_request htt_req
WHERE source_type='CSV';


/*******************************************************************************************
This view provides a consolidated view of failed CSV HTTP requests and associated interactions.
******************************************************************************************/
DROP VIEW IF EXISTS techbd_udi_ingress.interaction_csv_http_request_forward_failure;
CREATE OR REPLACE VIEW techbd_udi_ingress.interaction_csv_http_request_forward_failure
AS SELECT sat_interaction_fhir_request_id,
hub_interaction_id AS interaction_id,
tenant_id,
uri,
bundle_id,
nature,
created_at AS interaction_created_at,
created_by AS interaction_created_by,
provenance AS interaction_provenance,
client_ip_address,
user_agent,
from_state,
to_state,
outbound_http_message,
error_message AS error,
issues_count,
resource_type_set AS resource_types,
patient_id,
payload,
patient_mrn,
concat_ws('-'::text, tenant_id, organization_id, patient_mrn) AS source_mrn,
(SELECT string_agg(concat_ws(': ', key, COALESCE(value, 'NULL')), ', ') FROM jsonb_each_text((payload->>'responseBody')::jsonb) AS json_data(key, value)) AS response_body_details,
source_hub_interaction_id
FROM techbd_udi_ingress.sat_interaction_fhir_request intr_hreq
WHERE to_state = 'FAIL'::text AND source_type = 'CSV';

0 comments on commit a0227a0

Please sign in to comment.