Skip to content

Commit

Permalink
Merge pull request tech-by-design#238 from anoopvarma-2000-p/main
Browse files Browse the repository at this point in the history
feat: added organization tab in the content tech-by-design#205
  • Loading branch information
ratheesh-kr authored Jul 31, 2024
2 parents 988e72a + c36d3f9 commit 853599c
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 26 deletions.
Binary file modified hub-prime/lib/techbd-udi-jooq-ingress.auto.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion hub-prime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>org.techbd</groupId>
<artifactId>hub-prime</artifactId>
<version>0.139.0</version>
<version>0.140.0</version>
<packaging>war</packaging>
<name>TechBD Hub (Prime)</name>
<description>TechBD Hub (Primary)</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ public String patients(final Model model, final HttpServletRequest request) {
return presentation.populateModel("page/content/patients", model, request);
}

@GetMapping("/content/organizations")
@RouteMapping(label = "Organizations", title = "Organizations", siblingOrder = 30)
public String organizations(final Model model, final HttpServletRequest request) {
return presentation.populateModel("page/content/organizations", model, request);
}

}
103 changes: 103 additions & 0 deletions hub-prime/src/main/resources/templates/page/content/organizations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/prime}">

<head>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-grid.css">
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-theme-alpine.css">

<!-- if JSON Viewer is not already in the layout, add the following -->
<!-- <script src="https://unpkg.com/@alenaksu/[email protected]/dist/json-viewer.bundle.js"></script> -->

<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.js"></script>
<script src="https://www.jsviews.com/download/jsrender.js"></script>
<script type="module">
import { AGGridAide, AGGridAideBuilder } from '@presentation/shell/aggrid-aide.js';
import ModalAide from '@presentation/shell/modal-aide.js';
import { FhirViewer } from '@presentation/shell/fhir-view.js';
customElements.define('fhir-viewer', FhirViewer);
const schemaName = 'techbd_udi_ingress';
const viewName = 'fhir_screening_organization';
const detailTableViewName = 'fhir_screening_info';

document.addEventListener('DOMContentLoaded', function () {
const modalAide = new ModalAide();
const agGridInstance = new AGGridAideBuilder()
.withColumnDefs([
{ headerName: "Organization ID", field: "org_id", filter: "agTextColumnFilter", hide: true },
{ headerName: "Organization Name", field: "org_name", filter: "agTextColumnFilter", cellRenderer: 'agGroupCellRenderer' },
{ headerName: "QE Name", field: "qe_name", filter: "agTextColumnFilter" },
{ headerName: "Active", field: "org_active", filter: "agTextColumnFilter" },
{ headerName: "Address", field: "org_address", filter: "agTextColumnFilter" },
{ headerName: "City", field: "org_city", filter: "agTextColumnFilter" },
{ headerName: "State", field: "org_state", filter: "agTextColumnFilter" },
{ headerName: "Postal Code", field: "org_postal_code", filter: "agTextColumnFilter" }
])
.withServerSideDatasource(
window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${viewName}.json`),
(data, valueCols) => {
return valueCols.map(col => ({
headerName: col.displayName,
field: col.field
}));
},
)
.withDetailCellRendererParams({// provide the Grid Options to use on the Detail Grid
detailGridOptions: {
columnDefs: [
{ headerName: "QE Name", field: "qe_name", filter: "agTextColumnFilter" },
{
headerName: "Patient MRN",
field: "patient_mrn",
filter: "agTextColumnFilter"
},
{
headerName: "Survey Date",
field: "survey_date_time",
filter: "agNumberColumnFilter",
valueFormatter: AGGridAide.isoDateTimeValueFormatter()
},

{ headerName: "Areas of Interest ", field: "areas_of_interest", filter: "agTextColumnFilter" },
{ headerName: "Total Safety Score", field: "total_safety_score", filter: "agTextColumnFilter" },
{
headerName: "Submission Date",
field: "submitted_date_time",
sort: "desc",
filter: "agNumberColumnFilter",
valueFormatter: AGGridAide.dateTimeValueFormatter()
}
],
defaultColDef: {
flex: 1
}
},
getDetailRowData: params => {
const value = params.data.org_id;
fetch(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${detailTableViewName}/org_id/${value}.json`))
.then(response => response.json())
.then(response => {
params.successCallback(response);
})
.catch(error => {
console.error('Error fetching details data' + error);
});
}
})
.withMasterDetail(true)
.withModalAide(modalAide)
.withGridDivStyles({ height: "750px", width: "100%" })
.build();
agGridInstance.init('serverDataGrid');
});
</script>
</head>

<body>
<div layout:fragment="content">
<div id="serverDataGrid" class="ag-theme-alpine"></div>
</div>

