Skip to content

Commit

Permalink
Remove default selection of patient category (#6354)
Browse files Browse the repository at this point in the history
* Remove default selection of patient category

* Fix cypress
  • Loading branch information
Ashesh3 authored Sep 27, 2023
1 parent 9bc19ed commit 6319cff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe("Patient Creation with consultation", () => {
patientConsultationPage.selectSymptoms("ASYMPTOMATIC");

patientConsultationPage.enterConsultationDetails(
"Stable",
"Examination details and Clinical conditions",
"70",
"170",
Expand Down
8 changes: 8 additions & 0 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class PatientConsultationPage {
}

enterConsultationDetails(
category: string,
examinationDetails: string,
weight: string,
height: string,
Expand All @@ -31,6 +32,11 @@ export class PatientConsultationPage {
verificationBy: string
) {
cy.get("#symptoms").click();
cy.get("#category")
.click()
.then(() => {
cy.get("[role='option']").contains(category).click();
});
cy.get("#examination_details").click().type(examinationDetails);
cy.get("#weight").click().type(height);
cy.get("#height").click().type(weight);
Expand All @@ -39,10 +45,12 @@ export class PatientConsultationPage {
cy.get(
"#icd11_diagnoses_object input[placeholder='Select'][role='combobox']"
)
.scrollIntoView()
.click()
.type("1A");
cy.get("#icd11_diagnoses_object [role='option']")
.contains("1A03 Intestinal infections due to Escherichia coli")
.scrollIntoView()
.click();
cy.get("label[for='icd11_diagnoses_object']").click();
cy.wait("@getIcdResults").its("response.statusCode").should("eq", 200);
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const initForm: FormDetails = {
facility: "",
admitted: "false",
admitted_to: "",
category: "Comfort",
category: "",
admission_date: new Date(),
discharge_date: null,
referred_to: "",
Expand Down Expand Up @@ -373,8 +373,8 @@ export const ConsultationForm = (props: any) => {
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
category: res.data.category
? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)
?.id ?? "Comfort"
: "Comfort",
?.id ?? ""
: "",
patient_no: res.data.patient_no ?? "",
OPconsultation: res.data.consultation_notes,
is_telemedicine: `${res.data.is_telemedicine}`,
Expand Down
18 changes: 12 additions & 6 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const initForm: any = {
other_symptoms: "",
physical_examination_info: "",
other_details: "",
patient_category: "Comfort",
patient_category: "",
current_health: 0,
recommend_discharge: false,
action: null,
Expand Down Expand Up @@ -142,14 +142,14 @@ export const DailyRounds = (props: any) => {
);

if (!status.aborted) {
if (res && res.data) {
if (res?.data) {
const data = {
...res.data,
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id || "Comfort"
: "Comfort",
)?.id ?? ""
: "",
rhythm:
(res.data.rhythm &&
RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) ||
Expand Down Expand Up @@ -186,8 +186,8 @@ export const DailyRounds = (props: any) => {
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id || "Comfort"
: "Comfort",
)?.id ?? ""
: "",
rhythm:
(res.data.rhythm &&
RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) ||
Expand All @@ -205,6 +205,12 @@ export const DailyRounds = (props: any) => {
let invalidForm = false;
Object.keys(state.form).forEach((field) => {
switch (field) {
case "patient_category":
if (!state.form[field]) {
errors[field] = "Please select a category";
invalidForm = true;
}
return;
case "other_symptoms":
if (
state.form.additional_symptoms?.includes(9) &&
Expand Down

0 comments on commit 6319cff

Please sign in to comment.