Skip to content

Commit

Permalink
MAT-7476: Restrict SDE and Risk to 128
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips committed Jan 14, 2025
1 parent 1755384 commit ca40b11
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const RiskAdjustment = () => {
const onCancel = () => {
setDiscardDialogOpen(true);
};

const MAX_LENGTH = 128;
return (
<MetaDataWrapper
header="Risk Adjustment"
Expand Down Expand Up @@ -157,6 +157,9 @@ const RiskAdjustment = () => {
multipleSelect={true}
limitTags={1}
options={definitions}
getOptionDisabled={() =>
formik?.values?.riskAdjustments?.length >= MAX_LENGTH
}
onClose={() => {}}
onChange={(e, v, r) => {
if (r === "removeOption") {
Expand All @@ -168,21 +171,23 @@ const RiskAdjustment = () => {
formik.setFieldValue("riskAdjustments", filteredValues);
}
if (r === "selectOption") {
const copiedValues = formik.values.riskAdjustments.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
if (v?.length <= MAX_LENGTH) {
const copiedValues = formik.values.riskAdjustments.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
}
}
}
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
});
formik.setFieldValue("riskAdjustments", copiedValues);
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
});
formik.setFieldValue("riskAdjustments", copiedValues);
}
}
if (r === "clear") {
formik.setFieldValue("riskAdjustments", []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const RiskAdjustment = () => {
(a, b) =>
definitions?.indexOf(a.definition) - definitions?.indexOf(b.definition)
);

const MAX_LENGTH = 128;
return (
<MetaDataWrapper
header="Risk Adjustment"
Expand Down Expand Up @@ -188,6 +188,9 @@ const RiskAdjustment = () => {
multipleSelect={true}
limitTags={1}
options={definitions}
getOptionDisabled={() =>
formik?.values?.riskAdjustments?.length >= MAX_LENGTH
}
onClose={() => {}}
onChange={(e, v, r) => {
if (r === "removeOption") {
Expand All @@ -199,22 +202,24 @@ const RiskAdjustment = () => {
formik.setFieldValue("riskAdjustments", filteredValues);
}
if (r === "selectOption") {
const copiedValues = formik.values.riskAdjustments.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
if (v?.length <= MAX_LENGTH) {
const copiedValues = formik.values.riskAdjustments.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
}
}
}
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
includeInReportType: [...measureReportTypeOptions],
});
formik.setFieldValue("riskAdjustments", copiedValues);
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
includeInReportType: [...measureReportTypeOptions],
});
formik.setFieldValue("riskAdjustments", copiedValues);
}
}
if (r === "clear") {
formik.setFieldValue("riskAdjustments", []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const SupplementalData = () => {
const onCancel = () => {
setDiscardDialogOpen(true);
};

const MAX_LENGTH = 128;
return (
<MetaDataWrapper
header="Supplemental Data"
Expand Down Expand Up @@ -157,6 +157,9 @@ const SupplementalData = () => {
multipleSelect={true}
limitTags={1}
options={definitions}
getOptionDisabled={() =>
formik?.values?.supplementalData?.length >= MAX_LENGTH
}
onClose={() => {}}
onChange={(e, v, r) => {
if (r === "removeOption") {
Expand All @@ -168,21 +171,23 @@ const SupplementalData = () => {
formik.setFieldValue("supplementalData", filteredValues);
}
if (r === "selectOption") {
const copiedValues = formik.values.supplementalData.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
if (v?.length <= MAX_LENGTH) {
const copiedValues = formik.values.supplementalData.slice();
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
}
}
}
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
});
formik.setFieldValue("supplementalData", copiedValues);
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
});
formik.setFieldValue("supplementalData", copiedValues);
}
}
if (r === "clear") {
formik.setFieldValue("supplementalData", []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const SupplementalData = () => {
definitions?.indexOf(a.definition) - definitions?.indexOf(b.definition)
);

const MAX_LENGTH = 128;
return (
<MetaDataWrapper
header="Supplemental Data"
Expand Down Expand Up @@ -194,6 +195,9 @@ const SupplementalData = () => {
limitTags={1}
options={definitions}
onClose={() => {}}
getOptionDisabled={() =>
formik?.values?.supplementalData?.length >= MAX_LENGTH
}
onChange={(e, v, r) => {
if (r === "removeOption") {
const copiedValues = _.cloneDeep(
Expand All @@ -206,24 +210,26 @@ const SupplementalData = () => {
formik.setFieldValue("supplementalData", filteredValues);
}
if (r === "selectOption") {
const copiedValues = _.cloneDeep(
formik.values.supplementalData
);
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
if (v?.length <= MAX_LENGTH) {
const copiedValues = _.cloneDeep(
formik.values.supplementalData
);
// we don't seem to have a good way of knowing exactly what was selected, but we can compare
const selectedOption = v.filter((v) => {
for (let i = 0; i < copiedValues.length; i++) {
if (copiedValues[i].definition === v) {
return false;
}
}
}
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
includeInReportType: [...measureReportTypeOptions],
});
formik.setFieldValue("supplementalData", copiedValues);
return true;
});
copiedValues.push({
definition: selectedOption[0],
description: "",
includeInReportType: [...measureReportTypeOptions],
});
formik.setFieldValue("supplementalData", copiedValues);
}
}
if (r === "clear") {
formik.setFieldValue("supplementalData", []);
Expand Down

0 comments on commit ca40b11

Please sign in to comment.