Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-1833: resolve conflicts #62

Draft
wants to merge 55 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e94c9a8
Merge branch 'develop' of github.com:mngoe/openimis-fe-medical_js int…
mngoe Jul 11, 2022
515c61a
modification ServiceType
mngoe Jul 12, 2022
44486a3
ajustement Traduction FR
mngoe Jul 12, 2022
f997762
Merge pull request #1 from mngoe/develop-cs
mngoe Jul 12, 2022
7e735b1
Ajout Traduction FR
mngoe Jul 12, 2022
08ac63f
Merge pull request #2 from mngoe/develop-cs
mngoe Jul 12, 2022
39c1f3b
ajout message_fr
mngoe Jul 12, 2022
6d409af
Ajout de l'affichage conditionnel Manual
mngoe Jul 13, 2022
ef1afee
ajustement Show Manual
mngoe Jul 13, 2022
4b6f6dd
correction index.js et package.json pour correction nom module
mngoe Jul 13, 2022
8453ca3
Merge pull request #3 from mngoe/develop-cs
mngoe Jul 13, 2022
65cff58
ajustement ReadOnly et Required
mngoe Jul 13, 2022
4605af3
ajustement ClaimChildPanel
mngoe Jul 20, 2022
02e0ff0
ajustement fe-medical pour ajout de la selection de service unitaire …
mngoe Jul 21, 2022
b4c6ebc
ajustement MedicalChildPanel
mngoe Jul 21, 2022
4b7d720
Merge pull request #4 from mngoe/develop-cs
mngoe Jul 21, 2022
22dd310
justement terms Ceiling
mngoe Jul 21, 2022
4812e7a
justement traduction
mngoe Jul 25, 2022
f022749
Merge branch 'develop-cs' into develop
mngoe Jul 25, 2022
47db2d4
Merge branch 'develop' of github.com:mngoe/openimis-fe-medical_js int…
mngoe Jul 25, 2022
523bb02
ajustement des services filtres
mngoe Jul 26, 2022
67e9b95
Merge branch 'develop' into develop-cs
mngoe Jul 26, 2022
263c84d
ajout de selection Item sur Service Package
mngoe Jul 26, 2022
0928151
ajustement translations
mngoe Jul 27, 2022
00c4f2a
Calcul MedicalService
mngoe Jul 28, 2022
645e8e2
edit
vaneck237 Jul 29, 2022
22c4960
ajustement divers pour gestion des montants total + ajout colonne tab…
mngoe Jul 30, 2022
068d510
fix PackageType list + Check save Simple Product
mngoe Jul 30, 2022
aa8b71f
edited price fix
mngoe Jul 30, 2022
9712f2b
ajustement du formulaire d'enregistrement pour traitement CanSave et …
mngoe Jul 31, 2022
1f09b54
Fix Package Save
mngoe Jul 31, 2022
e6d05e0
Fix Loading Manual Value + Price ReadOnly Change
mngoe Jul 31, 2022
c69b8cb
correction pour affichage par defaut des valeurs deja existantes
mngoe Aug 4, 2022
81a2830
Merge branch 'develop-cs' of github.com:mngoe/openimis-fe-medical_js …
mngoe Aug 4, 2022
e39b5ef
Fix MedicalService for Deleteion
mngoe Aug 6, 2022
94f1976
ajustement transaction Colonne Supplementaire
mngoe Aug 6, 2022
0009f2e
ajustement Medical Service Master Panel
mngoe Aug 9, 2022
a5b2a69
ajustement ChildPanel Hide for Atomic elemt
mngoe Aug 9, 2022
05a5eb0
edit medical picker
vaneck237 Aug 9, 2022
801c697
Fix double ligne on add Services / items for Service Package
mngoe Aug 9, 2022
e5b51b6
resolve merge conflict
vaneck237 Aug 10, 2022
b7ef00b
Merge pull request #7 from mngoe/develop-jb
mngoe Aug 10, 2022
38b82e0
ajustement index.js
mngoe Aug 12, 2022
5c16b32
ajustement MedicalService
mngoe Aug 14, 2022
ec3fd28
Merge branch 'develop' of github.com:openimis/openimis-fe-medical_js …
mngoe Sep 1, 2022
7b6f243
Merge branch 'openimis-develop' into develop-cs
mngoe Sep 1, 2022
101287e
ajustement Action.js pour gestion du champ "ManualPrice" au cas ou il…
mngoe Sep 5, 2022
f24b515
ajutement Update Product
mngoe Sep 5, 2022
3d87c4a
ajustement MedicalServiceForm pour gestion des prix à 0
mngoe Sep 5, 2022
2418393
ajustement on MedicalItem for price at 0
mngoe Sep 5, 2022
7c08815
update with openimis develop branch
Aug 3, 2023
fd495cb
edit package.json
Aug 3, 2023
e7df094
OP-1833: resolve conflicts
olewandowski1 Mar 13, 2024
59bb4a7
OP-1833: initial clean up and refactor
olewandowski1 Mar 14, 2024
00fa350
OP-1833: be adjustmnets
olewandowski1 Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 67 additions & 17 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { formatGQLString, formatMutation, formatPageQuery, formatPageQueryWithCount, graphql, graphqlWithVariables } from "@openimis/fe-core";
import {
formatGQLString,
formatMutation,
formatPageQuery,
formatPageQueryWithCount,
graphql,
graphqlWithVariables,
decodeId,
} from "@openimis/fe-core";
import _ from "lodash";

