Skip to content

Commit

Permalink
Merge pull request #166 from openimis/develop
Browse files Browse the repository at this point in the history
MERGING develop into release/23.10
  • Loading branch information
delcroip authored Dec 15, 2023
2 parents 99aef15 + d87e961 commit 34de2cd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ None
- `canSaveClaimWithoutServiceNorItem`, wherever user can save a claim without service nor item, default: true
- `canSubmitClaimWithZero`, wherever user can submit with 0 as claimed amount (probably a claim without service/item), default: false
- `claimAttachments`, boolean to enable/disable claim attachments. Default true;
- `claimForm.referHF`, boolean to enable/disable referal HF (mandatory when visit type = Referal, optional without). Default true;
- `claimForm.isReferHFMandatory`, boolean to make referal HF mandatory when visit type = Referal. Default false;
- `claimForm.claimTypeReferSymbol`, used for checking referHF option, indicate which letter represents referal. Default R.
- `claimForm.autoGenerateClaimCode`, boolean to enable autogenerating claim code by the backend. Default false.
- `claimForm.numberOfAdditionalDiagnosis`, integer to enable required number of additional diagnoses. Default 4, up to 4 supported.
Expand Down
47 changes: 30 additions & 17 deletions src/components/ClaimForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
STATUS_REJECTED,
STORAGE_KEY_ADMIN,
STORAGE_KEY_CLAIM_HEALTH_FACILITY,
DEFAULT
DEFAULT,
} from "../constants";
import ClaimMasterPanel from "./ClaimMasterPanel";
import ClaimChildPanel from "./ClaimChildPanel";
Expand Down Expand Up @@ -109,6 +109,7 @@ class ClaimForm extends Component {
"claimForm.quantityMaxValue",
DEFAULT.QUANTITY_MAX_VALUE,
);
this.isReferHFMandatory = props.modulesManager.getConf("fe-claim", "claimForm.isReferHFMandatory", false);
}

_newClaim() {
Expand All @@ -117,12 +118,13 @@ class ClaimForm extends Component {
this?.state?.claim?.healthFacility ??
this.props.claimHealthFacility ??
JSON.parse(localStorage.getItem(STORAGE_KEY_CLAIM_HEALTH_FACILITY));
claim.admin = this?.state?.claim?.admin ?? this.props.claimAdmin ?? JSON.parse(localStorage.getItem(STORAGE_KEY_ADMIN));
claim.admin =
this?.state?.claim?.admin ?? this.props.claimAdmin ?? JSON.parse(localStorage.getItem(STORAGE_KEY_ADMIN));
claim.status = this.props.modulesManager.getConf("fe-claim", "newClaim.status", 2);
claim.dateClaimed = toISODate(moment().toDate());
claim.dateFrom = toISODate(moment().toDate());
claim.visitType = this.props.modulesManager.getConf("fe-claim", "newClaim.visitType", "O");
claim.code = ""
claim.code = "";
claim.jsonExt = {};
return claim;
}
Expand Down Expand Up @@ -155,13 +157,13 @@ class ClaimForm extends Component {
adjustment: null,
valuated: null,
referFrom: null,
referTo: null
}
referTo: null,
};
}

_duplicateClaim(claim) {
const restoredClaim = this._restoreClaim(claim);
return { ...restoredClaim, insuree: null, code: "", restore: null}
return { ...restoredClaim, insuree: null, code: "", restore: null };
}

