Skip to content

Commit

Permalink
BAH-4104 | Add. Show detailed consent information for each consent as…
Browse files Browse the repository at this point in the history
… expanded row
  • Loading branch information
mohan-13 committed Sep 5, 2024
1 parent e0862ed commit 847b27b
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 36 deletions.
59 changes: 30 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- 'release-*'
- BAH-4104
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
Expand Down Expand Up @@ -37,38 +38,38 @@ jobs:
platforms: linux/amd64,linux/arm64
file: package/docker/Dockerfile
push: true
tags: bahmniindiadistro/hiu-ui:${{env.ARTIFACT_VERSION}},bahmniindiadistro/hiu-ui:latest
- name: Helm - Update Version and Image Tag
run: |
yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml
yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml
tags: bahmniindiadistro/hiu-ui:${{env.ARTIFACT_VERSION}}
# - name: Helm - Update Version and Image Tag
# run: |
# yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml
# yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml

- name: Helm Lint
run: helm lint $HELM_CHART_PATH
# - name: Helm Lint
# run: helm lint $HELM_CHART_PATH

- name: Helm Package
run: helm package $HELM_CHART_PATH
# - name: Helm Package
# run: helm package $HELM_CHART_PATH

- name: Helm - Checkout Charts Repository
uses: actions/checkout@v2
with:
repository: Bahmniindiadistro/helm-charts
ref: gh-pages
path: helm-charts
persist-credentials: false
# - name: Helm - Checkout Charts Repository
# uses: actions/checkout@v2
# with:
# repository: Bahmniindiadistro/helm-charts
# ref: gh-pages
# path: helm-charts
# persist-credentials: false

- name: Helm - Copy chart
run: mkdir -p helm-charts/hiu-ui/ && cp hiu-ui-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/hiu-ui/
# - name: Helm - Copy chart
# run: mkdir -p helm-charts/hiu-ui/ && cp hiu-ui-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/hiu-ui/

- name: Helm - reIndex
working-directory: helm-charts/
run: helm repo index --merge index.yaml --url https://bahmniindiadistro.github.io/helm-charts/ .
# - name: Helm - reIndex
# working-directory: helm-charts/
# run: helm repo index --merge index.yaml --url https://bahmniindiadistro.github.io/helm-charts/ .

- name: Helm - Publish Chart
working-directory: helm-charts/
run: |
git config user.name ${{ secrets.BAHMNI_USERNAME}}
git config user.email ${{ secrets.BAHMNI_EMAIL}}
git add .
git commit -m "Release of hiu-ui-${{ env.ARTIFACT_VERSION }}"
git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmniindiadistro/helm-charts.git' gh-pages
# - name: Helm - Publish Chart
# working-directory: helm-charts/
# run: |
# git config user.name ${{ secrets.BAHMNI_USERNAME}}
# git config user.email ${{ secrets.BAHMNI_EMAIL}}
# git add .
# git commit -m "Release of hiu-ui-${{ env.ARTIFACT_VERSION }}"
# git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmniindiadistro/helm-charts.git' gh-pages
130 changes: 130 additions & 0 deletions src/components/ConsentsListTable/ConsentDetailPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import React from 'react';
import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import { Grid, Table, TableBody, TableCell, TableHead, TableRow } from '@material-ui/core';
import { formatDateString } from '../common/HealthInfo/FhirResourcesUtils';

const useStyles = makeStyles(theme => ({
detailPanel: {
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(2),
paddingLeft: theme.spacing(5),
backgroundColor: theme.palette.background.default
}
}));

const getHiTypesText = hiTypes => {
return hiTypes.join(', ');
};

const getPermissionDateRangeText = permission => {
let fromDate = formatDateString(permission.dateRange.from, false);
let toDate = formatDateString(permission.dateRange.to, false);
return `${fromDate} - ${toDate}`;
};

const consentExpiredComponent = (expiryTimestamp) => {
return (
<Typography variant="body2">
Consent Request <strong>Expired</strong> on {formatDateString(expiryTimestamp, true)}
</Typography>
)
}

const consentDeniedComponent = (deniedTimestamp) => {
return (
<Typography variant="body2">
Consent Request <strong>Denied</strong> on {formatDateString(deniedTimestamp, true)}
</Typography>
)
}

