forked from IMA-WorldHealth/bhima
-
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 pull request #452 from mbayopanda/patient_document_preview
Patient document preview
- Loading branch information
Showing
17 changed files
with
495 additions
and
86 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
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,117 @@ | ||
angular.module('bhima.components') | ||
.component('bhFindDocument', { | ||
controller : FindDocumentComponent, | ||
controllerAs : '$ctrl', | ||
templateUrl : 'partials/templates/bhFindDocument.tmpl.html', | ||
bindings: { | ||
enablePatientDetails : '<', // bind boolean (true|false) : Enable patient details option | ||
enableOptionBar : '<', // bind boolean (true|false) : Enable option for add, display list or display thumbnail in a bar | ||
enableSearch : '<', // bind boolean (true|false) : Enable search bar option | ||
display : '@', // bind (list|thumbnail) : Display either in list or thumbnail mode | ||
patientUuid : '<' // Required patient uuid | ||
} | ||
}); | ||
|
||
FindDocumentComponent.$inject = [ | ||
'PatientService', 'ModalService', 'DocumentService', | ||
'NotifyService', 'UserService', '$translate' | ||
]; | ||
|
||
/** | ||
* Find Document Component | ||
* This component is responsible for displaying documents for specific patient given | ||
*/ | ||
function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translate) { | ||
var vm = this; | ||
|
||
/** global variables */ | ||
vm.session = { | ||
patientUuid : this.patientUuid, | ||
enablePatientDetails : Boolean(this.enablePatientDetails), | ||
enableOptionBar : Boolean(this.enableOptionBar), | ||
enableSearch : Boolean(this.enableSearch), | ||
display : this.display, | ||
showAction : false | ||
}; | ||
|
||
/** expose to the view */ | ||
vm.switchDisplay = switchDisplay; | ||
vm.toggleAction = toggleAction; | ||
vm.addDocument = addDocument; | ||
vm.deleteDocument = deleteDocument; | ||
vm.mimeIcon = mimeIcon; | ||
|
||
// startup the component | ||
startup(); | ||
|
||
/** function switchDisplay */ | ||
function switchDisplay(mode) { | ||
vm.session.display = mode; | ||
} | ||
|
||
/** toggle document actions */ | ||
function toggleAction(index) { | ||
vm.selectedIndex = index; | ||
vm.session.showAction = vm.session.showAction === true ? false : true; | ||
} | ||
|
||
/** function add documents modal */ | ||
function addDocument() { | ||
Modal.openUploadDocument({ patient_uuid: vm.session.patientUuid }) | ||
.then(startup); | ||
} | ||
|
||
/** delete document */ | ||
function deleteDocument(uuid) { | ||
Modal.confirm($translate.instant('FORM.DIALOGS.CONFIRM_DELETE')) | ||
.then(function (ans) { | ||
if (!ans) { return; } | ||
|
||
return Document.remove(vm.session.patientUuid, uuid) | ||
.then(function () { | ||
Notify.success('FORM.INFOS.DELETE_SUCCESS'); | ||
startup(); | ||
}); | ||
|
||
}) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
/** getting patient document */ | ||
function startup() { | ||
if (!vm.session.patientUuid) { return; } | ||
|
||
Patient.read(vm.session.patientUuid) | ||
.then(function (patient) { | ||
vm.session.patient = patient; | ||
}) | ||
.catch(Notify.handleError); | ||
|
||
Document.read(vm.session.patientUuid) | ||
.then(function (documents) { | ||
vm.session.patientDocuments = documents; | ||
}) | ||
.catch(Notify.handleError); | ||
} | ||
|
||
/** format the image type */ | ||
function mimeIcon(mimetype) { | ||
var result = {}; | ||
|
||
if (mimetype.indexOf('image') > -1) { | ||
result = { icon : 'fa-file-image-o', label : 'Image' }; | ||
} else if (mimetype.indexOf('pdf') > -1) { | ||
result = { icon : 'fa-file-pdf-o', label : 'PDF' }; | ||
} else if (mimetype.indexOf('word') > -1) { | ||
result = { icon : 'fa-file-word-o', label : 'MS WORD' }; | ||
} else if (mimetype.indexOf('sheet') > -1) { | ||
result = { icon : 'fa-file-excel-o', label : 'MS EXCEL' }; | ||
} else if (mimetype.indexOf('presentation') > -1) { | ||
result = { icon : 'fa-file-powerpoint-o', label : 'MS Power Point' }; | ||
} else { | ||
result = { icon : 'fa-file-o', label : 'Fichier' }; | ||
}; | ||
|
||
return result; | ||
} | ||
} |
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,23 @@ | ||
angular.module('bhima.filters') | ||
.filter('bytes', BytesFilter); | ||
|
||
BytesFilter.$inject = ['$translate']; | ||
|
||
/** | ||
* Bytes Filter | ||
* Format bytes size to human readable format | ||
*/ | ||
function BytesFilter($translate) { | ||
return function(bytes, precision) { | ||
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) { return '-'; } | ||
if (typeof precision === 'undefined') { precision = 1; } | ||
var units = ['SIZE_BYTES', 'SIZE_KB', 'SIZE_MB', 'SIZE_GB', 'SIZE_TB', 'SIZE_TB'], | ||
number = Math.floor(Math.log(bytes) / Math.log(1024)); | ||
|
||
units = units.map(function (unit) { | ||
return $translate.instant('FORM.LABELS.' + unit); | ||
}); | ||
|
||
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number]; | ||
} | ||
} |
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.