Skip to content

Commit

Permalink
AM-168 , UHM-1578 - Added confidential property to AppointmentType
Browse files Browse the repository at this point in the history
  • Loading branch information
djazayeri committed Sep 25, 2014
1 parent 007a5d6 commit becff70
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class AppointmentType extends BaseOpenmrsMetadata {
private Integer appointmentTypeId;

private Integer duration;

public AppointmentType() {

private boolean confidential = false;

public AppointmentType() {

}

Expand Down Expand Up @@ -72,4 +74,13 @@ public void setDuration(Integer duration) {
public String getDisplayString() {
return getName();
}

public void setConfidential(boolean confidential) {
this.confidential = confidential;
}

public boolean isConfidential() {
return confidential;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
*/
package org.openmrs.module.appointmentscheduling.api;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.openmrs.Location;
import org.openmrs.Patient;
import org.openmrs.Provider;
Expand All @@ -35,6 +30,11 @@
import org.openmrs.module.appointmentscheduling.TimeSlot;
import org.openmrs.module.appointmentscheduling.exception.TimeSlotFullException;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* This service exposes module's core functionality. It is a Spring managed bean
* which is configured in moduleApplicationContext.xml.
Expand Down Expand Up @@ -118,6 +118,7 @@ List<AppointmentType> getAppointmentTypes(String fuzzySearchPhrase,
* @return the created or updated appointment type.
* @should save new appointment type
* @should save edited appointment type
* @should save confidential appointment type
* @should throw error when name is null
* @should throw error when name is empty string
*/
Expand Down
1 change: 1 addition & 0 deletions api/src/main/resources/AppointmentType.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<property name="name" type="java.lang.String" not-null="true" length="255" />
<property name="description" type="java.lang.String" length="1024" />
<property name="duration" type="int" />
<property name="confidential" type="boolean" length="1" not-null="true" />

<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" />

Expand Down
12 changes: 12 additions & 0 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,16 @@
referencedTableName="provider" referencedColumnNames="provider_id"/>
</changeSet>

<changeSet id="201409251456-appointmentscheduling-confidential" author="djazayeri">
<preConditions onFail="MARK_RAN">
<not><columnExists tableName="appointmentscheduling_appointment_type" columnName="confidential" /></not>
</preConditions>
<comment>Adding confidential column to appointmentscheduling_appointment_type table</comment>
<addColumn tableName="appointmentscheduling_appointment_type">
<column name="confidential" type="tinyint" defaultValueNumeric="0">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,18 @@ public void saveAppointmentType_shouldSaveEditedAppointmentType() throws Excepti
//Should not change the number of appointment types.
assertEquals(4, service.getAllAppointmentTypes().size());
}

@Test

@Test
@Verifies(value = "should save confidential appointment type", method = "saveAppointmentType(AppointmentType)")
public void saveAppointmentType_shouldSaveConfidentialAppointmentType() throws Exception {
AppointmentType appointmentType = new AppointmentType("HIV Followup", "Scheduled followup", 30);
appointmentType.setConfidential(true);

appointmentType = service.saveAppointmentType(appointmentType);
assertTrue(appointmentType.isConfidential());
}

@Test
@Verifies(value = "should retire given appointment type", method = "retireAppointmentType(AppointmentType, String)")
public void retireAppointmentType_shouldRetireGivenAppointmentType() throws Exception {
AppointmentType appointmentType = service.getAppointmentType(1);
Expand Down
8 changes: 4 additions & 4 deletions api/src/test/resources/standardAppointmentTestDataset.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<appointmentscheduling_appointment_type appointment_type_id="1" name="Initial HIV Clinic Appointment" duration="54" description="Initial HIV Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="c0c579b0-8e59-401d-8a4a-976a0b183519"/>
<appointmentscheduling_appointment_type appointment_type_id="2" name="Return TB Clinic Appointment" duration="5" description="Return TB Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="759799ab-c9a5-435e-b671-77773ada74e4"/>
<appointmentscheduling_appointment_type appointment_type_id="3" name="Hospitalization2" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77773ada74e6"/>
<appointmentscheduling_appointment_type appointment_type_id="4" name="Hospitalization" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="true" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77373ada74e6"/>
<appointmentscheduling_appointment_type appointment_type_id="1" name="Initial HIV Clinic Appointment" duration="54" description="Initial HIV Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="c0c579b0-8e59-401d-8a4a-976a0b183519" confidential="1"/>
<appointmentscheduling_appointment_type appointment_type_id="2" name="Return TB Clinic Appointment" duration="5" description="Return TB Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="759799ab-c9a5-435e-b671-77773ada74e4" confidential="0"/>
<appointmentscheduling_appointment_type appointment_type_id="3" name="Hospitalization2" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77773ada74e6" confidential="0"/>
<appointmentscheduling_appointment_type appointment_type_id="4" name="Hospitalization" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="true" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77373ada74e6" confidential="0"/>

<appointmentscheduling_appointment_block appointment_block_id="1" start_date="2005-01-01 00:00:00.0" end_date="2005-01-01 11:00:00.0" provider_id="1" location_id="3" uuid="c0c579b0-8e59-401d-8a4a-976a0b183599" date_created="2005-01-01 00:00:00.0" date_changed="2005-01-01 00:00:00.0" date_voided="2005-01-01 00:00:00.0" voided="false" creator="1" changed_by="1"/>
<appointmentscheduling_appointment_block appointment_block_id="2" start_date="2005-01-02 00:00:00.0" end_date="2005-01-02 11:00:00.0" provider_id="1" location_id="1" uuid="759799ab-c9a5-435e-b671-77773ada99e9" date_created="2005-01-01 00:00:00.0" date_changed="2005-01-01 00:00:00.0" date_voided="2005-01-01 00:00:00.0" voided="false" creator="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("name");
description.addProperty("description");
description.addProperty("duration");
description.addProperty("confidential");
description.addProperty("retired");
description.addSelfLink();
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
Expand All @@ -40,6 +41,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("name");
description.addProperty("description");
description.addProperty("duration");
description.addProperty("confidential");
description.addProperty("retired");
description.addProperty("auditInfo", findMethod("getAuditInfo"));
description.addSelfLink();
Expand All @@ -54,6 +56,7 @@ public DelegatingResourceDescription getCreatableProperties() {
description.addRequiredProperty("name");
description.addRequiredProperty("description");
description.addRequiredProperty("duration");
description.addProperty("confidential");
return description;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void shouldGetAppointmentTypeByUuid() throws Exception {
Assert.assertEquals("Initial HIV Clinic Appointment", PropertyUtils.getProperty(result, "display"));
Assert.assertEquals("Initial HIV Clinic Appointment Description", PropertyUtils.getProperty(result, "description"));
Assert.assertEquals(45, PropertyUtils.getProperty(result, "duration"));
Assert.assertEquals(true, PropertyUtils.getProperty(result, "confidential"));
Assert.assertEquals(false, PropertyUtils.getProperty(result, "retired"));
}

Expand All @@ -54,6 +55,7 @@ public void shouldGetFullAppointmentTypeByUuid() throws Exception {
Assert.assertEquals("Initial HIV Clinic Appointment", PropertyUtils.getProperty(result, "display"));
Assert.assertEquals("Initial HIV Clinic Appointment Description", PropertyUtils.getProperty(result, "description"));
Assert.assertEquals(45, PropertyUtils.getProperty(result, "duration"));
Assert.assertEquals(true, PropertyUtils.getProperty(result, "confidential"));
Assert.assertEquals(false, PropertyUtils.getProperty(result, "retired"));
Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void validateDefaultRepresentation() throws Exception {
assertPropEquals("name", getObject().getName());
assertPropEquals("description", getObject().getDescription());
assertPropEquals("duration", getObject().getDuration());
assertPropEquals("confidential", getObject().isConfidential());
assertPropEquals("retired", getObject().isRetired());
}

Expand All @@ -39,6 +40,7 @@ public void validateFullRepresentation() throws Exception {
assertPropEquals("name", getObject().getName());
assertPropEquals("description", getObject().getDescription());
assertPropEquals("duration", getObject().getDuration());
assertPropEquals("confidential", getObject().isConfidential());
assertPropEquals("retired", getObject().isRetired());
assertPropPresent("auditInfo");
}
Expand Down
8 changes: 4 additions & 4 deletions omod/src/test/resources/standardWebAppointmentTestDataset.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<appointmentscheduling_appointment_type appointment_type_id="1" name="Initial HIV Clinic Appointment" duration="45" description="Initial HIV Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="c0c579b0-8e59-401d-8a4a-976a0b183519"/>
<appointmentscheduling_appointment_type appointment_type_id="2" name="Return TB Clinic Appointment" duration="20" description="Return TB Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="759799ab-c9a5-435e-b671-77773ada74e4"/>
<appointmentscheduling_appointment_type appointment_type_id="3" name="Hospitalization2" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77773ada74e6"/>
<appointmentscheduling_appointment_type appointment_type_id="4" name="Hospitalization" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="true" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77373ada74e6"/>
<appointmentscheduling_appointment_type appointment_type_id="1" name="Initial HIV Clinic Appointment" duration="45" description="Initial HIV Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="c0c579b0-8e59-401d-8a4a-976a0b183519" confidential="1"/>
<appointmentscheduling_appointment_type appointment_type_id="2" name="Return TB Clinic Appointment" duration="20" description="Return TB Clinic Appointment Description" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" uuid="759799ab-c9a5-435e-b671-77773ada74e4" confidential="0"/>
<appointmentscheduling_appointment_type appointment_type_id="3" name="Hospitalization2" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="false" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77773ada74e6" confidential="0"/>
<appointmentscheduling_appointment_type appointment_type_id="4" name="Hospitalization" description="Hospitalization Description" duration="10" creator="1" date_created="2005-01-01 00:00:00.0" retired="true" retire_reason="Some Retire Reason" uuid="759799ab-c9a5-435e-b671-77373ada74e6" confidential="0"/>

<appointmentscheduling_appointment_block appointment_block_id="1" start_date="2005-01-01 00:00:00.0" end_date="2005-01-01 11:00:00.0" provider_id="1" location_id="3" uuid="c0c579b0-8e59-401d-8a4a-976a0b183599" date_created="2005-01-01 00:00:00.0" date_changed="2005-01-01 00:00:00.0" date_voided="2005-01-01 00:00:00.0" voided="false" creator="1" changed_by="1"/>
<appointmentscheduling_appointment_block appointment_block_id="2" start_date="2005-01-02 00:00:00.0" end_date="2005-01-02 11:00:00.0" provider_id="1" location_id="1" uuid="759799ab-c9a5-435e-b671-77773ada99e9" date_created="2005-01-01 00:00:00.0" date_changed="2005-01-01 00:00:00.0" date_voided="2005-01-01 00:00:00.0" voided="false" void_reason="Some void reason" creator="1" voided_by="1"/>
Expand Down

0 comments on commit becff70

Please sign in to comment.