-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathEncounterQuestionnaire.tsx
More file actions
87 lines (80 loc) · 2.47 KB
/
EncounterQuestionnaire.tsx
File metadata and controls
87 lines (80 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { useQuery } from "@tanstack/react-query";
import { navigate } from "raviger";
import { useTranslation } from "react-i18next";
import { Card, CardContent } from "@/components/ui/card";
import Page from "@/components/Common/Page";
import { QuestionnaireForm } from "@/components/Questionnaire/QuestionnaireForm";
import query from "@/Utils/request/query";
import {
PatientDeceasedInfo,
PatientHeader,
} from "@/components/Patient/PatientHeader";
import encounterApi from "@/types/emr/encounter/encounterApi";
interface Props {
facilityId?: string;
patientId: string;
encounterId?: string;
questionnaireSlug?: string;
subjectType?: string;
}
export default function EncounterQuestionnaire({
facilityId,
patientId,
encounterId,
questionnaireSlug,
subjectType,
}: Props) {
const { t } = useTranslation();
const { data: encounter } = useQuery({
queryKey: ["encounter", encounterId],
queryFn: query(encounterApi.get, {
pathParams: { id: encounterId ?? "" },
queryParams: { facility: facilityId! },
}),
enabled: !!encounterId,
});
return (
<Page
title={t("questionnaire_one")}
className="block md:px-1 -mt-4"
hideTitleOnPage
>
<div className="flex flex-col space-y-4">
{encounter && (
<div className="flex flex-col gap-2">
<PatientHeader
patient={encounter.patient}
facilityId={facilityId}
className="bg-white shadow-sm rounded-sm"
/>
<PatientDeceasedInfo patient={encounter.patient} />
</div>
)}
<Card className="mt-2">
<CardContent className="lg:p-4 p-0">
<QuestionnaireForm
facilityId={facilityId}
patientId={patientId}
subjectType={subjectType}
encounterId={encounterId}
questionnaireSlug={questionnaireSlug}
onSubmit={() => {
if (encounterId && facilityId) {
navigate(
`/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}/updates`,
);
} else if (facilityId) {
navigate(
`/facility/${facilityId}/patient/${patientId}/updates`,
);
} else {
navigate(`/patient/${patientId}/updates`);
}
}}
/>
</CardContent>
</Card>
</div>
</Page>
);
}