Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
Browse files Browse the repository at this point in the history
…structured_prefills
  • Loading branch information
amjithtitus09 committed Jan 20, 2025
2 parents 82c70b5 + c098db2 commit bd4ba61
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 45 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
"cross-env": "^7.0.3",
"cypress": "^13.17.0",
"cypress": "^14.0.0",
"date-fns": "^3.6.0",
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
Expand Down
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@
"error_fetching_slots_data": "Error while fetching slots data",
"error_fetching_user_data": "Error while fetching user data",
"error_fetching_user_details": "Error while fetching user details: ",
"error_loading_questionnaire_response": "Error loading questionnaire response",
"error_sending_otp": "Error while sending OTP, Please try again later",
"error_updating_encounter": "Error to Updating Encounter",
"error_verifying_otp": "Error while verifying OTP, Please request a new OTP",
Expand Down
28 changes: 18 additions & 10 deletions scripts/generate-supported-browsers.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { getUserAgentRegex } from 'browserslist-useragent-regexp';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { getUserAgentRegex } from "browserslist-useragent-regexp";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const regex = getUserAgentRegex({
ignoreMinor: true,
ignorePatch: true,
allowZeroSubversions: false,
allowHigherVersions: true,
ignoreMinor: true,
ignorePatch: true,
allowZeroSubversions: false,
allowHigherVersions: true,
});

const supportedBrowsersPath = path.resolve(__dirname, '../src/supportedBrowsers.ts');
fs.writeFileSync(supportedBrowsersPath, `export default ${regex};`);
const supportedBrowsersPath = path.resolve(
__dirname,
"../src/supportedBrowsers.ts",
);
fs.writeFileSync(
supportedBrowsersPath,
`/* eslint-disable */
export default ${regex};
`,
);
3 changes: 2 additions & 1 deletion scripts/setup-care-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const plugins = readAppsConfig();

