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

openmrs / openmrs-core / 10946298164

19 Sep 2024 05:33PM UTC coverage: 63.759% (+0.09%) from 63.671%
10946298164

push

github

mogoodrich
TRUNK-6265: Bugs in Concept.getPreferredName(Locale) method (#4749)

(cherry picked from commit bc725f242)

14 of 16 new or added lines in 1 file covered. (87.5%)

12 existing lines in 9 files now uncovered.

21692 of 34022 relevant lines covered (63.76%)

0.64 hits per line

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

98.72
/api/src/main/java/org/openmrs/ConceptNumeric.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.HashSet;
13
import java.util.TreeSet;
14

15
import org.codehaus.jackson.annotate.JsonIgnore;
16
import org.hibernate.search.annotations.Indexed;
17

18
/**
19
 * The ConceptNumeric extends upon the Concept object by adding some number range values
20
 * 
21
 * @see Concept
22
 */
23
@Indexed
24
public class ConceptNumeric extends Concept {
25
        
26
        public static final long serialVersionUID = 47323L;
27
        
28
        // Fields
29
        
30
        private Double hiAbsolute;
31
        
32
        private Double hiCritical;
33
        
34
        private Double hiNormal;
35
        
36
        private Double lowAbsolute;
37
        
38
        private Double lowCritical;
39
        
40
        private Double lowNormal;
41
        
42
        private String units;
43
        
44
        private Boolean allowDecimal = false;
1✔
45
        
46
        /**
47
         * displayPrecision, represents the number of significant digits
48
         * to be used for display of a numeric value
49
         */
50
        private Integer displayPrecision;
51
        
52
        // Constructors
53
        
54
        /** default constructor */
55
        public ConceptNumeric() {
1✔
56
        }
1✔
57
        
58
        /**
59
         * Generic constructor taking the primary key
60
         * 
61
         * @param conceptId key for this numeric concept
62
         */
63
        public ConceptNumeric(Integer conceptId) {
1✔
64
                setConceptId(conceptId);
1✔
65
        }
1✔
66
        
67
        /**
68
         * Optional constructor for turning a Concept into a ConceptNumeric <br>
69
         * <br>
70
         * Note: This cannot copy over numeric specific values
71
         * 
72
         * @param c
73
         * <strong>Should</strong> make deep copy of collections
74
         * <strong>Should</strong> change reference to the parent object  for objects in answers collection
75
         * <strong>Should</strong> change reference to the parent object  for objects in conceptSets collection
76
         * <strong>Should</strong> change reference to the parent object  for objects in names collection
77
         * <strong>Should</strong> change reference to the parent object  for objects in descriptions collection
78
         * <strong>Should</strong> change reference to the parent object  for objects in conceptMappings collection
79
         */
80
        public ConceptNumeric(Concept c) {
1✔
81
                this.setChangedBy(c.getChangedBy());
1✔
82
                this.setConceptClass(c.getConceptClass());
1✔
83
                this.setConceptId(c.getConceptId());
1✔
84
                this.setCreator(c.getCreator());
1✔
85
                this.setDatatype(c.getDatatype());
1✔
86
                this.setDateChanged(c.getDateChanged());
1✔
87
                this.setDateCreated(c.getDateCreated());
1✔
88
                this.setSet(c.getSet());
1✔
89
                this.setRetired(c.getRetired());
1✔
90
                this.setRetiredBy(c.getRetiredBy());
1✔
91
                this.setRetireReason(c.getRetireReason());
1✔
92
                this.setVersion(c.getVersion());
1✔
93
                this.setUuid(c.getUuid());
1✔
94
                
95
                this.setNames(new HashSet<>(c.getNames()));
1✔
96
                for (ConceptName cName : this.getNames()) {
1✔
97
                        cName.setConcept(this);
1✔
98
                }
1✔
99
                
100
                this.setAnswers(new HashSet<>(c.getAnswers(true)));
1✔
101
                for (ConceptAnswer cAnswer : this.getAnswers()) {
1✔
102
                        cAnswer.setConcept(this);
1✔
103
                }
1✔
104
                
105
                this.setConceptSets(new TreeSet<>(c.getConceptSets()));
1✔
106
                for (ConceptSet cSet : this.getConceptSets()) {
1✔
107
                        cSet.setConceptSet(this);
1✔
108
                }
1✔
109
                
110
                this.setDescriptions(new HashSet<>(c.getDescriptions()));
1✔
111
                for (ConceptDescription cDescription : this.getDescriptions()) {
1✔
112
                        cDescription.setConcept(this);
1✔
113
                }
1✔
114
                
115
                this.setConceptMappings(new HashSet<>(c.getConceptMappings()));
1✔
116
                for (ConceptMap cMap : this.getConceptMappings()) {
1✔
117
                        cMap.setConcept(this);
1✔
118
                }
1✔
119
                
120
                this.hiAbsolute = null;
1✔
121
                this.hiCritical = null;
1✔
122
                this.hiNormal = null;
1✔
123
                this.lowAbsolute = null;
1✔
124
                this.lowCritical = null;
1✔
125
                this.lowNormal = null;
1✔
126
                this.units = "";
1✔
127
                this.allowDecimal = false;
1✔
128
        }
1✔
129
        
130
        // Property accessors
131
        
132
        public Double getHiAbsolute() {
133
                return this.hiAbsolute;
1✔
134
        }
135
        
136
        public void setHiAbsolute(Double hiAbsolute) {
137
                this.hiAbsolute = hiAbsolute;
1✔
138
        }
1✔
139
        
140
        public Double getHiCritical() {
141
                return this.hiCritical;
1✔
142
        }
143
        
144
        public void setHiCritical(Double hiCritical) {
145
                this.hiCritical = hiCritical;
1✔
146
        }
1✔
147
        
148
        public Double getHiNormal() {
149
                return this.hiNormal;
1✔
150
        }
151
        
152
        public void setHiNormal(Double hiNormal) {
153
                this.hiNormal = hiNormal;
1✔
154
        }
1✔
155
        
156
        public Double getLowAbsolute() {
157
                return this.lowAbsolute;
1✔
158
        }
159
        
160
        public void setLowAbsolute(Double lowAbsolute) {
161
                this.lowAbsolute = lowAbsolute;
1✔
162
        }
1✔
163
        
164
        public Double getLowCritical() {
165
                return this.lowCritical;
1✔
166
        }
167
        
168
        public void setLowCritical(Double lowCritical) {
169
                this.lowCritical = lowCritical;
1✔
170
        }
1✔
171
        
172
        public Double getLowNormal() {
173
                return this.lowNormal;
1✔
174
        }
175
        
176
        public void setLowNormal(Double lowNormal) {
177
                this.lowNormal = lowNormal;
1✔
178
        }
1✔
179
        
180
        public String getUnits() {
181
                return this.units;
1✔
182
        }
183
        
184
        public void setUnits(String units) {
185
                this.units = units;
1✔
186
        }
1✔
187

188
        /**
189
         * This method will <i>always</i> return true for ConceptNumeric objects that have a datatype of
190
         * Numeric
191
         * 
192
         * @see org.openmrs.Concept#isNumeric()
193
         */
194
        @Override
195
        public boolean isNumeric() {
196
                return "Numeric".equals(getDatatype().getName());
1✔
197
        }
198
        
199
        /**
200
         * @return displayPrecision to be used for the display of a numeric value
201
         */
202
        public Integer getDisplayPrecision() {
203
                return displayPrecision;
1✔
204
        }
205

206
        /**
207
         * @param displayPrecision sets displayPrecision to be used for the display of a numeric value
208
         */
209
        public void setDisplayPrecision(Integer displayPrecision) {
210
                this.displayPrecision = displayPrecision;
1✔
211
        }
1✔
212
        
213
        public Boolean getAllowDecimal() {
214
                return allowDecimal == null ? Boolean.FALSE : allowDecimal;
1✔
215
        }
216
        
217
        public void setAllowDecimal(Boolean allowDecimal) {
218
                this.allowDecimal = allowDecimal;
1✔
219
        }
1✔
220
        
221
        /**
222
         * @deprecated as of 2.0, use {@link #getAllowDecimal()}
223
         */
224
        @Deprecated
225
        @JsonIgnore
226
        public Boolean isAllowDecimal() {
UNCOV
227
                return getAllowDecimal();
×
228
        }
229
}
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