Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#TRUNK-4126] Add duration and durationUnits properties to DrugOrder class #486

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions api/src/main/java/org/openmrs/DrugOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public enum DosingType {

private String dosingInstructions;

private Double duration;

private Concept durationUnits;

// Constructors

/** default constructor */
Expand Down Expand Up @@ -89,6 +93,8 @@ protected DrugOrder copyHelper(DrugOrder target) {
target.drug = getDrug();
target.dosingType = getDosingType();
target.dosingInstructions = getDosingInstructions();
target.duration = getDuration();
target.durationUnits = getDurationUnits();
return target;
}

Expand Down Expand Up @@ -336,6 +342,44 @@ public String getDosingInstructions() {
return this.dosingInstructions;
}

/**
* Gets the duration of a Drug Order
*
* @since 1.10
*/
public Double getDuration() {
return duration;
}

/**
* Sets the duration of a Drug Order
*
* @param duration to set
* @since 1.10
*/
public void setDuration(Double duration) {
this.duration = duration;
}

/**
* Gets durationUnits of a Drug Order
*
* @since 1.10
*/
public Concept getDurationUnits() {
return durationUnits;
}

/**
* Sets the durationUnits of a Drug Order
*
* @param durationUnits
* @since 1.10
*/
public void setDurationUnits(Concept durationUnits) {
this.durationUnits = durationUnits;
}

public String toString() {
return "DrugOrder(" + getDose() + getUnits() + " of " + (getDrug() != null ? getDrug().getName() : "[no drug]")
+ " from " + getStartDate() + " to " + (getDiscontinued() ? getDiscontinuedDate() : getAutoExpireDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public <o extends Order> o getOrder(Integer orderId, Class<o> orderClassType) th
* java.util.List, java.util.List)
*/
public <Ord extends Order> List<Ord> getOrders(Class<Ord> orderClassType, List<Patient> patients,
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
if (orderClassType == null)
throw new APIException(
"orderClassType cannot be null. An order type of Order.class or DrugOrder.class is required");
Expand Down
27 changes: 27 additions & 0 deletions api/src/main/resources/liquibase-update-to-latest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6599,5 +6599,32 @@
</column>
</addColumn>
</changeSet>

<changeSet id="201312162044-TRUNK-4126" author="k-joseph">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="drug_order" columnName="duration" />
</not>
</preConditions>
<comment>Adding duration column to drug_order table</comment>
<addColumn tableName="drug_order">
<column name="duration" type="double" />
</addColumn>
</changeSet>

<changeSet id="201312162059-TRUNK-4126" author="k-joseph">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="drug_order" columnName="duration_units" />
</not>
</preConditions>
<comment>Adding duration_units column to drug_order table</comment>
<addColumn tableName="drug_order">
<column name="duration_units" type="int" />
</addColumn>
<addForeignKeyConstraint constraintName="drug_order_duration_units_fk"
baseTableName="drug_order" baseColumnNames="duration_units"
referencedTableName="concept" referencedColumnNames="concept_id" />
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
<property name="numRefills" type="int" column="num_refills" />
<property name="administrationInstructions" type="java.lang.String" column="administration_instructions" length="65535"/>
<property name="dosingInstructions" type="java.lang.String" column="dosing_instructions" length="65535"/>
<property name="duration" type="double" column="duration" length="22"/>
<many-to-one name="durationUnits" class="org.openmrs.Concept">
<column name="duration_units"/>
</many-to-one>
</joined-subclass>

<joined-subclass name="org.openmrs.TestOrder" table="test_order" lazy="false">
Expand Down