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

openmrs / openmrs-core / 8602317784

08 Apr 2024 03:00PM CUT coverage: 64.693% (+0.002%) from 64.691%
8602317784

push

github

web-flow
Restrict permissions on token for stale PR job

22763 of 35186 relevant lines covered (64.69%)

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 java.util.Date;
13

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

© 2025 Coveralls, Inc