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

Wound treatment and surgery form edit #58

Merged
merged 24 commits into from
Feb 21, 2025
Merged
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8cfdbaf
add re-stitching option and treatment duration
david-roper Feb 12, 2025
f3b3613
fix analgesia typo
david-roper Feb 12, 2025
3df323f
add intracerebral injection to surgery option
david-roper Feb 12, 2025
252a804
anesthesia, recovery days, surgery duration added to form
david-roper Feb 12, 2025
e9df408
add hydration provided and volume to form
david-roper Feb 12, 2025
7e63148
add hydration provided field to surgery section
david-roper Feb 12, 2025
f6b03c7
fix typos
david-roper Feb 13, 2025
73d730b
remove days until recovery question
david-roper Feb 13, 2025
713bc51
add anesthesia recovery time
david-roper Feb 14, 2025
cb1df93
add anesthesia adminitration type
david-roper Feb 14, 2025
a0acc30
change analgesia and anesthesia type to chemical name
david-roper Feb 14, 2025
6b42851
Update lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
david-roper Feb 14, 2025
95c4ea7
Update lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
david-roper Feb 17, 2025
935f20b
recovery time now number
david-roper Feb 17, 2025
a809eee
add treatment start and end date
david-roper Feb 17, 2025
66003bc
remove treatment end date questions
david-roper Feb 18, 2025
305e808
add anesthesia duration if inhalation type chosen
david-roper Feb 18, 2025
61b9f11
add intracerebral injection type and batch type
david-roper Feb 19, 2025
183f653
reordered intracerebral injection questions
david-roper Feb 19, 2025
b64bf91
add intracerebral injection to tags
david-roper Feb 19, 2025
a42fac2
fix createDependentField typing
david-roper Feb 19, 2025
05f3f0d
remove redundant any typing
david-roper Feb 20, 2025
3eb8913
fix clinical condition typo
david-roper Feb 20, 2025
fedb694
make all measures visible
david-roper Feb 20, 2025
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
170 changes: 145 additions & 25 deletions lib/forms/CoBrALab-Mouse-Surgery-Form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core'
import { z } from '/runtime/v1/zod@3.23.x'

type TreatmentType = "Surgery" | "Wound treatment"
type TreatmentType = "Surgery" | "Wound treatment" | "Re-stitching" | "Intracerebral injection"