const MEDICAL_SERVICES_SUMMARY_PROJECTION = [
"uuid",
"code",
"name",
"packagetype",
"type",
"price",
"maximumAmount",
Expand All @@ -29,6 +38,8 @@ const MEDICAL_SERVICE_FULL_PROJECTION = (mm) => [
"uuid",
"code",
"name",
"packagetype",
"manualPrice",
"type",
"price",
"maximumAmount",
Expand Down Expand Up @@ -59,13 +70,38 @@ const MEDICAL_ITEM_FULL_PROJECTION = (mm) => [
"package",
];

function formatGQLBoolean(value) {
return value ? "1" : "0";
}

export function formatDetail(type, detail) {
return `{
${detail.id ? `id: ${detail.id}` : ""}
${type}Id: ${decodeId(detail[type].id)}
${detail.priceAsked ? `priceAsked: "${_.round(detail.priceAsked, 2).toFixed(2)}"` : ""}
${detail.qtyProvided ? `qtyProvided: "${_.round(detail.qtyProvided, 2).toFixed(2)}"` : ""}
status: 1
}`;
}

export function formatDetails(type, details) {
if (!details) return "";

const dets = details
.filter((d) => Boolean(d[type]))
.map((d) => formatDetail(type, d))
.join("\n");

return `${type}s: [${dets}]`;
}

export function formatMedicalItemOrServiceGQL(mm, ms) {
const req = `
${ms.uuid ? `uuid: "${ms.uuid}"` : ""}
${ms.code ? `code: "${ms.code}"` : ""}
${ms.name ? `name: "${formatGQLString(ms.name)}"` : ""}
${ms.type ? `type: "${formatGQLString(ms.type)}"` : ""}
${ms.price ? `price: "${ms.price}"` : ""}
${!isNaN(ms.price) ? `price: "${ms.price}"` : ""}
${ms.quantity ? `quantity: "${ms.quantity}"` : ""}
${ms.maximumAmount ? `maximumAmount: "${ms.maximumAmount}"` : ""}
${ms.careType ? `careType: "${formatGQLString(ms.careType)}"` : ""}
Expand All @@ -74,6 +110,10 @@ export function formatMedicalItemOrServiceGQL(mm, ms) {
${ms.category && ms.category !== " " ? `category: "${formatGQLString(ms.category)}"` : ""}
${ms.level ? `level: "${formatGQLString(ms.level)}"` : ""}
${ms.package ? `package: "${formatGQLString(ms.package)}"` : ""}
${ms.packagetype ? `packagetype: "${formatGQLString(ms.packagetype)}"` : ""}
${ms.packagetype ? `manualPrice: "${formatGQLBoolean(ms.manualPrice)}"` : ""}
${formatDetails("service", ms.serviceserviceSet)}
${formatDetails("item", ms.servicesLinked)}
`;
return req;
}
Expand Down Expand Up @@ -122,12 +162,13 @@ export function createMedicalItem(mm, medicalItem, clientMutationLabel) {
let mutation = formatMutation("createItem", formatMedicalItemOrServiceGQL(mm, medicalItem), clientMutationLabel);
let requestedDateTime = new Date();
return graphql(
mutation.payload, ["MEDICAL_ITEM_MUTATION_REQ", "MEDICAL_ITEM_CREATE_RESP", "MEDICAL_ITEM_MUTATION_ERR"],
mutation.payload,
["MEDICAL_ITEM_MUTATION_REQ", "MEDICAL_ITEM_CREATE_RESP", "MEDICAL_ITEM_MUTATION_ERR"],
{
clientMutationId: mutation.clientMutationId,
clientMutationLabel,
requestedDateTime,
}
},
);
}

Expand Down Expand Up @@ -202,10 +243,24 @@ export function fetchMedicalService(mm, medicalServiceId, clientMutationId) {
} else if (clientMutationId) {
filters.push(`clientMutationId: "${formatGQLString(clientMutationId)}"`);
}
const payload = formatPageQuery("medicalServices", filters, MEDICAL_SERVICE_FULL_PROJECTION(mm));

const projection = MEDICAL_SERVICE_FULL_PROJECTION(mm);

projection.push(
"serviceserviceSet{" + "id service {id code name } qtyProvided, priceAsked, scpDate" + "}",
"servicesLinked{" + "id item {id code name } qtyProvided, priceAsked, pcpDate" + "}",
);

const payload = formatPageQuery("medicalServices", filters, projection);
return graphql(payload, "MEDICAL_SERVICE_OVERVIEW");
}

