From fe6e616b502f1c07be68cc56896ed6cf3f5397d3 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 2 Apr 2024 19:13:55 +0530 Subject: [PATCH 1/2] Perform type checks during build and fix all errors (#7469) * Fail build if typescript errors present * error fixes part 1 * fixes part 2 * fix merge conflict * fixes part 3 * fixes part 4 * fixes facility select using -1 for id * fixes type errors in daily rounds * fixes #7482 * some minor fixes.. * fixes #7473 * update lockfile * ignore generated files * fix node 20 code present in codebase * remove more errors * run `lint-fix` * Switch off classnames order in eslint * fix lint from linux * fix lint --------- Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- .eslintrc.json | 2 +- .prettierrc.json | 9 +- package-lock.json | 209 ++++++++++++++++++ package.json | 2 + ...akeCareIcons.mts => treeShakeCareIcons.ts} | 0 src/Common/constants.tsx | 2 +- src/Common/utils.tsx | 2 +- src/Components/Assets/AssetConfigure.tsx | 6 +- src/Components/Assets/AssetManage.tsx | 8 +- src/Components/Assets/AssetWarrantyCard.tsx | 2 +- src/Components/Assets/AssetsList.tsx | 4 +- src/Components/Auth/Login.tsx | 4 +- src/Components/CameraFeed/NoFeedAvailable.tsx | 2 +- .../Common/BloodPressureFormField.tsx | 4 +- src/Components/Common/Export.tsx | 2 +- src/Components/Common/FacilitySelect.tsx | 1 - src/Components/Common/GLocationPicker.tsx | 2 +- .../Common/Sidebar/SidebarUserCard.tsx | 4 +- .../ConsultationDiagnosisBuilder.tsx | 2 +- src/Components/Facility/AddBedForm.tsx | 2 +- src/Components/Facility/ConsultationCard.tsx | 2 +- .../ConsultationUpdatesTab.tsx | 2 +- .../Facility/ConsultationDetails/index.tsx | 3 +- src/Components/Facility/ConsultationForm.tsx | 30 +-- .../Facility/Consultations/Beds.tsx | 6 +- .../DailyRounds/DefaultLogUpdateCard.tsx | 4 +- .../DailyRounds/LogUpdateCardAttribute.tsx | 14 +- .../Consultations/DailyRoundsList.tsx | 18 +- .../Facility/CoverImageEditModal.tsx | 4 +- src/Components/Facility/DischargeModal.tsx | 8 +- src/Components/Facility/DoctorNote.tsx | 1 - .../Facility/DoctorVideoSlideover.tsx | 11 +- src/Components/Facility/FacilityHome.tsx | 2 +- src/Components/Facility/FacilityUsers.tsx | 53 +---- .../Facility/PatientConsultationNotesList.tsx | 44 ++-- src/Components/Facility/PatientNoteCard.tsx | 14 +- src/Components/Facility/TreatmentSummary.tsx | 22 +- src/Components/Facility/models.tsx | 12 +- .../Form/FormFields/CheckBoxFormField.tsx | 2 +- .../Form/FormFields/DosageFormField.tsx | 6 +- .../Form/FormFields/OtpFormField.tsx | 2 +- src/Components/Form/MultiSelectMenuV2.tsx | 6 +- .../HCX/InsuranceDetailsBuilder.tsx | 2 +- src/Components/HCX/validators.ts | 2 +- .../Medicine/AdministerMedicine.tsx | 4 +- src/Components/Medicine/models.ts | 2 +- src/Components/Patient/ManagePatients.tsx | 4 +- src/Components/Patient/PatientInfoCard.tsx | 4 +- src/Components/Patient/PatientRegister.tsx | 19 +- src/Components/Patient/SampleViewAdmin.tsx | 2 +- src/Components/Patient/ShiftCreate.tsx | 16 +- src/Components/Patient/models.tsx | 31 ++- .../Shifting/ShiftDetailsUpdate.tsx | 23 +- src/Components/Users/UserAdd.tsx | 4 +- src/Redux/api.tsx | 4 +- tsconfig.json | 5 +- vite.config.mts | 4 +- 57 files changed, 416 insertions(+), 245 deletions(-) rename plugins/{treeShakeCareIcons.mts => treeShakeCareIcons.ts} (100%) diff --git a/.eslintrc.json b/.eslintrc.json index b444a07c3c8..a2f7b667856 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -85,7 +85,7 @@ ], "tailwindcss/no-custom-classname": "off", "tailwindcss/migration-from-tailwind-2": "error", - "tailwindcss/classnames-order": "error", + "tailwindcss/classnames-order": "off", "tailwindcss/enforces-shorthand": "off", "tailwindcss/no-contradicting-classname": "error" }, diff --git a/.prettierrc.json b/.prettierrc.json index 48552107a8d..96ff50bd324 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -5,5 +5,10 @@ "semi": true, "jsxSingleQuote": false, "arrowParens": "always", - "tailwindFunctions": ["classNames"] -} + "tailwindFunctions": [ + "classNames" + ], + "plugins": [ + "prettier-plugin-tailwindcss" + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b4a125cead4..7a0f730ba75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,6 +74,7 @@ "@tailwindcss/typography": "^0.5.9", "@types/cypress": "^1.1.3", "@types/echarts": "^4.9.18", + "@types/google.maps": "^3.55.5", "@types/lodash-es": "^4.17.9", "@types/qrcode.react": "^1.0.2", "@types/react": "18.2.14", @@ -119,6 +120,7 @@ "tailwindcss": "^3.3.3", "typescript": "^5.1.6", "vite": "^5.1.3", + "vite-plugin-checker": "^0.6.4", "vite-plugin-pwa": "^0.18.2" }, "engines": { @@ -6358,6 +6360,12 @@ "@types/node": "*" } }, + "node_modules/@types/google.maps": { + "version": "3.55.5", + "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.5.tgz", + "integrity": "sha512-U1QwCo1GeeLm0YI/GoHvfd1VfwgnoUSBcKCMXXFAM+2izSSuqqwZUJ9XNO6NxZxmYKjBNI+NF5eGF6uUSb1aSg==", + "dev": true + }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -25100,6 +25108,111 @@ } } }, + "node_modules/vite-plugin-checker": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/vite-plugin-checker/-/vite-plugin-checker-0.6.4.tgz", + "integrity": "sha512-2zKHH5oxr+ye43nReRbC2fny1nyARwhxdm0uNYp/ERy4YvU9iZpNOsueoi/luXw5gnpqRSvjcEPxXbS153O2wA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "ansi-escapes": "^4.3.0", + "chalk": "^4.1.1", + "chokidar": "^3.5.1", + "commander": "^8.0.0", + "fast-glob": "^3.2.7", + "fs-extra": "^11.1.0", + "npm-run-path": "^4.0.1", + "semver": "^7.5.0", + "strip-ansi": "^6.0.0", + "tiny-invariant": "^1.1.0", + "vscode-languageclient": "^7.0.0", + "vscode-languageserver": "^7.0.0", + "vscode-languageserver-textdocument": "^1.0.1", + "vscode-uri": "^3.0.2" + }, + "engines": { + "node": ">=14.16" + }, + "peerDependencies": { + "eslint": ">=7", + "meow": "^9.0.0", + "optionator": "^0.9.1", + "stylelint": ">=13", + "typescript": "*", + "vite": ">=2.0.0", + "vls": "*", + "vti": "*", + "vue-tsc": ">=1.3.9" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + }, + "meow": { + "optional": true + }, + "optionator": { + "optional": true + }, + "stylelint": { + "optional": true + }, + "typescript": { + "optional": true + }, + "vls": { + "optional": true + }, + "vti": { + "optional": true + }, + "vue-tsc": { + "optional": true + } + } + }, + "node_modules/vite-plugin-checker/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/vite-plugin-checker/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vite-plugin-checker/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vite-plugin-checker/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/vite-plugin-pwa": { "version": "0.18.2", "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.18.2.tgz", @@ -25590,6 +25703,102 @@ "node": ">=0.10.0" } }, + "node_modules/vscode-jsonrpc": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz", + "integrity": "sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==", + "dev": true, + "engines": { + "node": ">=8.0.0 || >=10.0.0" + } + }, + "node_modules/vscode-languageclient": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-7.0.0.tgz", + "integrity": "sha512-P9AXdAPlsCgslpP9pRxYPqkNYV7Xq8300/aZDpO35j1fJm/ncize8iGswzYlcvFw5DQUx4eVk+KvfXdL0rehNg==", + "dev": true, + "dependencies": { + "minimatch": "^3.0.4", + "semver": "^7.3.4", + "vscode-languageserver-protocol": "3.16.0" + }, + "engines": { + "vscode": "^1.52.0" + } + }, + "node_modules/vscode-languageclient/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vscode-languageclient/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vscode-languageclient/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/vscode-languageserver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-7.0.0.tgz", + "integrity": "sha512-60HTx5ID+fLRcgdHfmz0LDZAXYEV68fzwG0JWwEPBode9NuMYTIxuYXPg4ngO8i8+Ou0lM7y6GzaYWbiDL0drw==", + "dev": true, + "dependencies": { + "vscode-languageserver-protocol": "3.16.0" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz", + "integrity": "sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==", + "dev": true, + "dependencies": { + "vscode-jsonrpc": "6.0.0", + "vscode-languageserver-types": "3.16.0" + } + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.11.tgz", + "integrity": "sha512-X+8T3GoiwTVlJbicx/sIAF+yuJAqz8VvwJyoMVhwEMoEKE/fkDmrqUgDMyBECcM2A2frVZIUj5HI/ErRXCfOeA==", + "dev": true + }, + "node_modules/vscode-languageserver-types": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz", + "integrity": "sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==", + "dev": true + }, + "node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", + "dev": true + }, "node_modules/walk-up-path": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-3.0.1.tgz", diff --git a/package.json b/package.json index a6772e67243..205612f3ac0 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "@tailwindcss/typography": "^0.5.9", "@types/cypress": "^1.1.3", "@types/echarts": "^4.9.18", + "@types/google.maps": "^3.55.5", "@types/lodash-es": "^4.17.9", "@types/qrcode.react": "^1.0.2", "@types/react": "18.2.14", @@ -159,6 +160,7 @@ "tailwindcss": "^3.3.3", "typescript": "^5.1.6", "vite": "^5.1.3", + "vite-plugin-checker": "^0.6.4", "vite-plugin-pwa": "^0.18.2" }, "browserslist": { diff --git a/plugins/treeShakeCareIcons.mts b/plugins/treeShakeCareIcons.ts similarity index 100% rename from plugins/treeShakeCareIcons.mts rename to plugins/treeShakeCareIcons.ts diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index f1aed577cea..0e14203d4fa 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -315,7 +315,7 @@ export const DISCHARGE_REASONS = [ { id: 2, text: "Referred" }, { id: 3, text: "Expired" }, { id: 4, text: "LAMA" }, -]; +] as const; export const CONSCIOUSNESS_LEVEL = [ { id: "UNRESPONSIVE", text: "Unresponsive" }, diff --git a/src/Common/utils.tsx b/src/Common/utils.tsx index 3596469a6d5..b1e98a9e196 100644 --- a/src/Common/utils.tsx +++ b/src/Common/utils.tsx @@ -31,7 +31,7 @@ export const useAbortableEffect = ( }; export const parseOptionId: ( - options: OptionsType[], + options: readonly OptionsType[], id: string | string[] ) => string = (options, id) => { const textArray = options diff --git a/src/Components/Assets/AssetConfigure.tsx b/src/Components/Assets/AssetConfigure.tsx index fd431ae35ea..aa6b7c9221e 100644 --- a/src/Components/Assets/AssetConfigure.tsx +++ b/src/Components/Assets/AssetConfigure.tsx @@ -26,7 +26,7 @@ const AssetConfigure = ({ assetId, facilityId }: AssetConfigureProps) => { { { { {
{[ { - label: asset?.location_object.facility.name, + label: asset?.location_object.facility?.name, icon: "l-location-pin-alt", content: asset?.location_object.name, }, @@ -426,7 +426,7 @@ const AssetManage = (props: AssetManageProps) => { className="flex gap-2" onClick={() => navigate( - `/facility/${asset?.location_object.facility.id}/assets/${asset?.id}/update` + `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/update` ) } id="update-asset" @@ -444,7 +444,7 @@ const AssetManage = (props: AssetManageProps) => { navigate( - `/facility/${asset?.location_object.facility.id}/assets/${asset?.id}/configure` + `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/configure` ) } id="configure-asset" diff --git a/src/Components/Assets/AssetWarrantyCard.tsx b/src/Components/Assets/AssetWarrantyCard.tsx index 63636fea694..860fb5ab7af 100644 --- a/src/Components/Assets/AssetWarrantyCard.tsx +++ b/src/Components/Assets/AssetWarrantyCard.tsx @@ -62,7 +62,7 @@ export default function AssetWarrantyCard(props: { asset: AssetData }) {
))} -
+
diff --git a/src/Components/Assets/AssetsList.tsx b/src/Components/Assets/AssetsList.tsx index 9596ceb7faa..9e21d1bfb04 100644 --- a/src/Components/Assets/AssetsList.tsx +++ b/src/Components/Assets/AssetsList.tsx @@ -130,7 +130,7 @@ const AssetsList = () => { try { if (assetData) { navigate( - `/facility/${assetData.location_object.facility.id}/assets/${assetId}` + `/facility/${assetData.location_object.facility?.id}/assets/${assetId}` ); } } catch (err) { @@ -188,7 +188,7 @@ const AssetsList = () => { {assets.map((asset: AssetData) => ( diff --git a/src/Components/Auth/Login.tsx b/src/Components/Auth/Login.tsx index 4c88e6e5aea..b3d2fef8d31 100644 --- a/src/Components/Auth/Login.tsx +++ b/src/Components/Auth/Login.tsx @@ -218,7 +218,7 @@ export const Login = (props: { forgot?: boolean }) => { alt="Logo of Digital Public Goods Alliance" /> -
+
{ className="h-14 rounded-lg py-3" alt="state logo" /> -
+
)} Configure diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index e64b2a15ff6..3f7ecacce46 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -6,9 +6,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver, } from "../Form/FormFields/Utils"; -import { DailyRoundsModel } from "../Patient/models"; - -type BloodPressure = NonNullable; +import { BloodPressure } from "../Patient/models"; type Props = FormFieldBaseProps; diff --git a/src/Components/Common/Export.tsx b/src/Components/Common/Export.tsx index e94a2826398..72d5f447e57 100644 --- a/src/Components/Common/Export.tsx +++ b/src/Components/Common/Export.tsx @@ -52,7 +52,7 @@ export const ExportMenu = ({ ghost className="py-2.5" > - + {isExporting ? "Exporting..." : label} ); diff --git a/src/Components/Common/FacilitySelect.tsx b/src/Components/Common/FacilitySelect.tsx index b207189d27d..cac9958db4f 100644 --- a/src/Components/Common/FacilitySelect.tsx +++ b/src/Components/Common/FacilitySelect.tsx @@ -56,7 +56,6 @@ export const FacilitySelect = (props: FacilitySelectProps) => { if (freeText) data?.results?.push({ - id: -1, name: text, }); return data?.results; diff --git a/src/Components/Common/GLocationPicker.tsx b/src/Components/Common/GLocationPicker.tsx index 6fc1a4c2b6c..69efbeffe30 100644 --- a/src/Components/Common/GLocationPicker.tsx +++ b/src/Components/Common/GLocationPicker.tsx @@ -209,7 +209,7 @@ const Map: React.FC = ({ id="pac-input" ref={searchRef} type="text" - className="cui-input-base peer m-[10px] w-[60%] py-2.5" + className="cui-input-base peer m-[10px] w-3/5 py-2.5" placeholder="Start typing to search" /> {handleOnClose && ( diff --git a/src/Components/Common/Sidebar/SidebarUserCard.tsx b/src/Components/Common/Sidebar/SidebarUserCard.tsx index d083867738c..02170f453d7 100644 --- a/src/Components/Common/Sidebar/SidebarUserCard.tsx +++ b/src/Components/Common/Sidebar/SidebarUserCard.tsx @@ -31,7 +31,7 @@ const SidebarUserCard = ({ shrinked }: { shrinked: boolean }) => { shrinked ? "hidden" : "grow" } flex min-w-0 flex-col pb-2 pl-3`} > -
+
{
{ value={diagnosis} onChange={(action) => { if (action.type === "remove") { - props.onChange(props.value.toSpliced(index, 1)); + props.onChange([...props.value].splice(index, 1)); } if (action.type === "edit") { diff --git a/src/Components/Facility/AddBedForm.tsx b/src/Components/Facility/AddBedForm.tsx index 379a9a532b8..0a612fa776b 100644 --- a/src/Components/Facility/AddBedForm.tsx +++ b/src/Components/Facility/AddBedForm.tsx @@ -143,7 +143,7 @@ export const AddBedForm = ({ facilityId, locationId, bedId }: Props) => { title={action} backUrl={`/facility/${facilityId}/location/${locationId}/beds`} crumbsReplacements={{ - [facilityId]: { name: location?.facility.name }, + [facilityId]: { name: location?.facility?.name }, [locationId]: { name: location?.name, uri: `/facility/${facilityId}/location`, diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index 96728c6a2e3..debc59e45df 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -203,7 +203,7 @@ export const ConsultationCard = (props: ConsultationProps) => { ); } }} - disabled={itemData.discharge_date} + disabled={!!itemData.discharge_date} authorizeFor={NonReadOnlyUsers} > Add Consultation Updates diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 6b9848ad898..ecbe157a8aa 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -724,7 +724,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { tab2={
Events - + beta
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 6ce75c6ed70..99a70343cee 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -1,7 +1,6 @@ import { CONSULTATION_TABS, GENDER_TYPES, - OptionsType, SYMPTOM_CHOICES, } from "../../../Common/constants"; import { ConsultationModel } from "../models"; @@ -420,7 +419,7 @@ export const ConsultationDetails = (props: any) => { className="flex space-x-6 overflow-x-auto pb-2 pl-2 " id="consultation_tab_nav" > - {CONSULTATION_TABS.map((p: OptionsType) => { + {CONSULTATION_TABS.map((p) => { if (p.text === "FEED") { if ( isCameraAttached === false || // No camera attached diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 4d2d58457e5..09d843c502e 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -304,7 +304,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { ref: treatmentPlanRef, }, "Consent Records": { - iconClass: "care-l-file-alt", + iconClass: "l-file-alt", visible: consentRecordsVisible, ref: consentRecordsRef, }, @@ -402,7 +402,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { if (res.data.suggestion === "R") { if (res.data.referred_to_external) setReferredToFacility({ - id: -1, name: res.data.referred_to_external, }); else setReferredToFacility(res.data.referred_to_object); @@ -410,7 +409,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { if (res.data.route_to_facility === 20) { if (res.data.referred_from_facility_external) setReferredFromFacility({ - id: -1, name: res.data.referred_from_facility_external, }); else setReferredFromFacility(res.data.referred_from_facility_object); @@ -884,12 +882,12 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const selectedFacility = selected as FacilityModel; setReferredToFacility(selectedFacility); const form: FormDetails = { ...state.form }; - if (selectedFacility?.id) { - if (selectedFacility.id === -1) { + if (selectedFacility) { + if (!selectedFacility.id) { form.referred_to_external = selectedFacility.name ?? ""; delete form.referred_to; } else { - form.referred_to = selectedFacility.id.toString() || ""; + form.referred_to = selectedFacility.id; delete form.referred_to_external; } } @@ -902,12 +900,12 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const selectedFacility = selected as FacilityModel; setReferredFromFacility(selectedFacility); const form: FormDetails = { ...state.form }; - if (selectedFacility?.id) { - if (selectedFacility.id === -1) { + if (selectedFacility) { + if (!selectedFacility.id) { form.referred_from_facility_external = selectedFacility.name ?? ""; delete form.referred_from_facility; } else { - form.referred_from_facility = selectedFacility.id.toString() || ""; + form.referred_from_facility = selectedFacility.id; delete form.referred_from_facility_external; } } @@ -1616,13 +1614,14 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { } > { CONSENT_TYPE_CHOICES.find( @@ -1637,7 +1636,10 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { setShowDeleteConsent(record.id); }} > - +
{ {showBedDetails?.assets_objects?.map((asset: AssetData) => ( @@ -244,7 +244,7 @@ const Beds = (props: BedsProps) => {

Previous beds:

-
+
Bed
@@ -260,7 +260,7 @@ const Beds = (props: BedsProps) => {
{consultationBeds.length > 0 ? ( consultationBeds.map((bed) => ( -
+
{bed?.bed_object?.name} {bed?.assets_objects && bed.assets_objects.length > 0 && ( diff --git a/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx b/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx index ab09c7eb2bd..2043cc442c5 100644 --- a/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx @@ -20,8 +20,8 @@ const DefaultLogUpdateCard = ({ round, ...props }: Props) => { id="dailyround-entry" > { attributeKey: T; @@ -28,7 +33,7 @@ const LogUpdateCardAttribute = ({ return (
- +
); @@ -37,7 +42,8 @@ const LogUpdateCardAttribute = ({
- {attributeValue.systolic}/{attributeValue.diastolic} mmHg + {(attributeValue as BloodPressure).systolic}/ + {(attributeValue as BloodPressure).diastolic} mmHg
); @@ -47,7 +53,7 @@ const LogUpdateCardAttribute = ({
- {attributeValue.map((output: any) => ( + {(attributeValue as DailyRoundsOutput[]).map((output) => ( {output.name}: {output.quantity} diff --git a/src/Components/Facility/Consultations/DailyRoundsList.tsx b/src/Components/Facility/Consultations/DailyRoundsList.tsx index edcf00f3016..635b09c1000 100644 --- a/src/Components/Facility/Consultations/DailyRoundsList.tsx +++ b/src/Components/Facility/Consultations/DailyRoundsList.tsx @@ -13,6 +13,7 @@ import { useSlugs } from "../../../Common/hooks/useSlug"; import Timeline, { TimelineNode } from "../../../CAREUI/display/Timeline"; import { useState } from "react"; import { QueryParams } from "../../../Utils/request/types"; +import { UserRole } from "../../../Common/constants"; interface Props { consultation: ConsultationModel; @@ -61,13 +62,14 @@ export default function DailyRoundsList({ consultation }: Props) { type: "created", timestamp: item.taken_at?.toString() ?? "", by: { - user_type: "", + user_type: + "Virtual Nursing Assistant" as UserRole, first_name: "Virtual", last_name: "Assistant", username: "", - id: "", + id: -1, email: "", - last_login: "", + last_login: new Date().toISOString(), }, icon: "l-robot", }} @@ -92,15 +94,7 @@ export default function DailyRoundsList({ consultation }: Props) { event={{ type: "created", timestamp: item.taken_at?.toString() ?? "", - by: { - user_type: item.created_by?.user_type ?? "", - first_name: item.created_by?.first_name ?? "", - last_name: item.created_by?.last_name ?? "", - username: "", - id: "", - email: "", - last_login: "", - }, + by: item.created_by, icon: "l-user-nurse", }} isLast={items.indexOf(item) == items.length - 1} diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index e2aef8cd0d4..55f0b1d3ed1 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -185,7 +185,7 @@ const CoverImageEditModal = ({ >
{!isCameraOpen ? ( -
+ {hasImage ? ( <>
@@ -305,7 +305,7 @@ const CoverImageEditModal = ({
) : ( -
+
{t("capture_cover_photo")} diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index e3952ed0825..50108329f9d 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -31,7 +31,7 @@ interface PreDischargeFormInterface { discharge_date?: string; death_datetime?: string; death_confirmed_doctor?: string; - referred_to?: number | null | undefined; + referred_to?: string | null | undefined; referred_to_external?: string | null | undefined; } @@ -167,12 +167,10 @@ const DischargeModal = ({ const handleFacilitySelect = (selected: FacilityModel) => { setFacility(selected); - const { id, name } = selected || {}; - const isExternal = id === -1; setPreDischargeForm((prev) => ({ ...prev, - referred_to: isExternal ? null : id, - referred_to_external: isExternal ? name : null, + referred_to: selected.id ?? null, + referred_to_external: !selected.id ? selected.name : null, })); }; diff --git a/src/Components/Facility/DoctorNote.tsx b/src/Components/Facility/DoctorNote.tsx index 1fe28ba38d0..13e490cbd05 100644 --- a/src/Components/Facility/DoctorNote.tsx +++ b/src/Components/Facility/DoctorNote.tsx @@ -33,7 +33,6 @@ const DoctorNote = (props: DoctorNoteProps) => { > {state.notes.map((note: any) => ( void), + noHandlerCB?: null | (() => void) +) => void; + function UserListItem(props: { user: UserAssignedModel; facilityId: string }) { const user = props.user; const facilityId = props.facilityId; @@ -146,8 +152,9 @@ function UserListItem(props: { user: UserAssignedModel; facilityId: string }) { }; if (isEdge) { - if (navigator.msLaunchUri) { - navigator.msLaunchUri(whatsappAppURL, null, openWhatsAppWebFallback); + if ("msLaunchUri" in navigator) { + const launch = navigator.msLaunchUri as MSLaunchURI; + launch(whatsappAppURL, null, openWhatsAppWebFallback); } else { openWhatsAppWebFallback(); } diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 0f068e72aed..17b952eb699 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -106,7 +106,7 @@ export const FacilityHome = (props: any) => { const editCoverImageTooltip = hasPermissionToEditCoverImage && (
{`${hasCoverImage ? "Edit" : "Upload"}`} diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 781dbad9e40..af6dcd1d90f 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -3,12 +3,7 @@ import CountBlock from "../../CAREUI/display/Count"; import CareIcon from "../../CAREUI/icons/CareIcon"; import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants"; import * as Notification from "../../Utils/Notifications.js"; -import { - classNames, - isUserOnline, - relativeTime, - showUserDelete, -} from "../../Utils/utils"; +import { classNames, isUserOnline, relativeTime } from "../../Utils/utils"; import Pagination from "../Common/Pagination"; import UserDetails from "../Common/UserDetails"; import ButtonV2 from "../Common/components/ButtonV2"; @@ -17,11 +12,9 @@ import { FacilityModel } from "../Facility/models"; import LinkFacilityDialog from "../Users/LinkFacilityDialog"; import UnlinkFacilityDialog from "../Users/UnlinkFacilityDialog"; import UserDeleteDialog from "../Users/UserDeleteDialog"; -import useAuthUser from "../../Common/hooks/useAuthUser"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import useQuery from "../../Utils/request/useQuery"; -import { UserModel } from "../Users/models"; const Loading = lazy(() => import("../Common/Loading")); @@ -34,7 +27,6 @@ export default function FacilityUsers(props: any) { const [currentPage, setCurrentPage] = useState(1); // eslint-disable-next-line @typescript-eslint/no-unused-vars const [offset, setOffset] = useState(0); - const authUser = useAuthUser(); const [linkFacility, setLinkFacility] = useState<{ show: boolean; @@ -162,14 +154,6 @@ export default function FacilityUsers(props: any) { facilityUserFetch(); }; - const handleDelete = (user: any) => { - setUserData({ - show: true, - username: user.username, - name: `${user.first_name} ${user.last_name}`, - }); - }; - const facilityClassname = classNames( "align-baseline text-sm font-bold", isAddFacilityLoading || isUnlinkFacilityLoading || isLoadFacilityLoading @@ -262,7 +246,7 @@ export default function FacilityUsers(props: any) { facilityUserData && facilityUserData.results && facilityUserData.results.length && - (userList = facilityUserData.results.map((user: UserModel) => { + (userList = facilityUserData.results.map((user) => { return (
{`${user.first_name} ${user.last_name}`} - {showUserDelete(authUser, user) && ( -
handleDelete(user)} - > - -
- )}
@@ -317,27 +293,8 @@ export default function FacilityUsers(props: any) {
{user.user_type}
)} - {user.district_object && ( - -
- {user.district_object.name} -
-
- )}
- {user.local_body_object && ( - -
- {user.local_body_object.name} -
-
- )}
- {user.created_by && ( - -
{user.created_by}
-
- )} {user.phone_number && (
@@ -359,9 +316,9 @@ export default function FacilityUsers(props: any) { {user.username && ( - {user.facilities && - showFacilities(user.username, user.facilities)} - {!user.facilities && ( + {(user as any).facilities && + showFacilities(user.username, (user as any).facilities)} + {!(user as any).facilities && ( loadFacilities(user.username)} className={`inline-block ${facilityClassname}`} diff --git a/src/Components/Facility/PatientConsultationNotesList.tsx b/src/Components/Facility/PatientConsultationNotesList.tsx index 2b9df8c3902..35822508d4b 100644 --- a/src/Components/Facility/PatientConsultationNotesList.tsx +++ b/src/Components/Facility/PatientConsultationNotesList.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants"; import CircularProgress from "../Common/components/CircularProgress"; import routes from "../../Redux/api"; @@ -9,9 +9,9 @@ import request from "../../Utils/request/request"; interface PatientNotesProps { state: PatientNoteStateType; - setState: any; + setState: Dispatch>; reload?: boolean; - setReload?: any; + setReload?: (value: boolean) => void; disableEdit?: boolean; } @@ -25,9 +25,9 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => { const fetchNotes = async () => { setIsLoading(true); - const { data }: any = await request(routes.getPatientNotes, { + const { data } = await request(routes.getPatientNotes, { pathParams: { - patientId: props.state.patientId, + patientId: props.state.patientId || "", }, query: { consultation: consultationId, @@ -35,21 +35,23 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => { }, }); - if (state.cPage === 1) { - setState((prevState: any) => ({ - ...prevState, - notes: data.results, - totalPages: Math.ceil(data.count / pageSize), - })); - } else { - setState((prevState: any) => ({ - ...prevState, - notes: [...prevState.notes, ...data.results], - totalPages: Math.ceil(data.count / pageSize), - })); + if (data) { + if (state.cPage === 1) { + setState((prevState) => ({ + ...prevState, + notes: data.results, + totalPages: Math.ceil(data.count / pageSize), + })); + } else { + setState((prevState) => ({ + ...prevState, + notes: [...prevState.notes, ...data.results], + totalPages: Math.ceil(data.count / pageSize), + })); + } } setIsLoading(false); - setReload(false); + setReload?.(false); }; useEffect(() => { @@ -59,16 +61,16 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => { }, [reload]); useEffect(() => { - setReload(true); + setReload?.(true); }, []); const handleNext = () => { if (state.cPage < state.totalPages) { - setState((prevState: any) => ({ + setState((prevState) => ({ ...prevState, cPage: prevState.cPage + 1, })); - setReload(true); + setReload?.(true); } }; diff --git a/src/Components/Facility/PatientNoteCard.tsx b/src/Components/Facility/PatientNoteCard.tsx index 671c1744acf..eadb7588481 100644 --- a/src/Components/Facility/PatientNoteCard.tsx +++ b/src/Components/Facility/PatientNoteCard.tsx @@ -1,10 +1,6 @@ import { relativeDate, formatDateTime, classNames } from "../../Utils/utils"; import { USER_TYPES_MAP } from "../../Common/constants"; -import { - PatientNoteStateType, - PatientNotesEditModel, - PatientNotesModel, -} from "./models"; +import { PatientNotesEditModel, PatientNotesModel } from "./models"; import ButtonV2 from "../Common/components/ButtonV2"; import CareIcon from "../../CAREUI/icons/CareIcon"; import { useState } from "react"; @@ -16,18 +12,18 @@ import { t } from "i18next"; import dayjs from "dayjs"; import Spinner from "../Common/Spinner"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import useSlug from "../../Common/hooks/useSlug"; const PatientNoteCard = ({ - state, note, setReload, disableEdit, }: { - state: PatientNoteStateType; note: PatientNotesModel; setReload: any; disableEdit?: boolean; }) => { + const patientId = useSlug("patient"); const [isEditing, setIsEditing] = useState(false); const [noteField, setNoteField] = useState(note.note); const [showEditHistory, setShowEditHistory] = useState(false); @@ -36,7 +32,7 @@ const PatientNoteCard = ({ const fetchEditHistory = async () => { const { res, data } = await request(routes.getPatientNoteEditHistory, { - pathParams: { patientId: state.patientId, noteId: note.id }, + pathParams: { patientId, noteId: note.id }, }); if (res?.status === 200) { setEditHistory(data?.results ?? []); @@ -59,7 +55,7 @@ const PatientNoteCard = ({ } const { res } = await request(routes.updatePatientNote, { - pathParams: { patientId: state.patientId, noteId: note.id }, + pathParams: { patientId, noteId: note.id }, body: payload, }); if (res?.status === 200) { diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index b55c86216a7..f3c59791d63 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -53,8 +53,8 @@ const TreatmentSummary = (props: any) => {
{formatDate(date)}
-
-
+
+
Name : {patientData?.name ?? ""}
@@ -62,9 +62,9 @@ const TreatmentSummary = (props: any) => {
-
-
-
+
+
+
Age :{" "} {formatAge( patientData?.age ?? 0, @@ -72,7 +72,7 @@ const TreatmentSummary = (props: any) => { true )}
-
+
OP : {consultationData?.patient_no ?? ""}
@@ -87,8 +87,8 @@ const TreatmentSummary = (props: any) => {
-
-
+
+
Gender : {GENDER_TYPES.find((i) => i.id === patientData?.gender)?.text}
@@ -106,7 +106,7 @@ const TreatmentSummary = (props: any) => {
Comorbidities : -
+
@@ -187,7 +187,7 @@ const TreatmentSummary = (props: any) => {
Relevant investigations : -
+
@@ -282,7 +282,7 @@ const TreatmentSummary = (props: any) => { )} Treatment summary/Treament Plan : -
+
diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 1e590797f83..73e027421a7 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -1,4 +1,8 @@ -import { ConsultationSuggestionValue, UserRole } from "../../Common/constants"; +import { + ConsultationSuggestionValue, + DISCHARGE_REASONS, + UserRole, +} from "../../Common/constants"; import { AssetData, AssetLocationType } from "../Assets/AssetTypes"; import { RouteToFacility } from "../Common/RouteToFacilitySelect"; import { InvestigationType } from "../Common/prescription-builder/InvestigationBuilder"; @@ -105,7 +109,7 @@ export interface ConsultationModel { category?: PatientCategory; created_date?: string; discharge_date?: string; - new_discharge_reason?: number; + new_discharge_reason?: (typeof DISCHARGE_REASONS)[number]["id"]; discharge_prescription?: NormalPrescription; discharge_prn_prescription?: PRNPrescription; discharge_notes?: string; @@ -514,8 +518,8 @@ export interface PatientNotesModel { export interface PatientNoteStateType { notes: PatientNotesModel[]; - patientId: string; - facilityId: string; + patientId?: string; + facilityId?: string; cPage: number; totalPages: number; } diff --git a/src/Components/Form/FormFields/CheckBoxFormField.tsx b/src/Components/Form/FormFields/CheckBoxFormField.tsx index f3382d522de..c9ff52c23aa 100644 --- a/src/Components/Form/FormFields/CheckBoxFormField.tsx +++ b/src/Components/Form/FormFields/CheckBoxFormField.tsx @@ -8,7 +8,7 @@ export default function CheckBoxFormField(props: FormFieldBaseProps) {
& { +type Props = FormFieldBaseProps & { placeholder?: string; autoComplete?: string; min?: string | number; @@ -10,5 +10,5 @@ type Props = FormFieldBaseProps & { }; export default function DosageFormField(props: Props) { - return ; + return ; } diff --git a/src/Components/Form/FormFields/OtpFormField.tsx b/src/Components/Form/FormFields/OtpFormField.tsx index 904675db833..ad2a0817f58 100644 --- a/src/Components/Form/FormFields/OtpFormField.tsx +++ b/src/Components/Form/FormFields/OtpFormField.tsx @@ -13,7 +13,7 @@ const OtpFormField = ({ length = 6, ...props }: TextAreaFormFieldProps) => { const inputs = useRef>({}); return ( - +
{new Array(length).fill(null).map((_, i) => ( (props: Props) => { return props.renderSelectedOptions(selectedOptions.map((o) => o.option)); }; - const buttonRef = useRef(null); + const buttonRef = useRef(null); const handleSingleSelect = (o: any) => { if ( @@ -104,9 +104,9 @@ const MultiSelectMenuV2 = (props: Props) => { {selectedOptions.length !== 0 && (
- {selectedOptions.map((option) => ( + {selectedOptions.map((option, index) => ( { const updatedOptions = selectedOptions.filter( diff --git a/src/Components/HCX/InsuranceDetailsBuilder.tsx b/src/Components/HCX/InsuranceDetailsBuilder.tsx index c507566a259..9c2e1190f99 100644 --- a/src/Components/HCX/InsuranceDetailsBuilder.tsx +++ b/src/Components/HCX/InsuranceDetailsBuilder.tsx @@ -95,7 +95,7 @@ const InsuranceDetailEditCard = ({ }) => { const { enable_hcx } = useConfig(); const seletedInsurer = - policy.insurer_id || policy.insurer_name + policy.insurer_id && policy.insurer_name ? { code: policy.insurer_id, name: policy.insurer_name } : undefined; diff --git a/src/Components/HCX/validators.ts b/src/Components/HCX/validators.ts index 4a6875a85fe..39bdd8018de 100644 --- a/src/Components/HCX/validators.ts +++ b/src/Components/HCX/validators.ts @@ -8,7 +8,7 @@ const HCXPolicyValidator: FieldValidator = ( if ( !value.policy_id.trim() || !value.subscriber_id.trim() || - (enable_hcx && (!value.insurer_id.trim() || !value.insurer_name.trim())) + (enable_hcx && (!value.insurer_id?.trim() || !value.insurer_name?.trim())) ) return "All fields are mandatory"; }; diff --git a/src/Components/Medicine/AdministerMedicine.tsx b/src/Components/Medicine/AdministerMedicine.tsx index f7353051ea7..6f5822e8604 100644 --- a/src/Components/Medicine/AdministerMedicine.tsx +++ b/src/Components/Medicine/AdministerMedicine.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import ConfirmDialog from "../Common/ConfirmDialog"; -import { Prescription } from "./models"; +import { DosageValue, Prescription } from "./models"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import { Success } from "../../Utils/Notifications"; import PrescriptionDetailCard from "./PrescriptionDetailCard"; @@ -26,7 +26,7 @@ export default function AdministerMedicine({ prescription, ...props }: Props) { const consultation = useSlug("consultation"); const [isLoading, setIsLoading] = useState(false); const [notes, setNotes] = useState(""); - const [dosage, setDosage] = useState(); + const [dosage, setDosage] = useState(); const [error, setError] = useState(); const [isCustomTime, setIsCustomTime] = useState(false); const [customTime, setCustomTime] = useState( diff --git a/src/Components/Medicine/models.ts b/src/Components/Medicine/models.ts index 1a5f6fe8a13..53fd39d90f8 100644 --- a/src/Components/Medicine/models.ts +++ b/src/Components/Medicine/models.ts @@ -68,7 +68,7 @@ export type MedicineAdministrationRecord = { readonly id: string; readonly prescription: Prescription; notes: string; - dosage?: string; + dosage?: DosageValue; administered_date?: string; readonly administered_by: PerformedByModel; readonly archived_by: PerformedByModel | undefined; diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index ff3dede4072..aacad50dc19 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -480,7 +480,7 @@ export const PatientManager = () => {
-
+
{patient?.last_consultation?.current_bed && patient?.last_consultation?.discharge_date === null ? (
@@ -515,7 +515,7 @@ export const PatientManager = () => {
) : ( -
+
{consultation?.current_bed && consultation?.discharge_date === null ? ( @@ -375,7 +375,7 @@ export default function PatientInfoCard(props: { } {" "} on {formatDateTime(consultation.encounter_date)}, - {consultation?.new_discharge_reason === "EXP" ? ( + {consultation?.new_discharge_reason === 3 ? ( {" "} Expired on{" "} diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 85a5002f8da..4d022b85af2 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -222,7 +222,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { useEffect(() => { if (extId && formField) { setCareExtId(extId); - fetchExtResultData(null, formField); + fetchExtResultData(formField); } }, [careExtId, formField]); @@ -284,8 +284,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { } }; - const fetchExtResultData = async (e: any, field: any) => { - if (e) e.preventDefault(); + const fetchExtResultData = async (field: any) => { if (!careExtId) return; const { res, data } = await request(routes.externalResult, { pathParams: { id: careExtId }, @@ -312,10 +311,6 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? parseGenderFromExt(data.gender, state.form.gender) : state.form.gender, }); - field.onChange({ - name: "occupation", - value: data.meta_info?.occupation ?? state.form.occupation, - }); field.onChange({ name: "test_id", value: data.test_id ? data.test_id : state.form.test_id, @@ -414,7 +409,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { local_body: data.local_body ? data.local_body : "", ward: data.ward_object ? data.ward_object.id : undefined, village: data.village ? data.village : "", - medical_history: [], + medical_history: [] as number[], is_antenatal: String(!!data.is_antenatal), allergies: data.allergies ? data.allergies : "", pincode: data.pincode ? data.pincode : "", @@ -469,8 +464,9 @@ export const PatientRegister = (props: PatientRegisterProps) => { ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); - formData[`medical_history_${String(medicalHistory.id)}`] = - i.details; + (formData as any)[ + `medical_history_${String(medicalHistory.id)}` + ] = i.details; } } ); @@ -1119,7 +1115,8 @@ export const PatientRegister = (props: PatientRegisterProps) => { id="submit-importexternalresult-button" className="btn btn-primary mr-4" onClick={(e) => { - fetchExtResultData(e, showImport?.field?.("name")); + e.preventDefault(); + fetchExtResultData(showImport?.field?.("name")); }} disabled={!careExtId} > diff --git a/src/Components/Patient/SampleViewAdmin.tsx b/src/Components/Patient/SampleViewAdmin.tsx index 431fc09a317..d11d4ad23b2 100644 --- a/src/Components/Patient/SampleViewAdmin.tsx +++ b/src/Components/Patient/SampleViewAdmin.tsx @@ -157,7 +157,7 @@ export default function SampleViewAdmin() {
{item.sample_type && ( - + Type: {item.sample_type} )} diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index 0323ddb7c4b..6cb3cd90692 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -202,17 +202,11 @@ export const ShiftCreate = (props: patientShiftProps) => { const data = { status: wartime_shifting ? "PENDING" : "APPROVED", origin_facility: props.facilityId, - shifting_approving_facility: ( - state.form.shifting_approving_facility || {} - ).id, - assigned_facility: - state.form?.assigned_facility?.id != -1 - ? state.form?.assigned_facility?.id - : null, - assigned_facility_external: - state.form?.assigned_facility?.id === -1 - ? state.form?.assigned_facility?.name - : null, + shifting_approving_facility: state.form.shifting_approving_facility?.id, + assigned_facility: state.form?.assigned_facility?.id, + assigned_facility_external: !state.form?.assigned_facility?.id + ? state.form?.assigned_facility?.name + : null, patient: props.patientId, emergency: state.form.emergency === "true", is_up_shift: state.form.is_up_shift === "true", diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index 7648ea18c5e..d62a66dbfca 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -282,16 +282,23 @@ export const DailyRoundTypes = [ "TELEMEDICINE", ] as const; +export interface BloodPressure { + diastolic?: number; + mean?: number; + systolic?: number; +} + export interface DailyRoundsModel { ventilator_spo2?: number; + ventilator_interface?: + | "UNKNOWN" + | "OXYGEN_SUPPORT" + | "NON_INVASIVE" + | "INVASIVE"; spo2?: string; rhythm?: string; rhythm_detail?: string; - bp?: { - diastolic?: number; - mean?: number; - systolic?: number; - }; + bp?: BloodPressure; pulse?: number; resp?: number; temperature?: string; @@ -307,7 +314,7 @@ export interface DailyRoundsModel { other_symptoms?: string; admitted_to?: string; patient_category?: PatientCategory; - output?: DailyRoundsOutput; + output?: DailyRoundsOutput[]; recommend_discharge?: boolean; created_date?: string; modified_date?: string; @@ -323,16 +330,8 @@ export interface DailyRoundsModel { rounds_type?: (typeof DailyRoundTypes)[number]; last_updated_by_telemedicine?: boolean; created_by_telemedicine?: boolean; - created_by?: { - first_name?: string; - last_name?: string; - user_type?: string; - }; - last_edited_by?: { - first_name?: string; - last_name?: string; - user_type?: string; - }; + created_by?: PerformedByModel; + last_edited_by?: PerformedByModel; bed?: string; } diff --git a/src/Components/Shifting/ShiftDetailsUpdate.tsx b/src/Components/Shifting/ShiftDetailsUpdate.tsx index a726150c9e1..a3df51fa289 100644 --- a/src/Components/Shifting/ShiftDetailsUpdate.tsx +++ b/src/Components/Shifting/ShiftDetailsUpdate.tsx @@ -38,6 +38,7 @@ import useQuery from "../../Utils/request/useQuery.js"; import routes from "../../Redux/api.js"; import { IShift } from "./models.js"; import request from "../../Utils/request/request.js"; +import { PatientModel } from "../Patient/models.js"; const Loading = lazy(() => import("../Common/Loading")); @@ -196,14 +197,10 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { origin_facility: state.form.origin_facility_object?.id, shifting_approving_facility: state.form?.shifting_approving_facility_object?.id, - assigned_facility: - state.form?.assigned_facility_object?.id != -1 - ? state.form?.assigned_facility_object?.id - : null, - assigned_facility_external: - state.form?.assigned_facility_object?.id === -1 - ? state.form?.assigned_facility_object?.name - : null, + assigned_facility: state.form?.assigned_facility_object?.id, + assigned_facility_external: !state.form?.assigned_facility_object?.id + ? state.form?.assigned_facility_object?.name + : null, patient: state.form.patient_object?.id, emergency: [true, "true"].includes(state.form.emergency), is_kasp: [true, "true"].includes(state.form.is_kasp), @@ -251,17 +248,19 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { onResponse: ({ res, data }) => { if (res?.ok && data) { const d = data; - setConsultationData(d.patient.last_consultation as ConsultationModel); + setConsultationData( + (d.patient as PatientModel).last_consultation as ConsultationModel + ); if (d.assigned_facility_external) d["assigned_facility_object"] = { - id: -1, name: String(data.assigned_facility_external), }; d["initial_status"] = data.status; d["status"] = qParams.status || data.status; const patient_category = - d.patient.last_consultation?.last_daily_round?.patient_category ?? - d.patient.last_consultation?.category; + (d.patient as PatientModel).last_consultation?.last_daily_round + ?.patient_category ?? + (d.patient as PatientModel).last_consultation?.category; d["patient_category"] = PATIENT_CATEGORIES.find((c) => c.text === patient_category)?.id ?? ""; dispatch({ type: "set_form", form: d }); diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index c6de6c18fa4..cf7fa652fe3 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -58,7 +58,7 @@ type UserForm = { gender: string; password: string; c_password: string; - facilities: Array; + facilities: Array; home_facility: FacilityModel | null; username: string; first_name: string; @@ -326,7 +326,7 @@ export const UserAdd = (props: UserProps) => { setSelectedFacility(selected as FacilityModel[]); const form = { ...state.form }; form.facilities = selected - ? (selected as FacilityModel[]).map((i) => i.id ?? -1) + ? (selected as FacilityModel[]).map((i) => i.id!) : []; dispatch({ type: "set_form", form }); }; diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 4f19d0cb696..08673318b19 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -541,8 +541,8 @@ const routes = { partialUpdateConsultation: { path: "/api/v1/consultation/{id}/", method: "PATCH", - TRes: Type>(), - TBody: Type(), + TBody: Type>(), + TRes: Type(), }, deleteConsultation: { path: "/api/v1/consultation/{id}/", diff --git a/tsconfig.json b/tsconfig.json index ab2b142d3a4..23f7ab14d4a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,5 +17,8 @@ "jsx": "react-jsx", "types": ["vite/client", "vite-plugin-pwa/client"] }, - "include": ["src"] + "include": ["src"], + "exclude": [ + "src/**/*.gen.tsx" + ] } diff --git a/vite.config.mts b/vite.config.mts index 9285f495850..1b102f62ed4 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,7 +1,8 @@ import { VitePWA } from "vite-plugin-pwa"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; -import { treeShakeCareIcons } from "./plugins/treeShakeCareIcons.mts"; +import checker from "vite-plugin-checker"; +import { treeShakeCareIcons } from "./plugins/treeShakeCareIcons"; const cdnUrls = process.env.CARE_CDN_URL ?? @@ -15,6 +16,7 @@ export default defineConfig({ envPrefix: "REACT_", plugins: [ react(), + checker({ typescript: true }), treeShakeCareIcons({ iconWhitelist: ["default"], }), From 2b71cd330aa2ce332e328302189ea70b0e1cff86 Mon Sep 17 00:00:00 2001 From: Mohan Raj A Date: Tue, 2 Apr 2024 19:15:08 +0530 Subject: [PATCH 2/2] Handle no option available case when local body returns empty response (#7359) * Handle no option available case when result array is empty * Add Length check validation in rendering Select List * Add validation in the Select Component --- src/Components/Form/SelectMenuV2.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Form/SelectMenuV2.tsx b/src/Components/Form/SelectMenuV2.tsx index 640f3163b9d..2c22510cef1 100644 --- a/src/Components/Form/SelectMenuV2.tsx +++ b/src/Components/Form/SelectMenuV2.tsx @@ -59,7 +59,8 @@ const SelectMenuV2 = (props: SelectMenuProps) => { const showChevronIcon = props.showChevronIcon ?? true; - const placeholder = props.placeholder ?? "Select"; + const placeholder = + valueOptions?.length > 0 ? props.placeholder ?? "Select" : "No options"; const defaultOption = { label: placeholder, selectedLabel:

{placeholder}

, @@ -77,7 +78,7 @@ const SelectMenuV2 = (props: SelectMenuProps) => { return (
props.onChange(selection.value)} >