Skip to content

Commit

Permalink
Merge pull request #816 from palladiumkenya/prod
Browse files Browse the repository at this point in the history
Prod
  • Loading branch information
cbrianbet authored Apr 24, 2024
2 parents d7776fd + e4754fd commit 888ddd8
Show file tree
Hide file tree
Showing 53 changed files with 1,018 additions and 167 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(
Expand All @@ -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,
Expand Down
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(
Expand All @@ -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,
Expand Down
42 changes: 42 additions & 0 deletions src/actions/CT/ViralLoad/viralLoadCategorizationUToUActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING } from '../../../constants';

export const loadViralLoadCategorizationUToU = (tab) => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
moment(getState().viralLoadCategorizationUToU.lastFetch),
'minutes'
);
if (getState().ui.ctTab !== 'vl' &&
tab !== 'vl') {
return;
}
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) {
return;
} else {
await dispatch(fetchViralLoadCategorizationUToU());
}
};

export const fetchViralLoadCategorizationUToU = () => async (dispatch, getState) => {
dispatch({ type: actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST });
const params = {
county: getState().filters.counties,
subCounty: getState().filters.subCounties,
facility: getState().filters.facilities,
partner: getState().filters.partners,
agency: getState().filters.agencies,
pbfw: getState().filters.pbfws,
gender: getState().filters.genders,
datimAgeGroup: getState().filters.datimAgeGroups,
};
const response = await getAll(
'care-treatment/vlCategorizationUToU',
params
);
dispatch({
type: actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FETCH,
payload: { filtered: getState().filters.filtered, list: response },
});
};
37 changes: 37 additions & 0 deletions src/actions/CT/ViralLoad/viralLoadUptakeUToUActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import moment from 'moment';
import * as actionTypes from '../../types';
import { getAll } from '../../../views/Shared/Api';
import { CACHING } from '../../../constants';

export const loadViralLoadUptakeUToU = (tab) => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
moment(getState().viralLoadUptakeUToU.lastFetch),
'minutes'
);
if (getState().ui.ctTab !== 'vl' &&
tab !== 'vl') {
return;
}
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) {
return;
} else {
await dispatch(fetchViralLoadUptakeUToU());
}
};

