[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) |
---|
[253] | 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() |
---|
[144] | 23 | |
---|
[146] | 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 |
---|
[253] | 28 | f.each { field -> |
---|
[146] | 29 | println field.name + "(" + field.type + ")" |
---|
| 30 | } |
---|
[144] | 31 | |
---|
[146] | 32 | //Let's get a certain field for a certain subject |
---|
[187] | 33 | /*def subject = st.subjects.get(1) |
---|
| 34 | |
---|
| 35 | if (subject) { |
---|
[146] | 36 | println st.template.getSubjectFieldType('Age') |
---|
[176] | 37 | println subject.getFieldValue('Genotype') |
---|
| 38 | subject.setFieldValue('Genotype','wildtype') |
---|
| 39 | println subject.getFieldValue('Genotype') |
---|
| 40 | subject.setFieldValue('name','hallo') |
---|
[187] | 41 | println subject.name }*/ |
---|
[186] | 42 | |
---|
| 43 | |
---|
[187] | 44 | // Demonstration of querying mechanism |
---|
[188] | 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[]) |
---|
[187] | 47 | |
---|
[146] | 48 | // Specify which variables we want to be available in the controller (implicit return statement) |
---|
[253] | 49 | [fields: f, subjects: st.subjects, studyInstance: st] |
---|
[187] | 50 | } |
---|
[144] | 51 | } |
---|