Skip to content

Commit

Permalink
Adds Patient Category in Daily Rounds and Consultation (#3565)
Browse files Browse the repository at this point in the history
* patient category in daily rounds and consultation

* hot fix default value not in state issue
  • Loading branch information
rithviknishad authored Sep 15, 2022
1 parent 3067e68 commit 3d43afc
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 74 deletions.
17 changes: 6 additions & 11 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,14 @@ export const PATIENT_FILTER_ADMITTED_TO = [
{ id: "2", text: "ICU" },
];

export const PATIENT_CATEGORY = [
{ id: "ASYMPTOMATIC", text: "ASYM (ASYMPTOMATIC) " },
{ id: "Category-A", text: "Mild (Category A)" },
{ id: "Category-B", text: "Moderate (Category B)" },
{ id: "Category-C", text: "Severe (Category C)" },
export const PATIENT_CATEGORIES = [
"Comfort Care",
"Stable",
"Slightly Abnormal",
"Critical",
];

export const PATIENT_FILTER_CATEGORY = [
{ id: "ASYM", text: "ASYM (ASYMPTOMATIC) " },
{ id: "Mild", text: "Mild (Category A)" },
{ id: "Moderate", text: "Moderate (Category B)" },
{ id: "Severe", text: "Severe (Category C)" },
];
export const PATIENT_FILTER_CATEGORIES = PATIENT_CATEGORIES;

export const CURRENT_HEALTH_CHANGE = [
{ id: 0, text: "NO DATA", desc: "" },
Expand Down
9 changes: 1 addition & 8 deletions src/Components/Facility/ConsultationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import loadable from "@loadable/component";
import { ConsultationModel } from "./models";
import { PatientModel } from "../Patient/models";
import {
PATIENT_CATEGORY,
SYMPTOM_CHOICES,
CONSULTATION_TABS,
OptionsType,
Expand Down Expand Up @@ -57,7 +56,6 @@ interface PreDischargeFormInterface {
const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
const symptomChoices = [...SYMPTOM_CHOICES];
const patientCategoryChoices = [...PATIENT_CATEGORY];

export const ConsultationDetails = (props: any) => {
const { facilityId, patientId, consultationId } = props;
Expand Down Expand Up @@ -216,9 +214,6 @@ export const ConsultationDetails = (props: any) => {
const data: ConsultationModel = {
...res.data,
symptoms_text: "",
category:
patientCategoryChoices.find((i) => i.id === res.data.category)
?.text || res.data.category,
};
if (res.data.symptoms && res.data.symptoms.length) {
const symptoms = res.data.symptoms
Expand Down Expand Up @@ -1221,9 +1216,7 @@ export const ConsultationDetails = (props: any) => {
facilityId={facilityId}
patientId={patientId}
/>
<ViewInvestigationSuggestions
consultationId={consultationId}
/>
<ViewInvestigationSuggestions consultationId={consultationId} />
</div>
)}
</div>
Expand Down
80 changes: 52 additions & 28 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React, {
import { useDispatch } from "react-redux";
import {
CONSULTATION_SUGGESTION,
PATIENT_CATEGORY,
PATIENT_CATEGORIES,
SYMPTOM_CHOICES,
TELEMEDICINE_ACTIONS,
REVIEW_AT_CHOICES,
Expand Down Expand Up @@ -52,10 +52,16 @@ import { UserModel } from "../Users/models";
import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date";
import { BedSelect } from "../Common/BedSelect";
import Beds from "./Consultations/Beds";
import PrescriptionBuilder, { PrescriptionType } from "../Common/prescription-builder/PrescriptionBuilder";
import PRNPrescriptionBuilder, { PRNPrescriptionType } from "../Common/prescription-builder/PRNPrescriptionBuilder";
import PrescriptionBuilder, {
PrescriptionType,
} from "../Common/prescription-builder/PrescriptionBuilder";
import PRNPrescriptionBuilder, {
PRNPrescriptionType,
} from "../Common/prescription-builder/PRNPrescriptionBuilder";
import { DiagnosisSelect } from "../Common/DiagnosisSelect";
import InvestigationBuilder, { InvestigationType } from "../Common/prescription-builder/InvestigationBuilder";
import InvestigationBuilder, {
InvestigationType,
} from "../Common/prescription-builder/InvestigationBuilder";
import { ICD11DiagnosisModel } from "./models";

const Loading = loadable(() => import("../Common/Loading"));
Expand Down Expand Up @@ -89,7 +95,7 @@ type FormDetails = {
consultation_notes: string;
ip_no: string;
discharge_advice: PrescriptionType[];
prn_prescription : PRNPrescriptionType[],
prn_prescription: PRNPrescriptionType[];
investigation: InvestigationType[];
is_telemedicine: BooleanStrings;
action: string;
Expand Down Expand Up @@ -117,7 +123,7 @@ const initForm: FormDetails = {
facility: "",
admitted: "false",
admitted_to: "",
category: "",
category: "Comfort Care",
admission_date: new Date().toISOString(),
discharge_date: null,
referred_to: "",
Expand All @@ -132,7 +138,7 @@ const initForm: FormDetails = {
consultation_notes: "",
ip_no: "",
discharge_advice: [],
prn_prescription : [],
prn_prescription: [],
investigation: [],
is_telemedicine: "false",
action: "PENDING",
Expand Down Expand Up @@ -182,15 +188,6 @@ const suggestionTypes = [

const symptomChoices = [...SYMPTOM_CHOICES];

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const categoryChoices = [
{
id: 0,
text: "Select suspect category",
},
...PATIENT_CATEGORY,
];

const goBack = () => {
window.history.go(-1);
};
Expand All @@ -209,7 +206,9 @@ export const ConsultationForm = (props: any) => {
[]
);
const [PRNAdvice, setPRNAdvice] = useState<PRNPrescriptionType[]>([]);
const [InvestigationAdvice, setInvestigationAdvice] = useState<InvestigationType[]>([]);
const [InvestigationAdvice, setInvestigationAdvice] = useState<
InvestigationType[]
>([]);

const [selectedFacility, setSelectedFacility] =
useState<FacilityModel | null>(null);
Expand Down Expand Up @@ -241,8 +240,14 @@ export const ConsultationForm = (props: any) => {
setIsLoading(true);
const res = await dispatchAction(getConsultation(id));
setDischargeAdvice(res && res.data && res.data.discharge_advice);
setPRNAdvice(!Array.isArray(res.data.prn_prescription) ? [] : res.data.prn_prescription);
setInvestigationAdvice(!Array.isArray(res.data.investigation) ? [] : res.data.investigation);
setPRNAdvice(
!Array.isArray(res.data.prn_prescription)
? []
: res.data.prn_prescription
);
setInvestigationAdvice(
!Array.isArray(res.data.investigation) ? [] : res.data.investigation
);

if (!status.aborted) {
if (res && res.data) {
Expand All @@ -258,7 +263,7 @@ export const ConsultationForm = (props: any) => {
!!res.data.symptoms.filter((i: number) => i === 9).length,
admitted: res.data.admitted ? String(res.data.admitted) : "false",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
category: res.data.category ? res.data.category : "",
category: res.data.category || "Comfort Care",
ip_no: res.data.ip_no ? res.data.ip_no : "",
verified_by: res.data.verified_by ? res.data.verified_by : "",
OPconsultation: res.data.consultation_notes,
Expand Down Expand Up @@ -304,6 +309,16 @@ export const ConsultationForm = (props: any) => {
invalidForm = true;
}
return;
case "category":
if (
!state.form[field] ||
!PATIENT_CATEGORIES.includes(state.form[field])
) {
errors[field] = "Please select a category";
if (!error_div) error_div = field;
invalidForm = true;
}
return;
case "suggestion":
if (!state.form[field]) {
errors[field] = "Please enter the decision";
Expand Down Expand Up @@ -421,12 +436,14 @@ export const ConsultationForm = (props: any) => {
return;
}

case "investigation":{
case "investigation": {
let invalid = false;
for (let f of InvestigationAdvice) {
for (const f of InvestigationAdvice) {
if (
f.type?.length === 0 ||
(f.repetitive ? !f.frequency?.replace(/\s/g, "").length : !f.time?.replace(/\s/g, "").length)
(f.repetitive
? !f.frequency?.replace(/\s/g, "").length
: !f.time?.replace(/\s/g, "").length)
) {
invalid = true;
break;
Expand Down Expand Up @@ -481,7 +498,7 @@ export const ConsultationForm = (props: any) => {
icd11_diagnoses: state.form.icd11_diagnoses,
verified_by: state.form.verified_by,
discharge_advice: dischargeAdvice,
prn_prescription : PRNAdvice,
prn_prescription: PRNAdvice,
investigation: InvestigationAdvice,
patient: patientId,
facility: facilityId,
Expand Down Expand Up @@ -746,17 +763,24 @@ export const ConsultationForm = (props: any) => {
errors={state.errors.prescribed_medication}
/>
</div>
{/* <div className="flex-1" id="category-div">
<InputLabel id="category-label">Category*</InputLabel>
<div className="flex-1" id="category-div">
<InputLabel id="category-label" required>
Category
</InputLabel>
<SelectField
name="category"
variant="standard"
value={state.form.category}
options={categoryChoices}
options={PATIENT_CATEGORIES.map((c) => {
return {
id: c,
text: c,
};
})}
onChange={handleChange}
errors={state.errors.category}
/>
</div> */}
</div>

<div id="suggestion-div">
<InputLabel
Expand Down
7 changes: 1 addition & 6 deletions src/Components/Facility/Consultations/DailyRoundsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import { getDailyReport } from "../../../Redux/actions";
import loadable from "@loadable/component";
import Pagination from "../../Common/Pagination";
import { DailyRoundsModel } from "../../Patient/models";
import { PATIENT_CATEGORY } from "../../../Common/constants";
import { smallCard } from "../../Common/components/SkeletonLoading.gen";

const PageTitle = loadable(() => import("../../Common/PageTitle"));

const patientCategoryChoices = [...PATIENT_CATEGORY];

export const DailyRoundsList = (props: any) => {
const { facilityId, patientId, consultationId, consultationData } = props;
const dispatch: any = useDispatch();
Expand Down Expand Up @@ -126,9 +123,7 @@ export const DailyRoundsList = (props: any) => {
<Typography>
<span className="text-gray-700">Category: </span>
<span className="badge badge-pill badge-warning">
{patientCategoryChoices.find(
(i) => i.id === itemData.patient_category
)?.text || "-"}
{itemData.patient_category || "-"}
</span>
</Typography>
</Grid>
Expand Down
8 changes: 7 additions & 1 deletion src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ export interface OptionsType {
disabled?: boolean;
}

export type PatientCategory =
| "Comfort Care"
| "Stable"
| "Slightly Abnormal"
| "Critical";

export interface ConsultationModel {
admission_date?: string;
admitted?: boolean;
test_id?: string;
admitted_to?: string;
category?: string;
category?: PatientCategory;
created_date?: string;
discharge_date?: string;
examination_details?: string;
Expand Down
11 changes: 1 addition & 10 deletions src/Components/Patient/DailyRoundListDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import loadable from "@loadable/component";
import moment from "moment";
import React, { useCallback, useState } from "react";
import { useDispatch } from "react-redux";
import {
CURRENT_HEALTH_CHANGE,
PATIENT_CATEGORY,
SYMPTOM_CHOICES,
} from "../../Common/constants";
import { CURRENT_HEALTH_CHANGE, SYMPTOM_CHOICES } from "../../Common/constants";
import { statusType, useAbortableEffect } from "../../Common/utils";
import { getConsultationDailyRoundsDetails } from "../../Redux/actions";
import { DailyRoundsModel } from "./models";
const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
const symptomChoices = [...SYMPTOM_CHOICES];
const currentHealthChoices = [...CURRENT_HEALTH_CHANGE];
const patientCategoryChoices = [...PATIENT_CATEGORY];

export const DailyRoundListDetails = (props: any) => {
const { facilityId, patientId, consultationId, id } = props;
Expand Down Expand Up @@ -47,10 +42,6 @@ export const DailyRoundListDetails = (props: any) => {
Object.keys(res.data.medication_given).length === 0
? []
: res.data.medication_given,
patient_category:
patientCategoryChoices.find(
(i) => i.id === res.data.patient_category
)?.text || res.data.patient_category,
current_health: currentHealth
? currentHealth.desc
: res.data.current_health,
Expand Down
Loading

0 comments on commit 3d43afc

Please sign in to comment.