Skip to content

Commit 3349485

Browse files
authored
Merge pull request CoBrALab#106 from david-roper/improve-physical-form
Removing genotyping, adding anesthesia to ear tagging Added new ear tagging systems to ear tag questions fix typos
2 parents 9bff620 + 66b5172 commit 3349485

File tree

1 file changed

+199
-67
lines changed
  • public/forms/CoBrALab-Physical-Intervention-Form

1 file changed

+199
-67
lines changed

public/forms/CoBrALab-Physical-Intervention-Form/index.ts

Lines changed: 199 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-disable perfectionist/sort-objects */
22

3-
import { z }from '/runtime/v1/zod@3.23.x/index.js';
4-
import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core';
3+
const { defineInstrument } = await import('/runtime/v1/@opendatacapture/runtime-core/index.js');
4+
const { z } = await import('/runtime/v1/zod@3.23.x/index.js');
55

66
const interventionTypeList = [ "Blood extraction",
77
"Teeth extraction",
88
"Ear tagging",
99
"Tattooing",
1010
"Vaginal cytology",
11-
"Genotyping",
11+
"Fecal matter collection",
1212
"Blood glucose",
1313
"Anesthesia"] as const
1414

@@ -30,9 +30,9 @@ function createDependentField<const T>(field: T, fn: (interventionType?: Interve
3030
export default defineInstrument({
3131
kind: 'FORM',
3232
language: 'en',
33-
tags: ['Physical intervention','Blood extraction', 'Ear tagging', 'Genotyping', 'Vaginal cytology','Blood glucose','anesthesia'],
33+
tags: ['Physical intervention','Blood extraction', 'Ear tagging', 'Genotyping', 'Vaginal cytology','Blood glucose','anesthesia', 'Fecal matter collection'],
3434
internal: {
35-
edition: 3,
35+
edition: 4,
3636
name: 'PHYSICAL_INTERVENTION_FORM'
3737
},
3838
content: {
@@ -46,16 +46,11 @@ export default defineInstrument({
4646
"Ear tagging": "Ear tagging",
4747
"Tattooing": "Tattooing",
4848
"Vaginal cytology": "Vaginal cytology",
49-
"Genotyping": "Genotyping",
49+
"Fecal matter collection": "Fecal matter collection",
5050
"Blood glucose": "Blood glucose",
5151
"Anesthesia": "Anesthesia"
5252
}
5353
},
54-
nameOfVaginalSwabber: createDependentField({
55-
kind: "string",
56-
variant: 'input',
57-
label: "Person swabbing"
58-
}, (type) => type === 'Vaginal cytology'),
5954

6055
vaginalSwabNumber: createDependentField({
6156
kind: 'number',
@@ -75,48 +70,152 @@ export default defineInstrument({
7570
label: "Cytology solution volume (ml)"
7671
}, (type) => type === 'Vaginal cytology'),
7772

78-
genotypeBodyPartUsed: createDependentField({
79-
kind: "string",
80-
variant: "select",
81-
label: "Part of animal used for genotyping",
82-
options: {
83-
"Tail":"Tail",
84-
"Ear":"Ear",
85-
"Fecal matter": "Fecal matter"
86-
}
87-
}, (type) => type === "Genotyping"),
88-
genotypeCompanyUsed: createDependentField({
89-
kind: "string",
90-
variant: "select",
91-
label: "Company used",
92-
options: {
93-
"Transnetyx": "Transnetyx",
94-
"Other": "Other"
73+
wasGenotypingDone: createDependentField({
74+
kind: "boolean",
75+
variant: "radio",
76+
label: "Was genotyping done?"
77+
},
78+
(type) => (type === 'Fecal matter collection' || type === 'Ear tagging')),
79+
80+
genotypeCompanyUsed: {
81+
kind: "dynamic",
82+
deps: ["wasGenotypingDone"],
83+
render(data) {
84+
if(data.wasGenotypingDone){
85+
return {
86+
kind: "string",
87+
variant: "select",
88+
label: "Company used",
89+
options: {
90+
"Transnetyx": "Transnetyx",
91+
"Other": "Other"
92+
}
93+
}
94+
9595
}
96-
}, (type) => type === "Genotyping"),
97-
genotypeCopy: createDependentField({
98-
kind: "string",
99-
variant: "select",
100-
label: "Genotype copy (if available)",
101-
options: {
102-
"Homozygous": "Homozygous",
103-
"Heterozygous": "Heterozygous",
104-
"Null": "Null",
105-
"Other": "Other"
96+
return null
97+
}
98+
},
99+
genotypeCopy: {
100+
kind: "dynamic",
101+
deps: ["wasGenotypingDone"],
102+
render(data) {
103+
if(data.wasGenotypingDone){
104+
return {
105+
kind: "string",
106+
variant: "select",
107+
label: "Genotype copy (if available)",
108+
options: {
109+
"Homozygous": "Homozygous",
110+
"Heterozygous": "Heterozygous",
111+
"Null": "Null",
112+
"Other": "Other"
113+
}
114+
115+
}
116+
117+
}
118+
return null
106119
}
120+
107121
},
108-
(type) => type === "Genotyping"),
109122
earTaggingSystem: createDependentField({
110123
kind: "string",
111124
variant: "select",
112125
label: "Ear tagging system",
113126
options: {
127+
'1-64':'1-64',
128+
'L-R-LL-LR-RR':'L-R-LL-LR-RR',
114129
"1-99 System": "1-99 System",
115130
"1-32 System": "1-32 System",
116131
"Other": "Other"
117132
}
118133
},
119134
(type) => type === "Ear tagging"),
135+
anesthesiaUsed: createDependentField({
136+
kind: 'boolean',
137+
variant: 'radio',
138+
label: "Anesthesia used"
139+
},
140+
(type) => type === "Ear tagging"),
141+
142+
anesthesiaType: {
143+
kind: 'dynamic',
144+
deps: ['anesthesiaUsed','interventionType'],
145+
render(data) {
146+
if(data.anesthesiaUsed || data.interventionType === 'Anesthesia') {
147+
return {
148+
kind: "string",
149+
variant: "select",
150+
label: 'Anesthesia type',
151+
options: {
152+
"Isoflurane": "Isoflurane",
153+
"Other": "Other"
154+
}
155+
156+
}
157+
}
158+
return null
159+
}
160+
},
161+
otherAnesthesiaType: {
162+
kind: 'dynamic',
163+
deps: ['anesthesiaUsed', 'anesthesiaType', 'interventionType'],
164+
render(data) {
165+
if(((data.interventionType === 'Anesthesia' || data.anesthesiaUsed) && data.anesthesiaType === "Other")) {
166+
return {
167+
kind: "string",
168+
variant: "input",
169+
label: "Specify anesthesia type"
170+
}
171+
}
172+
return null
173+
}
174+
},
175+
anesthesiaDose: {
176+
kind: 'dynamic',
177+
deps: ['anesthesiaUsed', 'anesthesiaType', 'interventionType'],
178+
render(data) {
179+
if(((data.interventionType === 'Anesthesia' || data.anesthesiaUsed) && data.anesthesiaType === "Other")) {
180+
return {
181+
kind: "number",
182+
variant: "input",
183+
label: "Dose amount (μl)",
184+
}
185+
}
186+
return null
187+
}
188+
},
189+
isofluranePercentage: {
190+
kind: 'dynamic',
191+
deps: ['anesthesiaUsed', 'anesthesiaType', 'interventionType'],
192+
render(data) {
193+
if((data.interventionType === 'Anesthesia' || data.anesthesiaUsed) && data.anesthesiaType === 'Isoflurane') {
194+
return {
195+
kind: "number",
196+
variant: "input",
197+
label: "Isoflurane percentage"
198+
}
199+
}
200+
return null
201+
}
202+
203+
},
204+
anesthesiaInductionTime: {
205+
kind: 'dynamic',
206+
deps: ['anesthesiaUsed', 'anesthesiaType', 'interventionType'],
207+
render(data) {
208+
if((data.interventionType === 'Anesthesia' || data.anesthesiaUsed) && data.anesthesiaType === 'Isoflurane') {
209+
return {
210+
kind: "number",
211+
variant: "input",
212+
label: "Isoflurane induction time (minutes)"
213+
}
214+
}
215+
return null
216+
}
217+
},
218+
120219
tattooLocationInfo: createDependentField({
121220
kind: "record-array",
122221
label: "Tattooing information",
@@ -167,11 +266,6 @@ export default defineInstrument({
167266
visibility: "visible",
168267
ref: "interventionType"
169268
},
170-
nameOfVaginalSwabber: {
171-
kind: "const",
172-
visibility: "visible",
173-
ref: "nameOfVaginalSwabber"
174-
},
175269
vaginalSwabNumber: {
176270
kind: "const",
177271
visibility: "visible",
@@ -187,26 +281,61 @@ export default defineInstrument({
187281
visibility: "visible",
188282
ref: "vaginalCytologySolutionVolume"
189283
},
190-
genotypeBodyPartUsed: {
191-
kind: "const",
192-
visibility: "visible",
193-
ref: "genotypeBodyPartUsed"
194-
},
195-
genotypeCompanyUsed: {
196-
kind: "const",
197-
visibility: "visible",
198-
ref: "genotypeCompanyUsed"
199-
},
200-
genotypeCopy: {
201-
kind: "const",
202-
visibility: "visible",
203-
ref: "genotypeCopy"
204-
},
284+
wasGenotypingDone: {
285+
kind: "const",
286+
visibility: "visible",
287+
ref: "wasGenotypingDone"
288+
},
289+
290+
genotypeCompanyUsed: {
291+
kind: "const",
292+
visibility: "visible",
293+
ref: "genotypeCompanyUsed"
294+
},
295+
296+
genotypeCopy: {
297+
kind: "const",
298+
visibility: "visible",
299+
ref: "genotypeCopy"
300+
},
205301
earTaggingSystem: {
206302
kind: "const",
207303
visibility: "visible",
208304
ref: "earTaggingSystem"
209305
},
306+
anesthesiaUsed: {
307+
kind: "const",
308+
visibility: "visible",
309+
ref: "anesthesiaUsed"
310+
},
311+
312+
anesthesiaType: {
313+
kind: "const",
314+
visibility: "visible",
315+
ref: "anesthesiaType"
316+
},
317+
318+
otherAnesthesiaType: {
319+
kind: "const",
320+
visibility: "visible",
321+
ref: "otherAnesthesiaType"
322+
},
323+
324+
anesthesiaDose: {
325+
kind: "const",
326+
visibility: "visible",
327+
ref: "anesthesiaDose"
328+
},
329+
isofluranePercentage: {
330+
kind: 'const',
331+
visibility: 'visible',
332+
ref: 'isofluranePercentage'
333+
},
334+
anesthesiaInductionTime: {
335+
kind: "const",
336+
visibility: "visible",
337+
ref: "anesthesiaInductionTime"
338+
},
210339
tattooLocationInfo: {
211340
kind: "computed",
212341
label: "Tattoo Locations",
@@ -242,19 +371,14 @@ export default defineInstrument({
242371
"Ear tagging",
243372
"Tattooing",
244373
"Vaginal cytology",
245-
"Genotyping",
374+
"Fecal matter collection",
246375
"Blood glucose",
247376
"Anesthesia"
248377
]),
249-
nameOfVaginalSwabber: z.string().optional(),
250378
vaginalSwabNumber: z.number().min(1).int().optional(),
251379
vaginalCytologyDuration: z.number().min(1).optional(),
252380
vaginalCytologySolutionVolume: z.number().min(0).optional(),
253-
genotypeBodyPartUsed: z.enum([
254-
"Tail",
255-
"Ear",
256-
"Fecal matter"
257-
]).optional(),
381+
wasGenotypingDone: z.boolean().optional(),
258382
genotypeCompanyUsed: z.enum([
259383
"Transnetyx",
260384
"Other"
@@ -266,10 +390,18 @@ export default defineInstrument({
266390
"Other"
267391
]).optional(),
268392
earTaggingSystem: z.enum([
393+
'1-64',
394+
'L-R-LL-LR-RR',
269395
"1-99 System",
270396
"1-32 System",
271397
"Other"
272398
]).optional(),
399+
anesthesiaUsed: z.boolean().optional(),
400+
anesthesiaType: z.enum(["Isoflurane", "Other"]).optional(),
401+
otherAnesthesiaType: z.string().optional(),
402+
anesthesiaDose: z.number().min(0).optional(),
403+
isofluranePercentage: z.number().min(0).max(100).optional(),
404+
anesthesiaInductionTime: z.number().int().min(0).optional(),
273405
tattooLocationInfo: z.array(z.object({
274406
tattooLocation: z.enum([
275407
"Upper left",
@@ -282,4 +414,4 @@ export default defineInstrument({
282414
bloodGlucoseLevel: z.string().optional(),
283415
additionalComments: z.string().optional()
284416
})
285-
});
417+
});

0 commit comments

Comments
 (0)