</body>

</html>
27 changes: 19 additions & 8 deletions hub-prime/src/main/resources/templates/page/content/patients.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
const agGridInstance = new AGGridAideBuilder()
.withColumnDefs([
{
headerName: "Patient ID", field: "patient_id", filter: "agTextColumnFilter"
headerName: "Patient MRN", field: "patient_mrn", filter: "agTextColumnFilter"
, cellRenderer: 'agGroupCellRenderer'
},
{ headerName: "QE Name", field: "qe_name", filter: "agTextColumnFilter" },
Expand All @@ -44,7 +44,6 @@
{ headerName: "State", field: "patient_state", filter: "agTextColumnFilter" },
{ headerName: "Postal Code", field: "patient_postal_code", filter: "agTextColumnFilter" },
{ headerName: "Language", field: "patient_language", filter: "agTextColumnFilter" },
{ headerName: "Patient MRN", field: "patient_mrn", filter: "agTextColumnFilter" },
{ headerName: "SSN", field: "patient_ssn", filter: "agTextColumnFilter" }
])
.withServerSideDatasource(
Expand All @@ -60,12 +59,24 @@
detailGridOptions: {
columnDefs: [
{
headerName: "Interaction ID",
field: "hub_interaction_id",
headerName: "Patient MRN",
field: "patient_mrn",
filter: "agTextColumnFilter",
cellRenderer: AGGridAide.modalCellRenderer((value, modalAide) => {
modalAide.showFhirViewer(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${popViewName}/hub_interaction_id/${value}.json`));
}, modalAide)
cellRenderer: params => {
const patientMrn = params.value;
const hubInteractionId = params.data.hub_interaction_id;
console.log(hubInteractionId);
const button = document.createElement('button');
button.innerText = patientMrn;
button.addEventListener('click', () => {
if (hubInteractionId) {
modalAide.showFhirViewer(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${popViewName}/hub_interaction_id/${hubInteractionId}.json`));
} else {
console.error('hub_interaction_id is undefined');
}
});
return button;
}
},
{
headerName: "Date",
Expand All @@ -88,7 +99,7 @@
}
},
getDetailRowData: params => {
const value = params.data.patient_id;
const value = params.data.patient_mrn;
fetch(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${detailTableViewName}/patient_mrn/${value}.json`))
.then(response => response.json())
.then(response => {
Expand Down
35 changes: 22 additions & 13 deletions hub-prime/src/main/resources/templates/page/content/screenings.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import { AGGridAide, AGGridAideBuilder } from '@presentation/shell/aggrid-aide.js';
import ModalAide from '@presentation/shell/modal-aide.js';

import { FhirViewer } from '@presentation/shell/fhir-view.js';
import { FhirViewer } from '@presentation/shell/fhir-view.js';
customElements.define('fhir-viewer', FhirViewer);

const schemaName = 'techbd_udi_ingress';
const viewName = 'fhir_screening_info';
const popViewName = 'fhir_screening_detail';
Expand All @@ -27,18 +27,27 @@
.withColumnDefs([
{ headerName: "QE Name", field: "qe_name", filter: "agTextColumnFilter" },
{
headerName: "Interaction ID",
field: "hub_interaction_id",
filter: "agTextColumnFilter",
cellRenderer: AGGridAide.modalCellRenderer((value, modalAide) => {
modalAide.showFhirViewer(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${popViewName}/hub_interaction_id/${value}.json`));
}, modalAide)
},
{
headerName: "Patient MRN ID",
headerName: "Patient MRN",
field: "patient_mrn",
filter: "agTextColumnFilter"
filter: "agTextColumnFilter",
cellRenderer: params => {
const patientMrn = params.value;
const hubInteractionId = params.data.hub_interaction_id;
console.log(hubInteractionId);
const button = document.createElement('button');
button.innerText = patientMrn;
button.addEventListener('click', () => {
if (hubInteractionId) {
modalAide.showFhirViewer(window.shell.serverSideUrl(`/api/ux/tabular/jooq/${schemaName}/${popViewName}/hub_interaction_id/${hubInteractionId}.json`));
} else {
console.error('hub_interaction_id is undefined');
}
});
return button;
}
},
{ headerName: "First Name", field: "first_name", filter: "agTextColumnFilter" },
{ headerName: "Last Name ", field: "last_name", filter: "agTextColumnFilter" },
{
headerName: "Date",
field: "survey_date_time",
Expand Down Expand Up @@ -71,7 +80,7 @@

agGridInstance.init('serverDataGrid');
});
</script>
</script>
</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ extracted_data AS (
END AS last_updated,

-- 2) If entry[] -> resource -> "resourceType" = "Patient", get entry[] -> resource -> id
( select (entry.value -> 'resource' -> 'identifier' -> 0 ->> 'value'::text)
FROM jsonb_array_elements(filtered_data.payload -> 'entry'::text) entry(value)
WHERE ((entry.value -> 'resource'::text) ->> 'resourceType'::text) = 'Patient'::text) AS patient_id,
( select ((((entry.value -> 'resource'::text) -> 'name'::text) -> 0)->> 'text'::text)
FROM jsonb_array_elements(filtered_data.payload -> 'entry'::text) entry(value)
WHERE ((entry.value -> 'resource'::text) ->> 'resourceType'::text) = 'Patient'::text) AS full_name,
( select ((((entry.value -> 'resource') -> 'name') -> 0) ->> 'family')
FROM jsonb_array_elements(filtered_data.payload -> 'entry'::text) entry(value)
WHERE ((entry.value -> 'resource'::text) ->> 'resourceType'::text) = 'Patient'::text) AS last_name,
( select array_to_string(ARRAY( SELECT jsonb_array_elements_text((((entry.value -> 'resource'::text) -> 'name'::text) -> 0) -> 'given'::text) AS jsonb_array_elements_text), ' '::text)
FROM jsonb_array_elements(filtered_data.payload -> 'entry'::text) entry(value)
WHERE ((entry.value -> 'resource'::text) ->> 'resourceType'::text) = 'Patient'::text) AS first_name,

