Skip to content

Commit

Permalink
Dubey | BDSHR-1198 | Fixed bug. Estimated DOB type was being changed …
Browse files Browse the repository at this point in the history
…to Declared while download.
  • Loading branch information
mddubey committed Mar 16, 2016
1 parent 6b2418b commit 3bd82da
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public org.openmrs.Patient createOrUpdateEmrPatient(Patient mciPatient) {

Date dob = mciPatient.getDateOfBirth();
emrPatient.setBirthdate(dob);
emrPatient.setBirthdateEstimated(Boolean.FALSE);
if (DOB_TYPE_ESTIMATED.equals(mciPatient.getDobType())) {
emrPatient.setBirthdateEstimated(Boolean.TRUE);
emrPatient.setBirthdateEstimated(Boolean.FALSE);
}

org.openmrs.Patient patient = patientService.savePatient(emrPatient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.net.URLClassLoader;
import java.util.List;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

@org.springframework.test.context.ContextConfiguration(locations = {"classpath:TestingApplicationContext.xml"}, inheritLocations = true)
Expand All @@ -32,6 +34,51 @@ public class EMRPatientServiceIT extends BaseModuleWebContextSensitiveTest {
@Autowired
private EMRPatientService emrPatientService;


@Test
public void shouldSaveAMCIPatientAsEmrPatient() throws Exception {
executeDataSet("testDataSets/patientUpdateDS.xml");
org.openmrs.module.shrclient.model.Patient patient = getPatientFromJson("patients_response/by_hid.json");

emrPatientService.createOrUpdateEmrPatient(patient);

Patient savedPatient = patientService.getPatient(1);

assertEquals("HouseHold", savedPatient.getGivenName());
assertEquals("Patient", savedPatient.getFamilyName());
assertEquals(savedPatient.getGender(), "F");
assertFalse(savedPatient.getBirthdateEstimated());

assertAttribute(savedPatient, Constants.HEALTH_ID_ATTRIBUTE, "11421467785");
assertAttribute(savedPatient, Constants.NATIONAL_ID_ATTRIBUTE, "7654376543127");
assertAttribute(savedPatient, Constants.BIRTH_REG_NO_ATTRIBUTE, "54098540985409815");
}

@Test
public void shouldSaveAMCIPatientWithEstimatedDOB() throws Exception {
executeDataSet("testDataSets/patientUpdateDS.xml");
org.openmrs.module.shrclient.model.Patient patient = getPatientFromJson("patients_response/patient_with_estimated_DOB.json");

emrPatientService.createOrUpdateEmrPatient(patient);

Patient savedPatient = patientService.getPatient(1);

assertEquals("HouseHold", savedPatient.getGivenName());
assertEquals("Patient", savedPatient.getFamilyName());
assertEquals(savedPatient.getGender(), "F");
assertTrue(savedPatient.getBirthdateEstimated());

assertAttribute(savedPatient, Constants.HEALTH_ID_ATTRIBUTE, "11421467785");
assertAttribute(savedPatient, Constants.NATIONAL_ID_ATTRIBUTE, "7654376543127");
assertAttribute(savedPatient, Constants.BIRTH_REG_NO_ATTRIBUTE, "54098540985409815");
}

public void assertAttribute(Patient savedPatient, String attributeName, String expected) {
PersonAttribute hidAttribute = savedPatient.getAttribute(attributeName);
assertNotNull(hidAttribute);
assertEquals(expected, hidAttribute.getValue());
}

@Test
public void shouldMapRelationsToPatientAttributesWhenPresent() throws Exception {
executeDataSet("testDataSets/patientUpdateDS.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"hid": "11421467785",
"nid": "7654376543127",
"bin_brn": "54098540985409815",
"given_name": "HouseHold",
"sur_name": "Patient",
"date_of_birth": "2015-02-15T00:00:00.000+05:30",
"dob_type": "3",
"gender": "F",
"uid": "54676546761",
"present_address": {
"address_line": "house",
"division_id": "30",
"district_id": "26",
"upazila_id": "06",
"country_code": "050"
},
"confidential": "No",
"household_code": "124",
"created_by": {
"facility": {
"id": "10019841",
"name": null
},
"provider": null,
"admin": null,
"active": true
},
"updated_by": {
"facility": {
"id": "10019841",
"name": null
},
"provider": null,
"admin": null
},
"status": {
"type": "1"
},
"modified": "2015-04-07T15:05:16.916+05:30",
"created": "2015-04-07T15:05:16.916+05:30",
"active": true
}
15 changes: 15 additions & 0 deletions shrclient-omod/src/test/resources/testDataSets/patientUpdateDS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
date_created="2005-01-01 00:00:00.0"
searchable="1" uuid="5b19584d-10ab-11e4-b4e1-x92kdxiii2ae"/>

<person_attribute_type person_attribute_type_id="103" name="healthId" description="Health ID"
format="java.lang.String" retired="0" creator="1" sort_weight="1"
date_created="2005-01-01 00:00:00.0"
searchable="1" uuid="5b19584d-kj45-11e4-b4e1-x92kdxiii2ae"/>

<person_attribute_type person_attribute_type_id="104" name="nationalId" description="National ID"
format="java.lang.String" retired="0" creator="1" sort_weight="1"
date_created="2005-01-01 00:00:00.0"
searchable="1" uuid="5b19584d-kj45-98uy-b4e1-x92kdxiii2ae"/>

<person_attribute_type person_attribute_type_id="105" name="birthRegistrationId" description="Birth Registration ID"
format="java.lang.String" retired="0" creator="1" sort_weight="1"
date_created="2005-01-01 00:00:00.0"
searchable="1" uuid="5b19584d-kj45-98uy-45re-x92kdxiii2ae"/>

<patient patient_id="1" creator="1" date_created="2005-09-22 00:00:00.0" changed_by="1"
date_changed="2008-08-18 12:29:59.0" voided="false" void_reason=""/>
<patient_identifier date_created="2005-09-22 00:00:00" patient_identifier_id="1" patient_id="1"
Expand Down

0 comments on commit 3bd82da

Please sign in to comment.