[146] | 1 | import dbnp.studycapturing.* |
---|
[187] | 2 | import dbnp.clinicaldata.ClinicalFloatData |
---|
| 3 | import dbnp.clinicaldata.ClinicalMeasurement |
---|
[144] | 4 | |
---|
| 5 | // The sandbox is meant for internal communication over code examples etc. |
---|
| 6 | |
---|
| 7 | class SandboxController { |
---|
| 8 | |
---|
[187] | 9 | def clinicalDataLayerService |
---|
| 10 | |
---|
[146] | 11 | def index = { |
---|
[144] | 12 | |
---|
[146] | 13 | // Get the example study in a lazy way |
---|
| 14 | def st = Study.get(1) |
---|
| 15 | def f = st.template.subjectFields |
---|
[144] | 16 | |
---|
[176] | 17 | //println st.giveAllFields() |
---|
| 18 | |
---|
[146] | 19 | // This is a way to iterate over the fields in your controller |
---|
| 20 | // And print them to the console |
---|
| 21 | // Most of the time, you would just iterate over them in the view using <g:each> |
---|
| 22 | // See also views/sandbox/index.gsp |
---|
| 23 | f.each {field -> |
---|
| 24 | println field.name + "(" + field.type + ")" |
---|
| 25 | } |
---|
[144] | 26 | |
---|
[146] | 27 | //Let's get a certain field for a certain subject |
---|
[187] | 28 | /*def subject = st.subjects.get(1) |
---|
| 29 | |
---|
| 30 | if (subject) { |
---|
[146] | 31 | println st.template.getSubjectFieldType('Age') |
---|
[176] | 32 | println subject.getFieldValue('Genotype') |
---|
| 33 | subject.setFieldValue('Genotype','wildtype') |
---|
| 34 | println subject.getFieldValue('Genotype') |
---|
| 35 | subject.setFieldValue('name','hallo') |
---|
[187] | 36 | println subject.name }*/ |
---|
[186] | 37 | |
---|
| 38 | |
---|
[187] | 39 | // Demonstration of querying mechanism |
---|
| 40 | println clinicalDataLayerService.getFeaturesQuantitative(1) |
---|
| 41 | clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[]) |
---|
| 42 | |
---|
[146] | 43 | // Specify which variables we want to be available in the controller (implicit return statement) |
---|
| 44 | [fields: f, subjects: st.subjects] |
---|
[187] | 45 | } |
---|
[144] | 46 | } |
---|