diff --git a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.test.tsx b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.test.tsx
index c2d3bf615..2cb5922bb 100644
--- a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.test.tsx
+++ b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.test.tsx
@@ -11,6 +11,8 @@ import {
PatientCharacteristicEthnicity,
PatientCharacteristicExpired,
DataElementCode,
+ PatientCharacteristicRace,
+ PatientCharacteristicSex,
} from "cqm-models";
const emptyPatient = new QDMPatient();
@@ -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(
+
+
+
+ );
+
+ 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(
+
+
+
+ );
+
+ 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");
+ });
});
diff --git a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.tsx b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.tsx
index cb132af50..a58cef5dc 100644
--- a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.tsx
+++ b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSection.tsx
@@ -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 {
@@ -110,6 +112,7 @@ const DemographicsSection = ({ canEdit }) => {
const expiredElement = getDataElementByStatus("expired", patient);
if (expiredElement) {
+ expiredElement.dataElementCodes = PATIENT_CHARACTERISTIC_EXPIRED;
setLivingStatusDataElement(expiredElement);
} else {
setLivingStatusDataElement("Living");
@@ -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,
diff --git a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSectionConst.tsx b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSectionConst.tsx
index bdcda0c43..1b24a5060 100644
--- a/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSectionConst.tsx
+++ b/src/components/editTestCase/qdm/LeftPanel/ElementsTab/Demographics/DemographicsSectionConst.tsx
@@ -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,
@@ -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;
};