source: trunk/grails-app/controllers/SandboxController.groovy @ 247

Last change on this file since 247 was 247, checked in by duh, 13 years ago
  • set keyword expansion
  • Property svn:keywords set to Author Rev Date
File size: 1.5 KB
Line 
1import dbnp.studycapturing.*
2import dbnp.clinicaldata.ClinicalFloatData
3import dbnp.clinicaldata.ClinicalMeasurement
4
5// The sandbox is meant for internal communication over code examples etc.
6
7class SandboxController {
8
9        def clinicalDataLayerService
10
11        def index = {
12
13                // Get the example study in a lazy way
14                def st = Study.get(1)
15                def f = st.template.subjectFields
16
17                //println st.giveAllFields()
18
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                }
26
27                //Let's get a certain field for a certain subject
28                /*def subject = st.subjects.get(1)
29
30                if (subject) {
31                println st.template.getSubjectFieldType('Age')
32                println subject.getFieldValue('Genotype')
33                subject.setFieldValue('Genotype','wildtype')
34                println subject.getFieldValue('Genotype')
35                subject.setFieldValue('name','hallo')
36                println subject.name }*/
37
38
39                // Demonstration of querying mechanism
40                println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0])
41                println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[])
42
43                // Specify which variables we want to be available in the controller (implicit return statement)
44                [fields: f, subjects: st.subjects]
45        }
46}
Note: See TracBrowser for help on using the repository browser.