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