Skip to content

Commit

Permalink
Reporting month fixed to constant variable
Browse files Browse the repository at this point in the history
cbrianbet committed Apr 17, 2024
1 parent bd25091 commit d67531b
Showing 17 changed files with 55 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/actions/CT/NewOnArt/currentNewOnArtOverviewActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING, PAGES } from '../../../constants';
import { CACHING, ETL_DAY, PAGES } from '../../../constants';

export const loadCurrentNewOnArtOverview = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
@@ -22,7 +22,7 @@ export const loadCurrentNewOnArtOverview = () => async (dispatch, getState) => {

export const fetchCurrentNewOnArtOverview = () => async (dispatch, getState) => {
dispatch({ type: actionTypes.CT_CURRENT_NEW_ON_ART_OVERVIEW_REQUEST });
const previousMonth = moment().subtract(2, 'month').add(16, 'days');
const previousMonth = moment().subtract(2, 'month').add(ETL_DAY, 'days');
const params = {
county: getState().filters.counties,
subCounty: getState().filters.subCounties,
4 changes: 2 additions & 2 deletions src/actions/CT/NewOnArt/newOnArtByAgeSexActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING, PAGES } from '../../../constants';
import { CACHING, ETL_DAY, PAGES } from '../../../constants';

export const loadNewOnArtByAgeSex = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
@@ -21,7 +21,7 @@ export const loadNewOnArtByAgeSex = () => async (dispatch, getState) => {

export const fetchNewOnArtByAgeSex = () => async (dispatch, getState) => {
dispatch({ type: actionTypes.CT_NEW_ON_ART_BY_AGE_SEX_REQUEST });
const previousMonth = moment().subtract(2, 'month').add(16, 'days');
const previousMonth = moment().subtract(2, 'month').add(ETL_DAY, 'days');
const params = {
county: getState().filters.counties,
subCounty: getState().filters.subCounties,
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING, PAGES } from '../../../constants';
import { CACHING, ETL_DAY, PAGES } from '../../../constants';

export const loadCurrOnARTKHISByCounty = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
@@ -30,8 +30,8 @@ export const fetchCurrOnARTKHISByCounty = () => async (dispatch, getState) => {
project: getState().filters.projects,
gender: getState().filters.genders,
datimAgeGroup: getState().filters.datimAgeGroups,
year: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("YYYY") : moment().subtract(2, 'month').add(16, 'days').format("YYYY"),
month: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("MM") : moment().subtract(2, 'month').add(16, 'days').format("MM"),
year: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("YYYY") : moment().subtract(2, 'month').add(ETL_DAY, 'days').format("YYYY"),
month: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("MM") : moment().subtract(2, 'month').add(ETL_DAY, 'days').format("MM"),
};
const response = await getAll('operational-his/getTxCurrKHISCounty', params);
dispatch({ type: actionTypes.KHIS_CURR_ON_ART_BY_COUNTY_FETCH, payload: { filtered: getState().filters.filtered, list: response }});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING, PAGES } from '../../../constants';
import { CACHING, ETL_DAY, PAGES } from '../../../constants';

export const loadNewOnARTPartnerFacilityDWH = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
@@ -30,8 +30,8 @@ export const fetchNewOnARTByFacilityDWH = () => async (dispatch, getState) => {
project: getState().filters.projects,
gender: getState().filters.genders,
datimAgeGroup: getState().filters.datimAgeGroups,
year: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("YYYY") : moment().subtract(2, 'month').add(16, 'days').format("YYYY"),
month: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("MM") : moment().subtract(2, 'month').add(16, 'days').format("MM"),
year: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("YYYY") : moment().subtract(2, 'month').add(ETL_DAY, 'days').format("YYYY"),
month: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("MM") : moment().subtract(2, 'month').add(ETL_DAY, 'days').format("MM"),
};
const response = await getAll('operational-his/getTxNewBySexDwh', params);
dispatch({ type: actionTypes.DWH_NEW_ON_ART_BY_PARTNER_FACILITY_FETCH, payload: { filtered: getState().filters.filtered, list: response }});
5 changes: 2 additions & 3 deletions src/actions/RR/overallReportingRatesByFacilityNotReported.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import moment from 'moment';
import * as actionTypes from '../types';
import { CACHING, DWH_API_URL, PAGES } from '../../constants';
import { CACHING, DWH_API_URL, ETL_DAY, PAGES } from '../../constants';

export const loadOverallReportingRatesByFacilityNotReported = () => async (dispatch, getState) => {
const docket = getState().ui.rrTab;
@@ -33,11 +33,10 @@ export const fetchOverallReportingRatesByFacilityNotReported = () => async (disp
params.period = getState().filters.fromDate
? moment(getState().filters.fromDate, 'MMM YYYY')
.startOf('month')
.subtract(0, 'month')
.format('YYYY,M')
: moment()
.subtract(1, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('YYYY,M');
try {
const response = await axios.get(`${DWH_API_URL}manifests/overallReportingByFacility/${docket}`, { params: params });
4 changes: 2 additions & 2 deletions src/actions/RR/overallReportingRatesByFacilityReported.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import moment from 'moment';
import * as actionTypes from '../types';
import { CACHING, DWH_API_URL, PAGES } from '../../constants';
import { CACHING, DWH_API_URL, ETL_DAY, PAGES } from '../../constants';

export const loadOverallReportingRatesByFacilityReported = () => async (dispatch, getState) => {
const docket = getState().ui.rrTab;
@@ -31,7 +31,7 @@ export const fetchOverallReportingRatesByFacilityReported = () => async (dispatc
.startOf('month')
.subtract(0, 'month')
.format('YYYY,M')
: moment().subtract(1, 'month').add(16, 'days').format('YYYY,M');
: moment().subtract(1, 'month').add(ETL_DAY, 'days').format('YYYY,M');
try {
const response = await axios.get(`${DWH_API_URL}manifests/overallReportingByFacility/${docket}`, { params: params });
dispatch({ type: actionTypes.RR_OVERALL_REPORTING_RATES_BY_FACILITY_REPORTED_FETCH, payload: { filtered: getState().filters.filtered, docket: docket, list: response.data }});
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -81,3 +81,5 @@ export const GA_TRACKING_ID = 'UA-137589703-2';

export const DWH_API_URL = process.env.REACT_APP_ENDPOINT;
export const HRH_API_URL = 'https://hrh.datacompanion.org';

export const ETL_DAY = 10;
3 changes: 2 additions & 1 deletion src/views/CT/CurrentOnArt/CurrentOnArtVerifiedByAgeSex.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import * as currentOnArtByAgeSexSelectors from '../../../selectors/CT/CurrentOnA
import { useRecoilValue } from 'recoil';
import moment from 'moment';
import { roundNumber } from '../../../utils/utils';
import { ETL_DAY } from '../../../constants';

const CurrentOnArtVerifiedByAgeSex = () => {
const [currentOnArtByAgeSexChart, setCurrentOnArtByAgeSexChart] = useState(
@@ -122,7 +123,7 @@ const CurrentOnArtVerifiedByAgeSex = () => {
<div className="col-12">
<Card className="trends-card">
<CardHeader className="trends-header">
VERIFIED AND CURRENT ON ART BY AGE GROUP AND GENDER - {moment().subtract(2, 'months').add(16, 'days').format('MMMM')}
VERIFIED AND CURRENT ON ART BY AGE GROUP AND GENDER - {moment().subtract(2, 'months').add(ETL_DAY, 'days').format('MMMM')}
</CardHeader>
<CardBody className="trends-body">
<div className="col-12">
4 changes: 2 additions & 2 deletions src/views/CT/NewOnArt/NewOnArt.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import {
enableStickyFilter,
disableStickyFilter,
} from '../../../actions/Shared/uiActions';
import { LOADING_DELAY } from '../../../constants';
import { ETL_DAY, LOADING_DELAY } from '../../../constants';
import Loading from './../../Shared/Loading';
import SectionFooter from '../../Shared/SectionFooter';
import SectionHeader from '../../Shared/SectionHeader';
@@ -105,7 +105,7 @@ const NewOnArt = () => {
were started on ART within the month of{' '}
{moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMMM YYYY')}
</li>
</ul>
3 changes: 2 additions & 1 deletion src/views/CT/OTZ/OTZOverview.js
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import { formatNumber, roundNumber } from '../../../utils/utils';
import DataCard from '../../Shared/DataCard';
import moment from 'moment';
import DataCardCT from '../../Shared/DataCardCT';
import { ETL_DAY } from '../../../constants';

const OTZOverview = () => {
const [otzTotalAdolescents, setOtzTotalAdolescents] = useState({});
@@ -26,7 +27,7 @@ const OTZOverview = () => {
'ADOLESCENTS CURRENT ON ART as at ' +
moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMM YYYY');

const loadOtzTotalAdolescents = useCallback(async () => {
12 changes: 6 additions & 6 deletions src/views/CT/TreatmentOutcomes/TreatmentOutcomes.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import VisibilitySensor from 'react-visibility-sensor';
import { useDispatch, useSelector } from 'react-redux';
import { Card, CardBody, CardHeader, Col, Nav, NavItem, NavLink, Row, TabContent, TabPane } from 'reactstrap';
import { enableStickyFilter, disableStickyFilter } from "../../../actions/Shared/uiActions";
import { LOADING_DELAY } from "../../../constants";
import { ETL_DAY, LOADING_DELAY } from '../../../constants';
import Loading from './../../Shared/Loading';
import SectionFooter from '../../Shared/SectionFooter';
import SectionHeader from '../../Shared/SectionHeader';
@@ -128,7 +128,7 @@ const TreatmentOutcomes = () => {
>
CONTINUITY OF TREATMENT
</NavLink>
</NavItem>
</NavItem>
*/}
</Nav>
<TabContent activeTab={mini_tab}>
@@ -145,7 +145,7 @@ const TreatmentOutcomes = () => {
: moment()
.startOf('month')
.subtract(13, 'month')
.add(16, 'days') // Because refresh happens on the 15th date should change on the 16th day of the month
.add(ETL_DAY, 'days') // Because refresh happens on the 15th date should change on the ETL_DAYth day of the month
.format('MMM YYYY')}
</strong>{' '}
to &nbsp;
@@ -155,7 +155,7 @@ const TreatmentOutcomes = () => {
: moment()
.startOf('month')
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMM YYYY')}
</strong>
</span>
@@ -167,7 +167,7 @@ const TreatmentOutcomes = () => {
{moment()
.startOf('month')
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMM YYYY')}
</strong>
</span>
@@ -430,7 +430,7 @@ const TreatmentOutcomes = () => {
<SectionFooter />
<IITTracingNoContact />
<SectionFooter />
</TabPane>
</TabPane>
*/}
</TabContent>
</div>
3 changes: 2 additions & 1 deletion src/views/Home/HomeVLCascade.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import * as currentOnArtSelectors from '../../selectors/CT/CurrentOnArt/currentO
import { formatNumber, roundNumber } from '../../utils/utils';
import DataCard from '../Shared/DataCard';
import moment from 'moment';
import { ETL_DAY } from '../../constants';

const HomeVLCascade = () => {
// const currentOnArt = useSelector(
@@ -14,7 +15,7 @@ const HomeVLCascade = () => {
const currentDate = moment();

// Check if the current date is before the 20th of the month
if (currentDate.date() < 18) {
if (currentDate.date() < 19) {
// If true, subtract 2 months
currentDate.subtract(2, 'months');
} else {
9 changes: 5 additions & 4 deletions src/views/RR/RRCounty.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import { capitalize, getAll } from '../Shared/Api';
import { Card, CardBody, CardHeader } from 'reactstrap';
import { ETL_DAY } from '../../constants';
const _ = require("lodash");

const RRCounty = () => {
@@ -32,7 +33,7 @@ const RRCounty = () => {
project: filters.projects,
fromDate: filters.fromDate || moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMM YYYY'),
};
params.period = filters.fromDate
@@ -42,12 +43,12 @@ const RRCounty = () => {
.format('YYYY,M')
: moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('YYYY,M');
const overallReportingRateResult = await getAll('manifests/recencyreportingbycounty/' + rrTab, params);
params.period = filters.fromDate ?
moment(params.fromDate, "MMM YYYY").startOf('month').subtract(1, 'month').format('YYYY,M') :
moment().subtract(3, 'month').add(16, 'days').format('YYYY,M');
moment().subtract(3, 'month').add(ETL_DAY, 'days').format('YYYY,M');
const consistencyResult = await getAll('manifests/consistencyreportingbycountypartner/' + rrTab + '?reportingType=county', params);
const rrData = await getAll('manifests/expectedPartnerCounty/' + rrTab + '?reportingType=county', params);

@@ -84,7 +85,7 @@ const RRCounty = () => {
}

const cos = expected === 0 ? 0 : parseInt(((value/expected)*100).toString());

if (cos <= 50) {
consistency_values.push({
county: key,
7 changes: 4 additions & 3 deletions src/views/RR/RRIndicatorDefinition.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Card, CardBody, CardHeader } from 'reactstrap';
import React from 'react';
import moment from 'moment';
import { ETL_DAY } from '../../constants';

const RRIndicatorDefinition = () => {
const today = new Date();
const year = today.getFullYear();
const month = moment().subtract(2, 'month').add(16, 'days').format('MMMM');
const previousMonthDate = moment().subtract(3, 'month').add(16, 'days');
const month = moment().subtract(2, 'month').add(ETL_DAY, 'days').format('MMMM');
const previousMonthDate = moment().subtract(3, 'month').add(ETL_DAY, 'days');
const previousMonth = new Date(previousMonthDate).toLocaleString(
'default',
{ month: 'long' }
);
const twoMonthsBackDate = moment().subtract(4, 'month').add(16, 'days');
const twoMonthsBackDate = moment().subtract(4, 'month').add(ETL_DAY, 'days');
const twoMonthsBackMonth = new Date(twoMonthsBackDate).toLocaleString(
'default',
{ month: 'long' }
13 changes: 6 additions & 7 deletions src/views/RR/RROverview.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import moment from 'moment';
import { getAll } from '../Shared/Api';
import CsvDownloader from 'react-csv-downloader';
import { Spinner } from 'reactstrap';
import { ETL_DAY } from '../../constants';

const RROverview = () => {
const filters = useSelector(state => state.filters);
@@ -67,7 +68,7 @@ const RROverview = () => {
partner: filters.partners,
agency: filters.agencies,
project: filters.projects,
fromDate: filters.fromDate ? filters.fromDate : moment().subtract(2, 'month').add(16, 'days').format('MMM YYYY')
fromDate: filters.fromDate || moment().subtract(2, 'month').add(ETL_DAY, 'days').format('MMM YYYY')
};
params.period = filters.fromDate
? moment(params.fromDate, 'MMM YYYY')
@@ -76,7 +77,7 @@ const RROverview = () => {
.format('YYYY,M')
: moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('YYYY,M');
const data = await getAll('manifests/consistency/' + rrTab, params);
setConsistnecy({ consistency: [], stats: data.consistency ? data.consistency.toLocaleString('en') : [], statsPerc: getPerc(data.consistency , expected) });
@@ -102,7 +103,7 @@ const RROverview = () => {
.add(1, 'month')
.format('YYYY,M')
: moment()
.subtract(16, 'days')
.subtract(19, 'days')
.format('YYYY,M');
const data = await getAll('manifests/recency/' + rrTab, params);
setRecency({ recency: [], stats: data.recency ? data.recency.toLocaleString('en') : 0, statsPerc: getPerc(data.recency , expected) });
@@ -231,9 +232,7 @@ const RROverview = () => {
&nbsp;
<sup className="overall-rates-sup">
{' '}
{recencyStats.statsPerc
? recencyStats.statsPerc
: 0}
{recencyStats.statsPerc || 0}
<span className="overall-rates-sup-perc">
{' '}
%
@@ -296,7 +295,7 @@ const RROverview = () => {
partner: l.Partner,
reporting_date: filters.fromDate || moment()
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('MMM YYYY'),
})
)}
5 changes: 3 additions & 2 deletions src/views/RR/RROverviewTrends.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import moment from 'moment';
import { getAll } from '../Shared/Api';
import { ETL_DAY } from '../../constants';

const RROverviewTrends = () => {
const filters = useSelector(state => state.filters);
@@ -98,13 +99,13 @@ const RROverviewTrends = () => {
let endDate = moment()
.endOf('month');
if (filters.toDate || filters.fromDate) {
endDate = moment(filters.toDate ? filters.toDate: filters.fromDate, 'MMM YYYY').endOf('month');
endDate = moment(filters.toDate || filters.fromDate, 'MMM YYYY').endOf('month');
}
const startDate = endDate
.clone()
.subtract(numberOfMonths, 'month')
.subtract(2, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.startOf('month');
params.startDate = startDate.format('YYYY-MM-DD');
params.endDate = endDate.format('YYYY-MM-DD');
15 changes: 7 additions & 8 deletions src/views/RR/RRPartner.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import { capitalize, getAll } from '../Shared/Api';
import { Card, CardBody, CardHeader } from 'reactstrap';
import { ETL_DAY } from '../../constants';
const _ = require("lodash");

const RRPartner = () => {
@@ -31,16 +32,14 @@ const RRPartner = () => {
partner: filters.partners,
agency: filters.agencies,
project: filters.projects,
fromDate: filters.fromDate
? filters.fromDate
: moment()
.subtract(2, 'month')
.add(16, 'days')
.format('MMM YYYY'),
fromDate: filters.fromDate || moment()
.subtract(2, 'month')
.add(ETL_DAY, 'days')
.format('MMM YYYY'),
};
params.period = filters.fromDate ?
moment(params.fromDate, "MMM YYYY").startOf('month').subtract(0, 'month').format('YYYY,M') :
moment().subtract(2, 'month').add(16, 'days').format('YYYY,M');
moment().subtract(2, 'month').add(ETL_DAY, 'days').format('YYYY,M');
const overallReportingRateResult = await getAll('manifests/recencyreportingbypartner/' + rrTab, params);
params.period = filters.fromDate
? moment(params.fromDate, 'MMM YYYY')
@@ -49,7 +48,7 @@ const RRPartner = () => {
.format('YYYY,M')
: moment()
.subtract(3, 'month')
.add(16, 'days')
.add(ETL_DAY, 'days')
.format('YYYY,M');
const consistencyResult = await getAll('manifests/consistencyreportingbycountypartner/' + rrTab + '?reportingType=partner', params);
const rrData = await getAll('manifests/expectedPartnerCounty/' + rrTab + '?reportingType=partner', params);

0 comments on commit d67531b

Please sign in to comment.