Skip to content

Commit

Permalink
O3-2382 Add column to denote patient previous queue
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Sep 14, 2023
1 parent 9e4b21c commit 6c4f77c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public class QueueEntry extends BaseChangeableOpenmrsData {
@JoinColumn(name = "provider_waiting_for", referencedColumnName = "provider_id")
private Provider providerWaitingFor;

//The Location the patient is coming from, if any.
//The queue the patient is coming from, if any.
@OneToOne
@JoinColumn(name = "location_coming_from", referencedColumnName = "queue_id")
private Queue locationComingFrom;
@JoinColumn(name = "queue_coming_from", referencedColumnName = "queue_id")
private Queue queueComingFrom;

@Column(name = "started_at", nullable = false)
private Date startedAt;
Expand Down
23 changes: 23 additions & 0 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,27 @@
</preConditions>
<addForeignKeyConstraint baseColumnNames="location_coming_from" baseTableName="queue_entry" constraintName="queue_entry_location_coming_from_id_fk" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="queue_id" referencedTableName="queue"/>
</changeSet>

<changeSet id="rename_queue_entry_location_coming_from_column_20230914" author="cynthiakamau" dbms="mysql">
<preConditions onFail="MARK_RAN">
<columnExists tableName="queue_entry" columnName="location_coming_from"/>
</preConditions>
<comment>Rename location_coming_from to queue_coming_from</comment>
<renameColumn tableName="queue_entry" oldColumnName="location_coming_from" newColumnName="queue_coming_from" columnDataType="int" />
</changeSet>

<changeSet id="drop_queue_entry_location_coming_from_fk_20230914" author="cynthiakamau" dbms="mysql">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="queue_entry_location_coming_from_id_fk" />
</preConditions>
<comment>Dropping foreign key on location_coming_from in queue_entry table</comment>
<dropForeignKeyConstraint baseTableName="queue_entry" constraintName="queue_entry_location_coming_from_id_fk"/>
</changeSet>

<changeSet id="add_queue_entry_queue_coming_from_fk_20230914" author="cynthiakamau">
<preConditions onFail="MARK_RAN">
<columnExists tableName="queue_entry" columnName="queue_coming_from"/>
</preConditions>
<addForeignKeyConstraint baseColumnNames="queue_coming_from" baseTableName="queue_entry" constraintName="queue_entry_queue_coming_from_id_fk" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="queue_id" referencedTableName="queue"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
description.addProperty("sortWeight");
description.addProperty("startedAt");
description.addProperty("locationWaitingFor");
description.addProperty("locationComingFrom");
description.addProperty("queueComingFrom");
description.addProperty("providerWaitingFor");
return description;
}
Expand All @@ -120,7 +120,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
resourceDescription.addProperty("patient", Representation.REF);
resourceDescription.addProperty("priority", Representation.REF);
resourceDescription.addProperty("locationWaitingFor", Representation.REF);
resourceDescription.addProperty("locationComingFrom", Representation.REF);
resourceDescription.addProperty("queueComingFrom", Representation.REF);
resourceDescription.addProperty("providerWaitingFor", Representation.REF);
resourceDescription.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
} else if (representation instanceof DefaultRepresentation) {
Expand All @@ -130,7 +130,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
resourceDescription.addProperty("patient", Representation.DEFAULT);
resourceDescription.addProperty("priority", Representation.DEFAULT);
resourceDescription.addProperty("locationWaitingFor", Representation.DEFAULT);
resourceDescription.addProperty("locationComingFrom", Representation.DEFAULT);
resourceDescription.addProperty("queueComingFrom", Representation.DEFAULT);
resourceDescription.addProperty("providerWaitingFor", Representation.DEFAULT);
resourceDescription.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
} else if (representation instanceof FullRepresentation) {
Expand All @@ -143,7 +143,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
resourceDescription.addProperty("patient", Representation.FULL);
resourceDescription.addProperty("priority", Representation.FULL);
resourceDescription.addProperty("locationWaitingFor", Representation.FULL);
resourceDescription.addProperty("locationComingFrom", Representation.FULL);
resourceDescription.addProperty("queueComingFrom", Representation.FULL);
resourceDescription.addProperty("providerWaitingFor", Representation.FULL);
} else if (representation instanceof CustomRepresentation) {
//Let the user decide
Expand Down

0 comments on commit 6c4f77c

Please sign in to comment.