Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #766 from MeasureAuthoringTool/MAT-7914_PatientCha…
Browse files Browse the repository at this point in the history
…racteristicExpired

Mat 7914 patient characteristic expired
  • Loading branch information
sb-cecilialiu authored Nov 20, 2024
2 parents ecac28f + 781c1c0 commit 433b371
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
PatientCharacteristicEthnicity,
PatientCharacteristicExpired,
DataElementCode,
PatientCharacteristicRace,
PatientCharacteristicSex,
} from "cqm-models";

const emptyPatient = new QDMPatient();
Expand Down Expand Up @@ -198,4 +200,72 @@ describe("DemographicsSection", () => {
});
});
});

it("should handle Race change", () => {
const qdmPatient = new QDMPatient();
const raceElement = new PatientCharacteristicRace();
const newCode: DataElementCode = {
code: "1002-5",
display: "American Indian or Alaska Native",
version: undefined,
system: "2.16.840.1.113883.6.238",
};
raceElement.dataElementCodes = [newCode];
qdmPatient.dataElements.push(raceElement);
(useQdmPatient as jest.Mock).mockImplementation(() => ({
state: { patient: qdmPatient },
dispatch: mockUseQdmPatientDispatch,
}));
render(
<FormikProvider value={mockFormik}>
<DemographicsSection canEdit={true} />
</FormikProvider>
);

expect(screen.getByText("Race")).toBeInTheDocument();
const raceInput = screen.getByTestId(
"demographics-race-input"
) as HTMLInputElement;
expect(raceInput).toBeInTheDocument();
expect(raceInput.value).toBe("American Indian or Alaska Native");

fireEvent.change(raceInput, {
target: { value: "Asian" },
});
expect(raceInput.value).toBe("Asian");
});

it("should handle Gender change", () => {
const qdmPatient = new QDMPatient();
const genderElement = new PatientCharacteristicSex();
const newCode: DataElementCode = {
system: "2.16.840.1.113883.5.1",
version: "2023-02-01",
code: "F",
display: "Female",
};
genderElement.dataElementCodes = [newCode];
qdmPatient.dataElements.push(genderElement);
(useQdmPatient as jest.Mock).mockImplementation(() => ({
state: { patient: qdmPatient },
dispatch: mockUseQdmPatientDispatch,
}));
render(
<FormikProvider value={mockFormik}>
<DemographicsSection canEdit={true} />
</FormikProvider>
);

expect(screen.getByText("Gender")).toBeInTheDocument();
const genderInput = screen.getByTestId(
"demographics-gender-input"
) as HTMLInputElement;
expect(genderInput).toBeInTheDocument();
expect(genderInput.value).toBe("Female");

fireEvent.change(genderInput, {
target: { value: "Male" },
});
expect(genderInput.value).toBe("Male");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
getRaceDataElement,
LIVING_STATUS_CODE_OPTIONS,
RACE_CODE_OPTIONS,
PATIENT_CHARACTERISTIC_EXPIRED,
getPatientCharacteristicExpiredDateElement,
} from "./DemographicsSectionConst";
import { MenuItem as MuiMenuItem } from "@mui/material";
import {
Expand Down Expand Up @@ -110,6 +112,7 @@ const DemographicsSection = ({ canEdit }) => {

const expiredElement = getDataElementByStatus("expired", patient);
if (expiredElement) {
expiredElement.dataElementCodes = PATIENT_CHARACTERISTIC_EXPIRED;
setLivingStatusDataElement(expiredElement);
} else {
setLivingStatusDataElement("Living");
Expand Down Expand Up @@ -209,10 +212,8 @@ const DemographicsSection = ({ canEdit }) => {

const handleExpiredDateTimeChange = (val) => {
const expiredElement = getDataElementByStatus("expired", patient);
const newExpiredElement: DataElement = new PatientCharacteristicExpired(
expiredElement
);
newExpiredElement.expiredDatetime = val;
const newExpiredElement: DataElement =
getPatientCharacteristicExpiredDateElement(val, expiredElement);
setLivingStatusDataElement(newExpiredElement);
dispatch({
type: PatientActionType.MODIFY_DATA_ELEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ export const ETHNICITY_CODE_OPTIONS: DataElementCode[] = [
];

export const LIVING_STATUS_CODE_OPTIONS = ["Living", "Expired"];
export const PATIENT_CHARACTERISTIC_EXPIRED: DataElementCode = {
code: "419099009",
system: "2.16.840.1.113883.6.96",
version: "2022-09",
display: "Dead (finding)",
};
export const getPatientCharacteristicExpiredDateElement = (
value,
existingElement: DataElement
): DataElement => {
const expired: DataElement = existingElement
? new PatientCharacteristicExpired(existingElement)
: new PatientCharacteristicExpired();
expired.expiredDatetime = value;
expired.dataElementCodes = [PATIENT_CHARACTERISTIC_EXPIRED];
return expired;
};

export const getBirthDateElement = (
value,
Expand Down Expand Up @@ -169,7 +186,7 @@ export const getEthnicityDataElement = (

export const getLivingStatusDataElement = (): DataElement => {
const pce: DataElement = new PatientCharacteristicExpired();
pce.dataElementCodes = [];
pce.dataElementCodes = [PATIENT_CHARACTERISTIC_EXPIRED];
return pce;
};

Expand Down

0 comments on commit 433b371

Please sign in to comment.