Changeset 3991
- Timestamp:
- 04/22/08 15:16:07 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/trunk/metadata/api/hibernate/org/openmrs/api/db/hibernate/Obs.hbm.xml
r3847 r3991 62 62 <!-- many-to-one association from this obs to its parent grouping obs --> 63 63 <!-- insert/update=false because the groupMembers set is doing the saving for us --> 64 <many-to-one name="obsGroup" class="Obs" column="obs_group_id" insert=" false" update="false"/>64 <many-to-one name="obsGroup" class="Obs" column="obs_group_id" insert="true" update="true"/> 65 65 66 66 <!-- one-to-many association to all obs in this grouping --> openmrs/trunk/test/api/org/openmrs/test/api/ObsServiceTest.java
r3847 r3991 304 304 Obs o4 = obsService.getObs(o.getObsId()); 305 305 306 assertNotNull(o4.getVoidReason()); 306 307 assertTrue(o4.getVoidReason().equals("testing void function")); 307 308 assertTrue(o4.getVoidedBy().equals(o3.getVoidedBy())); … … 315 316 } 316 317 318 /** 319 * Auto generated method comment 320 * 321 * @throws Exception 322 */ 317 323 public void testObsValidator() throws Exception { 318 324 executeDataSet(INITIAL_OBS_XML); … … 686 692 assertTrue(childLeafObs.isVoided()); 687 693 688 childLeafObs.setDateVoided(new Date( ));694 childLeafObs.setDateVoided(new Date(childLeafObs.getDateVoided().getTime() - 5000)); 689 695 os.updateObs(childLeafObs); 690 696 os.unvoidObs(oGGGP); … … 693 699 Obs childLeafObsTwo = os.getObs(childTwoId); 694 700 695 //childLeafObs had its date voided date changed, so it shoul not get unvoided by the unvoid cascade701 //childLeafObs had its date voided date changed, so it should not get unvoided by the unvoid cascade 696 702 //childLeafObsTwo should be unvoided, as the dateVoided date is still the same as the great-great 697 703 //grandparent Obs … … 708 714 assertNull(os.getObs(childTwoId)); 709 715 } 710 716 717 /** 718 * This test makes sure that child obs on a parent obs are given an obs group id when the 719 * parent obs is created 720 * 721 * @throws Throwable 722 */ 723 public void testCreateObsGroupId() throws Throwable { 724 725 executeDataSet(INITIAL_OBS_XML); 726 727 ConceptService cs = Context.getConceptService(); 728 ObsService os = Context.getObsService(); 729 730 Obs o2 = new Obs(); 731 o2.setConcept(cs.getConcept(1)); 732 o2.setDateCreated(new Date()); 733 o2.setCreator(Context.getAuthenticatedUser()); 734 o2.setLocation(new Location(1)); 735 o2.setObsDatetime(new Date()); 736 o2.setValueText("test"); 737 o2.setPerson(new Patient(2)); 738 739 //create a parent obs 740 Obs oParent = new Obs(); 741 oParent.setConcept(cs.getConcept(2)); //in the concept set table as a set 742 oParent.setDateCreated(new Date()); 743 oParent.setCreator(Context.getAuthenticatedUser()); 744 oParent.setLocation(new Location(1)); 745 oParent.setObsDatetime(new Date()); 746 oParent.setPerson(new Patient(2)); 747 748 oParent.addGroupMember(o2); 749 750 os.createObs(oParent); 751 752 // save the obs ids 753 Integer parentObsId = oParent.getObsId(); 754 assertNotNull(parentObsId); 755 756 Integer childObsId = o2.getObsId(); 757 assertNotNull(childObsId); 758 759 // clear out the session so we can refetch and test that it saved correctly 760 oParent = null; 761 o2 = null; 762 Context.clearSession(); 763 764 // try to get the same obs back and make sure it has children 765 766 Obs fetchedParent = os.getObs(parentObsId); 767 assertTrue(fetchedParent.isObsGrouping()); 768 assertEquals(1, fetchedParent.getGroupMembers().size()); 769 770 771 } 711 772 }