Skip to content

Commit

Permalink
Added U=U messaging for OTZ
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrianbet committed Sep 2, 2024
1 parent 20b8591 commit 55db17e
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 64 deletions.
36 changes: 36 additions & 0 deletions src/actions/CT/OTZ/OtzTotalWithDurableVlResultsActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import moment from 'moment';
import { CACHING, PAGES } from '../../../constants';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';

export const loadOtzTotalWithDurableVLResults = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
moment(getState().otzTotalWithDurableVlResults.lastFetch),
'minutes'
);
if (getState().ui.ctTab !== 'otz' &&
getState().ui.currentPage !== PAGES.ct) {
return;
}
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) {
return;
} else {
await dispatch(fetchOtzTotalWithDurableVLResults());
}
}

export const fetchOtzTotalWithDurableVLResults = () => async (dispatch, getState) => {
dispatch({ type: actionTypes.CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_REQUEST });
const params = {
county: getState().filters.counties,
subCounty: getState().filters.subCounties,
facility: getState().filters.facilities,
partner: getState().filters.partners,
agency: getState().filters.agencies,
project: getState().filters.projects,
gender: getState().filters.genders,
datimAgeGroup: getState().filters.datimAgeGroups
};
const response = await getAll('care-treatment/getOtzTotalWithDurableVl', params);
dispatch({ type: actionTypes.CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FETCH, payload: { filtered: getState().filters.filtered, list: response }});
};
5 changes: 5 additions & 0 deletions src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ export const CT_OTZ_ENROLLED_FAILED = 'CT_OTZ_ENROLLED_FAILED'
export const CT_OTZ_TOTAL_WITH_VL_RESULTS_REQUEST = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_REQUEST'
export const CT_OTZ_TOTAL_WITH_VL_RESULTS_FETCH = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_FETCH'
export const CT_OTZ_TOTAL_WITH_VL_RESULTS_FAILED = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_FAILED'

export const CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_REQUEST = 'CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_REQUEST'
export const CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FETCH = 'CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FETCH'
export const CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FAILED = 'CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FAILED'

export const CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_REQUEST = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_REQUEST'
export const CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_FETCH = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_FETCH'
export const CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_FAILED = 'CT_OTZ_TOTAL_WITH_VL_RESULTS_LESS_THAN_1000_FAILED'
Expand Down
31 changes: 31 additions & 0 deletions src/reducers/CT/OTZ/otzTotalWithDurableVlResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as actionTypes from "../../../actions/types";

const initialState = {
lastFetch: null,
loading: false,
listUnfiltered: [],
listFiltered: [],
};

export default (state = initialState, action) => {
let newState = { ...state };
switch (action.type) {
case actionTypes.CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_REQUEST:
newState.loading = true;
return newState;
case actionTypes.CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FETCH:
if (action.payload.filtered === true) {
newState.listFiltered = action.payload.list;
} else {
newState.listUnfiltered = action.payload.list;
newState.lastFetch = Date.now();
}
newState.loading = false;
return newState;
case actionTypes.CT_OTZ_TOTAL_WITH_DURABLE_VL_RESULTS_FAILED:
newState.loading = false;
return newState;
default:
return state;
}
}
2 changes: 2 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import otzVlSuppressionByAgeNotEnrolled from './CT/OTZ/otzVlSuppressionByAgeNotE
import otzVlSuppressionByCountyNotEnrolled from './CT/OTZ/otzVlSuppressionByCountyNotEnrolled';
import otzVlSuppressionByPartnerNotEnrolled from './CT/OTZ/otzVlSuppressionByPartnerNotEnrolled';
import otzVlSuppressionBySexNotEnrolled from './CT/OTZ/otzVlSuppressionBySexNotEnrolled';
import otzTotalWithDurableVlResults from './CT/OTZ/otzTotalWithDurableVlResults';

