Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add careSetting property to Order class - TRUNK-4156
TRUNK-4156-redesign. Introduce care_setting table 1. Introduce new care_setting table. 2. Replace existing care_setting varchar to care_setting_id referencing the care_setting table. 3. Make OUTPATIENT as default care_setting for existing orders that do not have a care_setting. 4. Introduce new method in OrderService. This fixes a test and provides a way to retrieve a care setting. Minor documentation fix TRUNK-4156 - Changes based on comments. Made some changes as a follow up in update file - TRUNK-4156 Fixed test data, order and caresetting hbm files - TRUNK-4156
- Loading branch information
Showing
18 changed files
with
256 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6806,4 +6806,121 @@ | |
<dropColumn tableName="orders" columnName="discontinued_by" /> | ||
</changeSet> | ||
|
||
<changeSet id="201312271822-TRUNK-4156" author="vinay"> | ||
<preConditions onFail="MARK_RAN"> | ||
<not><tableExists tableName="care_setting"/></not> | ||
</preConditions> | ||
<comment>Adding care_setting table</comment> | ||
<createTable tableName="care_setting"> | ||
<column name="care_setting_id" type="int(11)" autoIncrement="true"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
<column name="name" type="varchar(255)"> | ||
<constraints nullable="false" /> | ||
</column> | ||
<column name="description" type="varchar(255)"></column> | ||
<column name="care_setting_type" type="varchar(50)"> | ||
<constraints nullable="false" /> | ||
</column> | ||
<column name="creator" type="int(11)" > | ||
<constraints nullable="false" /> | ||
</column> | ||
<column name="date_created" type="datetime" > | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="retired" type="tinyint" defaultValueNumeric="0"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="retired_by" type="int(11)" /> | ||
<column name="date_retired" type="datetime" /> | ||
<column name="retired_reason" type="varchar(255)" defaultValue="null"/> | ||
<column name="uuid" type="char(38)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</createTable> | ||
|
||
<addForeignKeyConstraint constraintName="care_setting_creator" | ||
baseTableName="care_setting" baseColumnNames="creator" | ||
referencedTableName="users" referencedColumnNames="user_id"/> | ||
<addForeignKeyConstraint constraintName="care_setting_retired_by" | ||
baseTableName="care_setting" baseColumnNames="retired_by" | ||
referencedTableName="users" referencedColumnNames="user_id"/> | ||
</changeSet> | ||
|
||
<changeSet id="201312271823-TRUNK-4156" author="vinay"> | ||
<preConditions onFail="MARK_RAN"> | ||
<sqlCheck expectedResult="0"> | ||
SELECT COUNT(*) FROM care_setting where care_setting_type = 'OUTPATIENT' | ||
</sqlCheck> | ||
</preConditions> | ||
<comment>Adding OUTPATIENT care setting</comment> | ||
<insert tableName="care_setting"> | ||
<column name="name" value="Outpatient"/> | ||
<column name="description" value="Out-patient care setting"/> | ||
<column name="care_setting_type" value="OUTPATIENT"/> | ||
<column name="creator" valueNumeric="1"/> | ||
<column name="date_created" valueDate="2013-12-27T00:00:00"/> | ||
<column name="uuid" value="6f0c9a92-6f24-11e3-af88-005056821db0"/> | ||
</insert> | ||
</changeSet> | ||
|
||
<changeSet id="201312271824-TRUNK-4156" author="vinay"> | ||
<preConditions onFail="MARK_RAN"> | ||
<sqlCheck expectedResult="0"> | ||
SELECT COUNT(*) FROM care_setting where care_setting_type = 'INPATIENT' | ||
</sqlCheck> | ||
</preConditions> | ||
<comment>Adding INPATIENT care setting</comment> | ||
<insert tableName="care_setting"> | ||
<column name="name" value="Inpatient"/> | ||
<column name="description" value="In-patient care setting"/> | ||
<column name="care_setting_type" value="INPATIENT"/> | ||
<column name="creator" valueNumeric="1"/> | ||
<column name="date_created" valueDate="2013-12-27T00:00:00"/> | ||
<column name="uuid" value="6f0c9a92-6f24-11e3-af88-005056821db0"/> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wluyima
Member
|
||
</insert> | ||
</changeSet> | ||
|
||
<changeSet id="201312271826-TRUNK-4156" author="vinay"> | ||
<preConditions onFail="MARK_RAN"> | ||
<not><columnExists tableName="orders" columnName="care_setting"/></not> | ||
</preConditions> | ||
<comment>Add care_setting column to orders table</comment> | ||
<addColumn tableName="orders"> | ||
<column name="care_setting" type="int(11)"/> | ||
</addColumn> | ||
</changeSet> | ||
|
||
<changeSet id="201312271827-TRUNK-4156" author="vinay"> | ||
<preConditions> | ||
<not> | ||
<sqlCheck expectedResult="0"> | ||
SELECT * FROM orders WHERE care_setting IS NULL | ||
</sqlCheck> | ||
</not> | ||
</preConditions> | ||
<comment>Set default value for orders.care_setting column for existing rows</comment> | ||
<sql splitStatements="false"> | ||
<![CDATA[ | ||
update orders set care_setting = (select care_setting_id from care_setting where care_setting_type = 'OUTPATIENT' limit 1) | ||
where care_setting is null; | ||
]]> | ||
</sql> | ||
</changeSet> | ||
|
||
<changeSet id="201312271828-TRUNK-4156" author="vinay"> | ||
<comment>Make care_setting column non-nullable</comment> | ||
<addNotNullConstraint tableName="orders" columnName="care_setting" columnDataType="int(11)"/> | ||
</changeSet> | ||
|
||
|
||
<changeSet id="201312271829-TRUNK-4156" author="vinay"> | ||
<preConditions onFail="MARK_RAN"> | ||
<not><foreignKeyConstraintExists foreignKeyName="orders_care_setting"/></not> | ||
</preConditions> | ||
<comment>Add foreign key constraint</comment> | ||
<addForeignKeyConstraint constraintName="orders_care_setting" | ||
baseTableName="orders" baseColumnNames="care_setting" | ||
referencedTableName="care_setting" referencedColumnNames="care_setting_id"/> | ||
</changeSet> | ||
</databaseChangeLog> |
41 changes: 41 additions & 0 deletions
41
api/src/main/resources/org/openmrs/api/db/hibernate/CareSetting.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE hibernate-mapping PUBLIC | ||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | ||
<hibernate-mapping> | ||
|
||
<class name="org.openmrs.CareSetting" table="care_setting"> | ||
|
||
<id name="careSettingId" type="java.lang.Integer" column="care_setting_id" unsaved-value="0"> | ||
<generator class="native"> | ||
<param name="sequence">care_setting_care_setting_id_seq</param> | ||
</generator> | ||
</id> | ||
|
||
<property name="careSettingType" column="care_setting_type" length="50" not-null="true"> | ||
<type name="org.openmrs.util.HibernateEnumType"> | ||
<param name="enumClassName">org.openmrs.CareSetting$CareSettingType</param> | ||
</type> | ||
</property> | ||
|
||
<property name="name" type="java.lang.String" | ||
not-null="true" length="255" /> | ||
<property name="description" type="java.lang.String" | ||
not-null="true" length="255" /> | ||
<property name="dateCreated" type="java.util.Date" | ||
column="date_created" not-null="true" length="19" /> | ||
<many-to-one name="creator" class="org.openmrs.User" | ||
not-null="true" /> | ||
<property name="uuid" type="java.lang.String" | ||
column="uuid" length="38" unique="true" /> | ||
<many-to-one name="retiredBy" class="org.openmrs.User" | ||
column="retired_by" /> | ||
<property name="dateRetired" type="java.util.Date" | ||
column="date_retired" length="19" /> | ||
<property name="retireReason" type="java.lang.String" | ||
column="retire_reason" length="255" /> | ||
<property name="retired" type="boolean" | ||
length="1" not-null="true" /> | ||
|
||
</class> | ||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Are we intentionally having the same uuid for the in patient and out patient care settings?