• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 19233807477

10 Nov 2025 01:48PM UTC coverage: 64.874% (-0.02%) from 64.894%
19233807477

push

github

web-flow
Use the latest supported JDK17 for default docker images in 2.7.x (#5407)

23432 of 36119 relevant lines covered (64.87%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.09
/api/src/main/java/org/openmrs/ConceptAnswer.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs;
11

12
import org.hibernate.envers.Audited;
13

14
import java.util.Date;
15

16
/**
17
 * This class represents one option for an answer to a question type of {@link Concept}. The link to
18
 * the parent question Concept is stored in {@link #getConcept()} and the answer this object is
19
 * representing is stored in {@link #getAnswerConcept()}.
20
 *
21
 * @see Concept#getAnswers()
22
 */
23
@Audited
24
public class ConceptAnswer extends BaseOpenmrsObject implements Auditable, java.io.Serializable, Comparable<ConceptAnswer> {
25
        
26
        public static final long serialVersionUID = 3744L;
27
        
28
        // Fields
29
        private Integer conceptAnswerId;
30
        
31
        /**
32
         * The question concept that this object is answering
33
         */
34
        private Concept concept;
35
        
36
        /**
37
         * The answer to the question
38
         */
39
        private Concept answerConcept;
40
        
41
        /**
42
         * The {@link Drug} answer to the question. This can be null if this does not represent a drug
43
         * type of answer
44
         */
45
        private Drug answerDrug;
46
        
47
        private User creator;
48
        
49
        private Date dateCreated;
50
        
51
        private Double sortWeight;
52
        
53
        // Constructors
54
        
55
        /** default constructor */
56
        public ConceptAnswer() {
1✔
57
        }
1✔
58
        
59
        /** constructor with id */
60
        public ConceptAnswer(Integer conceptAnswerId) {
1✔
61
                this.conceptAnswerId = conceptAnswerId;
1✔
62
        }
1✔
63
        
64
        public ConceptAnswer(Concept answerConcept) {
1✔
65
                this.answerConcept = answerConcept;
1✔
66
        }
1✔
67
        
68
        public ConceptAnswer(Concept answerConcept, Drug d) {
×
69
                this.answerConcept = answerConcept;
×
70
                this.answerDrug = d;
×
71
        }
×
72
        
73
        /**
74
         * @return Returns the answerConcept.
75
         */
76
        public Concept getAnswerConcept() {
77
                return answerConcept;
1✔
78
        }
79
        
80
        /**
81
         * @param answerConcept The answerConcept to set.
82
         */
83
        public void setAnswerConcept(Concept answerConcept) {
84
                this.answerConcept = answerConcept;
1✔
85
        }
1✔
86
        
87
        /**
88
         * @return Returns the answerDrug.
89
         */
90
        public Drug getAnswerDrug() {
91
                return answerDrug;
1✔
92
        }
93
        
94
        /**
95
         * @param answerDrug The answerDrug to set.
96
         */
97
        public void setAnswerDrug(Drug answerDrug) {
98
                this.answerDrug = answerDrug;
1✔
99
        }
1✔
100
        
101
        /**
102
         * @return Returns the concept.
103
         */
104
        public Concept getConcept() {
105
                return concept;
1✔
106
        }
107
        
108
        /**
109
         * @param concept The concept to set.
110
         */
111
        public void setConcept(Concept concept) {
112
                this.concept = concept;
1✔
113
        }
1✔
114
        
115
        /**
116
         * @return Returns the conceptAnswerId.
117
         */
118
        public Integer getConceptAnswerId() {
119
                return conceptAnswerId;
1✔
120
        }
121
        
122
        /**
123
         * @param conceptAnswerId The conceptAnswerId to set.
124
         */
125
        public void setConceptAnswerId(Integer conceptAnswerId) {
126
                this.conceptAnswerId = conceptAnswerId;
1✔
127
        }
1✔
128
        
129
        /**
130
         * @return Returns the creator.
131
         */
132
        @Override
133
        public User getCreator() {
134
                return creator;
1✔
135
        }
136
        
137
        /**
138
         * @param creator The creator to set.
139
         */
140
        @Override
141
        public void setCreator(User creator) {
142
                this.creator = creator;
1✔
143
        }
1✔
144
        
145
        /**
146
         * @return Returns the dateCreated.
147
         */
148
        @Override
149
        public Date getDateCreated() {
150
                return dateCreated;
1✔
151
        }
152
        
153
        /**
154
         * @param dateCreated The dateCreated to set.
155
         */
156
        @Override
157
        public void setDateCreated(Date dateCreated) {
158
                this.dateCreated = dateCreated;
1✔
159
        }
1✔
160
        
161
        /**
162
         * @since 1.5
163
         * @see org.openmrs.OpenmrsObject#getId()
164
         */
165
        @Override
166
        public Integer getId() {
167
                return getConceptAnswerId();
1✔
168
        }
169
        
170
        /**
171
         * @since 1.5
172
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
173
         */
174
        @Override
175
        public void setId(Integer id) {
176
                setConceptAnswerId(id);
×
177
        }
×
178
        
179
        /**
180
         * Not currently used. Always returns null.
181
         *
182
         * @see org.openmrs.Auditable#getChangedBy()
183
         */
184
        @Override
185
        public User getChangedBy() {
186
                return null;
×
187
        }
188
        
189
        /**
190
         * Not currently used. Always returns null.
191
         *
192
         * @see org.openmrs.Auditable#getDateChanged()
193
         */
194
        @Override
195
        public Date getDateChanged() {
196
                return null;
×
197
        }
198
        
199
        /**
200
         * Not currently used.
201
         *
202
         * @see org.openmrs.Auditable#setChangedBy(org.openmrs.User)
203
         */
204
        @Override
205
        public void setChangedBy(User changedBy) {
206
        }
×
207
        
208
        /**
209
         * Not currently used.
210
         *
211
         * @see org.openmrs.Auditable#setDateChanged(java.util.Date)
212
         */
213
        @Override
214
        public void setDateChanged(Date dateChanged) {
215
        }
×
216
        
217
        /**
218
         * @return Returns the sortWeight.
219
         */
220
        public Double getSortWeight() {
221
                return sortWeight;
1✔
222
        }
223
        
224
        /**
225
         * @param sortWeight The sortWeight to set.
226
         */
227
        public void setSortWeight(Double sortWeight) {
228
                this.sortWeight = sortWeight;
1✔
229
        }
1✔
230
        
231
        /**
232
         * @see java.lang.Comparable#compareTo(java.lang.Object)
233
         * Note: this comparator imposes orderings that are inconsistent with equals.
234
         */
235
        @Override
236
        @SuppressWarnings("squid:S1210")
237
        public int compareTo(ConceptAnswer ca) {
238
                if ((getSortWeight() == null) && (ca.getSortWeight() != null)) {
1✔
239
                        return -1;
1✔
240
                }
241
                if ((getSortWeight() != null) && (ca.getSortWeight() == null)) {
×
242
                        return 1;
×
243
                }
244
                if ((getSortWeight() == null) && (ca.getSortWeight() == null)) {
×
245
                        return 0;
×
246
                }
247
                return (getSortWeight() < ca.getSortWeight()) ? -1 : (getSortWeight() > ca.getSortWeight()) ? 1 : 0;
×
248
        }
249
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc