Skip to content

Commit

Permalink
Merge branch 'develop' into camera_error_fix_1
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh-D-2004 authored Mar 7, 2025
2 parents 96a18ea + 54a5532 commit 4ef57ec
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 58 deletions.
3 changes: 0 additions & 3 deletions care.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ const careConfig = {
resendOtpTimeout: env.REACT_APP_RESEND_OTP_TIMEOUT
? parseInt(env.REACT_APP_RESEND_OTP_TIMEOUT, 10)
: 30,



} as const;

export default careConfig;
10 changes: 8 additions & 2 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,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 @@ -1192,7 +1193,6 @@
"footer_body": "Open Healthcare Network is an open-source public utility designed by a multi-disciplinary team of innovators and volunteers. Open Healthcare Network CARE is a Digital Public Good recognised by the United Nations.",
"forget_password": "Forgot password?",
"forget_password_instruction": "Enter your username, and if it exists, we will send you a link to reset your password.",
"preview_form": "Preview form",
"forms": "Forms",
"frequency": "Frequency",
"from": "from",
Expand Down Expand Up @@ -1887,6 +1887,7 @@
"preset_updated": "Preset updated",
"prev_sessions": "Prev Sessions",
"preview": "Preview",
"preview_form": "Preview form",
"previous": "Previous",
"primary_ph_no": "Primary Ph No.",
"primary_phone_no": "Primary ph. no.",
Expand Down Expand Up @@ -1917,12 +1918,17 @@
"quantity_requested": "Quantity Requested",
"quantity_required": "Quantity Required",
"question": "Question",
"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 Expand Up @@ -2015,7 +2021,7 @@
"rescheduled": "Rescheduled",
"rescheduling": "Rescheduling...",
"resend_otp": "Resend OTP",
"resend_otp_timer":"Resend OTP in {{time}} seconds",
"resend_otp_timer": "Resend OTP in {{time}} seconds",
"reserved": "Reserved",
"reset": "Reset",
"reset_password": "Reset Password",
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"
/>
),

Expand Down Expand Up @@ -88,6 +90,9 @@ const consultationRoutes: AppRoutes = {
subjectType="patient"
/>
),
"/patient/:patientId/questionnaire": ({ patientId }) => (
<EncounterQuestionnaire patientId={patientId} subjectType="patient" />
),
};

export default consultationRoutes;
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useQuery } from "@tanstack/react-query";
import { t } from "i18next";
import { useQueryParams } from "raviger";
import { Link, useQueryParams } from "raviger";
import { Trans, useTranslation } from "react-i18next";

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

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

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";

Expand All @@ -25,6 +28,7 @@ import { QuestionnaireResponse } from "@/types/questionnaire/questionnaireRespon
interface Props {
encounter?: Encounter;
patientId: string;
facilityId?: string;
isPrintPreview?: boolean;
onlyUnstructured?: boolean;
}
Expand Down Expand Up @@ -293,8 +297,8 @@ function ResponseCard({
}

export default function QuestionnaireResponsesList({
encounter,
patientId,
facilityId,
isPrintPreview = false,
onlyUnstructured,
}: Props) {
Expand All @@ -310,8 +314,8 @@ export default function QuestionnaireResponsesList({
limit: RESULTS_PER_PAGE_LIMIT,
offset: ((qParams.page ?? 1) - 1) * RESULTS_PER_PAGE_LIMIT,
}),
encounter: encounter?.id,
only_unstructured: onlyUnstructured,
subject_type: "patient",
},
maxPages: isPrintPreview ? undefined : 1,
pageSize: isPrintPreview ? 100 : RESULTS_PER_PAGE_LIMIT,
Expand All @@ -321,6 +325,23 @@ export default function QuestionnaireResponsesList({
return (
<div className="mt-4 gap-4">
<div className="max-w-full">
<div className="flex justify-between items-center mb-4">
<div className="mr-4 text-xl font-bold text-secondary-900">
{t("updates")}
</div>
<Button asChild variant="outline_primary">
<Link
href={
facilityId
? `/facility/${facilityId}/patient/${patientId}/questionnaire`
: `/patient/${patientId}/questionnaire`
}
>
<CareIcon icon="l-plus" className="mr-2" />
{t("add_patient_updates")}
</Link>
</Button>
</div>
{isLoading ? (
<div className="grid gap-5">
<CardListSkeleton count={RESULTS_PER_PAGE_LIMIT} />
Expand Down
10 changes: 7 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,10 +72,14 @@ export default function EncounterQuestionnaire({
encounterId={encounterId}
questionnaireSlug={questionnaireSlug}
onSubmit={() => {
if (encounterId) {
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`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Patient/PatientDetailsTab/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QuestionnaireResponsesList from "@/components/Facility/ConsultationDetails/QuestionnaireResponsesList";
import EncounterHistory from "@/components/Patient/PatientDetailsTab//EncounterHistory";
import { HealthProfileSummary } from "@/components/Patient/PatientDetailsTab//HealthProfileSummary";
import { Demography } from "@/components/Patient/PatientDetailsTab/Demography";
import { Updates } from "@/components/Patient/PatientDetailsTab/patientUpdates";

import { Patient } from "@/types/emr/newPatient";

Expand Down Expand Up @@ -35,7 +35,7 @@ export const patientTabs = [
},
{
route: "updates",
component: Updates,
component: QuestionnaireResponsesList,
},
{
route: "resource_requests",
Expand Down
19 changes: 0 additions & 19 deletions src/components/Patient/PatientDetailsTab/patientUpdates.tsx

This file was deleted.

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 @@ -62,7 +62,7 @@ export interface QuestionnaireFormProps {
subjectType?: string;
onSubmit?: () => void;
onCancel?: () => void;
facilityId: string;
facilityId?: string;
}

interface ValidationErrorDisplayProps {
Expand Down Expand Up @@ -587,7 +587,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
8 changes: 6 additions & 2 deletions src/pages/Encounters/tabs/EncounterNotesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const ThreadItem = ({
const MessageItem = forwardRef<HTMLDivElement, { message: Message }>(
({ message }, ref) => {
const authUser = useAuthUser();
const { facilityId } = usePathParams("/facility/:facilityId/*")!;
const { facilityId } = usePathParams("/facility/:facilityId/*") ?? {};
const isCurrentUser = authUser?.external_id === message.created_by.id;

return (
Expand All @@ -136,7 +136,11 @@ const MessageItem = forwardRef<HTMLDivElement, { message: Message }>(
>
<TooltipComponent content={message.created_by?.username}>
<Link
href={`/facility/${facilityId}/users/${message.created_by?.username}`}
href={
facilityId
? `/facility/${facilityId}/users/${message.created_by?.username}`
: `/users/${message.created_by?.username}`
}
>
<span className="flex pr-2">
<Avatar
Expand Down

0 comments on commit 4ef57ec

Please sign in to comment.