(SELECT entry -> 'resource' ->> 'id'
FROM jsonb_array_elements(payload -> 'entry') AS entry
WHERE (entry -> 'resource' ->> 'resourceType') = 'Patient'
) AS patient_id,

WHERE (entry -> 'resource' ->> 'resourceType') = 'Organization'
) AS org_id,


-- 3) If "resourceType" = "Observation", get category[] -> coding -> display element values in comma separated manner
(SELECT string_agg(DISTINCT coding ->> 'display', ', ')
FROM jsonb_array_elements(payload -> 'entry') AS entry
Expand All @@ -53,8 +67,13 @@ extracted_data AS (
FROM filtered_data
)
SELECT hub_interaction_id,

tenant_id AS qe_name,
created_at AS submitted_date_time,
org_id,
last_name,
full_name,
first_name,
created_at AS submitted_date_time,
patient_id AS patient_mrn,
last_updated AS survey_date_time,
category_display AS areas_of_interest,
Expand Down Expand Up @@ -154,3 +173,46 @@ AS WITH filtered_data AS (
GROUP BY tenant_id, patient_id
ORDER BY patient_id DESC;


/*******************************************************************************************
* Comprehensive view of FHIR Content Screening Organization. *
******************************************************************************************/
DROP VIEW IF EXISTS techbd_udi_ingress.fhir_screening_organization CASCADE;
CREATE OR REPLACE VIEW techbd_udi_ingress.fhir_screening_organization
AS WITH filtered_data AS (
SELECT sihr.hub_interaction_id,
sihr.nature ->> 'tenant_id' AS tenant_id,
sihr.payload::jsonb AS payload,
hintr.created_at
FROM techbd_udi_ingress.hub_interaction hintr
JOIN techbd_udi_ingress.sat_interaction_http_request sihr
ON hintr.hub_interaction_id = sihr.hub_interaction_id
WHERE hintr.key LIKE '/Bundle%'
AND sihr.nature ->> 'nature' = 'Original FHIR Payload'
),
patient_details AS (
SELECT tenant_id,
(entry -> 'resource') ->> 'id' AS org_id,
(entry -> 'resource') ->> 'resourceType' AS org_resource_type,
(entry -> 'resource') ->> 'name' AS org_name,
(entry -> 'resource') ->> 'active' AS org_active,
(entry -> 'resource') ->'address'->0->>'text' AS org_address,
(entry -> 'resource') ->'address'->0->>'city' AS org_city,
(entry -> 'resource') ->'address'->0->>'state' AS org_state,
(entry -> 'resource') ->'address'->0->>'postalCode' AS org_postal_code
FROM filtered_data,
jsonb_array_elements(payload -> 'entry') AS entry
WHERE (entry -> 'resource') ->> 'resourceType' = 'Organization'
)
SELECT tenant_id AS qe_name,
org_id,
MAX(org_resource_type) as org_type,
MAX(org_name) as org_name,
MAX(org_active) as org_active,
MAX(org_address) as org_address,
MAX(org_city) as org_city,
MAX(org_state) as org_state,
MAX(org_postal_code) as org_postal_code
FROM patient_details
GROUP BY tenant_id, org_id
ORDER BY org_id DESC;

0 comments on commit 853599c

Please sign in to comment.