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 fieldsAll = st.giveSubjectTemplates().fields |
---|
16 | def f = fieldsAll[0] |
---|
17 | println fieldsAll.class |
---|
18 | println f.class |
---|
19 | f.each { |
---|
20 | println "" + it + "-" + it.class |
---|
21 | } |
---|
22 | //println st.giveAllFields() |
---|
23 | |
---|
24 | // This is a way to iterate over the fields in your controller |
---|
25 | // And print them to the console |
---|
26 | // Most of the time, you would just iterate over them in the view using <g:each> |
---|
27 | // See also views/sandbox/index.gsp |
---|
28 | f.each { field -> |
---|
29 | println field.name + "(" + field.type + ")" |
---|
30 | } |
---|
31 | |
---|
32 | //Let's get a certain field for a certain subject |
---|
33 | /*def subject = st.subjects.get(1) |
---|
34 | |
---|
35 | if (subject) { |
---|
36 | println st.template.getSubjectFieldType('Age') |
---|
37 | println subject.getFieldValue('Genotype') |
---|
38 | subject.setFieldValue('Genotype','wildtype') |
---|
39 | println subject.getFieldValue('Genotype') |
---|
40 | subject.setFieldValue('name','hallo') |
---|
41 | println subject.name }*/ |
---|
42 | |
---|
43 | |
---|
44 | // Demonstration of querying mechanism |
---|
45 | println "Features available for first assay of PPSH study: " + clinicalDataLayerService.getFeaturesQuantitative(Study.findByCode("PPSH").assays*.id[0]) |
---|
46 | println "LDL feature value for two subjects: " + clinicalDataLayerService.getDataQuantitative('LDL',1,['A1_B','A3_B'] as String[]) |
---|
47 | |
---|
48 | // Specify which variables we want to be available in the controller (implicit return statement) |
---|
49 | [fields: f, subjects: st.subjects, studyInstance: st] |
---|
50 | } |
---|
51 | } |
---|