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

openmrs / openmrs-core / 31843719412

14 Aug 2026 09:43PM UTC coverage: 64.329% (+0.007%) from 64.322%
31843719412

push

github

ibacher
TRUNK-6717: Replace reflective BeanUtils property access with direct PersonName getters (#6431)

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

60 existing lines in 11 files now uncovered.

24629 of 38286 relevant lines covered (64.33%)

0.64 hits per line

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

60.0
/api/src/main/java/org/openmrs/OrderType.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.apache.commons.lang3.StringUtils;
13
import org.hibernate.annotations.GenericGenerator;
14
import org.hibernate.annotations.Parameter;
15
import org.hibernate.envers.Audited;
16
import org.openmrs.annotation.Independent;
17
import org.openmrs.api.APIException;
18
import org.openmrs.api.context.Context;
19

20
import javax.persistence.AttributeOverride;
21
import javax.persistence.AttributeOverrides;
22
import javax.persistence.Column;
23
import javax.persistence.Entity;
24
import javax.persistence.FetchType;
25
import javax.persistence.GeneratedValue;
26
import javax.persistence.GenerationType;
27
import javax.persistence.Id;
28
import javax.persistence.JoinColumn;
29
import javax.persistence.JoinTable;
30
import javax.persistence.ManyToMany;
31
import javax.persistence.ManyToOne;
32
import javax.persistence.Table;
33
import javax.persistence.UniqueConstraint;
34
import java.util.Collection;
35
import java.util.LinkedHashSet;
36
import java.util.Set;
37

38
/**
39
 * OrderTypes are used to classify different types of Orders e.g to distinguish between Serology and
40
 * Radiology TestOrders
41
 *
42
 */
43
@Entity
44
@Table(name = "order_type")
45
@Audited
46
public class OrderType extends BaseChangeableOpenmrsMetadata {
47
        
48
        public static final long serialVersionUID = 23232L;
49
        
50
        public static final String DRUG_ORDER_TYPE_UUID = "131168f4-15f5-102d-96e4-000c29c2a5d7";
51
        
52
        public static final String TEST_ORDER_TYPE_UUID = "52a447d3-a64a-11e3-9aeb-50e549534c5e";
53
        
54
        public static final String REFERRAL_ORDER_TYPE_UUID = "f1b63696-2b6c-11ec-8d3d-0242ac130003";
55

56
        @Id
57
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_type_id_seq")
58
        @GenericGenerator(
59
                name = "order_type_id_seq",
60
                strategy = "native",
61
                parameters = @Parameter(name = "sequence", value = "order_type_order_type_id_seq")
62
        )
63
        @Column(name = "order_type_id", nullable = false)
64
        private Integer orderTypeId;
65
        
66
        @Column(name = "java_class_name", nullable = false)
67
        private String javaClassName;
68
        
69
        @ManyToOne(fetch = FetchType.LAZY)
70
        @JoinColumn(name = "parent")
71
        private OrderType parent;
72
        
73
        @Independent
74
        @ManyToMany
75
        @JoinTable(
76
                name = "order_type_class_map", 
77
                joinColumns = @JoinColumn(name = "order_type_id"), 
78
                inverseJoinColumns = @JoinColumn(name = "concept_class_id"), 
79
                uniqueConstraints = @UniqueConstraint(columnNames = {"order_type_id", "concept_class_id"})
80
        )
81
        private Set<ConceptClass> conceptClasses;
82
        
83
        /**
84
         * default constructor
85
         */
86
        public OrderType() {
1✔
87
        }
1✔
88
        
89
        /**
90
         * Constructor with ID
91
         * 
92
         * @param orderTypeId the ID of the {@link OrderType}
93
         */
94
        public OrderType(Integer orderTypeId) {
×
95
                this.orderTypeId = orderTypeId;
×
UNCOV
96
        }
×
97
        
98
        /**
99
         * Convenience constructor that takes in the elements required to save this OrderType to the
100
         * database
101
         * 
102
         * @param name The name of this order Type
103
         * @param description A short description about this order type
104
         * @param javaClassName The fully qualified java class name
105
         */
106
        public OrderType(String name, String description, String javaClassName) {
×
107
                setName(name);
×
108
                setDescription(description);
×
109
                setJavaClassName(javaClassName);
×
UNCOV
110
        }
×
111
        
112
        /**
113
         * @return Returns the orderTypeId.
114
         */
115
        public Integer getOrderTypeId() {
116
                return orderTypeId;
1✔
117
        }
118
        
119
        /**
120
         * @param orderTypeId The orderTypeId to set.
121
         */
122
        public void setOrderTypeId(Integer orderTypeId) {
123
                this.orderTypeId = orderTypeId;
×
UNCOV
124
        }
×
125
        
126
        /**
127
         * @see OpenmrsObject#getId()
128
         */
129
        @Override
130
        public Integer getId() {
131
                return getOrderTypeId();
1✔
132
        }
133
        
134
        /**
135
         * @see OpenmrsObject#setId(Integer)
136
         */
137
        @Override
138
        public void setId(Integer id) {
UNCOV
139
                setOrderTypeId(id);
×
140
                
UNCOV
141
        }
×
142
        
143
        /**
144
         * @return Returns the Java className as String
145
         */
146
        public String getJavaClassName() {
147
                return javaClassName;
1✔
148
        }
149
        
150
        /**
151
         * @param javaClassName The Java class to set as String
152
         */
153
        public void setJavaClassName(String javaClassName) {
154
                this.javaClassName = javaClassName;
1✔
155
        }
1✔
156
        
157
        /**
158
         * @return Returns the {@link OrderType}
159
         */
160
        public OrderType getParent() {
161
                return parent;
1✔
162
        }
163
        
164
        /**
165
         * @param parent The {@link OrderType} to set
166
         */
167
        public void setParent(OrderType parent) {
168
                this.parent = parent;
1✔
169
        }
1✔
170
        
171
        /**
172
         * @return Get the {@link ConceptClass}es
173
         */
174
        public Collection<ConceptClass> getConceptClasses() {
175
                if (conceptClasses == null) {
1✔
176
                        conceptClasses = new LinkedHashSet<>();
1✔
177
                }
178
                return conceptClasses;
1✔
179
        }
180
        
181
        /**
182
         * @param conceptClasses the collection containing the {@link ConceptClass}es
183
         */
184
        public void setConceptClasses(Collection<ConceptClass> conceptClasses) {
185
                this.conceptClasses = (Set<ConceptClass>)conceptClasses;
1✔
186
        }
1✔
187
        
188
        /**
189
         * Convenience method that returns a {@link Class} object for the associated
190
         * javaClassName
191
         * 
192
         * @return The Java class as {@link Class}
193
         * @throws APIException
194
         */
195
        public Class getJavaClass() {
196
                try {
197
                        return Context.loadClass(javaClassName);
1✔
198
                }
UNCOV
199
                catch (ClassNotFoundException e) {
×
200
                        //re throw as a runtime exception
UNCOV
201
                        throw new APIException("OrderType.failed.load.class", new Object[] { javaClassName }, e);
×
202
                }
203
        }
204
        
205
        /**
206
         * Convenience method that adds the specified concept class
207
         * 
208
         * @param conceptClass the ConceptClass to add
209
         * <strong>Should</strong> add the specified concept class
210
         * <strong>Should</strong> not add a duplicate concept class
211
         */
212
        public void addConceptClass(ConceptClass conceptClass) {
213
                getConceptClasses().add(conceptClass);
1✔
214
        }
1✔
215
        
216
        /**
217
         * @see BaseOpenmrsObject#toString()
218
         */
219
        @Override
220
        public String toString() {
221
                if (StringUtils.isNotBlank(getName())) {
1✔
222
                        return getName();
1✔
223
                }
224
                return super.toString();
1✔
225
        }
226
}
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