Skip to content

Commit

Permalink
(feat) Add location coming from in queue entry model (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau authored Aug 29, 2023
1 parent 8840ae1 commit 9e4b21c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import java.util.Date;
Expand Down Expand Up @@ -80,6 +81,11 @@ 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.
@OneToOne
@JoinColumn(name = "location_coming_from", referencedColumnName = "queue_id")
private Queue locationComingFrom;

@Column(name = "started_at", nullable = false)
private Date startedAt;

Expand Down
21 changes: 21 additions & 0 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,25 @@
TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 86400, TRUE, 1, NOW(), UUID());
</sql>
</changeSet>

<changeSet id="add_location_coming_from_column_to_queue_entry_20230809" author="cynthiakamau">
<preConditions onError="WARN" onFail="MARK_RAN">
<tableExists tableName="queue_entry"/>
<not><columnExists tableName="queue_entry" columnName="location_coming_from"/></not>
</preConditions>
<comment>
Add column location_coming_from to queue entry table
</comment>
<addColumn tableName="queue_entry">
<column name="location_coming_from" type="int">
</column>
</addColumn>
</changeSet>

<changeSet id="add_queue_entry_location_coming_from_fk_20230809" author="cynthiakamau">
<preConditions onFail="MARK_RAN">
<columnExists tableName="queue_entry" columnName="location_coming_from"/>
</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>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
description.addProperty("sortWeight");
description.addProperty("startedAt");
description.addProperty("locationWaitingFor");
description.addProperty("locationComingFrom");
description.addProperty("providerWaitingFor");
return description;
}
Expand All @@ -119,6 +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("providerWaitingFor", Representation.REF);
resourceDescription.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
} else if (representation instanceof DefaultRepresentation) {
Expand All @@ -128,6 +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("providerWaitingFor", Representation.DEFAULT);
resourceDescription.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
} else if (representation instanceof FullRepresentation) {
Expand All @@ -140,6 +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("providerWaitingFor", Representation.FULL);
} else if (representation instanceof CustomRepresentation) {
//Let the user decide
Expand Down

0 comments on commit 9e4b21c

Please sign in to comment.