Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DinhNgocAnh committed May 9, 2020
1 parent b9b7c43 commit 2f5d5a7
Show file tree
Hide file tree
Showing 23 changed files with 1,797 additions and 1,743 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
18. project_admin_app
19. site_pages_app

# Document modules
# Admin functions
## Manage users
- Add user
- Edit user
- Deactive user

# Document modules
## Patient Administration
2 changes: 1 addition & 1 deletion apps/users_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ def set_user_medicare(request, patient_id):
resp = {'success': False}

user_profile = UserProfile.objects.get(user_id=patient_id)
user_profile.insurance_medicare = request.POST.get('medicare', False)
user_profile.insurance_medicare = "true" == request.POST.get('medicare')
user_profile.insurance_note = request.POST.get('note', '')
user_profile.save()

Expand Down
2 changes: 2 additions & 0 deletions static/apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Frontend include 3 module based on system roles
- All component (Have controller, template)filter
- All filters (Each filter is single file)
- All services (Each service is single file)
Date format: MM/DD/YYYY


TODO list
[ ] Unify how datepicker is initialized.
Expand Down
2 changes: 1 addition & 1 deletion static/apps/admin/admin.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
(function () {
'use strict';
angular.module('AdminApp', ['app.services', 'app.directives', 'ngRoute', 'ngCookies', 'ngDialog', 'toaster', '720kb.datepicker'])
angular.module('AdminApp', ['app.services', 'app.directives','app.constant', 'ngRoute', 'ngCookies', 'ngDialog', 'toaster', '720kb.datepicker'])
.config(function ($routeProvider, $httpProvider) {
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
Expand Down
29 changes: 28 additions & 1 deletion static/apps/common/constants.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
(function () {
'use strict';
angular.module('app.constant', [])
.constant('ROLES', {
ADMIN: 'nurse',
PHYSICIAN: 'doctor',
NURSE: 'nurse',
SECRETARY: 'secretary',
MID_LEVEL: 'mid-level',
PATIENT: 'patient'
})
.constant('RECORDER_STATUS', {
isRecording: 0,
isPaused: 1,
Expand Down Expand Up @@ -51,5 +59,24 @@
.constant('PROBLEM_NOTE_TYPE', {
WIKI: 'wiki',
HISTORY: 'history'
});
})
.constant('LABELS', [
{name: 'green', css_class: 'todo-label-green'},
{name: 'yellow', css_class: 'todo-label-yellow'},
{name: 'orange', css_class: 'todo-label-orange'},
{name: 'red', css_class: 'todo-label-red'},
{name: 'purple', css_class: 'todo-label-purple'},
{name: 'blue', css_class: 'todo-label-blue'},
{name: 'sky', css_class: 'todo-label-sky'},
])
.constant('DATEPICKER_OPTS', {
showWeeks: false,
startingDay: 1
})
.constant('VIEW_MODES', [
{label: 'All', value: 0},
{label: 'Week', value: 1},
{label: 'Month', value: 2},
{label: 'Year', value: 3},
]);
})();
1 change: 1 addition & 0 deletions static/apps/common/services/patient.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

angular.module('app.services')
.service('patientService', function ($http, $q, $cookies, $rootScope, $filter, httpService) {
console.log("service");
return {
activeUser: null,
patientInfo: null,
Expand Down
300 changes: 300 additions & 0 deletions static/apps/common/services/shared.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
/*
* Copyright (c) Small Brain Records 2014-2020. Kevin Perdue, James Ryan with contributors Timothy Clemens and Dinh Ngoc Anh
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
(function () {

'use strict';

angular.module('sharedModule').service('sharedService', sharedService);
sharedService.$inject = ['$http', '$cookies', 'Upload', 'httpService'];

function sharedService($http, $cookies, Upload, httpService) {
return {
settings: {},
uploadDocument: uploadDocument,
addCommonProblem: addCommonProblem,
deleteDocumentTag: deleteDocumentTag,
pinLabelToDocument: pinLabelToDocument,
unpinDocumentLabel: unpinDocumentLabel,
unpinDocumentProblem: unpinDocumentProblem,
unpinDocumentTodo: unpinDocumentTodo,
getDocumentInfo: getDocumentInfo,
removeDocument: removeDocument,
getUploadedDocument: getUploadedDocument,
getSettings: getSettings,
updateSettings: updateSettings,
fetchPatientInfo: fetchPatientInfo,
fetchActiveUser: fetchActiveUser,
fetchPatientTodos: fetchPatientTodos,
fetchProblems: fetchProblems,
addToDo: addToDo,
addProblem: addProblem,
listTerms: listTerms,
getTodoList: getTodoList,
getPendingRegistrationUsersList: getPendingRegistrationUsersList,
approveUser: approveUser,
rejectUser: rejectUser,
};

/**
* Upload multiple documentation
* @param files
* @param author
* @param patient
* @param callback
*/
function uploadDocument(files, author, patient, callback) {
if (files && files.length) {
for (let i = 0; i < files.length; i++) {
let file = files[i];
if (!file.$error) {
Upload.upload({
url: '/docs/upload_document',
data: {
author: author, // File owner
patient: patient, // Primary pinned patient
file: file // File itself
},
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
}).then(function (resp) {
callback(resp);
}, function (resp) {
}, function (evt) {
});
}
}
}
}

/**
*
* @param document Id of document will be delete
* @param tag_id Id of tag item will be deleted
* @param tag_type Type of tagging document 'problem' or 'todo'
* @param del_in_sys Flag indicate will file be deleted in system or not
*/
function deleteDocumentTag(document, tag_id, tag_type, del_in_sys) {
del_in_sys = del_in_sys === undefined ? false : del_in_sys;
return $http.post(`/docs/delete/${document.id}`, {
'document': document.id,
'del_tag_id': tag_id.id,
'del_tag_type': tag_type,
'del_in_sys': del_in_sys
}, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
})
}

/**
* Add a label to document
* @param document
* @param label
*/
function pinLabelToDocument(document, label) {
return $http.post('/docs/pin/label', {
document: document.id,
label: label.id
}, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

/**
* Remove a label in document
* @param document
* @param label
*/
function unpinDocumentLabel(document, label) {
return $http.post('/docs/remove/label', {
document: document.id,
label: label.id
}, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

/**
* Remove an pinned problem in document
* @param document
* @param problem
*/
function unpinDocumentProblem(document, problem) {
return $http.post('/docs/unpin/problem', {
document: document.id,
problem: problem.id
}, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

/**
* Remove an pinned todo in document
* @param document
* @param todo
*/
function unpinDocumentTodo(document, todo) {
return $http.post('/docs/unpin/todo', {
document: document.id,
todo: todo.id
}, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

/**
*
* @param documentId
*/
function getDocumentInfo(documentId) {
return $http.get(`/docs/info/${documentId}`);
}

/**
*
* @param document
*/
function removeDocument(document) {
return $http.post(`/docs/remove/${document.id}`, null, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

/**
* Get list of document user have uploaded
*/
function getUploadedDocument() {
return $http.get('/docs/list');
}

function getSettings() {
return $http.get('/u/setting');
}

function updateSettings(settingObj) {
return $http.post('/u/update_setting', settingObj, {
headers: {
'X-CSRFToken': $cookies.get('csrftoken')
}
});
}

function fetchPatientInfo(patient_id) {
var url = `/u/patient/${patient_id}/info`;

return $http.get(url);

}

function fetchActiveUser() {
var url = '/u/active/user/';
return $http.get(url);
}

function fetchPatientTodos(patient_id) {
var url = `/u/patient/${patient_id}/patient_todos_info`;

return $http.get(url);

}

function fetchProblems(patient_id) {
var url = `/p/problem/${patient_id}/getproblems`;
return $http.get(url);
}

function addToDo(form) {

var url = `/todo/patient/${form.patient_id}/todos/add/new_todo`;

return httpService.post(form, url);


}


function addProblem(form) {

var url = `/p/patient/${form.patient_id}/problems/add/new_problem`;

return httpService.post(form, url);


}

function listTerms(query) {

var params = {'query': query};
var url = "/list_terms/";

return httpService.get(params, url);


}

function addCommonProblem(form) {
var url = `/p/patient/${form.patient_id}/problems/add/new_common_problem`;

return httpService.post(form, url);
}

/**
* Condition
* @param userID
* @param isAccomplished
* @param loadAll
*/
function getTodoList(userID, isAccomplished = false, loadAll = false) {
return httpService.get({
accomplished: isAccomplished,
all: true
}, `/u/users/${userID}/todos`, true)
}

function getPendingRegistrationUsersList(form) {
let params = form;
let url = '/project/admin/list/unregistered/users/';
return httpService.get(params, url);
}

function approveUser(user) {

let form = user;
let url = '/project/admin/user/approve/';
return httpService.post(form, url);

}

function rejectUser(user) {
let form = user;
let url = '/project/admin/user/reject/';
return httpService.post(form, url);
}
}
})();
Loading

0 comments on commit 2f5d5a7

Please sign in to comment.