export const fetchViralLoadUptakeUToU = () => async (dispatch, getState) => {
console.log(getState().filters);
dispatch({ type: actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST });
const params = {
county: getState().filters.counties,
subCounty: getState().filters.subCounties,
facility: getState().filters.facilities,
partner: getState().filters.partners,
agency: getState().filters.agencies,
pbfw: getState().filters.pbfws,
gender: getState().filters.genders,
datimAgeGroup: getState().filters.datimAgeGroups,
};
const response = await getAll('care-treatment/vlUptakeUToU', params);
dispatch({ type: actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_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 loadCurrOnARTKHISByCounty = () => async (dispatch, getState) => {
const diffInMinutes = moment().diff(
Expand Down Expand Up @@ -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 }});
Expand Down
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(
Expand Down Expand Up @@ -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 }});
Expand Down
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;
Expand Down Expand Up @@ -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 });
Expand Down
6 changes: 3 additions & 3 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;
Expand Down Expand Up @@ -29,9 +29,9 @@ export const fetchOverallReportingRatesByFacilityReported = () => async (dispatc
params.period = getState().filters.fromDate
? moment(getState().filters.fromDate, 'MMM YYYY')
.startOf('month')
.subtract(0, 'month')
.add(1, '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 }});
Expand Down
13 changes: 13 additions & 0 deletions src/actions/Shared/filterActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const filterByAgency = agencies => ({
payload: { agencies }
});

export const filterByPBFW = (pbfws) => ({
type: actionTypes.FILTER_BY_PBFW,
payload: { pbfws },
});

export const filterByProject = projects => ({
type: actionTypes.FILTER_BY_PROJECT,
payload: { projects }
Expand Down Expand Up @@ -99,6 +104,14 @@ export const disableAgencyFilter = () => ({
type: actionTypes.DISABLE_AGENCY_FILTER
});

export const enablePBFWFilter = () => ({
type: actionTypes.ENABLE_PBFW_FILTER,
});

export const disablePBFWFilter = () => ({
type: actionTypes.DISABLE_PBFW_FILTER,
});

export const enableFacilityFilter = () => ({
type: actionTypes.ENABLE_FACILITY_FILTER
});
Expand Down
9 changes: 9 additions & 0 deletions src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const FILTER_BY_SUB_COUNTY = 'FILTER_BY_SUB_COUNTY'
export const FILTER_BY_FACILITY = 'FILTER_BY_FACILITY'
export const FILTER_BY_PARTNER = 'FILTER_BY_PARTNER'
export const FILTER_BY_AGENCY = 'FILTER_BY_AGENCY'
export const FILTER_BY_PBFW = 'FILTER_BY_PBFW';
export const FILTER_BY_PROJECT = 'FILTER_BY_PROJECT'
export const FILTER_BY_FROM_DATE = 'FILTER_BY_FROM_DATE'
export const FILTER_BY_TO_DATE = 'FILTER_BY_TO_DATE'
Expand Down Expand Up @@ -33,6 +34,7 @@ export const ENABLE_SUB_COUNTY_FILTER = 'ENABLE_SUB_COUNTY_FILTER'
export const ENABLE_FACILITY_FILTER = 'ENABLE_FACILITY_FILTER'
export const ENABLE_PARTNER_FILTER = 'ENABLE_PARTNER_FILTER'
export const ENABLE_AGENCY_FILTER = 'ENABLE_AGENCY_FILTER'
export const ENABLE_PBFW_FILTER = 'ENABLE_PBFW_FILTER';
export const ENABLE_PROJECT_FILTER = 'ENABLE_PROJECT_FILTER'
export const ENABLE_FROM_DATE_FILTER = 'ENABLE_FROM_DATE_FILTER'
export const ENABLE_TO_DATE_FILTER = 'ENABLE_TO_DATE_FILTER'
Expand All @@ -49,6 +51,7 @@ export const DISABLE_SUB_COUNTY_FILTER = 'DISABLE_SUB_COUNTY_FILTER'
export const DISABLE_FACILITY_FILTER = 'DISABLE_FACILITY_FILTER'
export const DISABLE_PARTNER_FILTER = 'DISABLE_PARTNER_FILTER'
export const DISABLE_AGENCY_FILTER = 'DISABLE_AGENCY_FILTER'
export const DISABLE_PBFW_FILTER = 'DISABLE_PBFW_FILTER';
export const DISABLE_PROJECT_FILTER = 'DISABLE_PROJECT_FILTER'
export const DISABLE_FROM_DATE_FILTER = 'DISABLE_FROM_DATE_FILTER'
export const DISABLE_TO_DATE_FILTER = 'DISABLE_TO_DATE_FILTER'
Expand Down Expand Up @@ -393,6 +396,12 @@ export const CT_VIRAL_LOAD_UPTAKE_BY_COUNTY_REQUEST_FAILED = 'CT_VIRAL_LOAD_UPTA
export const CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_REQUEST = 'CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_REQUEST'
export const CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_FETCH = 'CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_FETCH'
export const CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_REQUEST_FAILED = 'CT_VIRAL_LOAD_UPTAKE_BY_PARTNER_REQUEST_FAILED'
export const CT_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST = 'CT_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST'
export const CT_VIRAL_LOAD_UPTAKE_U_TO_U_FETCH = 'CT_VIRAL_LOAD_UPTAKE_U_TO_U_FETCH'
export const CT_VIRAL_LOAD_UPTAKE_U_TO_U_FAILED = 'CT_VIRAL_LOAD_UPTAKE_U_TO_U_FAILED'
export const CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST = 'CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST'
export const CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FETCH = 'CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FETCH'
export const CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FAILED = 'CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FAILED'

export const CT_VIRAL_LOAD_OUTCOMES_BY_SEX_REQUEST = 'CT_VIRAL_LOAD_OUTCOMES_BY_SEX_REQUEST'
export const CT_VIRAL_LOAD_OUTCOMES_BY_SEX_FETCH = 'CT_VIRAL_LOAD_OUTCOMES_BY_SEX_FETCH'
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
31 changes: 31 additions & 0 deletions src/reducers/CT/ViralLoad/viralLoadCategorizationUToU.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_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST:
newState.loading = true;
return newState;
case actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_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_VIRAL_LOAD_CATEGORIZATION_U_TO_U_FAILED:
newState.loading = false;
return newState;
default:
return state
}
}
31 changes: 31 additions & 0 deletions src/reducers/CT/ViralLoad/viralLoadUptakeUToU.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_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST:
newState.loading = true;
return newState;
case actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_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_VIRAL_LOAD_UPTAKE_U_TO_U_FAILED:
newState.loading = false;
return newState;
default:
return state
}
}
Loading

0 comments on commit 888ddd8

Please sign in to comment.