export function fetchMedicalServices(mm) {
const filters = [];
const payload = formatPageQuery("medicalServices", filters, MEDICAL_SERVICE_FULL_PROJECTION(mm));
return graphql(payload, "MEDICAL_SERVICE_LIST");
}

export function fetchMedicalItem(mm, medicalItemId, clientMutationId) {
const filters = [];
if (medicalItemId) {
Expand All @@ -219,7 +274,10 @@ export function fetchMedicalItem(mm, medicalItemId, clientMutationId) {

export function newMedicalService() {
return (dispatch) => {
dispatch({ type: "MEDICAL_SERVICE_NEW" });
dispatch({
type: "MEDICAL_SERVICE_NEW",
typepp: "MEDICAL_SERVICE_NEW",
});
};
}

Expand All @@ -230,20 +288,12 @@ export function newMedicalItem() {
}

export function fetchMedicalServiceMutation(mm, clientMutationId) {
const payload = formatPageQuery(
"medicalServices",
[`clientMutationId:"${clientMutationId}"`],
["uuid"],
);
const payload = formatPageQuery("medicalServices", [`clientMutationId:"${clientMutationId}"`], ["uuid"]);
return graphql(payload, "MEDICAL_SERVICE");
}

export function fetchMedicalItemMutation(mm, clientMutationId) {
const payload = formatPageQuery(
"medicalItems",
[`clientMutationId:"${clientMutationId}"`],
["uuid"],
);
const payload = formatPageQuery("medicalItems", [`clientMutationId:"${clientMutationId}"`], ["uuid"]);
return graphql(payload, "MEDICAL_ITEM");
}

Expand Down Expand Up @@ -305,4 +355,4 @@ export function clearItemForm() {
return (dispatch) => {
dispatch({ type: "CLEAR_ITEM_FORM" });
};
}
}
229 changes: 229 additions & 0 deletions src/components/MedicalItemChildPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import React, { Component } from "react";
import { connect } from "react-redux";
import { injectIntl } from "react-intl";
import _ from "lodash";

import { Paper, Box } from "@material-ui/core";
import { withTheme, withStyles } from "@material-ui/core/styles";

import {
formatMessage,
withModulesManager,
NumberInput,
Table,
PublishedComponent,
AmountInput,
} from "@openimis/fe-core";
import { SERVICE_TYPE_PP_F, SERVICE_TYPE_PP_P } from "../constants";

const styles = (theme) => ({
paper: theme.paper.paper,
});

class MedicalItemChildPanel extends Component {
state = {
data: [],
};

constructor(props) {
super(props);
this.fixedPricesAtEnter = props.modulesManager.getConf("fe-claim", "claimForm.fixedPricesAtEnter", false);
this.fixedPricesAtReview = props.modulesManager.getConf("fe-claim", "claimForm.fixedPricesAtReview", false);
this.showJustificationAtEnter = props.modulesManager.getConf(
"fe-claim",
"claimForm.showJustificationAtEnter",
false,
);
}

initData = () => {
let data = [];
if (!!this.props.edited[`servicesLinked`]) {
data = this.props.edited[`servicesLinked`] || [];
}
if (!_.isEqual(data[data.length - 1], {})) {
data.push({});
}
return data;
};

componentDidMount() {
this.setState({ data: this.initData() });
}

componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.edited_id && !this.props.edited_id) {
let data = [];
if (!this.props.forReview) {
data.push({});
}
this.setState({ data, reset: this.state.reset + 1 });
} else if (
prevProps.reset !== this.props.reset ||
(!!this.props.edited[`servicesLinked`] &&
!_.isEqual(prevProps.edited[`servicesLinked`], this.props.edited[`servicesLinked`]))
) {
this.setState({
data: this.initData(),
});
}
}

_updateData = (idx, updates) => {
const data = [...this.state.data];
updates.forEach((update) => (data[idx][update.attr] = update.v));
if (!this.props.forReview && data.length === idx + 1) {
data.push({});
}
return data;
};

_onEditedChanged = (data) => {
let edited = { ...this.props.edited };
edited[`servicesLinked`] = data;
this.props.onEditedChanged(edited);
};

_onChange = (idx, attr, v) => {
let data = this._updateData(idx, [{ attr, v }]);
let sumItems = 0;
data.forEach((update) => {
if (!isNaN(update.priceAsked) || !isNaN(update.qtyProvided)) {
sumItems += update.priceAsked * update.qtyProvided;
}
});
this._onEditedChanged(data);
};

_price = (v) => {
return v.price;
};

_onChangeItem = (idx, attr, v) => {
let data = this._updateData(idx, [{ attr, v }]);
if (!v) {
data[idx].priceAsked = null;
data[idx].qtyProvided = null;
} else {
data[idx].priceAsked = this._price(v);
if (!data[idx].qtyProvided) {
data[idx].qtyProvided = 1;
}
}
this._onEditedChanged(data);
};

_onDelete = (idx) => {
const data = [...this.state.data];
data.splice(idx, 1);
this._onEditedChanged(data);
};

formatRejectedReason = (i, idx) => {
if (i.status === 1) return null;
return (
<PublishedComponent
readOnly={true}
pubRef="claim.RejectionReasonPicker"
withLabel={false}
value={i.rejectionReason || null}
compact={true}
onChange={(v) => this._onChange(idx, "rejectionReason", v)}
/>
);
};

_onChangeApproval = (idx, attr, v) => {
let data = this._updateData(idx, [
{ attr, v },
{ attr: "rejectionReason", v: v === 2 ? -1 : null },
]);
this._onEditedChanged(data);
};

render() {
const {
intl,
classes,
edited,
type,
picker,
readOnly = false,
forReview,
fetchingPricelist,
medicalService,
} = this.props;

if (!edited) return null;

const preHeaders = ["\u200b", "", "", ""];
let headers = [`edit.${type}s.${type}`, `edit.${type}s.quantity`, `edit.${type}s.price`];

if (medicalService.packagetype === SERVICE_TYPE_PP_F) {
headers[2] = `edit.${type}s.ceiling`;
}

const itemFormatters = [
(i, idx) => (
<Box minWidth={400}>
<PublishedComponent
readOnly={!!forReview || readOnly}
pubRef={picker}
withLabel={false}
value={i.item}
fullWidth
date={edited.dateClaimed}
onChange={(v) => this._onChangeItem(idx, type, v)}
/>
</Box>
),
(i, idx) => (
<NumberInput
readOnly={!!forReview || readOnly}
value={i.qtyProvided}
onChange={(v) => this._onChange(idx, "qtyProvided", v)}
/>
),
(i, idx) => (
<AmountInput readOnly={readOnly} value={i.priceAsked} onChange={(v) => this._onChange(idx, "priceAsked", v)} />
),
];

if (!!forReview || edited.status !== 2) {
if (!this.fixedPricesAtReview) {
preHeaders.push("");
}
preHeaders.push("");
}

const header = formatMessage(intl, "claim", `edit.${type}s.title`);

if (medicalService.packagetype === SERVICE_TYPE_PP_P || medicalService.packagetype === SERVICE_TYPE_PP_F) {
return (
<Paper className={classes.paper}>
<Table
module="claim"
header={header}
preHeaders={preHeaders}
headers={headers}
itemFormatters={itemFormatters}
items={!fetchingPricelist ? this.state.data : []}
onDelete={this._onDelete}
/>
</Paper>
);
}

return null;
}
}

const mapStateToProps = (state) => ({
fetchingPricelist: !!state.medical_pricelist && state.medical_pricelist.fetchingPricelist,
servicesPricelists: !!state.medical_pricelist ? state.medical_pricelist.servicesPricelists : {},
itemsPricelists: !!state.medical_pricelist ? state.medical_pricelist.itemsPricelists : {},
});

export default withModulesManager(
injectIntl(withTheme(withStyles(styles)(connect(mapStateToProps)(MedicalItemChildPanel)))),
);
Loading