Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public Optional<Q> get(int id) {
public Optional<Q> get(@NotNull String uuid) {
Criteria criteria = getCurrentSession().createCriteria(getClazz());
includeVoidedObjects(criteria, false);
criteria.add(eq("uuid", uuid)).uniqueResult();
return Optional.ofNullable((Q) criteria.add(eq("uuid", uuid)).uniqueResult());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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 @@ -89,7 +88,7 @@ public class QueueEntry extends BaseChangeableOpenmrsData {

//The queue the patient is coming from, if any.
@ToString.Exclude
@OneToOne
@ManyToOne
Comment thread
UjjawalPrabhat marked this conversation as resolved.
@JoinColumn(name = "queue_coming_from", referencedColumnName = "queue_id")
private Queue queueComingFrom;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.models.properties.StringProperty;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.openmrs.Patient;
import org.openmrs.PersonName;
import org.openmrs.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
Expand Down Expand Up @@ -281,8 +282,12 @@ private void addSharedResourceDescriptionProperties(DelegatingResourceDescriptio

@PropertyGetter("display")
public String getDisplay(QueueEntry queueEntry) {
PersonName personName = queueEntry.getPatient().getPersonName();
return (personName == null ? queueEntry.getPatient().toString() : personName.getFullName());
Patient patient = queueEntry.getPatient();
if (patient == null) {
return queueEntry.getUuid();
}
Comment thread
UjjawalPrabhat marked this conversation as resolved.
PersonName personName = patient.getPersonName();
return (personName == null ? patient.toString() : personName.getFullName());
}

@PropertyGetter("previousQueueEntry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.*;
import lombok.Setter;
import org.openmrs.Patient;
import org.openmrs.PersonName;
import org.openmrs.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria;
Expand Down Expand Up @@ -232,10 +234,12 @@ public Model getGETModel(Representation rep) {
@PropertyGetter("display")
public String getDisplay(QueueEntry queueEntry) {
//Display patient name
if (queueEntry.getPatient().getPerson().getPersonName() == null) {
return "";
Patient patient = queueEntry.getPatient();
if (patient == null) {
return queueEntry.getUuid();
}
return queueEntry.getPatient().getPerson().getPersonName().getFullName();
PersonName personName = patient.getPersonName();
return (personName == null ? patient.toString() : personName.getFullName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ public void shouldSearchQueueEntriesByIncludeVoidedFalse() {
assertThat(criteria.isIncludedVoided(), equalTo(false));
}

@Test
public void shouldReturnUuidForDisplayWhenPatientIsNull() {
assertThat(resource.getDisplay(queueEntry), is(QUEUE_ENTRY_UUID));
}

@Test
public void shouldReturnPatientToStringForDisplayWhenPatientHasNoUnvoidedName() {
Patient patient = new Patient();
patient.setPatientId(7);
queueEntry.setPatient(patient);

assertThat(resource.getDisplay(queueEntry), is("Patient#7"));
}

@Test
public void shouldInstantiateNewDelegate() {
assertThat(getResource().newDelegate(), notNullValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openmrs.Patient;
import org.openmrs.api.ConceptService;
import org.openmrs.api.LocationService;
import org.openmrs.api.PatientService;
Expand Down Expand Up @@ -143,6 +144,20 @@ public void shouldCreateNewResource() {
assertThat(newlyCreatedObject.getUuid(), is(QUEUE_ENTRY_UUID));
}

@Test
public void shouldReturnUuidForDisplayWhenPatientIsNull() {
assertThat(getResource().getDisplay(queueEntry), is(QUEUE_ENTRY_UUID));
}

@Test
public void shouldReturnPatientToStringForDisplayWhenPatientHasNoUnvoidedName() {
Patient patient = new Patient();
patient.setPatientId(7);
when(queueEntry.getPatient()).thenReturn(patient);

assertThat(getResource().getDisplay(queueEntry), is("Patient#7"));
}

@Test
public void shouldInstantiateNewDelegate() {
assertThat(getResource().newDelegate(), notNullValue());
Expand Down