-
Notifications
You must be signed in to change notification settings - Fork 1
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
Wound treatment and surgery form edit #58
Conversation
WalkthroughThe pull request updates the mouse surgery form by expanding the treatment types to include "Re-stitching" and "Intracerebral injection." It modifies the logic for dependent fields to accommodate these new treatment scenarios and introduces additional fields related to anesthesia management, hydration, and treatment durations. The validation schema has been revised to ensure proper input validation for the newly added fields and treatment types. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant F as SurgeryForm
participant V as Validator
U->>F: Select treatment type
alt Treatment requires extra details
F->>F: Check treatment type conditions
F->>U: Render additional fields (anesthesia, hydration, durations)
else Standard treatment
F->>U: Render default fields
end
U->>F: Fill in form data
F->>V: Validate inputs based on updated schema
V-->>F: Return validation result
F->>U: Confirm form submission
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (4)
24-24
: Update tags to include all treatment types.The tags array should be updated to include the new treatment types "Re-stitching" and "Intracerebral injection" for consistency and better categorization.
- tags: ['Surgery', 'Vet Care', 'Wound Treatment', 'Ovariectomy'], + tags: ['Surgery', 'Vet Care', 'Wound Treatment', 'Ovariectomy', 'Re-stitching', 'Intracerebral injection'],
284-288
: Add integer validation to number input.The validation schema requires an integer for treatment duration, but the form field allows any number. Consider adding a step attribute to ensure integer input.
kind: "number", variant: "input", + step: 1, label: "Treatment duration (days)"
290-294
: Add integer validation to timing fields.Similar to treatment duration, surgery duration and days until recovery should enforce integer input to match their validation schema.
kind: "number", variant: "input", + step: 1, label: "Surgery duration (minutes)"
kind: "number", variant: "input", + step: 1, label: "Expected number of days until recovery"
Also applies to: 296-300
426-426
: Add maximum volume validation.Consider adding maximum volume validation for analgesia, anesthesia, and hydration to prevent unrealistic values.
- analgesiaVolume: z.number().min(0).optional(), + analgesiaVolume: z.number().min(0).max(10).optional(), // Adjust max value based on requirements - anesthesiaVolume: z.number().min(0).optional(), + anesthesiaVolume: z.number().min(0).max(10).optional(), // Adjust max value based on requirements - hydrationVolume: z.number().min(0).optional(), + hydrationVolume: z.number().min(0).max(50).optional(), // Adjust max value based on requirementsAlso applies to: 429-429, 431-431
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(9 hunks)
🔇 Additional comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
445-445
: Verify surgery duration precision requirements.Unlike treatment duration and recovery days which require integers, surgery duration allows decimal values. Please confirm if this is intentional, as it might affect data consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix typos: Analgesia not Analglesia
for Anesthesia volume (ml), this doesnt make sense for all type of anesthesia. After Anesthesia true or false, you should next ask both Anesthesia type (chemical name) and route of administration (drop down of inhalation, intraperitoneal, etc.) and if the route is anything other than inhalation then ask for Anesthesia volume (ml) else ask for time under anesthesia. Next, I would remove Treatment duration (days) in the restitching part of the form, it is not applicable here. Instead, if treatment is needed after restitching then the user should next fill out the wound treatment part of the form. Finally, as per my previous comment, remove "Expected number of days until recovery" from the intracerebral injection section, the user should record how long it took the mouse to recover from the anaesthesia -- this is part of the normal postop tracking we need to provide to the animal facility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
77-112
: Consider extracting common field patterns into reusable functions.The anesthesia fields follow the same pattern as analgesia fields. Consider creating a helper function to generate these related field sets to reduce code duplication and improve maintainability.
Example helper function:
function createMedicationFields(prefix: string, dependentTypes: TreatmentType[]) { return { [`${prefix}Used`]: createDependentField({ kind: "boolean", variant: "radio", label: `${prefix.charAt(0).toUpperCase() + prefix.slice(1)} used` }, (type) => dependentTypes.includes(type)), [`${prefix}Volume`]: { kind: "dynamic", deps: [`${prefix}Used`], render: (data) => data[`${prefix}Used`] ? { kind: "number", variant: "input", label: `${prefix.charAt(0).toUpperCase() + prefix.slice(1)} volume (ml)` } : null }, [`${prefix}Type`]: { kind: "dynamic", deps: [`${prefix}Used`], render: (data) => data[`${prefix}Used`] ? { kind: "string", variant: "input", label: `${prefix.charAt(0).toUpperCase() + prefix.slice(1)} type` } : null } } }
284-300
: Consider adding maximum bounds for duration fields.While the validation schema ensures minimum values of 0, consider adding maximum bounds to prevent unrealistic values:
- Treatment duration: Typically shouldn't exceed 30-60 days
- Surgery duration: Typically shouldn't exceed 8-12 hours
- Recovery days: Typically shouldn't exceed 30-60 days
Update the validation schema with reasonable maximum bounds:
- treatmentDuration: z.number().min(0).int().optional(), - surgeryDuration: z.number().min(0).optional(), - daysUntilRecovery: z.number().min(0).int().optional(), + treatmentDuration: z.number().min(0).max(60).int().optional(), + surgeryDuration: z.number().min(0).max(720).optional(), // 12 hours in minutes + daysUntilRecovery: z.number().min(0).max(60).int().optional(),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (4)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (4)
6-6
: LGTM! Treatment types expanded appropriately.The new treatment types "Re-stitching" and "Intracerebral injection" are consistently added to both the type definition and the form options.
Also applies to: 36-38
41-75
: LGTM! Analgesia fields updated correctly.The analgesia fields are properly configured with:
- Correct dependency logic for new treatment types
- Clear labeling
- Appropriate input types and units
136-156
: LGTM! Verify hydration requirements for Re-stitching.The hydration fields are properly implemented. However, verify if hydration should also be tracked for "Re-stitching" procedures, as it's currently only enabled for "Surgery" and "Intracerebral injection".
Please confirm with the veterinary team if hydration monitoring is necessary for re-stitching procedures.
423-447
: LGTM! Validation schema updated comprehensively.The validation schema properly includes all new fields with appropriate types, constraints, and optionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
41-75
: Consider extracting treatment type conditions for better maintainability.The treatment type conditions are repeated across multiple fields. Consider extracting these conditions into a helper function.
+const requiresAnalgesia = (type: TreatmentType) => + type === "Surgery" || type === "Re-stitching" || type === "Intracerebral injection"; - analgesiaUsed: createDependentField({ - kind: "boolean", - variant: "radio", - label: "Analgesia used" - }, (type) => type === "Surgery" || type === "Re-stitching" || type === "Intracerebral injection"), + analgesiaUsed: createDependentField({ + kind: "boolean", + variant: "radio", + label: "Analgesia used" + }, requiresAnalgesia),
77-112
: Consider creating a reusable field factory for medication inputs.The anesthesia fields follow the same pattern as analgesia fields. Consider creating a factory function to reduce code duplication.
+const createMedicationFields = (name: string, dependencyFn: (type: TreatmentType) => boolean) => ({ + [`${name}Used`]: createDependentField({ + kind: "boolean", + variant: "radio", + label: `${name} used` + }, dependencyFn), + [`${name}Volume`]: { + kind: "dynamic", + deps: [`${name}Used`], + render(data: Record<string, any>) { + if(data[`${name}Used`]){ + return { + kind: "number", + variant: "input", + label: `${name} volume (ml)` + } + } + return null + } + }, + [`${name}Type`]: { + kind: "dynamic", + deps: [`${name}Used`], + render(data: Record<string, any>) { + if(data[`${name}Used`]){ + return { + kind: "string", + variant: "input", + label: `${name} type` + } + } + return null + } + } +}); +const medicationFields = { + ...createMedicationFields('analgesia', requiresAnalgesia), + ...createMedicationFields('anesthesia', requiresAnalgesia) +};
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (4)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (4)
6-6
: LGTM! Treatment types expanded as requested.The addition of "Re-stitching" and "Intracerebral injection" addresses the previous feedback about including injections in the form.
Also applies to: 34-39
136-156
: LGTM! Hydration tracking appropriately scoped.The hydration fields are correctly implemented and appropriately shown only for procedures that typically require hydration monitoring.
284-294
: Consider consistent duration validation rules.The validation rules differ between treatment and surgery durations:
- Treatment duration requires integers (
z.number().min(0).int()
)- Surgery duration allows decimals (
z.number().min(0)
)Consider if this difference is intentional or if both should follow the same validation rules.
Also applies to: 434-435
412-438
: LGTM! Comprehensive validation schema.The validation schema has been properly updated to include all new fields with appropriate validation rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
122-122
: Fix typo in label: "Anethesia" should be "Anesthesia".- label: "Time until recovery from Anethesia (minutes)" + label: "Time until recovery from Anesthesia (minutes)"
456-456
: Update validation for surgery duration.Surgery duration should be an integer value since partial minutes are typically not recorded.
- surgeryDuration: z.number().min(0).optional(), + surgeryDuration: z.number().min(0).int().optional(),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (3)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (3)
129-134
: LGTM! Good extension of stereotax fields.The stereotax fields are now correctly available for all relevant treatment types.
173-182
: Surgery types have been previously reviewed and confirmed.
432-459
: LGTM! Validation schema is comprehensive.All fields are properly validated with appropriate constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
385-385
:⚠️ Potential issueFix typo in anesthesia recovery time reference.
This is a duplicate of a previous comment. The typo in "anethesiaRecoveryTime" will cause runtime issues.
- ref: "anethesiaRecoveryTime" + ref: "anesthesiaRecoveryTime"
🧹 Nitpick comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
480-481
: Ensure consistent integer validation for duration fields.
treatmentDuration
is validated as an integer butsurgeryDuration
isn't. Both should be integers for consistency.treatmentDuration: z.number().min(0).int().optional(), - surgeryDuration: z.number().min(0).optional(), + surgeryDuration: z.number().min(0).int().optional(),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.vscode/settings.json
(1 hunks)lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
✅ Files skipped from review due to trivial changes (1)
- .vscode/settings.json
🔇 Additional comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
6-6
: LGTM! Treatment types expanded as requested.The addition of "Re-stitching" and "Intracerebral injection" aligns with the feedback from issues #44 and #45.
Also applies to: 36-38
41-45
: LGTM! Analgesia fields updated for new treatment types.The analgesia fields are now correctly configured for all relevant treatment types including "Re-stitching" and "Intracerebral injection".
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
457-482
: 🛠️ Refactor suggestionStrengthen validation for anesthesia fields.
The anesthesia fields should be required when
anesthesiaUsed
is true.Apply this diff to strengthen the validation:
- anesthesiaChemicalName: z.string().optional(), - anesthesiaVolume: z.number().min(0).optional(), + anesthesiaChemicalName: z.string().optional().refine( + (val) => !data.anesthesiaUsed || (data.anesthesiaUsed && val), + "Anesthesia chemical name is required when anesthesia is used" + ), + anesthesiaVolume: z.number().min(0).optional().refine( + (val) => !data.anesthesiaUsed || (data.anesthesiaUsed && val && data.anesthesiaAdministrationType !== "Inhalation"), + "Anesthesia volume is required when anesthesia is used and not administered via inhalation" + ),
♻️ Duplicate comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
171-191
: 🛠️ Refactor suggestionStrengthen validation for hydration fields.
The hydration volume should be required when
hydrationProvided
is true.Apply this diff to strengthen the validation:
- hydrationVolume: z.number().min(0).optional(), + hydrationVolume: z.number().min(0).optional().refine( + (val) => !data.hydrationProvided || (data.hydrationProvided && val), + "Hydration volume is required when hydration is provided" + ),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
6-6
: LGTM! Treatment types have been expanded as requested.The addition of "Re-stitching" and "Intracerebral injection" addresses the previous feedback about surgery types being too restricted.
Also applies to: 36-38
319-330
: LGTM! Duration tracking fields have been added.The addition of
treatmentDuration
andsurgeryDuration
fields will help track the time spent on procedures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
171-191
: 🛠️ Refactor suggestionStrengthen validation for hydration fields.
When
hydrationProvided
is true,hydrationVolume
should be required.
41-45
: 🛠️ Refactor suggestionStrengthen validation for analgesia fields.
When
analgesiaUsed
is true,analgesiaChemicalName
andanalgesiaVolume
should be required.Apply this diff to strengthen the validation:
- analgesiaUsed: z.boolean().optional(), - analgesiaChemicalName: z.string().optional(), - analgesiaVolume: z.number().min(0).optional(), + analgesiaUsed: z.boolean().optional(), + analgesiaChemicalName: z.string().optional().refine( + (val) => !data.analgesiaUsed || (data.analgesiaUsed && val), + "Analgesia chemical name is required when analgesia is used" + ), + analgesiaVolume: z.number().min(0).optional().refine( + (val) => !data.analgesiaUsed || (data.analgesiaUsed && val), + "Analgesia volume is required when analgesia is used" + ),
🧹 Nitpick comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
457-482
: Verify validation ranges for surgery duration.The validation for
surgeryDuration
allows any non-negative number. Consider adding a reasonable maximum limit to catch potential data entry errors.Apply this diff to add a maximum limit:
- surgeryDuration: z.number().min(0).optional(), + surgeryDuration: z.number().min(0).max(480).optional(), // Max 8 hours
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
6-6
: LGTM! Treatment types have been expanded as requested.Based on the past review comments and discussion, the addition of "Re-stitching" and "Intracerebral injection" addresses the concern about restricted surgery types.
Also applies to: 36-38
319-330
: LGTM! Duration tracking fields have been added.The addition of
treatmentDuration
andsurgeryDuration
fields will help track the time spent on procedures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (3)
41-75
: 🛠️ Refactor suggestionStrengthen validation for analgesia fields.
The validation schema should enforce that when
analgesiaUsed
is true, bothanalgesiaChemicalName
andanalgesiaVolume
must be provided.Apply this diff to strengthen the validation:
- analgesiaChemicalName: z.string().optional(), - analgesiaVolume: z.number().min(0).optional(), + analgesiaChemicalName: z.string().optional().refine( + (val) => !data.analgesiaUsed || (data.analgesiaUsed && val), + "Analgesia chemical name is required when analgesia is used" + ), + analgesiaVolume: z.number().min(0).optional().refine( + (val) => !data.analgesiaUsed || (data.analgesiaUsed && val), + "Analgesia volume is required when analgesia is used" + ),
77-147
: 🛠️ Refactor suggestionStrengthen validation for anesthesia fields.
The validation schema should enforce that when
anesthesiaUsed
is true:
anesthesiaChemicalName
andanesthesiaRecoveryTime
must be providedanesthesiaVolume
must be provided for non-inhalation typesApply this diff to strengthen the validation:
- anesthesiaChemicalName: z.string().optional(), - anesthesiaVolume: z.number().min(0).optional(), - anesthesiaRecoveryTime: z.number().min(0).int().optional(), + anesthesiaChemicalName: z.string().optional().refine( + (val) => !data.anesthesiaUsed || (data.anesthesiaUsed && val), + "Anesthesia chemical name is required when anesthesia is used" + ), + anesthesiaVolume: z.number().min(0).optional().refine( + (val) => !data.anesthesiaUsed || (data.anesthesiaUsed && data.anesthesiaAdministrationType !== "Inhalation" && val), + "Anesthesia volume is required when anesthesia is used (except for inhalation)" + ), + anesthesiaRecoveryTime: z.number().min(0).int().optional().refine( + (val) => !data.anesthesiaUsed || (data.anesthesiaUsed && val), + "Recovery time is required when anesthesia is used" + ),
171-191
: 🛠️ Refactor suggestionStrengthen validation for hydration fields.
The validation schema should enforce that when
hydrationProvided
is true,hydrationVolume
must be provided.Apply this diff to strengthen the validation:
- hydrationProvided: z.boolean().optional(), - hydrationVolume: z.number().min(0).optional(), + hydrationProvided: z.boolean().optional(), + hydrationVolume: z.number().min(0).optional().refine( + (val) => !data.hydrationProvided || (data.hydrationProvided && val), + "Hydration volume is required when hydration is provided" + ),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(7 hunks)
🔇 Additional comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
6-6
: LGTM! Treatment types have been expanded as requested.The addition of "Re-stitching" and "Intracerebral injection" aligns with the feedback from issue #44 and #45, addressing the previous concern about restricted surgery types.
Also applies to: 34-39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
503-513
: 🛠️ Refactor suggestionStrengthen validation for analgesia, anesthesia, and hydration fields.
The validation schema should enforce that:
- When
analgesiaUsed
is true,analgesiaChemicalName
andanalgesiaVolume
should be required- When
anesthesiaUsed
is true,anesthesiaChemicalName
,anesthesiaAdministrationType
, andanesthesiaRecoveryTime
should be required- When
hydrationProvided
is true,hydrationVolume
should be required
🧹 Nitpick comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
344-344
: Fix typo in clinical condition label.There's a typo in "Clincal" which should be "Clinical".
- label: "Clincal condition" + label: "Clinical condition"Also applies to: 344-344
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(8 hunks)
🔇 Additional comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
6-6
: LGTM! Treatment types are properly defined and validated.The treatment types are consistently defined in both the type definition and validation schema.
Also applies to: 502-502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (2)
12-12
: Improve type safety by using a more specific type.The
data
parameter type could be more specific to better leverage TypeScript's type checking.- render: (data: { treatmentType?: TreatmentType }) => { + render: (data: Record<'treatmentType', TreatmentType | undefined>) => {
344-344
: Fix typo in label.There's a typo in "Clincal" which should be "Clinical".
- label: "Clincal condition" + label: "Clinical condition"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(9 hunks)
🔇 Additional comments (3)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (3)
42-58
: Strengthen validation for intracerebral injection fields.When treatment type is "Intracerebral injection", both fields should be required.
502-515
: Strengthen validation for dependent fields.The validation schema should enforce that:
- When
anesthesiaUsed
is true,anesthesiaType
,anesthesiaVolume
(for non-inhalation types), andanesthesiaRecoveryTime
should be required- When
hydrationProvided
is true,hydrationVolume
should be required- When treatment type is "Intracerebral injection", both
intracerebralInjectionType
andintracerebralInjectionBatchType
should be required
528-529
: Strengthen validation for treatment timing fields.The validation schema should enforce that:
treatmentStartDate
must be required for wound treatmentsurgeryDuration
must be required for surgery and intracerebral injection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (1)
8-19
: Improve type safety in createDependentField function.The function parameter type could be more specific to improve type safety.
-function createDependentField<const T>(field: T, fn: (treatmentType?: TreatmentType) => boolean) { +function createDependentField<const T>(field: T, fn: (treatmentType: TreatmentType | undefined) => boolean) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
(8 hunks)
🔇 Additional comments (5)
lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts (5)
42-58
: Strengthen validation for intracerebral injection fields.When treatment type is "Intracerebral injection", both fields should be required.
175-175
: Fix typo in anesthesia recovery time label.There's a typo in "Anesthesia" in the label.
204-224
: Strengthen validation for hydration fields.When
hydrationProvided
is true,hydrationVolume
should be required.
353-362
: Strengthen validation for treatment timing fields.The validation schema should enforce that:
treatmentStartDate
must be required for wound treatmentsurgeryDuration
must be required for surgery and intracerebral injection
530-561
: Strengthen validation schema for dependent fields.The validation schema should enforce that:
- When
analgesiaUsed
is true,analgesiaChemicalName
andanalgesiaVolume
should be required- When
anesthesiaUsed
is true,anesthesiaChemicalName
,anesthesiaVolume
(for non-inhalation types), andanesthesiaRecoveryTime
should be required- When
hydrationProvided
is true,hydrationVolume
should be required- When treatment type is "Intracerebral injection", both
intracerebralInjectionType
andintracerebralInjectionBatchType
should be requiredtreatmentStartDate
must be required for wound treatmentsurgeryDuration
must be required for surgery and intracerebral injection
Added the suggestions from issues #44 and #45
intracerebral injection questions moved from injection form to here as suggested in #43
Form can be viewed here
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Chores