function createDependentField<const T>(field: T, fn: (treatmentType: TreatmentType) => boolean) {
return {
Expand Down Expand Up @@ -33,49 +33,89 @@ export default defineInstrument({
label: "Select physical intervention",
options: {
"Surgery": "Surgery",
"Wound treatment": "Wound treatment"
"Wound treatment": "Wound treatment",
"Re-stitching": "Re-stitching",
"Intracerebral injection": "Intracerebral injection"
}
},
analglesiaUsed: createDependentField({
analgesiaUsed: createDependentField({
kind: "boolean",
variant: "radio",
label: "Analglesia used"
}, (type) => type === "Surgery"),
label: "Analgesia used"
}, (type) => type === "Surgery" || type === "Re-stitching" || type === "Intracerebral injection"),

analglesiaType: {
analgesiaType: {
kind: "dynamic",
deps: ["analglesiaUsed"],
deps: ["analgesiaUsed"],
render(data) {
if(data.analglesiaUsed){
if(data.analgesiaUsed){
return {
kind: "string",
variant: "input",
label: "Analglesia type"
label: "Analgesia type"
}
}
return null
}
},
analglesiaVolume: {
analgesiaVolume: {
kind: "dynamic",
deps: ["analglesiaUsed"],
deps: ["analgesiaUsed"],
render(data) {
if(data.analglesiaUsed){
if(data.analgesiaUsed){
return {
kind: "number",
variant: "input",
label: "Analglesia volume (ml)"
label: "Analgesia volume (ml)"
}
}
return null
}

},

anesthesiaUsed: createDependentField({
kind: "boolean",
variant: "radio",
label: "Anesthesia used"
}, (type) => type === "Surgery" || type === "Re-stitching" || type === "Intracerebral injection"),

anesthesiaVolume: {
kind: "dynamic",
deps: ["anesthesiaUsed"],
render(data) {
if(data.anesthesiaUsed){
return {
kind: "number",
variant: "input",
label: "Anesthesia volume (ml)"
}
}
return null
}

},

anesthesiaType: {
kind: "dynamic",
deps: ["anesthesiaUsed"],
render(data) {
if(data.anesthesiaUsed){
return {
kind: "string",
variant: "input",
label: "Anesthesia type"
}
}
return null
}
},

stereotaxUsed: createDependentField({
kind: "boolean",
variant: "radio",
label: "Stereotax used"
},(type) => type === "Surgery"),
},(type) => type === "Surgery" || type === "Re-stitching" || type === "Intracerebral injection"),

stereotaxId:{
kind: "dynamic",
Expand All @@ -93,6 +133,28 @@ export default defineInstrument({

},

hydrationProvided: createDependentField({
kind: "boolean",
variant: "radio",
label: "Was hydration provided"
}, (type) => type === "Surgery" || type === "Intracerebral injection"),

hydrationVolume: {
kind: "dynamic",
deps: ["hydrationProvided"],
render(data) {
if(data.hydrationProvided){
return {
kind: "number",
variant: "input",
label: "Hydration solution volume (ml)"
}
}
return null
}

},

surgeryType: createDependentField({
kind: "string",
variant: "select",
Expand Down Expand Up @@ -219,6 +281,24 @@ export default defineInstrument({
label: "Treatment provided"
}, (type) => type === "Wound treatment"),

treatmentDuration: createDependentField({
kind: "number",
variant: "input",
label: "Treatment duration (days)"
}, (type) => type === "Wound treatment" || type === "Re-stitching"),

surgeryDuration: createDependentField({
kind: "number",
variant: "input",
label: "Surgery duration (minutes)"
}, (type) => type === "Surgery" || type === "Intracerebral injection"),

daysUntilRecovery: createDependentField({
kind: "number",
variant: "input",
label: "Expected number of days until recovery"
}, (type) => type === "Surgery" || type === "Intracerebral injection"),

additionalComments: {
kind: "string",
variant: "textarea",
Expand All @@ -242,17 +322,37 @@ export default defineInstrument({
label: "Selected physical intervention",
ref: "treatmentType"
},
analglesiaUsed: {
analgesiaUsed: {
kind: "const",
ref: "analgesiaUsed"
},
analgesiaType: {
kind: "const",
ref: "analglesiaUsed"
ref: "analgesiaType"
},
analglesiaType: {
analgesiaVolume: {
kind: "const",
ref: "analglesiaType"
ref: "analgesiaVolume"
},
analglesiaVolume: {
anesthesiaUsed: {
kind: "const",
ref: "analglesiaVolume"
ref: "anesthesiaUsed"
},
anesthesiaType: {
kind: "const",
ref: "anesthesiaType"
},
anesthesiaVolume: {
kind: "const",
ref: "anesthesiaVolume"
},
hydrationProvided: {
kind: "const",
ref: "hydrationProvided"
},
hydrationVolume: {
kind: "const",
ref: "hydrationVolume"
},
stereotaxUsed: {
kind: "const",
Expand Down Expand Up @@ -302,16 +402,33 @@ export default defineInstrument({
kind: "const",
ref: "treatmentProvided"
},
treatmentDuration: {
kind: "const",
ref:"treatmentDuration"
},
surgeryDuration: {
kind: "const",
ref:"surgeryDuration"
},
daysUntilRecovery:{
kind: "const",
ref: "daysUntilRecovery"
},
additionalComments: {
kind: "const",
ref: "additionalComments"
}
},
validationSchema: z.object({
treatmentType: z.enum(["Surgery", "Wound treatment"]),
analglesiaUsed: z.boolean().optional(),
analglesiaType: z.string().optional(),
analglesiaVolume: z.number().min(0).optional(),
treatmentType: z.enum(["Surgery", "Wound treatment","Re-stitching", "Intracerebral injection"]),
analgesiaUsed: z.boolean().optional(),
analgesiaType: z.string().optional(),
analgesiaVolume: z.number().min(0).optional(),
anesthesiaUsed: z.boolean().optional(),
anesthesiaType: z.string().optional(),
anesthesiaVolume: z.number().min(0).optional(),
hydrationProvided: z.boolean().optional(),
hydrationVolume: z.number().min(0).optional(),
stereotaxUsed: z.boolean().optional(),
stereotaxId: z.string().optional(),
surgeryType: z.enum(["Ovariectomy", "Electrode implant", "Fiber optic implant"]).optional(),
Expand All @@ -324,7 +441,10 @@ export default defineInstrument({
woundDateReported: z.date().optional(),
clinicalCondition: z.string().optional(),
treatmentProvided: z.string().optional(),
additionalComments: z.string().optional()
treatmentDuration: z.number().min(0).int().optional(),
surgeryDuration: z.number().min(0).optional(),
daysUntilRecovery: z.number().min(0).int().optional(),
additionalComments: z.string().optional(),

})
});