Skip to content

Commit

Permalink
TRUNK-4973 | Support for form_namespace_and_path while editing obs
Browse files Browse the repository at this point in the history
  • Loading branch information
bharatak committed Nov 26, 2016
1 parent 6f90108 commit ef64de4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/src/main/java/org/openmrs/Obs.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public static Obs newInstance(Obs obsToCopy) {

newObs.setValueComplex(obsToCopy.getValueComplex());
newObs.setComplexData(obsToCopy.getComplexData());
newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());

// Copy list of all members, including voided, and put them in respective groups
if (obsToCopy.hasGroupMembers(true)) {
Expand Down
18 changes: 18 additions & 0 deletions api/src/test/java/org/openmrs/api/ObsServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1894,4 +1894,22 @@ public void saveObs_shouldNotVoidAnObsWithNoChanges() throws Exception {
}

}

/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
@Verifies(value = "should contain the form_namespace_and_path value in the edited obs", method = "saveObs(Obs,String)")
public void saveObs_shouldCopyTheFormNamespaceAndPathFieldInEditedObs() throws Exception {
executeDataSet(INITIAL_OBS_XML);
Obs obs = Context.getObsService().getObs(7);
obs.setValueNumeric(5.0);
Obs o2 = Context.getObsService().saveObs(obs, "just testing");
Assert.assertNotNull(obs.getFormFieldNamespace());

// fetch the obs from the database again
obs = Context.getObsService().getObs(o2.getObsId());
Assert.assertNotNull(obs.getFormFieldNamespace());
Assert.assertNotNull(obs.getFormFieldPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<obs obs_id="4" person_id="6" concept_id="1" order_id="42" obs_datetime="2006-02-12 00:00:00.0" location_id="1" value_numeric="4.0" creator="1" date_created="2006-02-13 15:57:35.0" voided="false" uuid="144cb55d-69ab-4009-8256-f4750e8770ee" accession_number="AN2"/>
<obs obs_id="5" person_id="7" concept_id="1" obs_datetime="2006-02-13 01:00:00.0" location_id="1" value_numeric="5.0" creator="1" date_created="2006-02-14 15:57:35.0" voided="false" uuid="6e76c1f1-6886-49bb-9dc0-f3b304936100"/>
<obs obs_id="6" person_id="7" concept_id="1" obs_datetime="2006-02-14 00:00:00.0" location_id="1" value_numeric="6.0" creator="1" date_created="2006-02-15 15:57:35.0" voided="false" uuid="14d3b79b-1f8f-4bb3-93c2-3eac710dc053"/>
<obs obs_id="7" person_id="8" concept_id="1" obs_datetime="2006-02-15 00:00:00.0" location_id="1" value_numeric="7.0" creator="1" date_created="2006-02-16 15:57:35.0" voided="false" uuid="adf212b7-05bd-4114-908a-b04cb058afa4"/>
<obs obs_id="7" person_id="8" concept_id="1" obs_datetime="2006-02-15 00:00:00.0" location_id="1" value_numeric="7.0" creator="1" date_created="2006-02-16 15:57:35.0" voided="false" uuid="adf212b7-05bd-4114-908a-b04cb058afa4" form_namespace_and_path="valid_form_namespace^path"/>
<obs obs_id="8" person_id="8" concept_id="1" obs_datetime="2006-02-16 00:00:00.0" location_id="1" value_numeric="8.0" creator="1" date_created="2006-02-17 15:57:35.0" voided="false" uuid="0ee1248e-08aa-4a2c-9f38-fb3875f605e0"/>
<obs obs_id="9" person_id="9" concept_id="1" obs_datetime="2004-01-01 00:00:00.0" location_id="1" value_numeric="9.0" obs_group_id="2" creator="1" date_created="2006-02-17 15:57:35.0" voided="false" uuid="0ee1248e-08aa-4a2c-9f38-fb3875f605e1"/>
<obs obs_id="10" person_id="9" concept_id="1" obs_datetime="2009-01-01 00:00:00.0" location_id="1" value_numeric="10.0" obs_group_id="2" creator="1" date_created="2006-02-17 15:57:35.0" voided="true" void_reason="testing" voided_by="1" date_voided="2006-03-17 15:57:35.0" uuid="0ee1248e-08aa-4a2c-9f38-fb3875f605e2"/>
Expand Down

0 comments on commit ef64de4

Please sign in to comment.