Skip to content

Commit

Permalink
Full width check function, bounds duration type
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 committed Jan 9, 2025
1 parent 0c4cfbe commit 40e4570
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/components/Questionnaire/QuestionRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import { cn } from "@/lib/utils";

import { QuestionValidationError } from "@/types/questionnaire/batch";
import { QuestionnaireResponse } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";
import {
Question,
StructuredQuestionType,
} from "@/types/questionnaire/question";

import { QuestionGroup } from "./QuestionTypes/QuestionGroup";

// Questions that should be rendered full width
const FULL_WIDTH_QUESTION_TYPES: StructuredQuestionType[] = [
"medication_request",
];

interface QuestionRendererProps {
questions: Question[];
responses: QuestionnaireResponse[];
Expand Down Expand Up @@ -57,11 +65,11 @@ export function QuestionRenderer({
onResponseChange(newResponses);
};

const isMedicationRequest = (question: Question): boolean => {
return (
question.type === "structured" &&
question.structured_type === "medication_request"
);
const shouldBeFullWidth = (question: Question): boolean => {
if (question.type !== "structured" || !question.structured_type) {
return false;
}
return FULL_WIDTH_QUESTION_TYPES.includes(question.structured_type);
};

return (
Expand All @@ -71,7 +79,7 @@ export function QuestionRenderer({
key={question.id}
ref={(el) => (questionRefs.current[question.id] = el)}
className={cn(
isMedicationRequest(question) ? "md:w-auto" : "max-w-4xl",
shouldBeFullWidth(question) ? "md:w-auto" : "max-w-4xl",
)}
>
<QuestionGroup
Expand Down
4 changes: 2 additions & 2 deletions src/types/emr/medicationRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export interface DosageQuantity {
}

export interface BoundsDuration {
value?: number;
unit?: keyof typeof BOUNDS_DURATION_UNITS;
value: number;
unit: keyof typeof BOUNDS_DURATION_UNITS;
}

export interface DoseRange {
Expand Down

0 comments on commit 40e4570

Please sign in to comment.