1 | import dbnp.studycapturing.* |
---|
2 | import dbnp.clinicaldata.ClinicalFloatData |
---|
3 | import dbnp.clinicaldata.ClinicalMeasurement |
---|
4 | |
---|
5 | // The sandbox is meant for internal communication over code examples etc. |
---|
6 | |
---|
7 | class 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 | } |
---|