componentDidMount() {
Expand Down Expand Up @@ -194,9 +196,14 @@ class ClaimForm extends Component {
this.props.claimHealthFacilitySet(this.props.claim.healthFacility),
);
} else if (prevProps.claim_uuid && !this.props.claim_uuid && this.state.isDuplicate) {
this.setState({ claim: this._duplicateClaim(this.state.claim), newClaim: true, lockNew: false, claim_uuid: null })
this.setState({
claim: this._duplicateClaim(this.state.claim),
newClaim: true,
lockNew: false,
claim_uuid: null,
});
} else if (prevProps.claim_uuid && !this.props.claim_uuid && this.state.isRestored) {
this.setState({ claim: this._restoreClaim(this.state.claim), newClaim: true, lockNew: false, claim_uuid: null })
this.setState({ claim: this._restoreClaim(this.state.claim), newClaim: true, lockNew: false, claim_uuid: null });
} else if (prevProps.claim_uuid && !this.props.claim_uuid) {
this.setState({ claim: this._newClaim(), newClaim: true, lockNew: false, claim_uuid: null });
} else if (prevProps.submittingMutation && !this.props.submittingMutation) {
Expand Down Expand Up @@ -228,7 +235,7 @@ class ClaimForm extends Component {
if (d.priceAsked === null || d.priceAsked === undefined || d.priceAsked === "") return false;
if (
this.explanationRequiredIfQuantityAboveThreshold &&
type === "service" &&
type === "service" &&
!d.explanation &&
d.qtyProvided > this.quantityExplanationThreshold
) {
Expand All @@ -248,19 +255,24 @@ class ClaimForm extends Component {
if (!this.props.isClaimCodeValid) return false;
if (!!this.state.claim.codeError) return false;
if (!this.state.claim.healthFacility) return false;
if (this.state.claim.visitType === this.claimTypeReferSymbol && !this.state.claim.referHF) return false;
if (
!!this.isReferHFMandatory &&
this.state.claim.visitType === this.claimTypeReferSymbol &&
!this.state.claim.referHF
)
return false;
if (!this.state.claim.insuree) return false;
if (!this.state.claim.admin) return false;
if (!this.state.claim.dateClaimed) return false;
if (!this.state.claim.dateFrom) return false;
if (this.state.claim.dateClaimed < this.state.claim.dateFrom) return false;
if (!!this.state.claim.dateTo && this.state.claim.dateFrom > this.state.claim.dateTo) return false;
if (!this.state.claim.icd) return false;
if (this.isCareTypeMandatory){
if (this.isCareTypeMandatory) {
if (!CARE_TYPE_STATUS.includes(this.state.claim.careType)) return false;
}
if (this.isExplanationMandatoryForIPD){
if (this.state.claim.careType===IN_PATIENT_STRING && !this.state.claim.explanation) return false;
if (this.isExplanationMandatoryForIPD) {
if (this.state.claim.careType === IN_PATIENT_STRING && !this.state.claim.explanation) return false;
}
if (!forFeedback) {
if (!this.state.claim.items && !this.state.claim.services) {
Expand Down Expand Up @@ -403,7 +415,8 @@ class ClaimForm extends Component {
{
condition:
rights.includes(RIGHT_RESTORE) &&
claim_uuid && isHealthFacilityPage &&
claim_uuid &&
isHealthFacilityPage &&
this.state.claim?.status === STATUS_REJECTED,
content: (
<span>
Expand Down Expand Up @@ -458,7 +471,7 @@ class ClaimForm extends Component {
readOnly: readOnly,
forReview: forReview,
forFeedback: forFeedback,
onEditedChanged: this.onEditedChanged
onEditedChanged: this.onEditedChanged,
};
return (
<Fragment>
Expand All @@ -483,7 +496,7 @@ class ClaimForm extends Component {
titleParams={{ code: this.state.claim.code }}
HeadPanel={ClaimMasterPanel}
Panels={!!forFeedback ? [ClaimFeedbackPanel] : [ClaimServicesPanel, ClaimItemsPanel]}
openDirty={save||forReview}
openDirty={save || forReview}
additionalTooltips={tooltips}
{...editingProps}
/>
Expand All @@ -507,7 +520,7 @@ const mapStateToProps = (state, props) => ({
claimAdmin: state.claim.claimAdmin,
claimHealthFacility: state.claim.claimHealthFacility,
generating: state.claim.generating,
isClaimCodeValid: state.claim.validationFields?.claimCode?.isValid
isClaimCodeValid: state.claim.validationFields?.claimCode?.isValid,
});

const mapDispatchToProps = (dispatch) => {
Expand Down
110 changes: 52 additions & 58 deletions src/components/ClaimMasterPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ClaimMasterPanel extends FormPanel {

shouldValidate = (inputValue) => {
const { savedClaimCode } = this.props;
const shouldValidate = inputValue !== (savedClaimCode);
const shouldValidate = inputValue !== savedClaimCode;
return shouldValidate;
};

Expand All @@ -62,16 +62,8 @@ class ClaimMasterPanel extends FormPanel {
"claimForm.insureePicker",
"insuree.InsureeChfIdPicker",
);
this.allowReferHF = props.modulesManager.getConf(
"fe-claim",
"claimForm.referHF",
true,
);
this.claimTypeReferSymbol = props.modulesManager.getConf(
"fe-claim",
"claimForm.claimTypeReferSymbol",
'R',
);
this.isReferHFMandatory = props.modulesManager.getConf("fe-claim", "claimForm.isReferHFMandatory", false);
this.claimTypeReferSymbol = props.modulesManager.getConf("fe-claim", "claimForm.claimTypeReferSymbol", "R");
this.numberOfAdditionalDiagnosis = props.modulesManager.getConf(
"fe-claim",
"claimForm.numberOfAdditionalDiagnosis",
Expand All @@ -82,17 +74,9 @@ class ClaimMasterPanel extends FormPanel {
"claimForm.isExplanationMandatoryForIPD",
false,
);
this.isCareTypeMandatory = props.modulesManager.getConf(
"fe-claim",
"claimForm.isCareTypeMandatory",
false,
);
this.isClaimedDateFixed = props.modulesManager.getConf(
"fe-claim",
"claimForm.isClaimedDateFixed",
false,
);
this.EMPTY_STRING = ""
this.isCareTypeMandatory = props.modulesManager.getConf("fe-claim", "claimForm.isCareTypeMandatory", false);
this.isClaimedDateFixed = props.modulesManager.getConf("fe-claim", "claimForm.isClaimedDateFixed", false);
this.EMPTY_STRING = "";
}

componentWillUnmount = () => {
Expand All @@ -108,7 +92,7 @@ class ClaimMasterPanel extends FormPanel {
parseFloat(currentItem.priceApproved) ||
parseFloat(currentItem.priceAsked) ||
0;
const priceTimesQty = price * ((parseInt(currentItem?.qtyApproved) || parseInt(currentItem?.qtyProvided)) || 0);
const priceTimesQty = price * (parseInt(currentItem?.qtyApproved) || parseInt(currentItem?.qtyProvided) || 0);
return total + priceTimesQty;
}, 0);
};
Expand All @@ -135,8 +119,7 @@ class ClaimMasterPanel extends FormPanel {
restore,
isRestored,
isDuplicate,
}
= this.props;
} = this.props;
if (!edited) return null;
let totalClaimed = 0;
let totalApproved = 0;
Expand Down Expand Up @@ -297,25 +280,30 @@ class ClaimMasterPanel extends FormPanel {
}
/>
)}
{!!this.allowReferHF && <ControlledField
<ControlledField
module="claim"
id="Claim.referHealthFacility"
field={
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="location.HealthFacilityReferPicker"
label={formatMessage(intl, "claim", "ClaimMasterPanel.referHFLabel")}
value={(edited.visitType === this.claimTypeReferSymbol ? edited.referFrom: edited.referTo) ?? this.EMPTY_STRING}
value={
(edited.visitType === this.claimTypeReferSymbol ? edited.referFrom : edited.referTo) ??
this.EMPTY_STRING
}
reset={reset}
readOnly={ro}
required={edited.visitType === this.claimTypeReferSymbol}
filterOptions={(options)=>options?.filter((option)=>option.uuid !== userHealthFacilityFullPath?.uuid)}
required={this.isReferHFMandatory && edited.visitType === this.claimTypeReferSymbol}
filterOptions={(options) =>
options?.filter((option) => option.uuid !== userHealthFacilityFullPath?.uuid)
}
filterSelectedOptions={true}
onChange={(d) => this.updateAttribute("referHF", d)}
/>
</Grid>
}
/>}
/>
<ControlledField
module="claim"
id="Claim.code"
Expand All @@ -337,7 +325,13 @@ class ClaimMasterPanel extends FormPanel {
setValidAction={claimCodeSetValid}
shouldValidate={this.shouldValidate}
validationError={codeValidationError}
value={!!this.state.data ? this.state.data.code : (this.autoGenerateClaimCode ? formatMessage(intl, "claim", "ClaimMasterPanel.autogenerate") : null)}
value={
!!this.state.data
? this.state.data.code
: this.autoGenerateClaimCode
? formatMessage(intl, "claim", "ClaimMasterPanel.autogenerate")
: null
}
inputProps={{
"maxLength": this.codeMaxLength,
}}
Expand Down Expand Up @@ -430,28 +424,25 @@ class ClaimMasterPanel extends FormPanel {
)}
{!forFeedback && (
<Fragment>
{Array.from(
{ length: this.numberOfAdditionalDiagnosis },
(_, diagnosisIndex) => (
<ControlledField
module="claim"
id={`Claim.secDiagnosis${diagnosisIndex + 1}`}
field={
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="medical.DiagnosisPicker"
name={`secDiagnosis${diagnosisIndex + 1}`}
label={formatMessage(intl, "claim", `secDiagnosis${diagnosisIndex + 1}`)}
value={edited[`icd${diagnosisIndex + 1}`]}
reset={reset}
onChange={(value) => this.updateAttribute(`icd${diagnosisIndex + 1}`, value)}
readOnly={ro}
/>
</Grid>
}
/>
)
)}
{Array.from({ length: this.numberOfAdditionalDiagnosis }, (_, diagnosisIndex) => (
<ControlledField
module="claim"
id={`Claim.secDiagnosis${diagnosisIndex + 1}`}
field={
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="medical.DiagnosisPicker"
name={`secDiagnosis${diagnosisIndex + 1}`}
label={formatMessage(intl, "claim", `secDiagnosis${diagnosisIndex + 1}`)}
value={edited[`icd${diagnosisIndex + 1}`]}
reset={reset}
onChange={(value) => this.updateAttribute(`icd${diagnosisIndex + 1}`, value)}
readOnly={ro}
/>
</Grid>
}
/>
))}
</Fragment>
)}
<ControlledField
Expand Down Expand Up @@ -482,7 +473,7 @@ class ClaimMasterPanel extends FormPanel {
reset={reset}
onChange={(v) => this.updateAttribute("explanation", v)}
readOnly={ro}
required={this.isExplanationMandatoryForIPD && edited.careType===IN_PATIENT_STRING ? true : false}
required={this.isExplanationMandatoryForIPD && edited.careType === IN_PATIENT_STRING ? true : false}
/>
</Grid>
}
Expand Down Expand Up @@ -539,10 +530,13 @@ const mapStateToProps = (state) => ({
});

const mapDispatchToProps = (dispatch) => {
return bindActionCreators({
claimHealthFacilitySet,
clearClaim,
}, dispatch);
return bindActionCreators(
{
claimHealthFacilitySet,
clearClaim,
},
dispatch,
);
};

export default withModulesManager(
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReviewsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class RawRandomAndValueFilters extends Component {
{
id: "claimedAbove",
value: this.state.value,
filter: `claimed_Gte: ${this.state.value}`,
filter: `claimed_Gte: "${this.state.value}"`,
},
];
}
Expand Down

0 comments on commit 34de2cd

Please sign in to comment.