diff --git a/src/main/resources/procedureSql/dischargeDateProc.sql b/src/main/resources/procedureSql/dischargeDateProc.sql index 49e1931d..9261e87b 100644 --- a/src/main/resources/procedureSql/dischargeDateProc.sql +++ b/src/main/resources/procedureSql/dischargeDateProc.sql @@ -12,10 +12,10 @@ FROM bed_patient_assignment_default bpam WHERE bpam.location = locationName AND patient_id = patientId AND date_started = dateStopped LIMIT 1; -if current_patient = patientId AND curr_start_date = dateStopped THEN +if current_patient = patientId AND curr_start_date = dateStopped AND curr_start_date != curr_stop_date THEN RETURN discharge_date(current_patient, locationName, curr_stop_date); ELSE RETURN dateStopped; END IF ; END; -$$ LANGUAGE plpgsql; \ No newline at end of file +$$ LANGUAGE plpgsql;