const consentArtefactDetailsComponent = (consentArtefacts) => {
return consentArtefacts.length === 0 ?
<Grid item xs={12}>
<Typography variant="body2">
<strong>No Consent Artefacts available</strong>
</Typography>
</Grid> :
(
<Grid container>
<Grid item xs={6}><Typography variant="body2">
<strong>Granted HI Types:</strong> {getHiTypesText(consentArtefacts[0].hiTypes)}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography variant="body2">
<strong>Granted Date Range:</strong> {getPermissionDateRangeText(consentArtefacts[0].permission)}
</Typography>
</Grid>
<Grid item xs={12}>
<Typography variant="body2">
<strong>Consent Artefacts:</strong>
</Typography>
<Table>
<TableHead>
<TableRow>
<TableCell>Facility Name</TableCell>
<TableCell>Status</TableCell>
<TableCell>Status Last Updated on</TableCell>
</TableRow>
</TableHead>
<TableBody>
{consentArtefacts.map((consentArtefact, index) => {
return (<TableRow>
<TableCell>{consentArtefact.hipName}</TableCell>
<TableCell>{consentArtefact.status}</TableCell>
<TableCell>{formatDateString(consentArtefact.dateModified, true)}</TableCell>
</TableRow>)
})}
</TableBody>
</Table>
</Grid>
</Grid>
)
}


const ConsentDetailPanel = ({ consentDetail }) => {
const classes = useStyles();
const consentStatus = consentDetail.status;
return (
<Grid container spacing={1} className={classes.detailPanel}>
<Grid item xs={6}>
<Typography variant="body2">
<strong>Requested HI Types:</strong> {getHiTypesText(consentDetail.hiTypes)}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography variant="body2">
<strong>Requested Date Range:</strong> {getPermissionDateRangeText(consentDetail.permission)}
</Typography>
</Grid>
<Grid item xs={12}>
{consentStatus === 'DENIED' && consentDeniedComponent(consentDetail.dateModified)}
{consentStatus === 'EXPIRED' && consentExpiredComponent(consentDetail.expiredDate)}
{(consentStatus === 'GRANTED' || consentStatus === 'REVOKED') && (
<Grid container>
{consentDetail.consentArtefacts.length === 0 ?
<Grid item xs={12}>
<Typography variant="body2">
<strong>No Consent Artefacts available</strong>
</Typography>
</Grid>
:
(
consentArtefactDetailsComponent(consentDetail.consentArtefacts)
)}
</Grid>
)}
</Grid>
</Grid>
);
};

ConsentDetailPanel.propTypes = {
consentDetail: PropTypes.object.isRequired
};

export default ConsentDetailPanel;
21 changes: 15 additions & 6 deletions src/components/ConsentsListTable/ConsentsListTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import { formatDateString } from '../common/HealthInfo/FhirResourcesUtils';
import compareDates from '../common/DateUtil';
import ConsentDetailPanel from './ConsentDetailPanel';

const useStyles = makeStyles(theme => ({
table: {
Expand All @@ -31,7 +32,7 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
requestStatus: 'Request Status',
consentGrantedDate: 'Consent granted on',
consentExpiryDate: 'Consent expiry on',
consentCreatedDate: 'Consent created on'
consentCreatedDate: 'Requested on'
};

function getStatusText(status) {
Expand All @@ -45,9 +46,9 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
case 'DENIED':
return 'Request Denied';
case 'REVOKED':
return 'Consent Revoked';
return 'Consent Revoked';
case 'EXPIRED':
return 'Consent Expired';
return 'Consent Expired';
default:
return 'Request sent';
}
Expand All @@ -57,6 +58,10 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
return status.toUpperCase() == 'GRANTED';
}

function showGrantedAndExpiredDate(status) {
return isGranted(status) || status.toUpperCase() == 'EXPIRED' || status.toUpperCase() == 'REVOKED';
}

function getPatientFullName(patient) {
return `${patient.firstName} ${patient.lastName}`;
}
Expand Down Expand Up @@ -103,10 +108,10 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
name: getPatientFullName(consent.patient),
id: consent.patient.id,
status: getStatusText(consent.status),
grantedOn: isGranted(consent.status)
grantedOn: showGrantedAndExpiredDate(consent.status)
? formatDateString(consent.approvedDate, true)
: '-',
expiredOn: isGranted(consent.status)
expiredOn: showGrantedAndExpiredDate(consent.status)
? formatDateString(consent.expiredDate, true)
: '-',
createdOn: formatDateString(consent.createdDate, true),
Expand All @@ -116,7 +121,8 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
</Link>
) : (
''
)
),
consentDetail: consent
}))}
title={(
<Typography className={classes.title} variant="h5">
Expand All @@ -131,6 +137,9 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
onClick: () => setRefreshCounter(refreshCounter + 1)
}
]}
detailPanel={rowData => (
<ConsentDetailPanel consentDetail={rowData.consentDetail}/>
)}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`ConsentsListTable should render properly 1`] = `
Object {
"customSort": [Function],
"field": "createdOn",
"title": "Consent created on",
"title": "Requested on",
},
Object {
"customSort": [Function],
Expand Down

0 comments on commit 847b27b

Please sign in to comment.