forked from HospitalRun/hospitalrun-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into feat/opd-report
- Loading branch information
Showing
57 changed files
with
709 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import AppointmentIndexController from 'hospitalrun/appointments/index/controller'; | ||
import AppointmentStatuses from 'hospitalrun/mixins/appointment-statuses'; | ||
import moment from 'moment'; | ||
import VisitTypes from 'hospitalrun/mixins/visit-types'; | ||
import SelectValues from 'hospitalrun/utils/select-values'; | ||
import Ember from 'ember'; | ||
|
||
const { | ||
computed, | ||
computed: { | ||
alias | ||
}, | ||
get, | ||
inject, | ||
isEmpty, | ||
set | ||
} = Ember; | ||
|
||
export default AppointmentIndexController.extend(AppointmentStatuses, VisitTypes, { | ||
appointmentType: null, | ||
endDate: null, | ||
location: null, | ||
provider: null, | ||
queryParams: ['appointmentType', 'endDate', 'provider', 'status', 'startDate', 'location', 'viewType'], | ||
startDate: null, | ||
status: null, | ||
viewType: 'agendaWeek', | ||
|
||
appointmentsController: inject.controller('appointments'), | ||
locations: alias('appointmentsController.locationList.value'), | ||
physicians: alias('appointmentsController.physicianList.value'), | ||
|
||
calendarDate: computed('startDate', function() { | ||
let startDate = get(this, 'startDate'); | ||
if (!isEmpty(startDate)) { | ||
return moment(parseInt(startDate)); | ||
} | ||
}), | ||
|
||
locationList: computed('locations', function() { | ||
return SelectValues.selectValues(get(this, 'locations'), true); | ||
}), | ||
|
||
physicianList: computed('physicians', function() { | ||
return SelectValues.selectValues(get(this, 'physicians'), true); | ||
}), | ||
|
||
_getSelectedFilteringCriteria() { | ||
let rawCriteria = { | ||
status: get(this, 'model.selectedStatus'), | ||
type: get(this, 'model.selectedAppointmentType'), | ||
provider: get(this, 'model.selectedProvider'), | ||
location: get(this, 'model.selectedLocation') | ||
}; | ||
|
||
return { | ||
status: isEmpty(rawCriteria.status) ? null : rawCriteria.status, | ||
type: isEmpty(rawCriteria.type) ? null : rawCriteria.type, | ||
provider: isEmpty(rawCriteria.provider) ? null : rawCriteria.provider, | ||
location: isEmpty(rawCriteria.location) ? null : rawCriteria.location | ||
}; | ||
}, | ||
|
||
actions: { | ||
clearFilteringCriteria() { | ||
set(this, 'model.selectedStatus', null); | ||
set(this, 'model.selectedAppointmentType', null); | ||
set(this, 'model.selectedProvider', null); | ||
set(this, 'model.selectedLocation', null); | ||
this.send('filter'); | ||
}, | ||
|
||
createNewAppointment(dateClicked) { | ||
let newAppointment = this.store.createRecord('appointment', { | ||
appointmentType: 'Admission', | ||
allDay: false, | ||
selectPatient: true, | ||
startDate: dateClicked.local().toDate() | ||
}); | ||
this.send('editAppointment', newAppointment); | ||
}, | ||
|
||
filter() { | ||
let criteria = this._getSelectedFilteringCriteria(); | ||
this.setProperties({ | ||
appointmentType: criteria.type, | ||
provider: criteria.provider, | ||
status: criteria.status, | ||
location: criteria.location | ||
}); | ||
}, | ||
|
||
handleVisualConfigurationChanged(newConfiguration) { | ||
this.setProperties(newConfiguration); | ||
}, | ||
|
||
navigateToAppointment(calendarEvent) { | ||
this.send('editAppointment', calendarEvent.referencedAppointment); | ||
}, | ||
|
||
updateAppointment(calendarEvent) { | ||
let appointmentToUpdate = calendarEvent.referencedAppointment; | ||
let newEnd = calendarEvent.end.local().toDate(); | ||
let newStart = calendarEvent.start.local().toDate(); | ||
set(appointmentToUpdate, 'startDate', newStart); | ||
set(appointmentToUpdate, 'endDate', newEnd); | ||
appointmentToUpdate.save().catch((error) => { | ||
this.send('error', error, 'appointments.calendar'); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import AppointmentIndexRoute from 'hospitalrun/appointments/index/route'; | ||
import Ember from 'ember'; | ||
import { translationMacro as t } from 'ember-i18n'; | ||
|
||
const { | ||
get, | ||
isEmpty | ||
} = Ember; | ||
|
||
export default AppointmentIndexRoute.extend({ | ||
|
||
dateIntervalEnd: null, | ||
dateIntervalStart: null, | ||
editReturn: 'appointments.calendar', | ||
filterParams: ['appointmentType', 'provider', 'status', 'location'], | ||
modelName: 'appointment', | ||
pageTitle: t('appointments.calendarTitle'), | ||
|
||
queryParams: { | ||
appointmentType: { refreshModel: true }, | ||
endDate: { refreshModel: true }, | ||
provider: { refreshModel: true }, | ||
status: { refreshModel: true }, | ||
startDate: { refreshModel: true }, | ||
location: { refreshModel: true }, | ||
viewType: { refreshModel: false } | ||
}, | ||
|
||
model(params) { | ||
function createCalendarEvent(appointment) { | ||
let title = get(appointment, 'patient.displayName'); | ||
let provider = get(appointment, 'provider'); | ||
if (!isEmpty(provider)) { | ||
title = `${title}\n${provider}`; | ||
} | ||
return { | ||
allDay: get(appointment, 'allDay'), | ||
title, | ||
start: get(appointment, 'startDate'), | ||
end: get(appointment, 'endDate'), | ||
referencedAppointment: appointment | ||
}; | ||
} | ||
|
||
function createCalendarEvents(appointments) { | ||
return appointments.map(createCalendarEvent); | ||
} | ||
|
||
return this._super(params) | ||
.then(createCalendarEvents) | ||
.then(function(calendarEvents) { | ||
return { | ||
events: calendarEvents, | ||
selectedAppointmentType: params.appointmentType, | ||
selectedProvider: params.provider, | ||
selectedStatus: params.status, | ||
selectedLocation: params.location | ||
}; | ||
}); | ||
}, | ||
|
||
_modelQueryParams(params) { | ||
let { endDate, startDate } = params; | ||
|
||
if (endDate === null || startDate === null) { | ||
return this._super(params); | ||
} | ||
let maxValue = get(this, 'maxValue'); | ||
let searchOptions = { | ||
startkey: [parseInt(startDate), null, this._getMinPouchId()], | ||
endkey: [parseInt(endDate), maxValue, this._getMaxPouchId()] | ||
}; | ||
|
||
return { | ||
options: searchOptions, | ||
mapReduce: 'appointments_by_date' | ||
}; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="panel panel-info"> | ||
<div class="panel-body"> | ||
{{#em-form model=model submitButton=false}} | ||
<div class="row"> | ||
{{em-select class="col-sm-3 form-input-group" | ||
label=(t "labels.status") | ||
property="selectedStatus" | ||
content=appointmentStatusesWithEmpty | ||
}} | ||
{{em-select class="col-sm-3 form-input-group" | ||
label=(t "labels.type") | ||
property="selectedAppointmentType" | ||
content=visitTypesWithEmpty | ||
}} | ||
{{em-select class="col-sm-3 form-input-group" | ||
label=(t 'labels.with') | ||
property="selectedProvider" | ||
content=physicianList | ||
}} | ||
{{em-select class="col-sm-3 form-input-group" | ||
label=(t 'labels.location') | ||
property="selectedLocation" | ||
content=locationList | ||
}} | ||
</div> | ||
{{/em-form}} | ||
<div class="panel-footer"> | ||
<button class="btn btn-default warning" {{action 'clearFilteringCriteria'}}>{{t 'buttons.clear'}}</button> | ||
<button class="btn btn-default" {{action 'filter'}}>{{t 'buttons.filter'}}</button> | ||
</div> | ||
{{calendar-control events=model.events | ||
defaultDate=calendarDate | ||
defaultView=viewType | ||
onDayClick=(action "createNewAppointment") | ||
onEventClick=(action "navigateToAppointment") | ||
onEventDrop=(action "updateAppointment") | ||
onEventResize=(action "updateAppointment") | ||
onVisualConfigurationChanged=(action "handleVisualConfigurationChanged") | ||
userCanEdit=canEdit | ||
}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.