| | 233 | public void testShouldModifyEncounterDatetime() throws Exception { |
|---|
| | 234 | authenticate(); |
|---|
| | 235 | |
|---|
| | 236 | //First, create an encounter with an obs: |
|---|
| | 237 | |
|---|
| | 238 | EncounterService es = Context.getEncounterService(); |
|---|
| | 239 | LocationService locationService = Context.getLocationService(); |
|---|
| | 240 | PatientService ps = Context.getPatientService(); |
|---|
| | 241 | Encounter enc = new Encounter(); |
|---|
| | 242 | |
|---|
| | 243 | Location loc1 = locationService.getAllLocations().get(0); |
|---|
| | 244 | assertNotNull("We need a location", loc1); |
|---|
| | 245 | EncounterType encType1 = es.getAllEncounterTypes().get(0); |
|---|
| | 246 | assertNotNull("We need an encounter type", encType1); |
|---|
| | 247 | Date d1 = new Date(); |
|---|
| | 248 | Patient pat1 = new Patient(3); |
|---|
| | 249 | User pro1 = Context.getAuthenticatedUser(); |
|---|
| | 250 | |
|---|
| | 251 | enc.setLocation(loc1); |
|---|
| | 252 | enc.setEncounterType(encType1); |
|---|
| | 253 | enc.setEncounterDatetime(d1); |
|---|
| | 254 | enc.setPatient(pat1); |
|---|
| | 255 | enc.setProvider(pro1); |
|---|
| | 256 | |
|---|
| | 257 | Obs o = new Obs(); |
|---|
| | 258 | o.setConcept(Context.getConceptService().getConcept(1)); |
|---|
| | 259 | o.setCreator(Context.getAuthenticatedUser()); |
|---|
| | 260 | o.setDateCreated(new Date()); |
|---|
| | 261 | o.setEncounter(enc); |
|---|
| | 262 | o.setVoided(false); |
|---|
| | 263 | o.setLocation(loc1); |
|---|
| | 264 | o.setPatient(pat1); |
|---|
| | 265 | o.setValueDatetime(new Date()); |
|---|
| | 266 | o.setObsDatetime(enc.getEncounterDatetime()); |
|---|
| | 267 | enc.addObs(o); |
|---|
| | 268 | es.saveEncounter(enc); |
|---|
| | 269 | |
|---|
| | 270 | //now modify the encounterDatetime and re-save. |
|---|
| | 271 | |
|---|
| | 272 | enc.setEncounterDatetime(new Date(5000)); |
|---|
| | 273 | es.saveEncounter(enc); |
|---|
| | 274 | |
|---|
| | 275 | |
|---|
| | 276 | } |
|---|
| | 277 | |
|---|