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

openmrs / openmrs-core / 41717837886

03 Nov 2026 08:59PM UTC coverage: 68.971% (+0.05%) from 68.922%
41717837886

push

github

ibacher
TRUNK-6863: Remove the generation token before clearing a node's cache locally (#6791)

1 of 1 new or added line in 1 file covered. (100.0%)

413 existing lines in 30 files now uncovered.

26445 of 38342 relevant lines covered (68.97%)

0.69 hits per line

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

73.68
/api/src/main/java/org/openmrs/Drug.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.Collection;
13
import java.util.LinkedHashSet;
14
import java.util.Locale;
15
import java.util.Set;
16

17
import org.apache.commons.lang3.StringUtils;
18
import org.codehaus.jackson.annotate.JsonIgnore;
19
import org.hibernate.envers.Audited;
20
import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate;
21
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.AssociationInverseSide;
22
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId;
23
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
24
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
25
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency;
26
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath;
27
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue;
28
import org.openmrs.api.context.Context;
29
import org.openmrs.util.CollectionUtil;
30

31
/**
32
 * Drug
33
 */
34
@Indexed
35
@Audited
36
public class Drug extends BaseChangeableOpenmrsMetadata {
37
        
38
        public static final long serialVersionUID = 285L;
39
        
40
        // Fields
41
        @DocumentId
42
        private Integer drugId;
43
        
44
        private Boolean combination = false;
1 ✔
45
        
46
        private Concept dosageForm;
47
        
48
        private Double maximumDailyDose;
49
        
50
        private Double minimumDailyDose;
51
        
52
        private String strength;
53
        
54
        private Concept doseLimitUnits;
55
        
56
        @IndexedEmbedded(includePaths = "conceptId", includeEmbeddedObjectId = true)
57
        @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
58
        private Concept concept;
59
        
60
        @IndexedEmbedded
61
        @AssociationInverseSide(inversePath = @ObjectPath({
62
                @PropertyValue(propertyName = "drug")
63
        }))
64
        private Set<DrugReferenceMap> drugReferenceMaps;
65
        
66
        private Collection<DrugIngredient> ingredients;
67
        
68
        // Constructors
69
        
70
        /** default constructor */
71
        public Drug() {
1 ✔
72
                ingredients = new LinkedHashSet<>();
1 ✔
73
        }
1 ✔
74
        
75
        /** constructor with id */
76
        public Drug(Integer drugId) {
×
77
                this.drugId = drugId;
×
UNCOV
78
        }
×
79
        
80
        // Property accessors
81
        
82
        /**
83
         * Gets the internal identification number for this drug
84
         *
85
         * @return Integer
86
         */
87
        public Integer getDrugId() {
88
                return this.drugId;
1 ✔
89
        }
90
        
91
        /**
92
         * Sets the internal identification number for this drug
93
         *
94
         * @param drugId
95
         */
96
        public void setDrugId(Integer drugId) {
97
                this.drugId = drugId;
1 ✔
98
        }
1 ✔
99
        
100
        /**
101
         * Gets the entries concept drug name in the form of CONCEPTNAME (Drug: DRUGNAME)
102
         * 
103
         * @param locale
104
         * @return full drug name (with concept name appended)
105
         */
106
        public String getFullName(Locale locale) {
107
                if (concept == null) {
×
UNCOV
108
                        return getName();
×
109
                } else {
UNCOV
110
                        return getName() + " (" + concept.getName(locale).getName() + ")";
×
111
                }
112
        }
113
        
114
        /**
115
         * Gets whether or not this is a combination drug
116
         *
117
         * @return Boolean
118
         * 
119
         * @deprecated as of 2.0, use {@link #getCombination()}
120
         */
121
        @Deprecated
122
        @JsonIgnore
123
        public Boolean isCombination() {
124
                return getCombination();
1 ✔
125
        }
126
        
127
        public Boolean getCombination() {
128
                return combination;
1 ✔
129
        }
130
        
131
        /**
132
         * Sets whether or not this is a combination drug
133
         *
134
         * @param combination
135
         */
136
        public void setCombination(Boolean combination) {
137
                this.combination = combination;
1 ✔
138
        }
1 ✔
139
        
140
        /**
141
         * Gets the strength
142
         *
143
         * @return String
144
         * @since 1.10
145
         */
146
        public String getStrength() {
147
                return strength;
1 ✔
148
        }
149
        
150
        /**
151
         * Sets the strength
152
         *
153
         * @param strength
154
         * @since 1.10
155
         */
156
        public void setStrength(String strength) {
157
                this.strength = strength;
1 ✔
158
        }
1 ✔
159
        
160
        /**
161
         * Gets the concept this drug is tied to
162
         *
163
         * @return Concept
164
         */
165
        public Concept getConcept() {
166
                return this.concept;
1 ✔
167
        }
168
        
169
        /**
170
         * Sets the concept this drug is tied to
171
         *
172
         * @param concept
173
         */
174
        public void setConcept(Concept concept) {
175
                this.concept = concept;
1 ✔
176
        }
1 ✔
177
        
178
        public Concept getDosageForm() {
179
                return dosageForm;
1 ✔
180
        }
181
        
182
        public void setDosageForm(Concept dosageForm) {
183
                this.dosageForm = dosageForm;
1 ✔
184
        }
1 ✔
185
        
186
        public Double getMaximumDailyDose() {
187
                return maximumDailyDose;
1 ✔
188
        }
189
        
190
        public void setMaximumDailyDose(Double maximumDailyDose) {
191
                this.maximumDailyDose = maximumDailyDose;
1 ✔
192
        }
1 ✔
193
        
194
        public Double getMinimumDailyDose() {
195
                return minimumDailyDose;
1 ✔
196
        }
197
        
198
        public void setMinimumDailyDose(Double minimumDailyDose) {
199
                this.minimumDailyDose = minimumDailyDose;
1 ✔
200
        }
1 ✔
201
        
202
        /**
203
         * @return Returns the ingredients
204
         * @since 1.10
205
         */
206
        public Collection<DrugIngredient> getIngredients() {
207
                return ingredients;
1 ✔
208
        }
209
        
210
        /**
211
         * @param ingredients
212
         *            The ingredients to set
213
         * @since 1.10
214
         */
215
        public void setIngredients(Collection<DrugIngredient> ingredients) {
UNCOV
216
                this.ingredients = CollectionUtil.setCollection(this.ingredients, ingredients);
×
UNCOV
217
        }
×
218
        
219
        /**
220
         * @since 1.5
221
         * @see org.openmrs.OpenmrsObject#getId()
222
         */
223
        @Override
224
        public Integer getId() {
225
                
226
                return getDrugId();
1 ✔
227
        }
228
        
229
        /**
230
         * @since 1.5
231
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
232
         */
233
        @Override
234
        public void setId(Integer id) {
235
                setDrugId(id);
×
UNCOV
236
        }
×
237
        
238
        /**
239
         * Convenience method that returns a display name for the drug, defaults to drug.name
240
         *
241
         * @return the display name
242
         * @since 1.8.5, 1.9.4, 1.10
243
         */
244
        public String getDisplayName() {
245
                if (StringUtils.isNotBlank(getName())) {
×
UNCOV
246
                        return getName();
×
247
                }
248
                if (getConcept() != null) {
×
UNCOV
249
                        return getConcept().getName().getName();
×
250
                }
UNCOV
251
                return "";
×
252
        }
253
        
254
        /**
255
         * @return Returns the drugReferenceMaps.
256
         * @since 1.10
257
         */
258
        public Set<DrugReferenceMap> getDrugReferenceMaps() {
259
                if (drugReferenceMaps == null) {
1 ✔
260
                        drugReferenceMaps = new LinkedHashSet<>();
1 ✔
261
                }
262
                return drugReferenceMaps;
1 ✔
263
        }
264
        
265
        /**
266
         * @param drugReferenceMaps The drugReferenceMaps to set.
267
         * @since 1.10
268
         */
269
        public void setDrugReferenceMaps(Set<DrugReferenceMap> drugReferenceMaps) {
270
                this.drugReferenceMaps = CollectionUtil.setCollection(this.drugReferenceMaps, drugReferenceMaps);
1 ✔
271
        }
1 ✔
272
        
273
        /**
274
         * Add the given DrugReferenceMap object to this drug's list of drug reference mappings. If there is
275
         * already a corresponding DrugReferenceMap object for this concept, this one will not be added.
276
         *
277
         * @param drugReferenceMap
278
         * @since 1.10
279
         *
280
         * <strong>Should</strong> set drug as the drug to which a mapping is being added
281
         *
282
         * <strong>Should</strong> should not add duplicate drug reference maps
283
         */
284
        public void addDrugReferenceMap(DrugReferenceMap drugReferenceMap) {
285
                if (drugReferenceMap != null && !getDrugReferenceMaps().contains(drugReferenceMap)) {
1 ✔
286
                        drugReferenceMap.setDrug(this);
1 ✔
287
                        if (drugReferenceMap.getConceptMapType() == null) {
1 ✔
288
                                drugReferenceMap.setConceptMapType(Context.getConceptService().getDefaultConceptMapType());
1 ✔
289
                        }
290
                        getDrugReferenceMaps().add(drugReferenceMap);
1 ✔
291
                }
292
        }
1 ✔
293
        
294
        /**
295
         * Gets the doseLimitUnits which represents the units of the existing maximumDailyDose and
296
         * minimumDailyDose
297
         * 
298
         * @return the doseLimitUnits.
299
         * @since 2.3.0
300
         */
301
        public Concept getDoseLimitUnits() {
302
                return doseLimitUnits;
1 ✔
303
        }
304
        
305
        /**
306
         * Sets the doseLimitUnits which represents the units of the existing maximumDailyDose and
307
         * minimumDailyDose
308
         * 
309
         * @param doseLimitUnits The doseLimitUnits to set.
310
         * @since 2.3.0
311
         */
312
        public void setDoseLimitUnits(Concept doseLimitUnits) {
313
                this.doseLimitUnits = doseLimitUnits;
1 ✔
314
        }
1 ✔
315
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc