Skip to content

Commit

Permalink
Merge pull request #187 from openimis/develop
Browse files Browse the repository at this point in the history
MERGING develop into release/24.04
  • Loading branch information
delcroip committed Mar 28, 2024
2 parents dfd6aff + b9712cf commit 4c4f55d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/components/ClaimMasterPanelExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
clearLastClaimWithSameDiagnosis,
fetchLastClaimWithSameDiagnosis,
} from "../actions";
import { DEFAULT } from "../constants";
import { DEFAULT, POLICY_ACTIVE_STATUS } from "../constants";
import AdditionalPanelHeaders from "./AdditionalPanelHeaders";
import AdditionalPanelInsuree from "./AdditionalPanelInsuree";
import AdditionalPanelClaim from "./AdditionalPanelClaim";
Expand Down Expand Up @@ -85,19 +85,27 @@ class ClaimMasterPanelExt extends Component {
clearLastClaimAt();
}

getPolicyStatusLabel(timeDelta) {
return timeDelta >= 0 ? ACTIVE_LABEL : INACTIVE_LABEL;
}

getPolicyStatusLabelStyle(timeDelta, classes) {
return timeDelta >= 0 ? classes.activeLabel : classes.inactiveLabel;
}

goToClaimUuid(uuid) {
const { modulesManager, history } = this.props;
historyPush(modulesManager, history, "claim.route.claimEdit", [uuid], true);
}

valuatePolicyValidity = (currentPolicy) => {
const { classes } = this.props;

if (!currentPolicy?.length) {
return { policyInfoLabel: INACTIVE_LABEL, policyInfoStyle: classes.inactiveLabel };
}

const validityPeriod = getTimeDifferenceInDaysFromToday(currentPolicy[0].expiryDate);
const isPolicyActive = currentPolicy[0].status === POLICY_ACTIVE_STATUS;

return {
policyInfoLabel: validityPeriod >= 0 && isPolicyActive ? ACTIVE_LABEL : INACTIVE_LABEL,
policyInfoStyle: validityPeriod >= 0 && isPolicyActive ? classes.activeLabel : classes.inactiveLabel,
};
};

render() {
const {
classes,
Expand All @@ -118,15 +126,13 @@ class ClaimMasterPanelExt extends Component {
dateFrom,
insuree,
} = this.props;
const timeDelta = getTimeDifferenceInDaysFromToday(currentPolicy ? currentPolicy?.[0]?.expiryDate : null);
const policyStatusLabel = currentPolicy ? this.getPolicyStatusLabel(timeDelta) : DEFAULT_LABEL;
const policyStatusLabelStyle = currentPolicy ? this.getPolicyStatusLabelStyle(timeDelta, classes) : classes.item;
const { policyInfoLabel, policyInfoStyle } = this.valuatePolicyValidity(currentPolicy);

return (
<Grid container>
<Grid item xs={6} className={classes.item}>
<Typography className={policyStatusLabelStyle}>
<FormattedMessage module="claim" id={policyStatusLabel} />
<Typography className={policyInfoStyle}>
<FormattedMessage module="claim" id={policyInfoLabel} />
</Typography>
<Divider />
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const RIGHT_RESTORE = 111012;
export const CLAIMS_WITH_AT_LEAST_ENTERED_STATUS = 'status_Gt: 2';

export const DEFAULT_ADDITIONAL_DIAGNOSIS_NUMBER = 4;
export const POLICY_ACTIVE_STATUS = 2;

export const DEFAULT = {
IS_ADDITIONAL_PANEL_ENABLED: false,
Expand Down

0 comments on commit 4c4f55d

Please sign in to comment.