Skip to content

Commit

Permalink
Structured Response View Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 committed Jan 6, 2025
1 parent 08ae3d8 commit 3180a7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { Card } from "@/components/ui/card";
import routes from "@/Utils/request/api";
import { formatDateTime, properCase } from "@/Utils/utils";
import { Encounter } from "@/types/emr/encounter";
import { Question } from "@/types/questionnaire/question";
import {
Question,
StructuredQuestionType,
} from "@/types/questionnaire/question";
import { QuestionnaireResponse } from "@/types/questionnaire/questionnaireResponse";

import { StructuredResponseView } from "./StructuredResponseView";
Expand Down Expand Up @@ -263,7 +266,7 @@ export default function QuestionnaireResponsesList({ encounter }: Props) {
return (
<StructuredResponseView
key={response.id}
type={type}
type={type as StructuredQuestionType}
id={response.id}
patientId={encounter.patient.id}
encounterId={encounter.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ import query from "@/Utils/request/query";
import allergyApi from "@/types/emr/allergyIntolerance/allergyIntoleranceApi";
import diagnosisApi from "@/types/emr/diagnosis/diagnosisApi";
import symptomApi from "@/types/emr/symptom/symptomApi";
import { StructuredQuestionType } from "@/types/questionnaire/question";

interface Props {
type: "symptom" | "diagnosis" | "allergy_intolerance";
type SupportedType = "symptom" | "diagnosis" | "allergy_intolerance";
type Props = {
type: StructuredQuestionType;
id: string;
patientId: string;
encounterId: string;
}
};

export function StructuredResponseView({
type,
id,
patientId,
encounterId,
}: Props) {
const isSupportedType = (t: StructuredQuestionType): t is SupportedType => {
return ["symptom", "diagnosis", "allergy_intolerance"].includes(t);
};

const basePathParams = { patientId };
const queryParams = { encounter: encounterId };

Expand All @@ -48,6 +54,8 @@ export function StructuredResponseView({
enabled: type === "allergy_intolerance" && !!id,
});

if (!isSupportedType(type)) return null;

const currentQuery = {
symptom: symptomQuery,
diagnosis: diagnosisQuery,
Expand Down

0 comments on commit 3180a7a

Please sign in to comment.