• 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

85.71
/api/src/main/java/org/openmrs/Visit.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
import java.util.HashSet;
14
import java.util.LinkedHashSet;
15
import java.util.List;
16
import java.util.Set;
17
import java.util.stream.Collectors;
18

19
import javax.persistence.Access;
20
import javax.persistence.AccessType;
21
import javax.persistence.CascadeType;
22
import javax.persistence.Column;
23
import javax.persistence.Entity;
24
import javax.persistence.GeneratedValue;
25
import javax.persistence.GenerationType;
26
import javax.persistence.Id;
27
import javax.persistence.JoinColumn;
28
import javax.persistence.ManyToOne;
29
import javax.persistence.OneToMany;
30
import javax.persistence.OrderBy;
31
import javax.persistence.Table;
32

33
import org.hibernate.annotations.BatchSize;
34
import org.hibernate.envers.Audited;
35
import org.openmrs.customdatatype.Customizable;
36
import org.openmrs.util.CollectionUtil;
37

38
/**
39
 * A 'visit' is a contiguous time period where encounters occur between patients and healthcare
40
 * providers. This can function as a grouper for encounters
41
 * 
42
 * @since 1.9
43
 */
44
@Entity
45
@Table(name = "visit")
46
@Audited
47
public class Visit extends BaseCustomizableData<VisitAttribute> implements Auditable, Customizable<VisitAttribute> {
48
        
49
        @Id
50
        @GeneratedValue(strategy = GenerationType.IDENTITY)
51
        @Column(name = "visit_id")
52
        private Integer visitId;
53
        
54
        @ManyToOne(optional = false)
55
        @JoinColumn(name = "patient_id")
56
        private Patient patient;
57
        
58
        @ManyToOne(optional = false)
59
        @JoinColumn(name = "visit_type_id")
60
        private VisitType visitType;
61
        
62
        @ManyToOne
63
        @JoinColumn(name = "indication_concept_id")
64
        private Concept indication;
65
        
66
        @ManyToOne
67
        @JoinColumn(name = "location_id")
68
        private Location location;
69
        
70
        @Column(name = "date_started", nullable = false, length = 19)
71
        private Date startDatetime;
72
        
73
        @Column(name = "date_stopped", length = 19)
74
        private Date stopDatetime;
75
        
76
        @OneToMany(mappedBy = "visit")
77
        @OrderBy("encounter_datetime desc, encounter_id desc")
78
        private Set<Encounter> encounters;
79
        
80
        @Access(AccessType.PROPERTY)
1 ✔
81
        @OneToMany(mappedBy = "visit", cascade = CascadeType.ALL, orphanRemoval = true)
82
        @OrderBy("voided asc")
83
        @BatchSize(size = 100)
84
        private Set<VisitAttribute> attributes = new LinkedHashSet<>();
85
        
86
        /**
87
         * Default Constructor
88
         */
89
        public Visit() {
1 ✔
90
        }
1 ✔
91
        
92
        /**
93
         * The attributes are mapped with property access, so Hibernate loads them through
94
         * {@link #setAttributes(Set)}, which must keep the collection it is given rather than copy it as
95
         * {@link BaseCustomizableData#setAttributes(Set)} does.
96
         *
97
         * @see org.openmrs.customdatatype.Customizable#getAttributes()
98
         */
99
        @Override
100
        public Set<VisitAttribute> getAttributes() {
101
                return attributes;
1 ✔
102
        }
103
        
104
        /**
105
         * @param attributes the attributes to set
106
         */
107
        @Override
108
        public void setAttributes(Set<VisitAttribute> attributes) {
109
                this.attributes = attributes;
1 ✔
110
        }
1 ✔
111
        
112
        /**
113
         * Constructor that takes in a visitId
114
         * 
115
         * @param visitId
116
         */
117
        public Visit(Integer visitId) {
1 ✔
118
                this.visitId = visitId;
1 ✔
119
        }
1 ✔
120
        
121
        /**
122
         * Convenience constructor that takes in the required fields i.e {@link Patient},
123
         * {@link VisitType} and dateStarted
124
         * 
125
         * @see VisitType
126
         * @param patient the patient associated to this visit
127
         * @param visitType The type of visit
128
         * @param startDatetime the date this visit was started
129
         */
130
        public Visit(Patient patient, VisitType visitType, Date startDatetime) {
1 ✔
131
                this.patient = patient;
1 ✔
132
                this.visitType = visitType;
1 ✔
133
                this.startDatetime = startDatetime;
1 ✔
134
        }
1 ✔
135
        
136
        /**
137
         * @return the visitId
138
         */
139
        public Integer getVisitId() {
140
                return visitId;
1 ✔
141
        }
142
        
143
        /**
144
         * @param visitId the visitId to set
145
         */
146
        public void setVisitId(Integer visitId) {
147
                this.visitId = visitId;
1 ✔
148
        }
1 ✔
149
        
150
        /**
151
         * @return the patient
152
         */
153
        public Patient getPatient() {
154
                return patient;
1 ✔
155
        }
156
        
157
        /**
158
         * @param patient the patient to set
159
         */
160
        public void setPatient(Patient patient) {
161
                this.patient = patient;
1 ✔
162
        }
1 ✔
163
        
164
        /**
165
         * @return the visitType
166
         */
167
        public VisitType getVisitType() {
168
                return visitType;
1 ✔
169
        }
170
        
171
        /**
172
         * @param visitType the visitType to set
173
         */
174
        public void setVisitType(VisitType visitType) {
175
                this.visitType = visitType;
1 ✔
176
        }
1 ✔
177
        
178
        /**
179
         * @return the indication
180
         */
181
        public Concept getIndication() {
182
                return indication;
1 ✔
183
        }
184
        
185
        /**
186
         * @param indication the indication to set
187
         */
188
        public void setIndication(Concept indication) {
UNCOV
189
                this.indication = indication;
×
UNCOV
190
        }
×
191
        
192
        /**
193
         * @return the location
194
         */
195
        public Location getLocation() {
196
                return location;
1 ✔
197
        }
198
        
199
        /**
200
         * @param location the location to set
201
         */
202
        public void setLocation(Location location) {
203
                this.location = location;
1 ✔
204
        }
1 ✔
205
        
206
        /**
207
         * @return the startDatetime
208
         */
209
        public Date getStartDatetime() {
210
                return startDatetime;
1 ✔
211
        }
212
        
213
        /**
214
         * @param startDatetime the startDatetime to set
215
         */
216
        public void setStartDatetime(Date startDatetime) {
217
                this.startDatetime = startDatetime;
1 ✔
218
        }
1 ✔
219
        
220
        /**
221
         * @return the stopDatetime
222
         */
223
        public Date getStopDatetime() {
224
                return stopDatetime;
1 ✔
225
        }
226
        
227
        /**
228
         * @param stopDatetime the stopDatetime to set
229
         */
230
        public void setStopDatetime(Date stopDatetime) {
231
                this.stopDatetime = stopDatetime;
1 ✔
232
        }
1 ✔
233
        
234
        /**
235
         * @see org.openmrs.OpenmrsObject#getId()
236
         */
237
        @Override
238
        public Integer getId() {
239
                return visitId;
1 ✔
240
        }
241
        
242
        /**
243
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
244
         */
245
        @Override
246
        public void setId(Integer id) {
UNCOV
247
                visitId = id;
×
UNCOV
248
        }
×
249
        
250
        /**
251
         * @see java.lang.Object#toString()
252
         */
253
        @Override
254
        public String toString() {
255
                return "Visit #" + visitId;
1 ✔
256
        }
257
        
258
        /**
259
         * @return the encounters
260
         */
261
        public Set<Encounter> getEncounters() {
262
                if (encounters == null) {
1 ✔
263
                        encounters = new HashSet<>();
1 ✔
264
                }
265
                return encounters;
1 ✔
266
        }
267
        
268
        /**
269
         * @param encounters the encounters to set
270
         */
271
        public void setEncounters(Set<Encounter> encounters) {
UNCOV
272
                this.encounters = CollectionUtil.setCollection(this.encounters, encounters);
×
UNCOV
273
        }
×
274
        
275
        /**
276
         * Gets a list of non voided encounters
277
         * 
278
         * @return the non voided encounter list
279
         * @since 1.11.0, 1.12.0
280
         */
281
        public List<Encounter> getNonVoidedEncounters() {
UNCOV
282
                return getEncounters().stream().filter(e -> !e.getVoided()).collect(Collectors.toList());
×
283
        }
284
        
285
        /**
286
         * adds an individual encounter to a visit
287
         *
288
         * @param encounter the encounter to add
289
         * @since 1.9.2, 1.10.0
290
         */
291
        public void addEncounter(Encounter encounter) {
292
                if (encounter != null) {
1 ✔
293
                        encounter.setVisit(this);
1 ✔
294
                        getEncounters().add(encounter);
1 ✔
295
                }
296
        }
1 ✔
297
}
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