Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting errors and add ventilator icon #5765

Merged
merged 11 commits into from
Jul 12, 2023
6 changes: 3 additions & 3 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const AssetManage = (props: AssetManageProps) => {
const assetData = await dispatch(getAsset(assetId));
if (!status.aborted) {
setIsLoading(false);
if (assetData && assetData.data) {
if (assetData?.data) {
setAsset(assetData.data);

const transactionFilter = assetData.qr_code_id
Expand All @@ -77,7 +77,7 @@ const AssetManage = (props: AssetManageProps) => {
offset,
})
);
if (transactionsData && transactionsData.data) {
if (transactionsData?.data) {
setTransactions(transactionsData.data.results);
setTotalCount(transactionsData.data.count);
} else {
Expand Down Expand Up @@ -124,7 +124,7 @@ const AssetManage = (props: AssetManageProps) => {
</div>
<h2 className="text-center">Print Preview</h2>
<div id="section-to-print" className="print flex justify-center">
<QRCode size={200} value={asset?.id || ""} />
<QRCode size={200} value={asset?.id ?? ""} />
</div>
</div>
);
Expand Down
13 changes: 7 additions & 6 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
getAnyFacility,
listAssets,
getFacilityAssetLocation,
getAsset,
} from "../../Redux/actions";
import { assetClassProps, AssetData } from "./AssetTypes";
import { getAsset } from "../../Redux/actions";
import { useState, useCallback, useEffect } from "react";
import { Link, navigate } from "raviger";
import loadable from "@loadable/component";
Expand Down Expand Up @@ -242,6 +242,7 @@ const AssetsList = () => {
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 md:-mx-8 gap-2">
{assets.map((asset: AssetData) => (
<Link
key={asset.id}
href={`/facility/${asset?.location_object.facility.id}/assets/${asset.id}`}
className="text-inherit"
>
Expand Down Expand Up @@ -395,12 +396,12 @@ const AssetsList = () => {
<>
<FilterBadges
badges={({ badge, value }) => [
value("Facility", "facility", facilityName || ""),
value("Facility", "facility", facilityName ?? ""),
badge("Name/Serial No./QR ID", "search"),
value("Asset Type", "asset_type", asset_type || ""),
value("Asset Class", "asset_class", asset_class || ""),
value("Status", "status", status?.replace(/_/g, " ") || ""),
value("Location", "location", locationName || ""),
value("Asset Type", "asset_type", asset_type ?? ""),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
value("Location", "location", locationName ?? ""),
]}
/>
<div className="grow">
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const DateInputV2: React.FC<Props> = ({
readOnly
disabled={disabled}
className={`cui-input-base cursor-pointer disabled:cursor-not-allowed ${className}`}
placeholder={placeholder || "Select date"}
placeholder={placeholder ?? "Select date"}
value={value && format(value, "yyyy-MM-dd")}
/>
<div className="absolute top-1/2 right-0 p-2 -translate-y-1/2">
Expand Down
8 changes: 4 additions & 4 deletions src/Components/CriticalCareRecording/CriticalCare__API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { fireRequestV2 } from "../../Redux/fireRequest";
export const loadDailyRound = (
consultationId: string,
id: string,
successCB: any = () => {},
errorCB: any = () => {}
successCB: any = () => null,
errorCB: any = () => null
) => {
fireRequestV2("getDailyReport", [], {}, successCB, errorCB, {
consultationId,
Expand All @@ -16,8 +16,8 @@ export const updateDailyRound = (
consultationId: string,
id: string,
params: object,
successCB: any = () => {},
errorCB: any = () => {}
successCB: any = () => null,
errorCB: any = () => null
) => {
fireRequestV2("updateDailyRound", [], params, successCB, errorCB, {
consultationId,
Expand Down
50 changes: 23 additions & 27 deletions src/Components/Facility/ConsultationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ export const ConsultationDetails = (props: any) => {
`${patientData.address},\n${patientData.ward_object?.name},\n${patientData.local_body_object?.name},\n${patientData.district_object?.name},\n${patientData.state_object?.name}`;

const getPatientComorbidities = (patientData: any) => {
if (
patientData &&
patientData.medical_history &&
patientData.medical_history.length
) {
if (patientData?.medical_history?.length) {
const medHis = patientData.medical_history;
return medHis.map((item: any) => item.disease).join(", ");
} else {
Expand Down Expand Up @@ -157,12 +153,12 @@ export const ConsultationDetails = (props: any) => {
setIsLoading(true);
const res = await dispatch(getConsultation(consultationId));
if (!status.aborted) {
if (res && res.data) {
if (res?.data) {
const data: ConsultationModel = {
...res.data,
symptoms_text: "",
};
if (res.data.symptoms && res.data.symptoms.length) {
if (res.data.symptoms?.length) {
const symptoms = res.data.symptoms
.filter((symptom: number) => symptom !== 9)
.map((symptom: number) => {
Expand All @@ -174,7 +170,7 @@ export const ConsultationDetails = (props: any) => {
setConsultationData(data);
const id = res.data.patient;
const patientRes = await dispatch(getPatient({ id }));
if (patientRes && patientRes.data) {
if (patientRes?.data) {
const patientGender = getPatientGender(patientRes.data);
const patientAddress = getPatientAddress(patientRes.data);
const patientComorbidities = getPatientComorbidities(
Expand Down Expand Up @@ -354,7 +350,7 @@ export const ConsultationDetails = (props: any) => {
{consultationData.admitted_to}
</span>
</div>
{(consultationData.admission_date ||
{(consultationData.admission_date ??
consultationData.discharge_date) && (
<div className="text-3xl font-bold">
{moment(
Expand Down Expand Up @@ -403,7 +399,7 @@ export const ConsultationDetails = (props: any) => {
},
]
: []),
...(consultationData?.icd11_diagnoses_object || []),
...(consultationData?.icd11_diagnoses_object ?? []),
]}
label="Diagnosis (as per ICD-11 recommended by WHO)"
/>
Expand Down Expand Up @@ -479,7 +475,7 @@ export const ConsultationDetails = (props: any) => {
{CONSULTATION_TABS.map((p: OptionsType) => {
if (p.text === "FEED") {
if (
!consultationData?.current_bed?.bed_object?.id ||
!consultationData?.current_bed?.bed_object?.id ??
consultationData?.discharge_date !== null
)
return null;
Expand Down Expand Up @@ -562,7 +558,7 @@ export const ConsultationDetails = (props: any) => {
{DISCHARGE_REASONS.find(
(d) =>
d.id === consultationData.discharge_reason
)?.text || "--"}
)?.text ?? "--"}
</span>
</div>
{consultationData.discharge_reason === "REC" && (
Expand All @@ -581,12 +577,12 @@ export const ConsultationDetails = (props: any) => {
<div>
Advice {" - "}
<span className="font-semibold">
{consultationData.discharge_notes || "--"}
{consultationData.discharge_notes ?? "--"}
</span>
</div>
<div className="overflow-x-auto overflow-y-hidden">
<PrescriptionsTable
consultation_id={consultationData.id}
consultation_id={consultationData.id ?? ""}
is_prn={false}
readonly
prescription_type="DISCHARGE"
Expand All @@ -595,7 +591,7 @@ export const ConsultationDetails = (props: any) => {
<hr className="border border-gray-300 my-2"></hr>
<div className="overflow-x-auto overflow-y-hidden">
<PrescriptionsTable
consultation_id={consultationData.id}
consultation_id={consultationData.id ?? ""}
is_prn
readonly
prescription_type="DISCHARGE"
Expand All @@ -618,20 +614,20 @@ export const ConsultationDetails = (props: any) => {
<div>
Cause of death {" - "}
<span className="font-semibold">
{consultationData.discharge_notes || "--"}
{consultationData.discharge_notes ?? "--"}
</span>
</div>
<div>
Confirmed By {" - "}
<span className="font-semibold">
{consultationData.death_confirmed_doctor ||
{consultationData.death_confirmed_doctor ??
"--"}
</span>
</div>
</div>
)}
{["REF", "LAMA"].includes(
consultationData.discharge_reason || ""
consultationData.discharge_reason ?? ""
) && (
<div className="grid gap-4">
<div>
Expand All @@ -648,7 +644,7 @@ export const ConsultationDetails = (props: any) => {
<div>
Notes {" - "}
<span className="font-semibold">
{consultationData.discharge_notes || "--"}
{consultationData.discharge_notes ?? "--"}
</span>
</div>
</div>
Expand Down Expand Up @@ -678,7 +674,7 @@ export const ConsultationDetails = (props: any) => {
text={
SYMPTOM_CHOICES.find(
(choice) => choice.id === symptom
)?.text || "Err. Unknown"
)?.text ?? "Err. Unknown"
}
color={"primary"}
size={"small"}
Expand Down Expand Up @@ -718,7 +714,7 @@ export const ConsultationDetails = (props: any) => {
text={
SYMPTOM_CHOICES.find(
(choice) => choice.id === symptom
)?.text || "Err. Unknown"
)?.text ?? "Err. Unknown"
}
color={"primary"}
size={"small"}
Expand Down Expand Up @@ -809,7 +805,7 @@ export const ConsultationDetails = (props: any) => {
</div>
)}

{(consultationData.operation ||
{(consultationData.operation ??
consultationData.special_instruction) && (
<div className="bg-white overflow-hidden shadow rounded-lg">
<div className="px-4 py-5 sm:p-6">
Expand Down Expand Up @@ -970,25 +966,25 @@ export const ConsultationDetails = (props: any) => {
<div>
Gender {" - "}
<span className="font-semibold">
{patientData.gender || "-"}
{patientData.gender ?? "-"}
</span>
</div>
<div>
Age {" - "}
<span className="font-semibold">
{patientData.age || "-"}
{patientData.age ?? "-"}
</span>
</div>
<div>
Weight {" - "}
<span className="font-semibold">
{consultationData.weight || "-"} Kg
{consultationData.weight ?? "-"} Kg
</span>
</div>
<div>
Height {" - "}
<span className="font-semibold">
{consultationData.height || "-"} cm
{consultationData.height ?? "-"} cm
</span>
</div>
<div>
Expand All @@ -1005,7 +1001,7 @@ export const ConsultationDetails = (props: any) => {
<div>
Blood Group {" - "}
<span className="font-semibold">
{patientData.blood_group || "-"}
{patientData.blood_group ?? "-"}
</span>
</div>
</div>
Expand Down
33 changes: 11 additions & 22 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ import {
getConsultation,
updateConsultation,
getPatient,
dischargePatient,
} from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
import { FacilitySelect } from "../Common/FacilitySelect";
import { BedModel, FacilityModel } from "./models";
import { BedModel, FacilityModel, ICD11DiagnosisModel } from "./models";
import { OnlineUsersSelect } from "../Common/OnlineUsersSelect";
import { UserModel } from "../Users/models";
import { BedSelect } from "../Common/BedSelect";
import { dischargePatient } from "../../Redux/actions";
import Beds from "./Consultations/Beds";
import InvestigationBuilder, {
InvestigationType,
} from "../Common/prescription-builder/InvestigationBuilder";
import ProcedureBuilder, {
ProcedureType,
} from "../Common/prescription-builder/ProcedureBuilder";
import { ICD11DiagnosisModel } from "./models";
import { Cancel, Submit } from "../Common/components/ButtonV2";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import { FieldChangeEventHandler } from "../Form/FormFields/Utils";
Expand All @@ -47,11 +46,8 @@ import useAppHistory from "../../Common/hooks/useAppHistory";
import useVisibility from "../../Utils/useVisibility";
import CareIcon from "../../CAREUI/icons/CareIcon";
import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField";
import {
DraftSection,
FormReducerAction,
useAutoSaveReducer,
} from "../../Utils/AutoSave";
import { DraftSection, useAutoSaveReducer } from "../../Utils/AutoSave";
import { FormAction } from "../Form/Utils";

const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -171,10 +167,7 @@ const fieldRef = formErrorKeys.reduce(
{}
);

const consultationFormReducer = (
state = initialState,
action: FormReducerAction
) => {
const consultationFormReducer = (state = initialState, action: FormAction) => {
switch (action.type) {
case "set_form": {
return {
Expand Down Expand Up @@ -301,7 +294,7 @@ export const ConsultationForm = (props: any) => {
else setSelectedFacility(res.data.referred_to_object);
}
if (!status.aborted) {
if (res && res.data) {
if (res?.data) {
const formData = {
...res.data,
symptoms_onset_date: isoStringToDate(res.data.symptoms_onset_date),
Expand All @@ -310,7 +303,7 @@ 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"
?.id ?? "Comfort"
: "Comfort",
ip_no: res.data.ip_no ? res.data.ip_no : "",
op_no: res.data.op_no ? res.data.op_no : "",
Expand Down Expand Up @@ -343,11 +336,7 @@ export const ConsultationForm = (props: any) => {

useAbortableEffect(
(status: statusType) => {
if (id && patientId && patientName) {
fetchData(status);
} else if (id && !patientId) {
fetchData(status);
}
if (id && ((patientId && patientName) || !patientId)) fetchData(status);
},
[fetchData, id, patientId, patientName]
);
Expand Down Expand Up @@ -640,7 +629,7 @@ export const ConsultationForm = (props: any) => {
id ? updateConsultation(id, data) : createConsultation(data)
);
setIsLoading(false);
if (res && res.data && res.status !== 400) {
if (res?.data && res.status !== 400) {
dispatch({ type: "set_form", form: initForm });

if (data.suggestion === "DD") {
Expand Down Expand Up @@ -755,9 +744,9 @@ export const ConsultationForm = (props: any) => {
const selectedFacility = selected as FacilityModel;
setSelectedFacility(selectedFacility);
const form: FormDetails = { ...state.form };
if (selectedFacility && selectedFacility.id) {
if (selectedFacility?.id) {
if (selectedFacility.id === -1) {
form.referred_to_external = selectedFacility.name || "";
form.referred_to_external = selectedFacility.name ?? "";
delete form.referred_to;
} else {
form.referred_to = selectedFacility.id.toString() || "";
Expand Down
Loading