33import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core'
44import { z } from '/runtime/v1/zod@3.23.x'
55
6- type TerminationType = 'Gas induction' | "Perfusion" | "Guillotine" | 'Cardiac puncture' | 'Cervical dislocation'
6+ type TerminationType = 'Gas induction' | "Perfusion" | "Guillotine" | 'Cardiac puncture' | 'Cervical dislocation' | 'Gas induction + Cervical dislocation'
77
88function createDependentField < const T > ( field : T , fn : ( terminationType ?: TerminationType ) => boolean ) {
99 return {
@@ -57,7 +57,7 @@ export default defineInstrument({
5757 kind : 'dynamic' ,
5858 deps : [ 'terminationReason' ] ,
5959 render ( data ) {
60- if ( data . terminationReason === "Surgical complications" || data . terminationReason === undefined ) {
60+ if ( data . terminationReason === "Surgical complications" || data . terminationReason === undefined || data . terminationReason === 'Veterinary Endpoint' ) {
6161 return null
6262 }
6363 return {
@@ -69,7 +69,8 @@ export default defineInstrument({
6969 "Perfusion" : 'Perfusion' ,
7070 "Guillotine" : 'Guillotine' ,
7171 'Cardiac puncture' : 'Cardiac puncture' ,
72- 'Cervical dislocation' : 'Cervical dislocation'
72+ 'Cervical dislocation' : 'Cervical dislocation' ,
73+ 'Gas induction + Cervical dislocation' : 'Gas induction + Cervical dislocation'
7374 }
7475 }
7576 }
@@ -138,9 +139,41 @@ export default defineInstrument({
138139 } , ( type ) => type === 'Perfusion' ) ,
139140
140141 anesthesiaUsed : {
141- kind : 'boolean' ,
142- variant : 'radio' ,
143- label : 'Anesthesia used'
142+ kind : 'dynamic' ,
143+ deps : [ 'terminationReason' ] ,
144+ render ( data ) {
145+ if ( data . terminationReason !== 'Veterinary Endpoint' && data . terminationReason !== undefined ) {
146+ return {
147+ kind : 'boolean' ,
148+ variant : 'radio' ,
149+ label : 'Anesthesia used'
150+ }
151+ }
152+ return null
153+ }
154+ } ,
155+ gasUsed : createDependentField ( {
156+ kind : "string" ,
157+ variant : "select" ,
158+ label : "Gas used for induction" ,
159+ options : {
160+ "CO2" : "CO2" ,
161+ "Other" : "Other"
162+ }
163+ } , ( type ) => type === 'Gas induction' || type === 'Gas induction + Cervical dislocation' ) ,
164+ otherGasUsed : {
165+ kind : "dynamic" ,
166+ deps : [ "gasUsed" ] ,
167+ render ( data ) {
168+ if ( data . gasUsed === 'Other' ) {
169+ return {
170+ kind : "string" ,
171+ variant : "input" ,
172+ label : "Other gas used"
173+ }
174+ }
175+ return null
176+ }
144177 } ,
145178 bodyExtractionDone : {
146179 kind : 'boolean' ,
@@ -333,6 +366,18 @@ export default defineInstrument({
333366 visibility : "visible" ,
334367 ref : "anesthesiaUsed"
335368 } ,
369+ gasUsed : {
370+ kind : "const" ,
371+ label : "Gas used" ,
372+ visibility : "visible" ,
373+ ref : "gasUsed"
374+ } ,
375+ otherGasUsed : {
376+ kind : "const" ,
377+ label : "Other gas used" ,
378+ visibility : "visible" ,
379+ ref : "otherGasUsed"
380+ } ,
336381 bodyExtractionDone : {
337382 kind : "const" ,
338383 label : "Body part extracted" ,
@@ -377,7 +422,8 @@ export default defineInstrument({
377422 'Perfusion' ,
378423 'Guillotine' ,
379424 'Cardiac puncture' ,
380- 'Cervical dislocation'
425+ 'Cervical dislocation' ,
426+ 'Gas induction + Cervical dislocation'
381427 ] ) . optional ( ) ,
382428 surgeryDeathCause : z . enum ( [
383429 'Irregular breathing' ,
@@ -396,7 +442,9 @@ export default defineInstrument({
396442 'PBS+Heparin' ,
397443 '4% Isoflurane'
398444 ] ) . optional ( ) ,
399- anesthesiaUsed : z . boolean ( ) ,
445+ anesthesiaUsed : z . boolean ( ) . optional ( ) ,
446+ gasUsed : z . enum ( [ "CO2" , "Other" ] ) . optional ( ) ,
447+ otherGasUsed : z . string ( ) . optional ( ) ,
400448 bodyExtractionDone : z . boolean ( ) ,
401449 bodyExtractionInfo : z
402450 . array (
0 commit comments