Changeset 5183 for openmrs/branches/data_synchronization_bidirectional/src/api/org/openmrs/api/impl/EncounterServiceImpl.java
- Timestamp:
- 08/06/08 17:17:55 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/branches/data_synchronization_bidirectional/src/api/org/openmrs/api/impl/EncounterServiceImpl.java
r4969 r5183 31 31 import org.openmrs.api.EncounterService; 32 32 import org.openmrs.api.ObsService; 33 import org.openmrs.api.OrderService; 33 34 import org.openmrs.api.context.Context; 34 35 import org.openmrs.api.db.EncounterDAO; … … 61 62 * @see org.openmrs.api.EncounterService#saveEncounter(org.openmrs.Encounter) 62 63 */ 63 public voidsaveEncounter(Encounter encounter) throws APIException {64 public Encounter saveEncounter(Encounter encounter) throws APIException { 64 65 Date now = new Date(); 65 66 User me = Context.getAuthenticatedUser(); … … 151 152 } 152 153 } 154 return encounter; 153 155 } 154 156 … … 211 213 * java.lang.String) 212 214 */ 213 public voidvoidEncounter(Encounter encounter, String reason) {215 public Encounter voidEncounter(Encounter encounter, String reason) { 214 216 if (reason == null) 215 217 reason = ""; … … 221 223 } 222 224 } 225 226 OrderService orderService = Context.getOrderService(); 227 for (Order o : encounter.getOrders()) { 228 if (!o.isVoided()) { 229 orderService.voidOrder(o, reason); 230 } 231 } 223 232 224 233 encounter.setVoided(true); … … 227 236 encounter.setVoidReason(reason); 228 237 saveEncounter(encounter); 238 return encounter; 229 239 } 230 240 … … 232 242 * @see org.openmrs.api.EncounterService#unvoidEncounter(org.openmrs.Encounter) 233 243 */ 234 public voidunvoidEncounter(Encounter encounter) throws APIException {244 public Encounter unvoidEncounter(Encounter encounter) throws APIException { 235 245 String voidReason = encounter.getVoidReason(); 236 246 if (voidReason == null) … … 248 258 encounter.setVoidReason(null); 249 259 saveEncounter(encounter); 260 return encounter; 250 261 } 251 262 … … 290 301 * @see org.openmrs.api.EncounterService#saveEncounterType(org.openmrs.EncounterType) 291 302 */ 292 public voidsaveEncounterType(EncounterType encounterType) {303 public EncounterType saveEncounterType(EncounterType encounterType) { 293 304 if (encounterType.getCreator() == null) { 294 305 encounterType.setCreator(Context.getAuthenticatedUser()); … … 297 308 298 309 dao.saveEncounterType(encounterType); 310 return encounterType; 299 311 } 300 312 … … 340 352 * @see org.openmrs.api.EncounterService#retireEncounterType(org.openmrs.EncounterType) 341 353 */ 342 public voidretireEncounterType(EncounterType encounterType, String reason)354 public EncounterType retireEncounterType(EncounterType encounterType, String reason) 343 355 throws APIException { 344 356 encounterType.setRetired(true); … … 346 358 encounterType.setDateRetired(new Date()); 347 359 encounterType.setRetireReason(reason); 348 dao.saveEncounterType(encounterType); 360 saveEncounterType(encounterType); 361 return encounterType; 349 362 } 350 363 … … 352 365 * @see org.openmrs.api.EncounterService#unretireEncounterType(org.openmrs.EncounterType) 353 366 */ 354 public voidunretireEncounterType(EncounterType encounterType)367 public EncounterType unretireEncounterType(EncounterType encounterType) 355 368 throws APIException { 356 369 encounterType.setRetired(false); … … 358 371 encounterType.setDateRetired(null); 359 372 encounterType.setRetireReason(null); 360 dao.saveEncounterType(encounterType); 373 saveEncounterType(encounterType); 374 return encounterType; 361 375 } 362 376