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

Patient Questionnaire: Org Access #10988

Merged
merged 7 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
"active_location_cannot_be_in_future": "Active location cannot be in the future",
"active_prescriptions": "Active Prescriptions",
"add": "Add",
"add_another": "Add Another",
"add_another_session": "Add another session",
"add_as": "Add as",
"add_attachments": "Add Attachments",
Expand Down Expand Up @@ -1891,12 +1892,17 @@
"quantity_approved": "Quantity Approved",
"quantity_requested": "Quantity Requested",
"quantity_required": "Quantity Required",
"questionnaire_diagnosis_no_encounter": "Diagnosis cannot be recorded without an active encounter",
"questionnaire_error_loading": "Error loading questionnaire",
"questionnaire_medication_request_no_encounter": "Medication requests cannot be recorded without an active encounter",
"questionnaire_medication_statement_no_encounter": "Medication statements cannot be recorded without an active encounter",
"questionnaire_no_encounter": "Create an encounter first in order to update it",
"questionnaire_not_exist": "The questionnaire you tried to access does not exist.",
"questionnaire_one": "Questionnaire",
"questionnaire_other": "Questionnaires",
"questionnaire_submission_failed": "Failed to submit questionnaire",
"questionnaire_submitted_successfully": "Questionnaire submitted successfully",
"questionnaire_symptom_no_encounter": "Symptoms cannot be recorded without an active encounter",
"quick_access": "Quick Access",
"quick_actions": "Quick Actions",
"quick_actions_description": "Schedule an appointment or create a new encounter",
Expand Down
5 changes: 5 additions & 0 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const consultationRoutes: AppRoutes = {
facilityId={facilityId}
encounterId={encounterId}
patientId={patientId}
subjectType="encounter"
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire/:slug":
Expand All @@ -38,6 +39,7 @@ const consultationRoutes: AppRoutes = {
encounterId={encounterId}
questionnaireSlug={slug}
patientId={patientId}
subjectType="encounter"
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
Expand Down Expand Up @@ -87,6 +89,9 @@ const consultationRoutes: AppRoutes = {
subjectType="patient"
/>
),
"/patient/:patientId/questionnaire": ({ patientId }) => (
<EncounterQuestionnaire patientId={patientId} subjectType="patient" />
),
};

export default consultationRoutes;
6 changes: 3 additions & 3 deletions src/components/Patient/EncounterQuestionnaire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import query from "@/Utils/request/query";
import { formatDateTime } from "@/Utils/utils";

interface Props {
facilityId: string;
facilityId?: string;
patientId: string;
encounterId?: string;
questionnaireSlug?: string;
Expand All @@ -34,7 +34,7 @@ export default function EncounterQuestionnaire({
queryKey: ["encounter", encounterId],
queryFn: query(routes.encounter.get, {
pathParams: { id: encounterId ?? "" },
queryParams: { facility: facilityId },
queryParams: { facility: facilityId! },
}),
enabled: !!encounterId,
});
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function EncounterQuestionnaire({
encounterId={encounterId}
questionnaireSlug={questionnaireSlug}
onSubmit={() => {
if (encounterId) {
if (encounterId && facilityId) {
navigate(
`/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}/updates`,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useQuery } from "@tanstack/react-query";
import { useQueryParams } from "raviger";
import { Link, useQueryParams } from "raviger";
import { useTranslation } from "react-i18next";

import { cn } from "@/lib/utils";

import CareIcon from "@/CAREUI/icons/CareIcon";

import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";

import PaginationComponent from "@/components/Common/Pagination";
Expand Down Expand Up @@ -41,6 +42,12 @@ export const Updates = (props: PatientProps) => {
<div className="mt-4 px-3 md:px-0">
<div className="flex justify-between items-center mb-4">
<h2 className="text-2xl font-semibold leading-tight">{t("updates")}</h2>
<Button asChild variant="outline_primary">
<Link href={`/patient/${patientId}/questionnaire`}>
<CareIcon icon="l-plus" className="mr-2" />
{t("add_patient_updates")}
</Link>
</Button>
</div>
<div className="flex w-full flex-col gap-4">
<div className="flex flex-col gap-4">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Questionnaire/QuestionRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface QuestionRendererProps {
disabled?: boolean;
activeGroupId?: string;
encounterId?: string;
facilityId: string;
facilityId?: string;
patientId: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface QuestionGroupProps {
clearError: (questionId: string) => void;
disabled?: boolean;
activeGroupId?: string;
facilityId: string;
facilityId?: string;
patientId: string;
}

Expand Down
31 changes: 11 additions & 20 deletions src/components/Questionnaire/QuestionTypes/QuestionInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useTranslation } from "react-i18next";

import { cn } from "@/lib/utils";

import CareIcon from "@/CAREUI/icons/CareIcon";
Expand Down Expand Up @@ -39,7 +41,7 @@ interface QuestionInputProps {
errors: QuestionValidationError[];
clearError: () => void;
disabled?: boolean;
facilityId: string;
facilityId?: string;
patientId: string;
}

Expand All @@ -54,6 +56,7 @@ export function QuestionInput({
facilityId,
patientId,
}: QuestionInputProps) {
const { t } = useTranslation();
const questionnaireResponse = questionnaireResponses.find(
(v) => v.question_id === question.id,
);
Expand Down Expand Up @@ -124,10 +127,7 @@ export function QuestionInput({
);
}
return (
<span>
Medication requests cannot be recorded without an active
encounter
</span>
<span>{t("questionnaire_medication_request_no_encounter")}</span>
);
case "medication_statement":
if (encounterId) {
Expand All @@ -140,8 +140,7 @@ export function QuestionInput({
}
return (
<span>
Medication statement cannot be recorded without an active
encounter
{t("questionnaire_medication_statement_no_encounter")}
</span>
);
case "allergy_intolerance":
Expand All @@ -156,24 +155,18 @@ export function QuestionInput({
/>
);
}
return (
<span> Symptoms cannot be recorded without an encounter </span>
);
return <span>{t("questionnaire_symptom_no_encounter")}</span>;
case "diagnosis":
if (encounterId) {
return (
<DiagnosisQuestion {...commonProps} encounterId={encounterId} />
);
}
return (
<span>
Diagnosis cannot be recorded without an active encounter
</span>
);
return <span>{t("questionnaire_diagnosis_no_encounter")}</span>;
case "appointment":
return <AppointmentQuestion {...commonProps} />;
case "encounter":
if (encounterId) {
if (encounterId && facilityId) {
return (
<EncounterQuestion
{...commonProps}
Expand All @@ -182,9 +175,7 @@ export function QuestionInput({
/>
);
}
return (
<span> Create an encounter first in order to update it </span>
);
return <span>{t("questionnaire_no_encounter")}</span>;
}
return null;

Expand Down Expand Up @@ -270,7 +261,7 @@ export function QuestionInput({
disabled={disabled}
>
<CareIcon icon="l-plus" className="mr-2 h-4 w-4" />
Add Another
{t("add_another")}
</Button>
<NotesInput
questionnaireResponse={questionnaireResponse}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Questionnaire/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface QuestionnaireFormProps {
subjectType?: string;
onSubmit?: () => void;
onCancel?: () => void;
facilityId: string;
facilityId?: string;
}

export function QuestionnaireForm({
Expand Down Expand Up @@ -294,7 +294,7 @@ export function QuestionnaireForm({
method: "POST",
reference_id: form.questionnaire.id,
body: {
resource_id: encounterId,
resource_id: encounterId ? encounterId : patientId,
encounter: encounterId,
patient: patientId,
results: nonStructuredResponses
Expand Down
Loading