// Generate pluginMap.ts
const pluginMapPath = path.join(__dirname, "..", "src", "pluginMap.ts");
const pluginMapContent = `// Use type assertion for the static import\n${plugins
const pluginMapContent = `/* eslint-disable */
// Use type assertion for the static import\n${plugins
.map(
(plugin) =>
`// @ts-expect-error Remote module will be available at runtime\nimport ${plugin.camelCaseName}Manifest from "${plugin.repo}/manifest";`,
Expand Down
10 changes: 7 additions & 3 deletions src/components/ErrorPages/DefaultErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

import useAppHistory from "@/hooks/useAppHistory";

import { Button } from "../ui/button";

type ErrorType = "PAGE_NOT_FOUND" | "PAGE_LOAD_ERROR" | "CUSTOM_ERROR";
Expand All @@ -18,6 +20,7 @@ export default function ErrorPage({
...props
}: ErrorPageProps) {
const { t } = useTranslation();
const { goBack } = useAppHistory();

useEffect(() => {
toast.dismiss();
Expand Down Expand Up @@ -56,10 +59,11 @@ export default function ErrorPage({
<br />
<br />
<Button
onClick={() =>
onClick={() => {
// Refresh the Page
window.location.reload()
}
goBack("/");
window.location.reload();
}}
className="inline-block rounded-lg bg-primary-600 px-4 py-2 text-white hover:bg-primary-700 hover:text-white"
>
{t("return_to_care")}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useQuery } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
Expand All @@ -9,28 +10,27 @@ import { Skeleton } from "@/components/ui/skeleton";
import Page from "@/components/Common/Page";

import routes from "@/Utils/request/api";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import { formatDateTime } from "@/Utils/utils";
import { QuestionnaireResponse as Response } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";

export default function QuestionnaireResponseView({
responseId,

patientId,
}: {
responseId: string;
patientId: string;
}) {
const { t } = useTranslation();
const { data: formResponse, loading } = useQuery(
routes.getQuestionnaireResponse,
{
const { data: formResponse, isLoading } = useQuery({
queryKey: ["getQuestionnaireResponse", patientId, responseId],
queryFn: query(routes.getQuestionnaireResponse, {
pathParams: { patientId, responseId },
},
);
}),
});

if (loading) {
if (isLoading) {
return (
<div className="flex h-full items-center justify-center">
<Skeleton className="h-8 w-64" />
Expand Down
5 changes: 5 additions & 0 deletions src/components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Loading from "@/components/Common/Loading";

import { FACILITY_FEATURE_TYPES } from "@/common/constants";

import { PLUGIN_Component } from "@/PluginEngine";
import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
import request from "@/Utils/request/request";
Expand Down Expand Up @@ -267,6 +268,10 @@ export const FacilityHome = ({ facilityId }: Props) => {
{t("delete_facility")}
</DropdownMenuItem>
)} */}
<PLUGIN_Component
__name="FacilityHomeActions"
facility={facilityData}
/>
</DropdownMenuContent>
</DropdownMenu>
</div>
Expand Down
15 changes: 9 additions & 6 deletions src/components/Questionnaire/QuestionnaireEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useNavigate } from "raviger";
import { useEffect, useState } from "react";
import { toast } from "sonner";
Expand Down Expand Up @@ -29,7 +29,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";

import mutate from "@/Utils/request/mutate";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import {
AnswerOption,
EnableWhen,
Expand Down Expand Up @@ -60,10 +60,13 @@ export default function QuestionnaireEditor({ id }: QuestionnaireEditorProps) {

const {
data: initialQuestionnaire,
loading,
isLoading,
error,
} = useQuery(questionnaireApi.detail, {
pathParams: { id },
} = useQuery({
queryKey: ["questionnaireDetail", id],
queryFn: query(questionnaireApi.detail, {
pathParams: { id },
}),
});

const { mutate: updateQuestionnaire, isPending } = useMutation({
Expand All @@ -87,7 +90,7 @@ export default function QuestionnaireEditor({ id }: QuestionnaireEditorProps) {
}
}, [initialQuestionnaire]);

if (loading) return <Loading />;
if (isLoading) return <Loading />;
if (error) {
return (
<Alert variant="destructive">
Expand Down
15 changes: 9 additions & 6 deletions src/components/Questionnaire/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";
import { t } from "i18next";
import { useNavigationPrompt } from "raviger";
import { useEffect, useState } from "react";
Expand All @@ -16,7 +16,7 @@ import Loading from "@/components/Common/Loading";
import { PLUGIN_Component } from "@/PluginEngine";
import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import {
DetailedValidationError,
QuestionValidationError,
Expand Down Expand Up @@ -74,11 +74,14 @@ export function QuestionnaireForm({

const {
data: questionnaireData,
loading: isQuestionnaireLoading,
isLoading: isQuestionnaireLoading,
error: questionnaireError,
} = useQuery(questionnaireApi.detail, {
pathParams: { id: questionnaireSlug ?? "" },
prefetch: !!questionnaireSlug && !FIXED_QUESTIONNAIRES[questionnaireSlug],
} = useQuery({
queryKey: ["questionnaireDetail", questionnaireSlug],
queryFn: query(questionnaireApi.detail, {
pathParams: { id: questionnaireSlug ?? "" },
}),
enabled: !!questionnaireSlug && !FIXED_QUESTIONNAIRES[questionnaireSlug],
});

const { mutate: submitBatch, isPending } = useMutation({
Expand Down
10 changes: 7 additions & 3 deletions src/components/Questionnaire/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "raviger";

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";

import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import { QuestionnaireDetail } from "@/types/questionnaire/questionnaire";
import questionnaireApi from "@/types/questionnaire/questionnaireApi";

import Loading from "../Common/Loading";

export function QuestionnaireList() {
const navigate = useNavigate();
const { data: response, loading } = useQuery(questionnaireApi.list);
const { data: response, isLoading } = useQuery({
queryKey: ["questionnaires"],
queryFn: query(questionnaireApi.list),
});

if (loading) {
if (isLoading) {
return <Loading />;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useQuestionnaireOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DEFAULT_OPTIONS: EditQuestionnaireOption[] = [

export default function useQuestionnaireOptions(slug: string) {
const { data } = useQuery({
queryKey: ["questionnaire", slug] as const,
queryKey: ["questionnaires", slug] as const,
queryFn: query(questionnaireApi.list, {
queryParams: {
tag_slug: slug,
Expand Down
7 changes: 7 additions & 0 deletions src/pluginTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Patient } from "@/types/emr/newPatient";
import { AppRoutes } from "./Routers/AppRouter";
import { QuestionnaireFormState } from "./components/Questionnaire/QuestionnaireForm";
import { pluginMap } from "./pluginMap";
import { FacilityData } from "./types/facility/facility";

export type DoctorConnectButtonComponentType = React.FC<{
user: UserAssignedModel;
Expand All @@ -30,6 +31,11 @@ export type PatientInfoCardActionsComponentType = React.FC<{
className?: string;
}>;

export type FacilityHomeActionsComponentType = React.FC<{
facility: FacilityData;
className?: string;
}>;

export type PatientRegistrationFormComponentType = React.FC<{
form: UseFormReturn<any>; // eslint-disable-line @typescript-eslint/no-explicit-any
patientId?: string;
Expand All @@ -41,6 +47,7 @@ export type SupportedPluginComponents = {
Scribe: ScribeComponentType;
PatientHomeActions: PatientHomeActionsComponentType;
PatientInfoCardActions: PatientInfoCardActionsComponentType;
FacilityHomeActions: FacilityHomeActionsComponentType;
PatientRegistrationForm: PatientRegistrationFormComponentType;
};

Expand Down
10 changes: 9 additions & 1 deletion vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ export default defineConfig(({ mode }) => {
],
}),
react(),
checker({ typescript: true }),
checker({
typescript: true,
eslint: {
lintCommand: "eslint ./src",
dev: {
logLevel: ["error"],
},
},
}),
treeShakeCareIcons({
iconWhitelist: ["default"],
}),
Expand Down

0 comments on commit bd4ba61

Please sign in to comment.