import CovidAdultPLHIVCurrentOnTreatment from './CT/Covid/covidAdultPLHIVCurrentOnTreatment';
import CovidAdultPLHIVPartiallyVaccinated from './CT/Covid/covidAdultPLHIVPartiallyVaccinated';
Expand Down Expand Up @@ -498,6 +499,7 @@ export default combineReducers({
otzVlSuppressionBySexNotEnrolled,
otzVlSuppressionByPartnerNotEnrolled,
otzVlSuppressionByCountyNotEnrolled,
otzTotalWithDurableVlResults,

ovcOverallServ,
ovcServByGender,
Expand Down
12 changes: 12 additions & 0 deletions src/selectors/CT/OTZ/otzTotalWithDurableVlResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createSelector } from 'reselect';

const filtered = state => state.filters.filtered;
const listFiltered = state => state.otzTotalWithDurableVlResults.listFiltered;
const listUnfiltered = state => state.otzTotalWithDurableVlResults.listUnfiltered;

export const getOtzTotalWithDurableVlResults = createSelector(
[listUnfiltered, listFiltered, filtered],
(listUnfiltered, listFiltered, filtered) => {
return filtered ? listFiltered : listUnfiltered;
}
);
2 changes: 2 additions & 0 deletions src/views/CT/CT.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ import { loadIITTracingOutcomes } from './../../actions/CT/TreatmentOutcomes/IIT
import { loadViralLoadUptakeUToU } from '../../actions/CT/ViralLoad/viralLoadUptakeUToUActions';
import { loadViralLoadCategorizationUToU } from '../../actions/CT/ViralLoad/viralLoadCategorizationUToUActions';
import { loadAlhivOnArtByAgeSex } from '../../actions/CT/OTZ/OtzAlhivOnArtByAgeSexActions';
import { loadOtzTotalWithDurableVLResults } from '../../actions/CT/OTZ/OtzTotalWithDurableVlResultsActions';

const NewOnArt = Loadable({ loader: () => import('./NewOnArt/NewOnArt'), loading: Loading, delay: LOADING_DELAY });
const CurrentOnArt = Loadable({
Expand Down Expand Up @@ -730,6 +731,7 @@ const CT = () => {
dispatch(loadOtzVlSuppressionBySexNotEnrolled());
dispatch(loadOtzVlSuppressionByPartnerNotEnrolled());
dispatch(loadOtzVlSuppressionByCountyNotEnrolled());
dispatch(loadOtzTotalWithDurableVLResults());
dispatch(loadAlhivOnArtByAgeSex());
break;
case 'ovc':
Expand Down
115 changes: 73 additions & 42 deletions src/views/CT/OTZ/OTZOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux';
import * as otzTotalAdolescentsSelector from '../../../selectors/CT/OTZ/otzTotalAdolescents';
import * as otzEnrolledSelector from '../../../selectors/CT/OTZ/otzEnrolled';
import * as otzTotalWithVlResultsSelector from '../../../selectors/CT/OTZ/otzTotalWithVlResults';
import * as otzTotalWithDurableVlResultsSelector from '../../../selectors/CT/OTZ/otzTotalWithDurableVlResults';
import * as otzTotalWithWithResultsLessThan1000Selector from '../../../selectors/CT/OTZ/otzTotalWithWithResultsLessThan1000';
import { formatNumber, roundNumber } from '../../../utils/utils';
import DataCard from '../../Shared/DataCard';
Expand All @@ -20,6 +21,9 @@ const OTZOverview = () => {
const otzTotalWithVlResults = useSelector(
otzTotalWithVlResultsSelector.getOtzTotalWithVlResults
);
const otzTotalWithDurableVlResults = useSelector(
otzTotalWithDurableVlResultsSelector.getOtzTotalWithDurableVlResults
);
const otzTotalWithVlResultsLessThan1000 = useSelector(
otzTotalWithWithResultsLessThan1000Selector.getOtzTotalWithVlResultsLessThan1000
);
Expand Down Expand Up @@ -48,6 +52,15 @@ const OTZOverview = () => {
otzEnrolled.enrolledInOTZ) *
100
: 0,

totalWithDurableVlResults: otzTotalWithDurableVlResults?.totalDurable,
totalWithDurableVlResultsPerc:
parseInt(otzTotalWithVlResultsLessThan1000.totalWithVlLessThan1000, 10) > 0
? (otzTotalWithDurableVlResults?.totalDurable /
otzTotalWithVlResultsLessThan1000.totalWithVlLessThan1000) *
100
: 0,

totalWithVlLessThan1000:
otzTotalWithVlResultsLessThan1000.totalWithVlLessThan1000,
totalWithVlLessThan1000Perc:
Expand All @@ -62,55 +75,73 @@ const OTZOverview = () => {
otzEnrolled,
otzTotalWithVlResults,
otzTotalWithVlResultsLessThan1000,
otzTotalWithDurableVlResults,
]);

useEffect(() => {
loadOtzTotalAdolescents();
}, [loadOtzTotalAdolescents]);

return (
<Row>
<Col>
<DataCardCT
title={currentOnArtText}
subtitle={null}
data={formatNumber(otzTotalAdolescents.otzTotalAdolescents)}
/>
</Col>
<Col>
<DataCardCT
title="ENROLLED ON OTZ"
subtitle={
roundNumber(otzTotalAdolescents.enrolledInOTZPerc) + '%'
}
data={formatNumber(otzTotalAdolescents.enrolledInOTZ)}
/>
</Col>
<Col>
<DataCardCT
title="ADOLESCENTS ON OTZ WITH VALID VL"
subtitle={
roundNumber(
otzTotalAdolescents.totalWithVlResultsPerc
) + '%'
}
data={formatNumber(otzTotalAdolescents.totalWithVlResults)}
/>
</Col>
<Col>
<DataCardCT
title="ADOLESCENTS ON OTZ VIRALLY SUPPRESSED"
subtitle={
roundNumber(
otzTotalAdolescents.totalWithVlLessThan1000Perc
) + '%'
}
data={formatNumber(
otzTotalAdolescents.totalWithVlLessThan1000
)}
/>
</Col>
</Row>
<>
<Row>
<Col>
<DataCardCT
title={currentOnArtText}
subtitle={null}
data={formatNumber(otzTotalAdolescents.otzTotalAdolescents)}
/>
</Col>
<Col>
<DataCardCT
title="ENROLLED ON OTZ"
subtitle={
roundNumber(otzTotalAdolescents.enrolledInOTZPerc) + '%'
}
data={formatNumber(otzTotalAdolescents.enrolledInOTZ)}
/>
</Col>
</Row>
<Row>
<Col>
<DataCardCT
title="ADOLESCENTS ON OTZ WITH VALID VL"
subtitle={
roundNumber(
otzTotalAdolescents.totalWithVlResultsPerc
) + '%'
}
data={formatNumber(otzTotalAdolescents.totalWithVlResults)}
/>
</Col>
<Col>
<DataCardCT
title="ADOLESCENTS ON OTZ VIRALLY SUPPRESSED"
subtitle={
roundNumber(
otzTotalAdolescents.totalWithVlLessThan1000Perc
) + '%'
}
data={formatNumber(
otzTotalAdolescents.totalWithVlLessThan1000
)}
/>
</Col>
<Col>
<DataCardCT
title="ADOLESCENTS ON OTZ DURABLY SUPPRESSED"
subtitle={
roundNumber(
otzTotalAdolescents.totalWithDurableVlResultsPerc
) + '%'
}
data={formatNumber(
otzTotalAdolescents.totalWithDurableVlResults
)}
/>
</Col>
</Row>
</>
);
};

Expand Down
19 changes: 0 additions & 19 deletions src/views/CT/OTZ/OtzEnrollmentOnOTZBySex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,22 @@ import HighchartsReact from 'highcharts-react-official';
import { useSelector } from 'react-redux';
import * as otzEnrollmentAmongAlhivBySex
from '../../../selectors/CT/OTZ/otzEnrollmentAmongAlhivBySex';
import * as otzTotalAdolescentsSelector from '../../../selectors/CT/OTZ/otzTotalAdolescents';

const OtzEnrollmentOnOTZBySex = () => {
const [otzEnrollmentAmongAlHivOnArtBySex, setOtzEnrollmentAmongAlHivOnArtBySex] = useState({});
const otzEnrollmentsBySex = useSelector(otzEnrollmentAmongAlhivBySex.getOtzEnrollmentAmongAlHivOnArtBySex);
const adolescents = useSelector(otzTotalAdolescentsSelector.getOtzTotalAdolescentsByGender);

let femalePercentage = 0;
let femaleTxCurr = 0;

let malePercentage = 0;
let maleTxCurr = 0;

const femaleVals = otzEnrollmentsBySex.filter(obj => obj.Gender === 'Female');
const maleVals = otzEnrollmentsBySex.filter(obj => obj.Gender === 'Male');
if (femaleVals.length > 0) {
const femaleAdolescents = adolescents.filter(obj => obj.Gender === 'Female');
if (femaleAdolescents.length > 0) {
const totalFemaleAdolescents = femaleAdolescents[0].totalAdolescents;
if (totalFemaleAdolescents > 0) {
femalePercentage = ((femaleVals[0].TXCurr/totalFemaleAdolescents)*100);
}
}
femaleTxCurr = femaleVals[0].TXCurr;
}

if (maleVals.length > 0) {
console.log(maleVals)
const maleAdolescents = adolescents.filter(obj => obj.Gender === 'Male');
if (maleAdolescents.length > 0) {
const totalMaleAdolescents = maleAdolescents[0].totalAdolescents;
if (totalMaleAdolescents > 0) {
malePercentage = ((maleVals[0].TXCurr/totalMaleAdolescents)*100);
}
}

maleTxCurr = maleVals[0].TXCurr;
}
Expand Down
4 changes: 1 addition & 3 deletions src/views/CT/OTZ/OtzEnrollmentTrends.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const OtzEnrollmentTrends = () => {
const loadOtzEnrollmentAmongAlhivOnArtByMonth = useCallback(async () => {
setEnrollmentAmongAlhivOnArtByMonth({
chart: {
type: 'column',
type: 'line',
},
title: {
text: '',
Expand All @@ -28,8 +28,6 @@ const OtzEnrollmentTrends = () => {
crosshair: true,
},
yAxis: {
// type: 'logarithmic',
// minorTickInterval: 0.1,
title: {
text: 'NUMBER OF PATIENTS',
},
Expand Down

0 comments on commit 55db17e

Please sign in to comment.