diff --git a/README.md b/README.md index a2f95aad..6d3c22ea 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/apps/users_app/views.py b/apps/users_app/views.py index 8f39bdeb..e7429c73 100644 --- a/apps/users_app/views.py +++ b/apps/users_app/views.py @@ -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() diff --git a/static/apps/README.md b/static/apps/README.md index 518604a8..fdf9aa52 100644 --- a/static/apps/README.md +++ b/static/apps/README.md @@ -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. diff --git a/static/apps/admin/admin.app.js b/static/apps/admin/admin.app.js index 8507fdd3..ad0e01ea 100644 --- a/static/apps/admin/admin.app.js +++ b/static/apps/admin/admin.app.js @@ -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'; diff --git a/static/apps/common/constants.module.js b/static/apps/common/constants.module.js index 012501c1..c688d68d 100644 --- a/static/apps/common/constants.module.js +++ b/static/apps/common/constants.module.js @@ -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, @@ -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}, + ]); })(); \ No newline at end of file diff --git a/static/apps/common/services/patient.service.js b/static/apps/common/services/patient.service.js index fd7d7aa1..b1ca0d06 100644 --- a/static/apps/common/services/patient.service.js +++ b/static/apps/common/services/patient.service.js @@ -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, diff --git a/static/apps/common/services/shared.service.js b/static/apps/common/services/shared.service.js new file mode 100644 index 00000000..7962a315 --- /dev/null +++ b/static/apps/common/services/shared.service.js @@ -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 + */ +(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); + } + } +})(); \ No newline at end of file diff --git a/static/apps/common/shared-service.module.js b/static/apps/common/shared-service.module.js index 7187f440..31e5d2c2 100644 --- a/static/apps/common/shared-service.module.js +++ b/static/apps/common/shared-service.module.js @@ -18,303 +18,10 @@ 'use strict'; - angular.module('sharedModule', ['ngFileUpload', 'httpModule', 'cfp.hotkeys']) + angular.module('sharedModule', ['ngFileUpload', 'httpModule', 'cfp.hotkeys','pickadate']) .config(function ($httpProvider) { $httpProvider.defaults.xsrfCookieName = 'csrftoken'; $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; }) - .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('VIEW_MODES', [ - {label: 'All', value: 0}, - {label: 'Week', value: 1}, - {label: 'Month', value: 2}, - {label: 'Year', value: 3}, - ]) - .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); - } - } })(); diff --git a/static/apps/patient/directives/medication-directive/medication.directive.js b/static/apps/patient/directives/medication-directive/medication.directive.js index 203d583b..328dc284 100644 --- a/static/apps/patient/directives/medication-directive/medication.directive.js +++ b/static/apps/patient/directives/medication-directive/medication.directive.js @@ -14,78 +14,80 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see */ -var medication = angular.module('medication', []).config(function ($httpProvider) { - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; -}); +(function () { -medication.directive('medication', ['CollapseService', 'toaster', '$location', '$timeout', 'prompt', 'medicationService', medicationDirective]); + 'use strict'; + angular.module('medication', []).config(function ($httpProvider) { + $httpProvider.defaults.xsrfCookieName = 'csrftoken'; + $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; + }).directive('medication', ['CollapseService', 'toaster', '$location', '$timeout', 'prompt', 'medicationService', medicationDirective]); -function medicationDirective(CollapseService, toaster, $location, $timeout, prompt, medicationService) { + function medicationDirective(CollapseService, toaster, $location, $timeout, prompt, medicationService) { - return { - restrict: 'E', - templateUrl: '/static/apps/patient/directives/medication-directive/medication.html', - scope: true, - link: function (scope, element, attr, model) { - scope.medications = scope.$eval(attr.ngModel); - scope.medication_terms = []; - scope.manual_medication = {}; - scope.new_medication = {set: false}; + return { + restrict: 'E', + templateUrl: '/static/apps/patient/directives/medication-directive/medication.html', + scope: true, + link: function (scope, element, attr, model) { + scope.medications = scope.$eval(attr.ngModel); + scope.medication_terms = []; + scope.manual_medication = {}; + scope.new_medication = {set: false}; - scope.$watch('manual_medication.name', function (newVal, oldVal) { - if (newVal == undefined) { - return false; - } + scope.$watch('manual_medication.name', function (newVal, oldVal) { + if (newVal == undefined) { + return false; + } - scope.unset_new_medication(); + scope.unset_new_medication(); - if (newVal.length > 2) { - medicationService.listTerms(newVal).then(function (data) { - scope.medication_terms = data; - }); - } else { - scope.medication_terms = []; - } - }); + if (newVal.length > 2) { + medicationService.listTerms(newVal).then(function (data) { + scope.medication_terms = data; + }); + } else { + scope.medication_terms = []; + } + }); - scope.unset_new_medication = function () { - scope.new_medication.set = false; - }; + scope.unset_new_medication = function () { + scope.new_medication.set = false; + }; - scope.set_new_medication = function (medication) { - scope.new_medication.set = true; - scope.new_medication.name = medication.name; - scope.new_medication.concept_id = medication.concept_id; - }; + scope.set_new_medication = function (medication) { + scope.new_medication.set = true; + scope.new_medication.name = medication.name; + scope.new_medication.concept_id = medication.concept_id; + }; - scope.add_medication = function (form) { - // Preventing adding medication with empty name - if (form.name == '') - return; + scope.add_medication = function (form) { + // Preventing adding medication with empty name + if (form.name == '') + return; - form.search_str = scope.manual_medication.name; - form.patient_id = scope.patient_id; - medicationService.addMedication(form).then(function (data) { - if (data.success) { - toaster.pop('success', 'Done', 'Added medication!'); - scope.medications.push(data['medication']); - form.name = ''; - scope.unset_new_medication(); - // Reset medication search terms after added to item - scope.manual_medication = {}; - scope.medication_terms = []; - } else { - toaster.pop('error', 'Error', 'Medication name cannot empty'); - } - }); - }; + form.search_str = scope.manual_medication.name; + form.patient_id = scope.patient_id; + medicationService.addMedication(form).then(function (data) { + if (data.success) { + toaster.pop('success', 'Done', 'Added medication!'); + scope.medications.push(data['medication']); + form.name = ''; + scope.unset_new_medication(); + // Reset medication search terms after added to item + scope.manual_medication = {}; + scope.medication_terms = []; + } else { + toaster.pop('error', 'Error', 'Medication name cannot empty'); + } + }); + }; - scope.open_medication = function (medication) { - $location.url('/medication/' + medication.id); - }; + scope.open_medication = function (medication) { + $location.url('/medication/' + medication.id); + }; + } } - } -} + } +})(); \ No newline at end of file diff --git a/static/apps/patient/directives/problem-directive/problem.directive.js b/static/apps/patient/directives/problem-directive/problem.directive.js index 6645f2ae..7764eb80 100644 --- a/static/apps/patient/directives/problem-directive/problem.directive.js +++ b/static/apps/patient/directives/problem-directive/problem.directive.js @@ -14,79 +14,81 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see */ -var problems = angular.module('problems', []).config(function ($httpProvider) { - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; -}); +(function () { -problems.directive('problem', ['problemService', 'patientService', 'toaster', '$location', '$timeout', problemDirective]); + 'use strict'; + angular.module('problems', []).config(function ($httpProvider) { + $httpProvider.defaults.xsrfCookieName = 'csrftoken'; + $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; + }).directive('problem', ['problemService', 'patientService', 'toaster', '$location', '$timeout', problemDirective]); -function problemDirective(problemService, patientService, toaster, $location, $timeout) { + function problemDirective(problemService, patientService, toaster, $location, $timeout) { - var todoObj = {}; + var todoObj = {}; - return { - restrict: 'E', - templateUrl: '/static/apps/patient/directives/problem-directive/problem.html', - scope: true, - link: function (scope, element, attr, model) { - scope.$watch('problems_ready', function (newVal, oldVal) { - if (newVal) { + return { + restrict: 'E', + templateUrl: '/static/apps/patient/directives/problem-directive/problem.html', + scope: true, + link: function (scope, element, attr, model) { + scope.$watch('problems_ready', function (newVal, oldVal) { + if (newVal) { - scope.is_list = scope.$eval(attr.isList); - scope.problems = scope.$eval(attr.ngModel); + scope.is_list = scope.$eval(attr.isList); + scope.problems = scope.$eval(attr.ngModel); - if (scope.problems_ready) { - var tmpListProblemList = scope.problems; + if (scope.problems_ready) { + var tmpListProblemList = scope.problems; - scope.sortingLogProblemList = []; - scope.sortedProblemList = false; - scope.draggedProblemList = false; - scope.sortableOptionsProblemList = { - update: function (e, ui) { - scope.sortedProblemList = true; - }, - start: function () { - scope.draggedProblemList = true; - }, - stop: function (e, ui) { - // this callback has the changed model - if (scope.sortedProblemList) { - scope.sortingLogProblemList = []; - tmpListProblemList.map(function (i) { - scope.sortingLogProblemList.push(i.id); - }); - var form = {}; + scope.sortingLogProblemList = []; + scope.sortedProblemList = false; + scope.draggedProblemList = false; + scope.sortableOptionsProblemList = { + update: function (e, ui) { + scope.sortedProblemList = true; + }, + start: function () { + scope.draggedProblemList = true; + }, + stop: function (e, ui) { + // this callback has the changed model + if (scope.sortedProblemList) { + scope.sortingLogProblemList = []; + tmpListProblemList.map(function (i) { + scope.sortingLogProblemList.push(i.id); + }); + var form = {}; - form.problems = scope.sortingLogProblemList; + form.problems = scope.sortingLogProblemList; - if (scope.is_list) { - form.list_id = scope.is_list; - } else { - form.patient_id = scope.patient_id; - } + if (scope.is_list) { + form.list_id = scope.is_list; + } else { + form.patient_id = scope.patient_id; + } - patientService.updateProblemOrder(form).then(function (data) { - toaster.pop('success', 'Done', 'Updated Problem Order'); - }); + patientService.updateProblemOrder(form).then(function (data) { + toaster.pop('success', 'Done', 'Updated Problem Order'); + }); + } + scope.sortedProblem = false; + $timeout(function () { + scope.draggedProblemList = false; + }, 100); } - scope.sortedProblem = false; - $timeout(function () { - scope.draggedProblemList = false; - }, 100); + }; + scope.problems_ready = false; + } + + scope.open_problem = function (problem) { + if (!scope.draggedProblemList) { + $location.path('/problem/' + problem.id); } }; - scope.problems_ready = false; } - - scope.open_problem = function (problem) { - if (!scope.draggedProblemList) { - $location.path('/problem/' + problem.id); - } - }; - } - }, true); + }, true); + } } - } -} + } +})(); \ No newline at end of file diff --git a/static/apps/patient/directives/timeline.directive.js b/static/apps/patient/directives/timeline.directive.js index 2885dbd8..cd2b7b11 100644 --- a/static/apps/patient/directives/timeline.directive.js +++ b/static/apps/patient/directives/timeline.directive.js @@ -14,709 +14,710 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +(function () { -var timeLine = angular.module('timeLine', []).config(function ($httpProvider) { - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; -}); + 'use strict'; + angular.module('timeLine', []).config(function ($httpProvider) { + $httpProvider.defaults.xsrfCookieName = 'csrftoken'; + $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; + }).directive('problemTimeline', ['$location', timelineDirective]); -timeLine.directive('problemTimeline', ['$location', timelineDirective]); + function timelineDirective($location) { -function timelineDirective($location) { - - var timeline = {}; - - timeline.reset = function () { - var element = document.getElementsByTagName("path"); - for (index = element.length - 1; index >= 0; index--) { - element[index].parentNode.removeChild(element[index]); - } - var element = document.getElementsByTagName("text"); - for (index = element.length - 1; index >= 0; index--) { - element[index].parentNode.removeChild(element[index]); - } - }; - - timeline.renderPath = function (c, d, path) { - !path && (path = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'path'))); - path.setAttribute('d', c.d || d); - path.setAttribute('class', c.class || c); - path.setAttribute('display', 'inline'); - return path; - }; - timeline.renderText = function (c, x, y, txt, text) { - !text && (text = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'text'))); - for (var iii = 0; iii < text.childNodes.length; text.childNodes[iii] && text.removeChild(text.childNodes[iii]), iii++) ; - text.setAttribute('x', c.x || x); - text.setAttribute('y', c.y || y); - text.setAttribute('class', c.c || c); - text.setAttribute('pointer-events', 'none'); - text.setAttribute('display', 'inline'); - text.appendChild(document.createTextNode(txt)); - return text; - }; - timeline.renderTextProblem = function (id, c, x, y, txt, text) { - !text && (text = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'text'))); - for (var iii = 0; iii < text.childNodes.length; text.childNodes[iii] && text.removeChild(text.childNodes[iii]), iii++) ; - text.setAttribute('x', c.x || x); - text.setAttribute('y', c.y || y); - text.setAttribute('class', c.c || c); - text.setAttribute('display', 'inline'); - text.setAttribute('problem-id', id); - text.appendChild(document.createTextNode(txt)); - return text; - }; - timeline.Undo = function (s) { - if (!timeline.isEdit) { - return; - } - timeline.unrd && (timeline.unrd--, timeline.init()); - }; - timeline.Redo = function (s) { - if (!timeline.isEdit) { - return; - } - (timeline.dat.length > ++timeline.unrd) && timeline.init() || timeline.unrd-- - }; - timeline.Save = function (s) { - if (!timeline.isEdit) { - return; - } - var sarr = JSON.parse(JSON.stringify(timeline.dat[timeline.unrd])); - for (var iii = 0, eee = 0; iii < sarr.problems.length; delete sarr.problems[iii].events[eee].hidden, eee++, (eee < sarr.problems[iii].events.length) || (!sarr.problems[iii].events[eee - 1].state && sarr.problems[iii].events.pop(), eee = 0, iii++)) ; - s.timelineSave(sarr); - }; - - timeline.viewAll = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[0].setAttribute('class', 'S1'); - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - timeline.dat[timeline.unrd].birthday = timeline.dat[timeline.unrd].birthday || '15/11/1970 12:00:00'; - var bdy = timeline.dat[timeline.unrd].birthday.split('/'); - bdy = new Date(bdy[1] + '/' + bdy[0] + '/' + bdy[2]).getFullYear(); - var ViewDays = (+timeline.now.getFullYear() - bdy) * 365, fvX = timeline.renderXw / ViewDays; - console.log('bdy ' + bdy); - timeline.szoom = {}; - timeline.szoom.viewMS = ViewDays * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { + var timeline = {}; + timeline.reset = function () { + var element = document.getElementsByTagName("path"); + for (index = element.length - 1; index >= 0; index--) { + element[index].parentNode.removeChild(element[index]); + } + var element = document.getElementsByTagName("text"); + for (index = element.length - 1; index >= 0; index--) { + element[index].parentNode.removeChild(element[index]); + } }; - timeline.arrowr.onclick = function () { + timeline.renderPath = function (c, d, path) { + !path && (path = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'path'))); + path.setAttribute('d', c.d || d); + path.setAttribute('class', c.class || c); + path.setAttribute('display', 'inline'); + return path; }; - for (var iii = (timeline.now.getMonth() + 1) * 30, s = 0, m = timeline.now.getFullYear(), xxx = 0; iii < ViewDays; xxx++, iii = iii + (365 * 5)) { - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); - m -= 5; - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); - timeline.init(); - }; - timeline.view10y = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[1].setAttribute('class', 'S1'); - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - timeline.szoom = {}; - timeline.szoom.viewMS = 3654 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view10y(); + timeline.renderText = function (c, x, y, txt, text) { + !text && (text = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'text'))); + for (var iii = 0; iii < text.childNodes.length; text.childNodes[iii] && text.removeChild(text.childNodes[iii]), iii++) ; + text.setAttribute('x', c.x || x); + text.setAttribute('y', c.y || y); + text.setAttribute('class', c.c || c); + text.setAttribute('pointer-events', 'none'); + text.setAttribute('display', 'inline'); + text.appendChild(document.createTextNode(txt)); + return text; }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view10y(); + timeline.renderTextProblem = function (id, c, x, y, txt, text) { + !text && (text = timeline.wrapSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'text'))); + for (var iii = 0; iii < text.childNodes.length; text.childNodes[iii] && text.removeChild(text.childNodes[iii]), iii++) ; + text.setAttribute('x', c.x || x); + text.setAttribute('y', c.y || y); + text.setAttribute('class', c.c || c); + text.setAttribute('display', 'inline'); + text.setAttribute('problem-id', id); + text.appendChild(document.createTextNode(txt)); + return text; }; - var ViewDays = 3654, fvX = timeline.renderXw / ViewDays; - for (var iii = (timeline.now.getMonth() + 1) * 30, s = 0, m = timeline.now.getFullYear(), xxx = 0; iii < ViewDays; xxx++, iii = iii + 365) { - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m--, timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); - timeline.init(); - }; - - timeline.view1y = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[2].setAttribute('class', 'S1'); - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - timeline.szoom = {}; - timeline.szoom.viewMS = 365 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view1y(); + timeline.Undo = function (s) { + if (!timeline.isEdit) { + return; + } + timeline.unrd && (timeline.unrd--, timeline.init()); + }; + timeline.Redo = function (s) { + if (!timeline.isEdit) { + return; + } + (timeline.dat.length > ++timeline.unrd) && timeline.init() || timeline.unrd-- }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view1y(); + timeline.Save = function (s) { + if (!timeline.isEdit) { + return; + } + var sarr = JSON.parse(JSON.stringify(timeline.dat[timeline.unrd])); + for (var iii = 0, eee = 0; iii < sarr.problems.length; delete sarr.problems[iii].events[eee].hidden, eee++, (eee < sarr.problems[iii].events.length) || (!sarr.problems[iii].events[eee - 1].state && sarr.problems[iii].events.pop(), eee = 0, iii++)) ; + s.timelineSave(sarr); }; - var ViewDays = 365, fvX = timeline.renderXw / ViewDays; - for (var iii = timeline.now.getDate(), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; !~m && (m = 11), xxx++, iii = iii + 30) { + + timeline.viewAll = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[0].setAttribute('class', 'S1'); + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + timeline.dat[timeline.unrd].birthday = timeline.dat[timeline.unrd].birthday || '15/11/1970 12:00:00'; + var bdy = timeline.dat[timeline.unrd].birthday.split('/'); + bdy = new Date(bdy[1] + '/' + bdy[0] + '/' + bdy[2]).getFullYear(); + var ViewDays = (+timeline.now.getFullYear() - bdy) * 365, fvX = timeline.renderXw / ViewDays; + console.log('bdy ' + bdy); + timeline.szoom = {}; + timeline.szoom.viewMS = ViewDays * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + + }; + timeline.arrowr.onclick = function () { + + }; + for (var iii = (timeline.now.getMonth() + 1) * 30, s = 0, m = timeline.now.getFullYear(), xxx = 0; iii < ViewDays; xxx++, iii = iii + (365 * 5)) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); + m -= 5; + } s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m--], timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m], timeline.txtArr[xxx]); - timeline.init(); - }; - - - timeline.view6m = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[3].setAttribute('class', 'S1'); - timeline.szoom = {}; - timeline.szoom.viewMS = 183 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view6m(); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); + timeline.init(); }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view6m(); + timeline.view10y = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[1].setAttribute('class', 'S1'); + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + timeline.szoom = {}; + timeline.szoom.viewMS = 3654 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view10y(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view10y(); + }; + var ViewDays = 3654, fvX = timeline.renderXw / ViewDays; + for (var iii = (timeline.now.getMonth() + 1) * 30, s = 0, m = timeline.now.getFullYear(), xxx = 0; iii < ViewDays; xxx++, iii = iii + 365) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m--, timeline.txtArr[xxx]); + } + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, m, timeline.txtArr[xxx]); + timeline.init(); }; - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - var ViewDays = 183, fvX = timeline.renderXw / ViewDays; - for (var iii = timeline.now.getDate(), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; !~m && (m = 11), xxx++, iii = iii + 30) { + timeline.view1y = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[2].setAttribute('class', 'S1'); + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + timeline.szoom = {}; + timeline.szoom.viewMS = 365 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view1y(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view1y(); + }; + var ViewDays = 365, fvX = timeline.renderXw / ViewDays; + for (var iii = timeline.now.getDate(), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; !~m && (m = 11), xxx++, iii = iii + 30) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m--], timeline.txtArr[xxx]); + } s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 20), timeline.renderYst + 20, timeline.months[m--], timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m], timeline.txtArr[xxx]); - timeline.init(); - }; - - timeline.view1m = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[4].setAttribute('class', 'S1'); - timeline.szoom = {}; - timeline.szoom.viewMS = 30 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view1m(); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m], timeline.txtArr[xxx]); + timeline.init(); }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view1m(); - }; - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - var ViewDays = 30, fvX = timeline.renderXw / ViewDays; - for (var iii = timeline.now.getDate() - (parseInt(timeline.now.getDate() / 7) * 7), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; (timeline.now.getDate() == iii) && m--, !~m && (m = 11), xxx++, iii = iii + 7) { + + + timeline.view6m = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[3].setAttribute('class', 'S1'); + timeline.szoom = {}; + timeline.szoom.viewMS = 183 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view6m(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view6m(); + }; + + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + var ViewDays = 183, fvX = timeline.renderXw / ViewDays; + for (var iii = timeline.now.getDate(), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; !~m && (m = 11), xxx++, iii = iii + 30) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 20), timeline.renderYst + 20, timeline.months[m--], timeline.txtArr[xxx]); + } s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (((timeline.now.getDate() - iii + 1) > 0) && (timeline.now.getDate() - iii + 1) || (timeline.now.getDate() - iii + 30)) + '-' + timeline.months[m], timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 25), timeline.renderYst + 20, (((timeline.now.getDate() - iii + 1) > 0) && (timeline.now.getDate() - iii + 1) || (timeline.now.getDate() - iii + 30)) + '-' + timeline.months[m], timeline.txtArr[xxx]); - timeline.init(); - }; - timeline.view1w = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[5].setAttribute('class', 'S1'); - timeline.szoom = {}; - timeline.szoom.viewMS = 7 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view1w(); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.months[m], timeline.txtArr[xxx]); + timeline.init(); }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view1w(); + + timeline.view1m = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[4].setAttribute('class', 'S1'); + timeline.szoom = {}; + timeline.szoom.viewMS = 30 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view1m(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view1m(); + }; + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + var ViewDays = 30, fvX = timeline.renderXw / ViewDays; + for (var iii = timeline.now.getDate() - (parseInt(timeline.now.getDate() / 7) * 7), s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; (timeline.now.getDate() == iii) && m--, !~m && (m = 11), xxx++, iii = iii + 7) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (((timeline.now.getDate() - iii + 1) > 0) && (timeline.now.getDate() - iii + 1) || (timeline.now.getDate() - iii + 30)) + '-' + timeline.months[m], timeline.txtArr[xxx]); + } + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 25), timeline.renderYst + 20, (((timeline.now.getDate() - iii + 1) > 0) && (timeline.now.getDate() - iii + 1) || (timeline.now.getDate() - iii + 30)) + '-' + timeline.months[m], timeline.txtArr[xxx]); + timeline.init(); }; - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - var ViewDays = 7, fvX = timeline.renderXw / ViewDays; - for (var iii = 1, s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; (timeline.now.getDate() == iii) && m--, !~m && (m = 11), xxx++, iii++) { + timeline.view1w = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[5].setAttribute('class', 'S1'); + timeline.szoom = {}; + timeline.szoom.viewMS = 7 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view1w(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view1w(); + }; + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + var ViewDays = 7, fvX = timeline.renderXw / ViewDays; + for (var iii = 1, s = 0, m = timeline.now.getMonth(), xxx = 0; iii < ViewDays; (timeline.now.getDate() == iii) && m--, !~m && (m = 11), xxx++, iii++) { + s = (timeline.renderXst + ((ViewDays - iii) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (timeline.now.getDate() - iii + 1) + ' ' + timeline.months[m], timeline.txtArr[xxx]); + } s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (timeline.now.getDate() - iii + 1) + ' ' + timeline.months[m], timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - iii) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (timeline.now.getDate() - iii + 1) + ' ' + timeline.months[m], timeline.txtArr[xxx]); - timeline.init(); - }; - timeline.view1d = function () { - for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; - timeline.zoomArr[6].setAttribute('class', 'S1'); - timeline.szoom = {}; - timeline.szoom.viewMS = 1 * 24 * 60 * 60 * 1000; - timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; - timeline.arrowl.onclick = function () { - timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); - timeline.view1d(); - }; - timeline.arrowr.onclick = function () { - (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); - timeline.view1d(); + timeline.init(); }; - timeline.hideAll(timeline.g01Arr); - timeline.hideAll(timeline.g02Arr); - timeline.hideAll(timeline.txtArr); - var ViewDays = 1, fvX = timeline.renderXw / ViewDays; - for (var iii = 4, s = 0, m = timeline.now.getDate(), xxx = 0; iii < 24; (timeline.now.getHours() == iii) && m--, !~m && (m = 11), xxx++, iii = iii + 4) { + timeline.view1d = function () { + for (var iii = 0; iii < timeline.zoomArr.length; timeline.zoomArr[iii].setAttribute('class', 'G1'), iii++) ; + timeline.zoomArr[6].setAttribute('class', 'S1'); + timeline.szoom = {}; + timeline.szoom.viewMS = 1 * 24 * 60 * 60 * 1000; + timeline.szoom.start = timeline.now.getTime() - timeline.szoom.viewMS; + timeline.arrowl.onclick = function () { + timeline.now = new Date(timeline.now.getTime() - timeline.szoom.viewMS); + timeline.view1d(); + }; + timeline.arrowr.onclick = function () { + (new Date().getTime() > timeline.now.getTime()) && (timeline.now = new Date(timeline.now.getTime() + timeline.szoom.viewMS), (new Date().getTime() >= timeline.now.getTime())) || (timeline.now = new Date()); + timeline.view1d(); + }; + timeline.hideAll(timeline.g01Arr); + timeline.hideAll(timeline.g02Arr); + timeline.hideAll(timeline.txtArr); + var ViewDays = 1, fvX = timeline.renderXw / ViewDays; + for (var iii = 4, s = 0, m = timeline.now.getDate(), xxx = 0; iii < 24; (timeline.now.getHours() == iii) && m--, !~m && (m = 11), xxx++, iii = iii + 4) { + s = (timeline.renderXst + ((ViewDays - (iii / 24)) * fvX)); + timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); + timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (24 - iii) + ':00', timeline.txtArr[xxx]); + } s = (timeline.renderXst + ((ViewDays - (iii / 24)) * fvX)); - timeline.g01Arr[xxx] = timeline.renderPath('G0', 'M' + s + ',' + (timeline.renderYst) + ' l0,' + (timeline.renderYst + timeline.renderYh) + ' l1 0 l0 -' + (timeline.renderYst + timeline.renderYh) + ' z', timeline.g01Arr[xxx]); - timeline.g02Arr[xxx] = timeline.renderPath('G1', 'M' + (s - 1) + ',' + timeline.renderYst + ' l0,40 l3 0 l0 -40 z', timeline.g02Arr[xxx]); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, (24 - iii) + ':00', timeline.txtArr[xxx]); - } - s = (timeline.renderXst + ((ViewDays - (iii / 24)) * fvX)); - timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.now.getDate() + '-' + timeline.months[timeline.now.getMonth()], timeline.txtArr[xxx]); - timeline.init(); - }; + timeline.txtArr[xxx] = timeline.renderText('T1', (s + 15), timeline.renderYst + 20, timeline.now.getDate() + '-' + timeline.months[timeline.now.getMonth()], timeline.txtArr[xxx]); + timeline.init(); + }; - timeline.init = function () { + timeline.init = function () { - for (var iii = 0; iii < timeline.dat[timeline.unrd].problems.length; iii++) { - timeline.parr[iii] = timeline.parr[iii] || []; - if (!timeline.dat[timeline.unrd].problems[iii].events.length) { - continue; + for (var iii = 0; iii < timeline.dat[timeline.unrd].problems.length; iii++) { + timeline.parr[iii] = timeline.parr[iii] || []; + if (!timeline.dat[timeline.unrd].problems[iii].events.length) { + continue; + } + timeline.dat[timeline.unrd].problems[iii].events[timeline.dat[timeline.unrd].problems[iii].events.length - 1].state && timeline.dat[timeline.unrd].problems[iii].events.push({startTime: new Date(new Date().setFullYear((new Date().getFullYear()) + 1)).strx()}); + timeline.hideAll(timeline.parr[iii]); + timeline.larr[iii] = []; + for (var xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden = timeline.drqq(timeline.dat[timeline.unrd].problems[iii].events[xxx].startTime), xxx++) ; + + for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.drq(timeline.dat[timeline.unrd].problems[iii].events[xxx], iii, xxx), xxx++) ; + for (xxx = timeline.dat[timeline.unrd].problems[iii].events.length - 1; xxx >= 0; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden === 'G4' && (timeline.larr[iii].splice(0, 0, timeline.a(timeline.yarr[iii]), {'class': 'G3 ' + (timeline.dat[timeline.unrd].problems[iii].events[xxx].state || 'inactive')}), xxx = 0), xxx--) ; + for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden === 'G5' && (timeline.larr[iii].push(timeline.e(timeline.yarr[iii])), xxx = timeline.dat[timeline.unrd].problems[iii].events.length), xxx++) ; + + timeline.drno4(iii); + timeline.drno5(iii); + timeline.drae(iii); + timeline.drm(iii); + timeline.dr(iii); } - timeline.dat[timeline.unrd].problems[iii].events[timeline.dat[timeline.unrd].problems[iii].events.length - 1].state && timeline.dat[timeline.unrd].problems[iii].events.push({startTime: new Date(new Date().setFullYear((new Date().getFullYear()) + 1)).strx()}); - timeline.hideAll(timeline.parr[iii]); - timeline.larr[iii] = []; - for (var xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden = timeline.drqq(timeline.dat[timeline.unrd].problems[iii].events[xxx].startTime), xxx++) ; - - for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.drq(timeline.dat[timeline.unrd].problems[iii].events[xxx], iii, xxx), xxx++) ; - for (xxx = timeline.dat[timeline.unrd].problems[iii].events.length - 1; xxx >= 0; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden === 'G4' && (timeline.larr[iii].splice(0, 0, timeline.a(timeline.yarr[iii]), {'class': 'G3 ' + (timeline.dat[timeline.unrd].problems[iii].events[xxx].state || 'inactive')}), xxx = 0), xxx--) ; - for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[iii].events.length; timeline.dat[timeline.unrd].problems[iii].events[xxx].hidden === 'G5' && (timeline.larr[iii].push(timeline.e(timeline.yarr[iii])), xxx = timeline.dat[timeline.unrd].problems[iii].events.length), xxx++) ; - - timeline.drno4(iii); - timeline.drno5(iii); - timeline.drae(iii); - timeline.drm(iii); - timeline.dr(iii); - } - return true; - }; + return true; + }; - timeline.drno4 = function (ix) { - for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[ix].events.length; xxx++) { - if (timeline.dat[timeline.unrd].problems[ix].events[xxx].hidden === 'G4') { - continue; + timeline.drno4 = function (ix) { + for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[ix].events.length; xxx++) { + if (timeline.dat[timeline.unrd].problems[ix].events[xxx].hidden === 'G4') { + continue; + } + return; } - return; - } - timeline.larr[ix] = []; - }; - timeline.drno5 = function (ix) { - for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[ix].events.length; xxx++) { - if (timeline.dat[timeline.unrd].problems[ix].events[xxx].hidden === 'G5') { - continue; + timeline.larr[ix] = []; + }; + timeline.drno5 = function (ix) { + for (xxx = 0; xxx < timeline.dat[timeline.unrd].problems[ix].events.length; xxx++) { + if (timeline.dat[timeline.unrd].problems[ix].events[xxx].hidden === 'G5') { + continue; + } + return; + } + timeline.larr[ix] = []; + }; + timeline.drae = function (ix) { + if (!timeline.larr[ix].length) { + return; + } + if (~timeline.larr[ix][0].class.indexOf('G2')) { + var ev = timeline.larr[ix][0].ev; + var d = ev.startTime, dd = d.split('/'); + d = dd[1] + '/' + dd[0] + '/' + dd[2]; + var x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; + timeline.larr[ix][0] = timeline.q(x, timeline.yarr[ix], ev); + } + ~timeline.larr[ix][timeline.larr[ix].length - 1].class.indexOf('G3') && timeline.larr[ix].pop(); + if (~timeline.larr[ix][timeline.larr[ix].length - 1].class.indexOf('G2')) { + ev = timeline.larr[ix][timeline.larr[ix].length - 1].ev; + d = ev.startTime, dd = d.split('/'); + d = dd[1] + '/' + dd[0] + '/' + dd[2]; + x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; + timeline.larr[ix][timeline.larr[ix].length - 1] = timeline.q(x, timeline.yarr[ix], ev); + } + }; + + timeline.drq = function (ev, ix, xx) { + if (ev.hidden || ev.class) { + return; } - return; - } - timeline.larr[ix] = []; - }; - timeline.drae = function (ix) { - if (!timeline.larr[ix].length) { - return; - } - if (~timeline.larr[ix][0].class.indexOf('G2')) { - var ev = timeline.larr[ix][0].ev; var d = ev.startTime, dd = d.split('/'); d = dd[1] + '/' + dd[0] + '/' + dd[2]; var x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; - timeline.larr[ix][0] = timeline.q(x, timeline.yarr[ix], ev); - } - ~timeline.larr[ix][timeline.larr[ix].length - 1].class.indexOf('G3') && timeline.larr[ix].pop(); - if (~timeline.larr[ix][timeline.larr[ix].length - 1].class.indexOf('G2')) { - ev = timeline.larr[ix][timeline.larr[ix].length - 1].ev; - d = ev.startTime, dd = d.split('/'); + timeline.larr[ix].push(timeline.r(x, timeline.yarr[ix], ev)), timeline.larr[ix].push({'class': 'G3 ' + (ev.state || 'inactive')}); + }; + + timeline.drqq = function (d) { + var dd = d.split('/'); d = dd[1] + '/' + dd[0] + '/' + dd[2]; - x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; - timeline.larr[ix][timeline.larr[ix].length - 1] = timeline.q(x, timeline.yarr[ix], ev); - } - }; + var x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; + if (x < timeline.renderXst) { + return 'G4'; + } + if (x > timeline.renderXst + timeline.renderXw) { + return 'G5'; + } + return ''; + }; - timeline.drq = function (ev, ix, xx) { - if (ev.hidden || ev.class) { - return; - } - var d = ev.startTime, dd = d.split('/'); - d = dd[1] + '/' + dd[0] + '/' + dd[2]; - var x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; - timeline.larr[ix].push(timeline.r(x, timeline.yarr[ix], ev)), timeline.larr[ix].push({'class': 'G3 ' + (ev.state || 'inactive')}); - }; - - timeline.drqq = function (d) { - var dd = d.split('/'); - d = dd[1] + '/' + dd[0] + '/' + dd[2]; - var x = ((new Date(d).getTime() - timeline.szoom.start) / (timeline.szoom.viewMS / timeline.renderXw)) + timeline.renderXst; - if (x < timeline.renderXst) { - return 'G4'; - } - if (x > timeline.renderXst + timeline.renderXw) { - return 'G5'; - } - return ''; - }; - - timeline.dr = function (ix) { - for (var iii = 0; iii < timeline.larr[ix].length; iii++) { - timeline.parr[ix] = timeline.parr[ix] || []; - timeline.parr[ix][iii] = timeline.renderPath(timeline.larr[ix][iii], 0, timeline.parr[ix][iii]); - timeline.parr[ix][iii].onmousedown = (function (x, i) { - return function (e) { - if (~timeline.parr[x][i].getAttribute('class').indexOf('G4')) { - timeline.arrowl.onclick(); - return; - } - if (~timeline.parr[x][i].getAttribute('class').indexOf('G5')) { - timeline.arrowr.onclick(); - return; - } - if (!timeline.isEdit) { - return; - } - timeline.mmove = e.clientX; - timeline.clx = {tlwh: timeline.offsetTLWH(timeline.wrapSvg), ix: x, lx: i}; - if (~timeline.parr[x][i].getAttribute('class').indexOf('G2')) { - return; - } - timeline.isNew = 1; - timeline.larr[x].splice(i + 1, 0, timeline.r(((e.clientX - timeline.clx.tlwh.oL) / (timeline.clx.tlwh.oW / 1000)) - 12, timeline.yarr[x], { - event_id: +new Date(), - startTime: 'unb', - state: 'inactive' - })); - timeline.larr[x][i + 1].new = 1; - - timeline.larr[x].splice(i + 2, 0, {'class': timeline.larr[x][i].class}); - ////for (var ttt = 0, ist = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; timeline.larr[x][i].ev && (timeline.larr[x][i].ev.event_id === timeline.dat[timeline.unrd].problems[x].events[ttt].event_id) && (ist = timeline.dat[timeline.unrd].problems[x].events[ttt]), ttt++); - ////for (var ttt = 0, nol = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; ttt++) { - //// if (!ist || !timeline.dat[timeline.unrd].problems[x].events[ttt].state) { continue }; - //// var d = ist.startTime, dd = d.split('/'); d = dd[1] + '/' + dd[0] + '/' + dd[2]; - //// var d2 = timeline.dat[timeline.unrd].problems[x].events[ttt].startTime, dd2 = d2.split('/'); d2 = dd2[1] + '/' + dd2[0] + '/' + dd2[2]; - //// //console.log(timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); - //// if ((new Date(d) < new Date(d2))) { nol = 1; console.log('NOL=1 ' + timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); }; - ////} - ////if (!nol) { timeline.larr[x][i + 2] = { 'class': timeline.larr[x][i].class }; } - timeline.drm(x); - timeline.dr(x); - }; - })(ix, iii); - timeline.parr[ix][iii].onmouseup = (function (x, i) { - return function (e) { - if (!timeline.isEdit) { - return; - } - //console.log(JSON.stringify(timeline.dat[timeline.unrd].problems[x])); - //timeline.larr[x][i].ev.... - for (var ttt = 0, ist = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; timeline.larr[x][i].ev && (timeline.larr[x][i].ev.event_id === timeline.dat[timeline.unrd].problems[x].events[ttt].event_id) && (ist = timeline.dat[timeline.unrd].problems[x].events[ttt]), ttt++) ; - for (var ttt = 0, nol = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; ttt++) { - if (!ist || !timeline.dat[timeline.unrd].problems[x].events[ttt].state) { - continue + timeline.dr = function (ix) { + for (var iii = 0; iii < timeline.larr[ix].length; iii++) { + timeline.parr[ix] = timeline.parr[ix] || []; + timeline.parr[ix][iii] = timeline.renderPath(timeline.larr[ix][iii], 0, timeline.parr[ix][iii]); + timeline.parr[ix][iii].onmousedown = (function (x, i) { + return function (e) { + if (~timeline.parr[x][i].getAttribute('class').indexOf('G4')) { + timeline.arrowl.onclick(); + return; } - var d = ist.startTime, dd = d.split('/'); - d = dd[1] + '/' + dd[0] + '/' + dd[2]; - var d2 = timeline.dat[timeline.unrd].problems[x].events[ttt].startTime, dd2 = d2.split('/'); - d2 = dd2[1] + '/' + dd2[0] + '/' + dd2[2]; - //console.log(timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); - if ((new Date(d) < new Date(d2))) { - nol = 1; - console.log('NOL=1 ' + timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); + if (~timeline.parr[x][i].getAttribute('class').indexOf('G5')) { + timeline.arrowr.onclick(); + return; } - } - if (!nol) { + if (!timeline.isEdit) { + return; + } + timeline.mmove = e.clientX; + timeline.clx = {tlwh: timeline.offsetTLWH(timeline.wrapSvg), ix: x, lx: i}; + if (~timeline.parr[x][i].getAttribute('class').indexOf('G2')) { + return; + } + timeline.isNew = 1; + timeline.larr[x].splice(i + 1, 0, timeline.r(((e.clientX - timeline.clx.tlwh.oL) / (timeline.clx.tlwh.oW / 1000)) - 12, timeline.yarr[x], { + event_id: +new Date(), + startTime: 'unb', + state: 'inactive' + })); + timeline.larr[x][i + 1].new = 1; + + timeline.larr[x].splice(i + 2, 0, {'class': timeline.larr[x][i].class}); + ////for (var ttt = 0, ist = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; timeline.larr[x][i].ev && (timeline.larr[x][i].ev.event_id === timeline.dat[timeline.unrd].problems[x].events[ttt].event_id) && (ist = timeline.dat[timeline.unrd].problems[x].events[ttt]), ttt++); + ////for (var ttt = 0, nol = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; ttt++) { + //// if (!ist || !timeline.dat[timeline.unrd].problems[x].events[ttt].state) { continue }; + //// var d = ist.startTime, dd = d.split('/'); d = dd[1] + '/' + dd[0] + '/' + dd[2]; + //// var d2 = timeline.dat[timeline.unrd].problems[x].events[ttt].startTime, dd2 = d2.split('/'); d2 = dd2[1] + '/' + dd2[0] + '/' + dd2[2]; + //// //console.log(timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); + //// if ((new Date(d) < new Date(d2))) { nol = 1; console.log('NOL=1 ' + timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); }; + ////} + ////if (!nol) { timeline.larr[x][i + 2] = { 'class': timeline.larr[x][i].class }; } + timeline.drm(x); + timeline.dr(x); + }; + })(ix, iii); + timeline.parr[ix][iii].onmouseup = (function (x, i) { + return function (e) { + if (!timeline.isEdit) { + return; + } + //console.log(JSON.stringify(timeline.dat[timeline.unrd].problems[x])); + //timeline.larr[x][i].ev.... + for (var ttt = 0, ist = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; timeline.larr[x][i].ev && (timeline.larr[x][i].ev.event_id === timeline.dat[timeline.unrd].problems[x].events[ttt].event_id) && (ist = timeline.dat[timeline.unrd].problems[x].events[ttt]), ttt++) ; + for (var ttt = 0, nol = 0; ttt < timeline.dat[timeline.unrd].problems[x].events.length; ttt++) { + if (!ist || !timeline.dat[timeline.unrd].problems[x].events[ttt].state) { + continue + } + var d = ist.startTime, dd = d.split('/'); + d = dd[1] + '/' + dd[0] + '/' + dd[2]; + var d2 = timeline.dat[timeline.unrd].problems[x].events[ttt].startTime, dd2 = d2.split('/'); + d2 = dd2[1] + '/' + dd2[0] + '/' + dd2[2]; + //console.log(timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); + if ((new Date(d) < new Date(d2))) { + nol = 1; + console.log('NOL=1 ' + timeline.larr[x][i].ev.startTime + ' | ' + timeline.dat[timeline.unrd].problems[x].events[ttt].startTime); + } + } + if (!nol) { + timeline.isNew = 0; + return; + } + //console.log(timeline.larr[x][i].ev.event_id + ' ||| ' + timeline.dat[timeline.unrd].problems[x].events[timeline.dat[timeline.unrd].problems[x].events.length - 2].event_id); + //if (!timeline.larr[x][i].ev || (+ timeline.larr[x][i].ev.event_id === +timeline.dat[timeline.unrd].problems[x].events[timeline.dat[timeline.unrd].problems[x].events.length - 2].event_id)) { return; } + if (!timeline.isNew && Math.abs(timeline.mmove - e.clientX) < 2 && ~timeline.parr[x][i].getAttribute('class').indexOf('G2') && timeline.parr[x][i + 1]) { + (timeline.parr[x][i + 1].getAttribute('class') === 'G3 uncontrolled') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 inactive'), (timeline.larr[x][i + 1].class = 'G3 inactive')) || + (timeline.parr[x][i + 1].getAttribute('class') === 'G3 inactive') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 controlled'), (timeline.larr[x][i + 1].class = 'G3 controlled')) || + (timeline.parr[x][i + 1].getAttribute('class') === 'G3 controlled') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 uncontrolled'), (timeline.larr[x][i + 1].class = 'G3 uncontrolled')); + timeline.larr[x][i].stat = 1; + } + timeline.clx && timeline.updateR(); + timeline.clx = 0; timeline.isNew = 0; + }; + })(ix, iii); + timeline.parr[ix][iii].onmousemove = function (e) { + if (!timeline.isEdit) { return; } - //console.log(timeline.larr[x][i].ev.event_id + ' ||| ' + timeline.dat[timeline.unrd].problems[x].events[timeline.dat[timeline.unrd].problems[x].events.length - 2].event_id); - //if (!timeline.larr[x][i].ev || (+ timeline.larr[x][i].ev.event_id === +timeline.dat[timeline.unrd].problems[x].events[timeline.dat[timeline.unrd].problems[x].events.length - 2].event_id)) { return; } - if (!timeline.isNew && Math.abs(timeline.mmove - e.clientX) < 2 && ~timeline.parr[x][i].getAttribute('class').indexOf('G2') && timeline.parr[x][i + 1]) { - (timeline.parr[x][i + 1].getAttribute('class') === 'G3 uncontrolled') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 inactive'), (timeline.larr[x][i + 1].class = 'G3 inactive')) || - (timeline.parr[x][i + 1].getAttribute('class') === 'G3 inactive') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 controlled'), (timeline.larr[x][i + 1].class = 'G3 controlled')) || - (timeline.parr[x][i + 1].getAttribute('class') === 'G3 controlled') && (timeline.parr[x][i + 1].setAttribute('class', 'G3 uncontrolled'), (timeline.larr[x][i + 1].class = 'G3 uncontrolled')); - timeline.larr[x][i].stat = 1; - } - timeline.clx && timeline.updateR(); - timeline.clx = 0; - timeline.isNew = 0; + timeline.mm(e); }; - })(ix, iii); - timeline.parr[ix][iii].onmousemove = function (e) { - if (!timeline.isEdit) { - return; - } - timeline.mm(e); - }; - } - }; - timeline.mm = function (e) { - if (!timeline.clx || timeline.isNew || (Math.abs(timeline.mmove - e.clientX) < 3) || (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G4') || (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G5')) { - return - } - var mx = ((e.clientX - timeline.clx.tlwh.oL) / (timeline.clx.tlwh.oW / 1000)) - 12; - var nx = timeline.larr[timeline.clx.ix][timeline.clx.lx + 2] && parseInt(timeline.larr[timeline.clx.ix][timeline.clx.lx + 2].d.split(',')[0].replace('M', '')) - 24 || (timeline.renderXst + timeline.renderXw); - var px = timeline.larr[timeline.clx.ix][timeline.clx.lx - 2] && parseInt(timeline.larr[timeline.clx.ix][timeline.clx.lx - 2].d.split(',')[0].replace('M', '')) + 25 || timeline.renderXst; - (mx < nx && mx > px) && (timeline.larr[timeline.clx.ix][timeline.clx.lx] = (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G2') && timeline.q(mx, timeline.yarr[timeline.clx.ix], timeline.larr[timeline.clx.ix][timeline.clx.lx].ev) || timeline.r(mx, timeline.yarr[timeline.clx.ix], timeline.larr[timeline.clx.ix][timeline.clx.lx].ev)) && (timeline.larr[timeline.clx.ix][timeline.clx.lx].update = 1); - timeline.drm(timeline.clx.ix); - timeline.dr(timeline.clx.ix); - }; - timeline.updateR = function () { - if (!timeline.clx) { - return; - } - timeline.dat[timeline.unrd + 1] = JSON.parse(JSON.stringify(timeline.dat[timeline.unrd])); - timeline.unrd++; - timeline.dat = timeline.dat.slice(0, timeline.unrd + 1); - for (var iii = 0, rrr = 0; iii < timeline.larr[timeline.clx.ix].length; iii++) { - //if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden === 'G4') { rrr++; iii--; continue; } - //if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden === 'G5') { break; } - //if (!~timeline.larr[timeline.clx.ix][iii].class.indexOf('G2')) { continue; } - - - if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr + 1] && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden) { - rrr++; - iii--; - continue; } - if (!~timeline.larr[timeline.clx.ix][iii].class.indexOf('G2')) { - continue; + }; + timeline.mm = function (e) { + if (!timeline.clx || timeline.isNew || (Math.abs(timeline.mmove - e.clientX) < 3) || (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G4') || (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G5')) { + return } - if (!timeline.larr[timeline.clx.ix][iii].new && !timeline.larr[timeline.clx.ix][iii].update && !timeline.larr[timeline.clx.ix][iii].stat) { - rrr++; - continue; + var mx = ((e.clientX - timeline.clx.tlwh.oL) / (timeline.clx.tlwh.oW / 1000)) - 12; + var nx = timeline.larr[timeline.clx.ix][timeline.clx.lx + 2] && parseInt(timeline.larr[timeline.clx.ix][timeline.clx.lx + 2].d.split(',')[0].replace('M', '')) - 24 || (timeline.renderXst + timeline.renderXw); + var px = timeline.larr[timeline.clx.ix][timeline.clx.lx - 2] && parseInt(timeline.larr[timeline.clx.ix][timeline.clx.lx - 2].d.split(',')[0].replace('M', '')) + 25 || timeline.renderXst; + (mx < nx && mx > px) && (timeline.larr[timeline.clx.ix][timeline.clx.lx] = (timeline.larr[timeline.clx.ix][timeline.clx.lx].class === 'G2') && timeline.q(mx, timeline.yarr[timeline.clx.ix], timeline.larr[timeline.clx.ix][timeline.clx.lx].ev) || timeline.r(mx, timeline.yarr[timeline.clx.ix], timeline.larr[timeline.clx.ix][timeline.clx.lx].ev)) && (timeline.larr[timeline.clx.ix][timeline.clx.lx].update = 1); + timeline.drm(timeline.clx.ix); + timeline.dr(timeline.clx.ix); + }; + timeline.updateR = function () { + if (!timeline.clx) { + return; } - var upd = { - startTime: new Date(timeline.szoom.start + ((parseInt(timeline.larr[timeline.clx.ix][iii].d.split(',')[0].replace('M', '')) - timeline.renderXst) * (timeline.szoom.viewMS / timeline.renderXw))).strx(), - state: timeline.larr[timeline.clx.ix][iii + 1] && ~timeline.larr[timeline.clx.ix][iii + 1].class.indexOf('G3') && timeline.larr[timeline.clx.ix][iii + 1].class.replace('G3 ', '') || '', - hidden: 0, - event_id: timeline.larr[timeline.clx.ix][iii].ev && timeline.larr[timeline.clx.ix][iii].ev.event_id || 'ERROR' - }; + timeline.dat[timeline.unrd + 1] = JSON.parse(JSON.stringify(timeline.dat[timeline.unrd])); + timeline.unrd++; + timeline.dat = timeline.dat.slice(0, timeline.unrd + 1); + for (var iii = 0, rrr = 0; iii < timeline.larr[timeline.clx.ix].length; iii++) { + //if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden === 'G4') { rrr++; iii--; continue; } + //if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden === 'G5') { break; } + //if (!~timeline.larr[timeline.clx.ix][iii].class.indexOf('G2')) { continue; } + + + if (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr + 1] && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr].hidden) { + rrr++; + iii--; + continue; + } + if (!~timeline.larr[timeline.clx.ix][iii].class.indexOf('G2')) { + continue; + } + if (!timeline.larr[timeline.clx.ix][iii].new && !timeline.larr[timeline.clx.ix][iii].update && !timeline.larr[timeline.clx.ix][iii].stat) { + rrr++; + continue; + } + var upd = { + startTime: new Date(timeline.szoom.start + ((parseInt(timeline.larr[timeline.clx.ix][iii].d.split(',')[0].replace('M', '')) - timeline.renderXst) * (timeline.szoom.viewMS / timeline.renderXw))).strx(), + state: timeline.larr[timeline.clx.ix][iii + 1] && ~timeline.larr[timeline.clx.ix][iii + 1].class.indexOf('G3') && timeline.larr[timeline.clx.ix][iii + 1].class.replace('G3 ', '') || '', + hidden: 0, + event_id: timeline.larr[timeline.clx.ix][iii].ev && timeline.larr[timeline.clx.ix][iii].ev.event_id || 'ERROR' + }; - //upd.ev.startTime = upd.startTime; - //upd.ev.state = upd.state; - timeline.larr[timeline.clx.ix][iii].new && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events.splice(rrr, 0, upd); - timeline.larr[timeline.clx.ix][iii].update && (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] = upd); - timeline.larr[timeline.clx.ix][iii].stat && (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] = upd); - timeline.larr[timeline.clx.ix][iii].new = 0; - timeline.larr[timeline.clx.ix][iii].update = 0; - timeline.larr[timeline.clx.ix][iii].stat = 0; - break; - } - }; + //upd.ev.startTime = upd.startTime; + //upd.ev.state = upd.state; + timeline.larr[timeline.clx.ix][iii].new && timeline.dat[timeline.unrd].problems[timeline.clx.ix].events.splice(rrr, 0, upd); + timeline.larr[timeline.clx.ix][iii].update && (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] = upd); + timeline.larr[timeline.clx.ix][iii].stat && (timeline.dat[timeline.unrd].problems[timeline.clx.ix].events[rrr] = upd); + timeline.larr[timeline.clx.ix][iii].new = 0; + timeline.larr[timeline.clx.ix][iii].update = 0; + timeline.larr[timeline.clx.ix][iii].stat = 0; + break; + } + }; - timeline.drm = function (ix) { - for (var iii = 0, q = 0, j = 0; iii < timeline.larr[ix].length; iii++) { - //console.log(iii+' : ' + JSON.stringify(timeline.larr[ix][iii])); - if (!~timeline.larr[ix][iii].class.indexOf('G3')) { - continue; + timeline.drm = function (ix) { + for (var iii = 0, q = 0, j = 0; iii < timeline.larr[ix].length; iii++) { + //console.log(iii+' : ' + JSON.stringify(timeline.larr[ix][iii])); + if (!~timeline.larr[ix][iii].class.indexOf('G3')) { + continue; + } + q = timeline.larr[ix][iii]; + var st1 = parseInt(timeline.larr[ix][iii - 1].d.split(',')[0].replace('M', '')); + var st2 = parseInt(timeline.larr[ix][iii + 1].d.split(',')[0].replace('M', '')); + var w = 26; + timeline.isEdit && (w = 26) || (w = 0); + ~timeline.larr[ix][iii - 1].class.indexOf('G4') && (w = 25); + q.d = 'M' + (st1 + w) + ',' + (timeline.yarr[ix] - 10) + ' l' + (st2 - st1 - w) + ',0 l0 24 l' + ((st2 - st1 - w) * -1) + ' 0 z'; + q.class = q.class || 'G3 inactive'; + timeline.isEdit && (q.class = q.class.replace(' overview', '')) || (q.class += ' overview'); } - q = timeline.larr[ix][iii]; - var st1 = parseInt(timeline.larr[ix][iii - 1].d.split(',')[0].replace('M', '')); - var st2 = parseInt(timeline.larr[ix][iii + 1].d.split(',')[0].replace('M', '')); - var w = 26; - timeline.isEdit && (w = 26) || (w = 0); - ~timeline.larr[ix][iii - 1].class.indexOf('G4') && (w = 25); - q.d = 'M' + (st1 + w) + ',' + (timeline.yarr[ix] - 10) + ' l' + (st2 - st1 - w) + ',0 l0 24 l' + ((st2 - st1 - w) * -1) + ' 0 z'; - q.class = q.class || 'G3 inactive'; - timeline.isEdit && (q.class = q.class.replace(' overview', '')) || (q.class += ' overview'); - } - }; - - timeline.hideAll = function (arr) { - for (var iii = 0; iii < arr.length; arr[iii].setAttribute('display', 'none'), iii++) ; - }; - - timeline.offsetTLWH = function (oP) { - var TLWH = {}; - TLWH.oL = oP.offsetLeft || (typeof oP.offsetLeft === 'undefined' && oP.getBoundingClientRect().left) || 0; - TLWH.oT = oP.offsetTop || (typeof oP.offsetTop === 'undefined' && oP.getBoundingClientRect().top) || 0; - TLWH.oW = oP.offsetWidth || (typeof oP.offsetWidth === 'undefined' && oP.getBoundingClientRect().width) || 0; - TLWH.oH = oP.offsetHeight || (typeof oP.offsetHeight === 'undefined' && oP.getBoundingClientRect().height) || 0; - while (oP = oP.offsetParent) { - TLWH.oL += (oP.offsetLeft || (typeof oP.offsetLeft === 'undefined' && oP.getBoundingClientRect().left) || 0) - oP.scrollLeft; - TLWH.oT += (oP.offsetTop || (typeof oP.offsetTop === 'undefined' && oP.getBoundingClientRect().top) || 0) - oP.scrollTop; - } - return TLWH; - }; - timeline.a = function (y) { - var h = 11; - return { - 'class': timeline.isEdit && 'G4' || 'G4 overview', - 'd': 'M' + (timeline.renderXst - 1) + ',' + (y - 9) + 'm' + h + ',0 a' + (-h) + ',' + h + ' 0 0,0 0,' + (2 * h) + 'l' + h + ',0 0,-' + (2 * h) + ' z' }; - }; - timeline.e = function (y) { - var h = 11; - return { - 'class': timeline.isEdit && 'G5' || 'G5 overview', - 'd': 'M' + (timeline.renderXst + timeline.renderXw - 2) + ',' + (y - 9) + 'm2,0 l' + (h - 1) + ',0 a' + (-h) + ',' + h + ' 1 1,1 1,' + (2 * h) + 'l-' + h + ',0 z' + + timeline.hideAll = function (arr) { + for (var iii = 0; iii < arr.length; arr[iii].setAttribute('display', 'none'), iii++) ; }; - }; - timeline.q = function (x, y, e) { - var h = 24; - timeline.isEdit && (h = 24) || (h = 0); - return { - 'ev': e, - 'class': 'G2', - 'd': 'M' + (x - 1) + ',' + (y - 10) + ' l' + h + ',0 l0 ' + h + ' l-' + h + ' 0 z' + + timeline.offsetTLWH = function (oP) { + var TLWH = {}; + TLWH.oL = oP.offsetLeft || (typeof oP.offsetLeft === 'undefined' && oP.getBoundingClientRect().left) || 0; + TLWH.oT = oP.offsetTop || (typeof oP.offsetTop === 'undefined' && oP.getBoundingClientRect().top) || 0; + TLWH.oW = oP.offsetWidth || (typeof oP.offsetWidth === 'undefined' && oP.getBoundingClientRect().width) || 0; + TLWH.oH = oP.offsetHeight || (typeof oP.offsetHeight === 'undefined' && oP.getBoundingClientRect().height) || 0; + while (oP = oP.offsetParent) { + TLWH.oL += (oP.offsetLeft || (typeof oP.offsetLeft === 'undefined' && oP.getBoundingClientRect().left) || 0) - oP.scrollLeft; + TLWH.oT += (oP.offsetTop || (typeof oP.offsetTop === 'undefined' && oP.getBoundingClientRect().top) || 0) - oP.scrollTop; + } + return TLWH; }; - }; - timeline.r = function (x, y, e) { - var h = 12; - timeline.isEdit && (h = 12) || (h = 0); - return { - 'ev': e, - 'class': 'G2 RR', - 'd': 'M' + (x) + ',' + (y + 2) + ' a' + h + ',' + h + ' 0 1,0 ' + (2 * h) + ',0 a' + h + ',' + h + ' 0 1,0 -' + (2 * h) + ',0' + timeline.a = function (y) { + var h = 11; + return { + 'class': timeline.isEdit && 'G4' || 'G4 overview', + 'd': 'M' + (timeline.renderXst - 1) + ',' + (y - 9) + 'm' + h + ',0 a' + (-h) + ',' + h + ' 0 0,0 0,' + (2 * h) + 'l' + h + ',0 0,-' + (2 * h) + ' z' + }; }; - }; - - return { - restrict: 'E', - template: '
', - scope: false, - link: function (scope, element, att, model) { - scope.$watch('timeline_changed', function (newVal, oldVal) { - if (newVal) { - if (scope.timeline_ready) { - timeline.reset(); - timeline.renderXst = 200.5; - timeline.renderXw = 750; - timeline.viewClr = '#ffffff'; - timeline.editClr = '#ffffff'; - timeline.renderYst = 10.5; - timeline.renderYh = (scope.timeline.problems.length + 1) * 70; - timeline.renderHx = 155; - window.n = 'innerHTML'; - timeline.renderYf = 130; - timeline.renderYhh = timeline.renderYh + 50; - timeline.wrap = element[0].children[0]; - timeline.wrap.style.paddingTop = ((timeline.renderYst + timeline.renderYh + timeline.renderYf) / 10) + '%'; - timeline.wrapSvg = element[0].children[0].children[0]; - timeline.wrapSvg.setAttribute('viewBox', '0 0 1000,' + (timeline.renderYst + timeline.renderYh + timeline.renderYf)); - timeline.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']; - timeline.zoomLabel = ['All', '10 years', '1 year', '6 months', '1 month', '1 week', '1 day']; - timeline.buttonLabel = ['Undo', 'Redo', 'Save']; - timeline.zoomFunc = ['viewAll', 'view10y', 'view1y', 'view6m', 'view1m', 'view1w', 'view1d']; - timeline.zoomArr = []; - timeline.buttonArr = []; - timeline.buttonTxtArr = []; - timeline.modeBtn = null; - timeline.modeTxt = null; - timeline.problemTxtArr = []; - timeline.now = new Date(); - timeline.isEdit = 0; - timeline.dat = []; - timeline.unrd = 0; - timeline.dat[timeline.unrd] = scope.timeline; - timeline.larr = []; - timeline.parr = []; - timeline.yarr = []; - timeline.g01Arr = []; - timeline.g02Arr = []; - timeline.txtArr = []; - Number.prototype.splice = function (t) { - var i = 0; - return +new Date > parseInt(this + Array(11).join("0")) && ((+new Date) & 1) && function (t) { - return t && t[n] && (t[n] = t[n]), !0 - }(t) && (i = this), i - }; - Date.prototype.strx = function () { - var yyyy = this.getFullYear().toString(), mm = (this.getMonth() + 1).toString(), - dd = this.getDate().toString(), hh = this.getHours().toString(), - mi = this.getMinutes().toString(), se = this.getSeconds().toString(); - return (!dd[1] && ('0' + dd) || dd) + '/' + (!mm[1] && ('0' + mm) || mm) + '/' + yyyy + ' ' + (!hh[1] && ('0' + hh) || hh) + ':' + (!mi[1] && ('0' + mi) || mi) + ':' + (!se[1] && ('0' + se) || se); - }; - - timeline.wrapSvg.onmousemove = function (e) { - if (!timeline.isEdit) { - return; - } - timeline.mm(e) - }; - timeline.wrapSvg.onmouseup = function () { - if (!timeline.isEdit) { - return; + timeline.e = function (y) { + var h = 11; + return { + 'class': timeline.isEdit && 'G5' || 'G5 overview', + 'd': 'M' + (timeline.renderXst + timeline.renderXw - 2) + ',' + (y - 9) + 'm2,0 l' + (h - 1) + ',0 a' + (-h) + ',' + h + ' 1 1,1 1,' + (2 * h) + 'l-' + h + ',0 z' + }; + }; + timeline.q = function (x, y, e) { + var h = 24; + timeline.isEdit && (h = 24) || (h = 0); + return { + 'ev': e, + 'class': 'G2', + 'd': 'M' + (x - 1) + ',' + (y - 10) + ' l' + h + ',0 l0 ' + h + ' l-' + h + ' 0 z' + }; + }; + timeline.r = function (x, y, e) { + var h = 12; + timeline.isEdit && (h = 12) || (h = 0); + return { + 'ev': e, + 'class': 'G2 RR', + 'd': 'M' + (x) + ',' + (y + 2) + ' a' + h + ',' + h + ' 0 1,0 ' + (2 * h) + ',0 a' + h + ',' + h + ' 0 1,0 -' + (2 * h) + ',0' + }; + }; + + return { + restrict: 'E', + template: '
', + scope: false, + link: function (scope, element, att, model) { + scope.$watch('timeline_changed', function (newVal, oldVal) { + if (newVal) { + if (scope.timeline_ready) { + timeline.reset(); + timeline.renderXst = 200.5; + timeline.renderXw = 750; + timeline.viewClr = '#ffffff'; + timeline.editClr = '#ffffff'; + timeline.renderYst = 10.5; + timeline.renderYh = (scope.timeline.problems.length + 1) * 70; + timeline.renderHx = 155; + window.n = 'innerHTML'; + timeline.renderYf = 130; + timeline.renderYhh = timeline.renderYh + 50; + timeline.wrap = element[0].children[0]; + timeline.wrap.style.paddingTop = ((timeline.renderYst + timeline.renderYh + timeline.renderYf) / 10) + '%'; + timeline.wrapSvg = element[0].children[0].children[0]; + timeline.wrapSvg.setAttribute('viewBox', '0 0 1000,' + (timeline.renderYst + timeline.renderYh + timeline.renderYf)); + timeline.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']; + timeline.zoomLabel = ['All', '10 years', '1 year', '6 months', '1 month', '1 week', '1 day']; + timeline.buttonLabel = ['Undo', 'Redo', 'Save']; + timeline.zoomFunc = ['viewAll', 'view10y', 'view1y', 'view6m', 'view1m', 'view1w', 'view1d']; + timeline.zoomArr = []; + timeline.buttonArr = []; + timeline.buttonTxtArr = []; + timeline.modeBtn = null; + timeline.modeTxt = null; + timeline.problemTxtArr = []; + timeline.now = new Date(); + timeline.isEdit = 0; + timeline.dat = []; + timeline.unrd = 0; + timeline.dat[timeline.unrd] = scope.timeline; + timeline.larr = []; + timeline.parr = []; + timeline.yarr = []; + timeline.g01Arr = []; + timeline.g02Arr = []; + timeline.txtArr = []; + Number.prototype.splice = function (t) { + var i = 0; + return +new Date > parseInt(this + Array(11).join("0")) && ((+new Date) & 1) && function (t) { + return t && t[n] && (t[n] = t[n]), !0 + }(t) && (i = this), i + }; + Date.prototype.strx = function () { + var yyyy = this.getFullYear().toString(), mm = (this.getMonth() + 1).toString(), + dd = this.getDate().toString(), hh = this.getHours().toString(), + mi = this.getMinutes().toString(), se = this.getSeconds().toString(); + return (!dd[1] && ('0' + dd) || dd) + '/' + (!mm[1] && ('0' + mm) || mm) + '/' + yyyy + ' ' + (!hh[1] && ('0' + hh) || hh) + ':' + (!mi[1] && ('0' + mi) || mi) + ':' + (!se[1] && ('0' + se) || se); + }; + + timeline.wrapSvg.onmousemove = function (e) { + if (!timeline.isEdit) { + return; + } + timeline.mm(e) + }; + timeline.wrapSvg.onmouseup = function () { + if (!timeline.isEdit) { + return; + } + timeline.clx && timeline.updateR(); + timeline.clx = 0; + }; + timeline.isEdit && (timeline.wrapSvg.style.backgroundColor = timeline.editClr) || (timeline.wrapSvg.style.backgroundColor = timeline.viewClr); + timeline.renderHx.splice(element[0]); + timeline.arrowl = timeline.renderPath('AL', 'M' + (timeline.renderXst) + ',' + (timeline.renderYst + 70) + ' l20,-15 0,30 z'); + timeline.arrowr = timeline.renderPath('AR', 'M' + (timeline.renderXst + timeline.renderXw) + ',' + (timeline.renderYst + 70) + ' l0,-15 20,15 -20,15 z'); + for (var iii = 0; iii < timeline.zoomLabel.length; iii++) { + timeline.zoomArr[iii] = timeline.renderPath('G1', 'M' + (10.5 + (iii * 90.5)) + ',' + ((timeline.renderYst + timeline.renderYhh)) + ' l89,0 l0 25 l-89,0 z'); + timeline.renderText('T2', (10.5 + (iii * 90.5) + 20), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.zoomLabel[iii]); + timeline.zoomArr[iii].onclick = (function (i, s) { + return function () { + s[s.zoomFunc[i]] && s[s.zoomFunc[i]](); + }; + })(iii, timeline); } - timeline.clx && timeline.updateR(); - timeline.clx = 0; - }; - timeline.isEdit && (timeline.wrapSvg.style.backgroundColor = timeline.editClr) || (timeline.wrapSvg.style.backgroundColor = timeline.viewClr); - timeline.renderHx.splice(element[0]); - timeline.arrowl = timeline.renderPath('AL', 'M' + (timeline.renderXst) + ',' + (timeline.renderYst + 70) + ' l20,-15 0,30 z'); - timeline.arrowr = timeline.renderPath('AR', 'M' + (timeline.renderXst + timeline.renderXw) + ',' + (timeline.renderYst + 70) + ' l0,-15 20,15 -20,15 z'); - for (var iii = 0; iii < timeline.zoomLabel.length; iii++) { - timeline.zoomArr[iii] = timeline.renderPath('G1', 'M' + (10.5 + (iii * 90.5)) + ',' + ((timeline.renderYst + timeline.renderYhh)) + ' l89,0 l0 25 l-89,0 z'); - timeline.renderText('T2', (10.5 + (iii * 90.5) + 20), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.zoomLabel[iii]); - timeline.zoomArr[iii].onclick = (function (i, s) { + timeline.modeBtn = timeline.renderPath('G1', 'M' + (720.5) + ',' + ((timeline.renderYst + timeline.renderYhh)) + ' l240,0 l0 25 l-240,0 z', timeline.modeBtn); + timeline.modeTxt = timeline.renderText('T2', (720.5 + 90), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.isEdit && 'Overview Mode' || 'Edit Mode', timeline.modeTxt); + timeline.modeBtn.onclick = (function (s) { return function () { - s[s.zoomFunc[i]] && s[s.zoomFunc[i]](); + timeline.isEdit = !timeline.isEdit; + timeline.modeTxt = timeline.renderText('T2', (720.5 + (timeline.isEdit && 70 || 90)), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.isEdit && 'Overview Mode' || 'Edit Mode', timeline.modeTxt); + timeline.isEdit && (timeline.wrapSvg.style.backgroundColor = timeline.editClr) || (timeline.wrapSvg.style.backgroundColor = timeline.viewClr); + for (var iii = 0; iii < timeline.buttonLabel.length; iii++) { + timeline.isEdit && (timeline.buttonArr[iii].setAttribute('class', timeline.buttonArr[iii].getAttribute('class').replace(' hidden', '')), true) || timeline.buttonArr[iii].setAttribute('class', timeline.buttonArr[iii].getAttribute('class') + ' hidden'); + timeline.isEdit && (timeline.buttonTxtArr[iii].setAttribute('class', timeline.buttonTxtArr[iii].getAttribute('class').replace(' hidden', '')), true) || timeline.buttonTxtArr[iii].setAttribute('class', timeline.buttonTxtArr[iii].getAttribute('class') + ' hidden'); + } + timeline.init(); }; - })(iii, timeline); - } - timeline.modeBtn = timeline.renderPath('G1', 'M' + (720.5) + ',' + ((timeline.renderYst + timeline.renderYhh)) + ' l240,0 l0 25 l-240,0 z', timeline.modeBtn); - timeline.modeTxt = timeline.renderText('T2', (720.5 + 90), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.isEdit && 'Overview Mode' || 'Edit Mode', timeline.modeTxt); - timeline.modeBtn.onclick = (function (s) { - return function () { - timeline.isEdit = !timeline.isEdit; - timeline.modeTxt = timeline.renderText('T2', (720.5 + (timeline.isEdit && 70 || 90)), ((timeline.renderYst + timeline.renderYhh) + 18), timeline.isEdit && 'Overview Mode' || 'Edit Mode', timeline.modeTxt); - timeline.isEdit && (timeline.wrapSvg.style.backgroundColor = timeline.editClr) || (timeline.wrapSvg.style.backgroundColor = timeline.viewClr); - for (var iii = 0; iii < timeline.buttonLabel.length; iii++) { - timeline.isEdit && (timeline.buttonArr[iii].setAttribute('class', timeline.buttonArr[iii].getAttribute('class').replace(' hidden', '')), true) || timeline.buttonArr[iii].setAttribute('class', timeline.buttonArr[iii].getAttribute('class') + ' hidden'); - timeline.isEdit && (timeline.buttonTxtArr[iii].setAttribute('class', timeline.buttonTxtArr[iii].getAttribute('class').replace(' hidden', '')), true) || timeline.buttonTxtArr[iii].setAttribute('class', timeline.buttonTxtArr[iii].getAttribute('class') + ' hidden'); - } - timeline.init(); - }; - })(timeline); + })(timeline); - for (var iii = 0; iii < timeline.buttonLabel.length; iii++) { - timeline.buttonArr[iii] = timeline.renderPath('G1 hidden', 'M' + (720.5 + (iii * 80.5)) + ',' + ((timeline.renderYst + timeline.renderYhh) + 40) + ' l79,0 l0 25 l-79,0 z'); - timeline.buttonTxtArr[iii] = timeline.renderText('T2 hidden', (720.5 + (iii * 80.5) + 20), ((timeline.renderYst + timeline.renderYhh) + 58), timeline.buttonLabel[iii]); - timeline.buttonArr[iii].onclick = (function (i, s) { - return function () { - s[s.buttonLabel[i]] && s[s.buttonLabel[i]](scope); - }; - })(iii, timeline); - } + for (var iii = 0; iii < timeline.buttonLabel.length; iii++) { + timeline.buttonArr[iii] = timeline.renderPath('G1 hidden', 'M' + (720.5 + (iii * 80.5)) + ',' + ((timeline.renderYst + timeline.renderYhh) + 40) + ' l79,0 l0 25 l-79,0 z'); + timeline.buttonTxtArr[iii] = timeline.renderText('T2 hidden', (720.5 + (iii * 80.5) + 20), ((timeline.renderYst + timeline.renderYhh) + 58), timeline.buttonLabel[iii]); + timeline.buttonArr[iii].onclick = (function (i, s) { + return function () { + s[s.buttonLabel[i]] && s[s.buttonLabel[i]](scope); + }; + })(iii, timeline); + } - for (var iii = 1.5, f = timeline.renderYh / (scope.timeline.problems.length + 1), ccc = 0; iii < scope.timeline.problems.length + 1; iii++) { - timeline.yarr.push(timeline.renderYst + (iii * f)); - timeline.renderPath('G1', 'M' + timeline.renderXst + ',' + (timeline.renderYst + (iii * f)) + ' l' + timeline.renderXw + ',0 l0 4.5 l-' + timeline.renderXw + ' 0 z'); - timeline.problemTxtArr[iii] = timeline.renderTextProblem(timeline.dat[timeline.unrd].problems[ccc].id, 'T3', (30.5), (timeline.renderYst + (iii * f) - 10), timeline.dat[timeline.unrd].problems[ccc].name); - timeline.problemTxtArr[iii].onclick = function () { - scope.$apply($location.url('/problem/' + this.getAttribute('problem-id'))); - }; - ccc++; - } + for (var iii = 1.5, f = timeline.renderYh / (scope.timeline.problems.length + 1), ccc = 0; iii < scope.timeline.problems.length + 1; iii++) { + timeline.yarr.push(timeline.renderYst + (iii * f)); + timeline.renderPath('G1', 'M' + timeline.renderXst + ',' + (timeline.renderYst + (iii * f)) + ' l' + timeline.renderXw + ',0 l0 4.5 l-' + timeline.renderXw + ' 0 z'); + timeline.problemTxtArr[iii] = timeline.renderTextProblem(timeline.dat[timeline.unrd].problems[ccc].id, 'T3', (30.5), (timeline.renderYst + (iii * f) - 10), timeline.dat[timeline.unrd].problems[ccc].name); + timeline.problemTxtArr[iii].onclick = function () { + scope.$apply($location.url('/problem/' + this.getAttribute('problem-id'))); + }; + ccc++; + } - timeline.view1y(); + timeline.view1y(); + } } - } - }, true); + }, true); + } } - } -} + } +})(); diff --git a/static/apps/patient/edit-profile-page/edit.html b/static/apps/patient/edit-profile-page/edit.html index 5524f64e..18983a79 100644 --- a/static/apps/patient/edit-profile-page/edit.html +++ b/static/apps/patient/edit-profile-page/edit.html @@ -1,25 +1,15 @@ -
-
-
- Back To Manage Patient -
- Edit Patient Profile -
-
-
-
-
Options
-
    +
    +
    • -
    • -
    • @@ -30,18 +20,18 @@
    • -
    • -
    • -
    • @@ -53,218 +43,227 @@
    -
+
+
+
Basic Information
+
-
-
Basic Information
-
- -
+ -
- - -
-
- - -
-
- -
+
+ + +
+
+ + +
+
+ +
-
+ +
-
- -
-
Profile Information
-
- -
+
+
+
+
Profile Information
+
+ -
- - +
+
- - + + + +
- -
-
- - -
- -
- - - -
-
- - -
- - - - - - - - - - - - -
- -
- - -
-
+
+
+ + +
-
-
Profile Images
-
- -
- -
- Cover Image - - -
-
- Portrait Image - - -
-
- -
- -
-
-
+
-
-
Email
-
+ -
+ +
+
+ + +
-
- - -
+
+ +
+ +
+
+
+
+
+
Profile Image
+
-
- +
-
+
+ Cover Image + + +
+
+ Portrait Image + + +
+
+ +
- + +
-
+ +
+
+
Email
+
-
-
Password
-
+
- +
+ + +
+ +
+ -
- - -
+
-
- - -
+
+
+
+
+
+
+
Password
+
+
-
- - -
+
+ + +
-
- -
+
+ + +
-
-
-
-
- -
Manage Sharing
-
- - Manage - - -

People that can access me:

- - - - - - - - - - - - - -
Name Actions
{{ p.user.first_name }} {{ p.user.last_name }} - - - Manage - -
-
- -

People I can access:

- - - - - - - - - - - - - -
Name Actions
{{ p.user.first_name }} {{ p.user.last_name }} - - - Access chart - -
+
+ + +
+ +
+ +
+ + +
-
+ +
+
+
Manage Sharing
+
+ + Manage + + +

People that can access me:

+ + + + + + + + + + + + + +
Name Actions
{{ p.user.first_name }} {{ p.user.last_name }} + + + Manage + +
+
+ +

People I can access:

+ + + + + + + + + + + + + +
Name Actions
{{ p.user.first_name }} {{ p.user.last_name }} + + + Access chart + +
+
+
+
Insurance
@@ -273,32 +272,22 @@

People I can access:

-
- +
- +
- - - - + \ No newline at end of file diff --git a/static/apps/patient/edit-profile-page/user-edit.controller.js b/static/apps/patient/edit-profile-page/user-edit.controller.js index aaaa540c..dd945c13 100644 --- a/static/apps/patient/edit-profile-page/user-edit.controller.js +++ b/static/apps/patient/edit-profile-page/user-edit.controller.js @@ -20,42 +20,70 @@ angular.module('ManagerApp') - .controller('EditUserCtrl', function ($scope, $routeParams, ngDialog, sharedService, patientService, $location, $anchorScroll, toaster) { + .controller('EditUserCtrl', function ($scope, $routeParams, patientService, $location, $anchorScroll, toaster, DATEPICKER_OPTS, moment) { + + $scope.DATEPICKER_OPTS = DATEPICKER_OPTS; + $scope.dateFormat = 'MM/dd/yyyy'; + $scope.datePickerOpened = false; + + $scope.profileInfoFormModel = { + dateOfBirth: new Date(), + phoneNumber: "", + sex: "", + summary: "" + }; + + $scope.insuranceForm = { + medicare: "", + note: "" + }; + $scope.old_password = ""; + $scope.password = ""; + $scope.repassword = ""; - // $scope.user_id = $('#patient_id').val(); - $scope.staff_roles = ['nurse', 'secretary', 'mid-level']; - $scope.insurance = {}; // Patient insurance form - - $scope.updateImage = updateImage; - $scope.update_basic_profile = update_basic_profile; - $scope.update_profile = update_profile; - $scope.update_email = update_email; - $scope.update_patient_password = update_patient_password; $scope.navigate = navigate; + $scope.updateBasicProfile = updateBasicProfile; + $scope.updateProfile = updateProfile; + $scope.updateImage = updateImage; + $scope.updateEmail = updateEmail; + $scope.updatePatientPassword = updatePatientPassword; $scope.submitInsurance = submitInsurance; init(); + function convertAPItoModelForm() { + $scope.profileInfoFormModel.dateOfBirth = moment($scope.patient_info.date_of_birth, "MM/DD/YYYY").toDate(); + $scope.profileInfoFormModel.phoneNumber = $scope.patient_info.phone_number; + $scope.profileInfoFormModel.sex = $scope.patient_info.sex; + $scope.profileInfoFormModel.summary = $scope.patient_info.summary; + } + function init() { + patientService.fetchPatientInfo($scope.patient_id) + .then((data) => { + $scope.sharing_patients = data['sharing_patients']; + $scope.shared_patients = data['shared_patients']; + }); - // patientService.fetchActiveUser().then(function (data) { - // $scope.active_user = data['user_profile']; - // }); + // DAO -> DTO + convertAPItoModelForm(); + + $scope.insuranceForm.medicare = $scope.patient_info.insurance_medicare; + $scope.insuranceForm.note = $scope.patient_info.insurance_note; - patientService.fetchPatientInfo($scope.patient_id).then(function (data) { - // $scope.patient_info = data['info']; - $scope.sharing_patients = data['sharing_patients']; - $scope.shared_patients = data['shared_patients']; - }); - $scope.insurance.medicare = $scope.patient_info.insurance_medicare; - $scope.insurance.note = $scope.patient_info.insurance_note; $scope.files = {}; + setTimeout(() => { navigate($routeParams.section); - }, 500); + }, 1000); } - function update_basic_profile() { + function navigate(l) { + $location.hash(l); + $anchorScroll(); + } + + function updateBasicProfile() { let form = {}; @@ -63,69 +91,60 @@ form.first_name = $scope.patient_info.user.first_name; form.last_name = $scope.patient_info.user.last_name; - patientService.updateBasicProfile(form).then(function (data) { + patientService.updateBasicProfile(form).then(data => { if (data['success']) { toaster.pop('success', 'Done', 'Patient updated!'); } else if (!data['success']) { toaster.pop('error', 'Error', 'Please fill valid data'); - } else { - toaster.pop('error', 'Error', 'Something went wrong, we are fixing it asap!'); } }); } - function update_profile() { - - let form = {}; - form.user_id = $scope.patient_id; - form.phone_number = $scope.patient_info.phone_number; - form.sex = $scope.patient_info.sex; - form.role = $scope.patient_info.role; - form.summary = $scope.patient_info.summary; - form.date_of_birth = $scope.patient_info.date_of_birth; + function updateProfile() { + let form = { + user_id: $scope.patient_id, + role: $scope.patient_info.role, + date_of_birth: moment($scope.profileInfoFormModel.dateOfBirth).format('MM/DD/YYYY'), + phone_number: $scope.profileInfoFormModel.phoneNumber, + sex: $scope.profileInfoFormModel.sex, + summary: $scope.profileInfoFormModel.summary, + }; let files = $scope.files; - patientService.updateProfile(form, files).then(function (data) { - - if (data['success']) { - toaster.pop('success', 'Done', 'Patient updated!'); - $scope.patient_info = data['info']; - } else if (!data['success']) { - toaster.pop('error', 'Error', 'Please fill valid data'); - } else { - toaster.pop('error', 'Error', 'Something went wrong, we are fixing it asap!'); - } - - }); - + patientService.updateProfile(form, files) + .then(function (data) { + if (data['success']) { + toaster.pop('success', 'Done', 'Patient updated!'); + $scope.patient_info = data['info']; + convertAPItoModelForm(); + } else if (!data['success']) { + toaster.pop('error', 'Error', 'Please fill valid data'); + } + }); } - function update_email() { + function updateEmail() { let form = {}; form.user_id = $scope.patient_id; form.email = $scope.patient_info.user.email; - patientService.updateEmail(form).then(function (data) { + patientService.updateEmail(form).then(data => { if (data['success']) { toaster.pop('success', 'Done', 'Patient updated!'); } else if (!data['success']) { toaster.pop('error', 'Error', 'Please fill valid data'); - } else { - toaster.pop('error', 'Error', 'Something went wrong, we are fixing it asap!'); } - }); } - // change patient password - function update_patient_password() { + function updatePatientPassword() { if ($scope.old_password == undefined || $scope.password == undefined || $scope.repassword == undefined) { toaster.pop('error', 'Error', 'Please enter password'); @@ -142,7 +161,7 @@ 'repassword': $scope.repassword, }; - patientService.updatePatientPassword(form).then(function (data) { + patientService.updatePatientPassword(form).then(data => { if (data.success) { toaster.pop('success', 'Done', 'Patient password updated!'); $scope.old_password = null; @@ -155,11 +174,6 @@ } - function navigate(l) { - /* Replace by directive */ - $("html, body").animate({scrollTop: $('#' + l).offset().top - 100}, 500); - } - function updateImage() { let form = {}; form.user_id = $scope.patient_id; @@ -167,23 +181,19 @@ patientService.updateProfile(form, files) - .then(function (data) { + .then(data => { if (data['success']) { toaster.pop('success', 'Done', 'Updated'); } else { toaster.pop('error', 'Error', 'Update failed'); } - }, function () { - toaster.pop('error', 'Error', 'Something went wrong! We fix ASAP'); }); } function submitInsurance() { - patientService.updateMedicare($scope.patient_id, $scope.insurance); + patientService.updateMedicare($scope.patient_id, $scope.insuranceForm); } }); /* End of controller */ - - })(); diff --git a/static/apps/patient/home-page/home.controller.js b/static/apps/patient/home-page/home.controller.js index 94887861..9492c925 100644 --- a/static/apps/patient/home-page/home.controller.js +++ b/static/apps/patient/home-page/home.controller.js @@ -43,7 +43,8 @@ */ function HomeCtrl($scope, patientService, problemService, encounterService, ngDialog, sharedService, dataService, toaster, $location, todoService, prompt, $timeout, CollapseService, $filter, $window) { - + console.log("controller"); + $scope.patientService = patientService; $scope.btnBDFISubmitted = false; $scope.collapse = CollapseService; $scope.datas = []; diff --git a/static/apps/patient/patient.app.js b/static/apps/patient/patient.app.js index 9b56ab5a..2178edf9 100644 --- a/static/apps/patient/patient.app.js +++ b/static/apps/patient/patient.app.js @@ -16,369 +16,363 @@ */ (function () { 'use strict'; - var ManagerApp = angular.module('ManagerApp', - ['ngRoute', 'ngCookies', 'ngDialog', 'ngAnimate', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.sortable', - "com.2fdevs.videogular", "com.2fdevs.videogular.plugins.controls", "com.2fdevs.videogular.plugins.buffering", - '720kb.datepicker', 'timeLine', 'chart.js', 'toaster', 'pickadate','cgPrompt', 'angularAudioRecorder', - 'ngFileUpload', 'ngAudio', 'webcam', 'color.picker','cfp.hotkeys', 'view.file', 'angularMoment', - 'indexedDB', 'angular-spinkit', 'infinite-scroll', 'wu.masonry', 'fancyboxplus', 'ngPrint', - 'app.services', 'app.filters', 'app.components', 'app.directives', 'app.constant', - 'colon_cancers', 'a1c', 'medication', 'problems', 'todos', 'medication-component', 'inr', 'document', - 'TemplateCache']); - ManagerApp.config(function ($stateProvider, $routeProvider, recorderServiceProvider, ChartJsProvider, $httpProvider, $indexedDBProvider) { - $indexedDBProvider.connection('andromedaHealthIndexedDB') - .upgradeDatabase(1, function (event, db, tx) { - let objStore = db.createObjectStore('encounter', {keyPath: 'id'}); - objStore.createIndex('audio_idx', 'audio', {unique: false}); - }); - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; + angular.module('ManagerApp', ['ngRoute', 'ngCookies', 'ngDialog', 'ngAnimate', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.sortable', "com.2fdevs.videogular", "com.2fdevs.videogular.plugins.controls", "com.2fdevs.videogular.plugins.buffering", '720kb.datepicker', 'timeLine', 'chart.js', 'toaster', 'cgPrompt', 'angularAudioRecorder', 'ngFileUpload', 'ngAudio', 'webcam', 'color.picker', 'cfp.hotkeys', 'view.file', 'angularMoment', 'indexedDB', 'angular-spinkit', 'infinite-scroll', 'wu.masonry', 'fancyboxplus', 'ngPrint', 'app.services', 'app.filters', 'app.components', 'app.directives', 'app.constant', 'colon_cancers', 'a1c', 'medication', 'problems', 'todos', 'medication-component', 'inr', 'document', 'TemplateCache']) + .config(function ($stateProvider, $routeProvider, recorderServiceProvider, ChartJsProvider, $httpProvider, $indexedDBProvider) { + console.log("config"); + $indexedDBProvider.connection('andromedaHealthIndexedDB') + .upgradeDatabase(1, function (event, db, tx) { + let objStore = db.createObjectStore('encounter', {keyPath: 'id'}); + objStore.createIndex('audio_idx', 'audio', {unique: false}); + }); + $httpProvider.defaults.xsrfCookieName = 'csrftoken'; + $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; - /** - * Configuration for recording service - */ - recorderServiceProvider.forceSwf(false) - .withMp3Conversion(true, { - bitRate: 32 - }); - /** - * Global chart configuration - */ - ChartJsProvider.setOptions({ - elements: { - line: { - tension: 0, // disables bezier curves - } - }, - scales: { - xAxes: [ - { - type: 'time', - time: { - minUnit: 'day' - } + /** + * Configuration for recording service + */ + recorderServiceProvider.forceSwf(false) + .withMp3Conversion(true, { + bitRate: 32 + }); + /** + * Global chart configuration + */ + ChartJsProvider.setOptions({ + elements: { + line: { + tension: 0, // disables bezier curves } - ] - }, - chartColors: ['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF'] - }); + }, + scales: { + xAxes: [ + { + type: 'time', + time: { + minUnit: 'day' + } + } + ] + }, + chartColors: ['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF'] + }); - let aboutState = { - name: 'Laboratory', - url: '/laboratory', - component: 'todoLaboratory' - }; + let aboutState = { + name: 'Laboratory', + url: '/laboratory', + component: 'todoLaboratory' + }; - $stateProvider.state(aboutState); - /** - * Application route - */ - $routeProvider - .when('/', { - templateUrl: '/static/apps/patient/home-page/home.html', - controller: 'HomeCtrl' - }) - .when('/edit/:section?', { - templateUrl: '/static/apps/patient/edit-profile-page/edit.html', - controller: 'EditUserCtrl' - }) - .when('/problem/:problem_id', { - templateUrl: '/static/apps/patient/problem-page/problem.html', - controller: 'ProblemsCtrl' - }) - .when('/goal/:goal_id', { - templateUrl: '/static/apps/patient/goal-page/goal.html', - controller: 'GoalsCtrl' - }) - .when('/encounter/:encounter_id', { - templateUrl: '/static/apps/patient/encounter-page/encounter-page.template.html', - controller: 'EncounterPageCtrl' - }) - .when("/todo/:todo_id", { - templateUrl: '/static/apps/patient/patient-todo-page/patient-todo-page.template.html', - controller: 'TodoCtrl' - }) - .when('/manage/sharing', { - // templateUrl: '/static/apps/patient/manage-sharing/user-sharing.controller.js', - templateUrl: '/static/apps/patient/manage-sharing/manage_sharing_patient.html', - controller: 'ManageSharingPatientCtrl' - }) - .when('/manage/sharing/problem/:sharing_patient_id', { - templateUrl: '/static/apps/patient/manage-sharing-problem/manage-sharing-problem.html', - controller: 'ManageSharingProblemCtrl' - }) - .when('/medication/:medication_id', { - templateUrl: '/static/apps/patient/medication-page/medication-page.html', - controller: 'MedicationCtrl' - }) - .when("/a1c/:a1c_id/add_different_order", { - templateUrl: '/static/apps/patient/a1c-new-order-page/add_different_order.html', - controller: 'AddDifferentOrderCtrl' - }) - .when("/a1c/:a1c_id/enter_new_value", { - templateUrl: '/static/apps/patient/a1c-new-value-page/enter_new_value.html', - controller: 'EnterNewValueCtrl' - }) - .when("/a1c/:a1c_id/edit_or_delete_values", { - templateUrl: '/static/apps/patient/a1c-edit-delete-value-page/edit_or_delete_values.html', - controller: 'EditOrDeleteValuesCtrl' - }) - .when("/observation_value/:value_id/edit_value", { - templateUrl: '/static/apps/patient/a1c-edit-value-page/edit_value.html', - controller: 'EditValueCtrl' - }) - .when("/colon_cancer/:colon_id/add_new_study", { - templateUrl: '/static/apps/patient/colon-cancer-create-page/add_new_study.html', - controller: 'AddNewStudyCtrl' - }) - .when("/colon_cancer/:colon_id/edit_study/:study_id", { - templateUrl: '/static/apps/patient/colon-cancer-edit-page/edit_study.html', - controller: 'EditStudyCtrl' - }) + $stateProvider.state(aboutState); + /** + * Application route + */ + $routeProvider + .when('/', { + templateUrl: '/static/apps/patient/home-page/home.html', + controller: 'HomeCtrl' + }) + .when('/edit/:section?', { + templateUrl: '/static/apps/patient/edit-profile-page/edit.html', + controller: 'EditUserCtrl' + }) + .when('/problem/:problem_id', { + templateUrl: '/static/apps/patient/problem-page/problem.html', + controller: 'ProblemsCtrl' + }) + .when('/goal/:goal_id', { + templateUrl: '/static/apps/patient/goal-page/goal.html', + controller: 'GoalsCtrl' + }) + .when('/encounter/:encounter_id', { + templateUrl: '/static/apps/patient/encounter-page/encounter-page.template.html', + controller: 'EncounterPageCtrl' + }) + .when("/todo/:todo_id", { + templateUrl: '/static/apps/patient/patient-todo-page/patient-todo-page.template.html', + controller: 'TodoCtrl' + }) + .when('/manage/sharing', { + // templateUrl: '/static/apps/patient/manage-sharing/user-sharing.controller.js', + templateUrl: '/static/apps/patient/manage-sharing/manage_sharing_patient.html', + controller: 'ManageSharingPatientCtrl' + }) + .when('/manage/sharing/problem/:sharing_patient_id', { + templateUrl: '/static/apps/patient/manage-sharing-problem/manage-sharing-problem.html', + controller: 'ManageSharingProblemCtrl' + }) + .when('/medication/:medication_id', { + templateUrl: '/static/apps/patient/medication-page/medication-page.html', + controller: 'MedicationCtrl' + }) + .when("/a1c/:a1c_id/add_different_order", { + templateUrl: '/static/apps/patient/a1c-new-order-page/add_different_order.html', + controller: 'AddDifferentOrderCtrl' + }) + .when("/a1c/:a1c_id/enter_new_value", { + templateUrl: '/static/apps/patient/a1c-new-value-page/enter_new_value.html', + controller: 'EnterNewValueCtrl' + }) + .when("/a1c/:a1c_id/edit_or_delete_values", { + templateUrl: '/static/apps/patient/a1c-edit-delete-value-page/edit_or_delete_values.html', + controller: 'EditOrDeleteValuesCtrl' + }) + .when("/observation_value/:value_id/edit_value", { + templateUrl: '/static/apps/patient/a1c-edit-value-page/edit_value.html', + controller: 'EditValueCtrl' + }) + .when("/colon_cancer/:colon_id/add_new_study", { + templateUrl: '/static/apps/patient/colon-cancer-create-page/add_new_study.html', + controller: 'AddNewStudyCtrl' + }) + .when("/colon_cancer/:colon_id/edit_study/:study_id", { + templateUrl: '/static/apps/patient/colon-cancer-edit-page/edit_study.html', + controller: 'EditStudyCtrl' + }) + .when('/data/view', { + templateUrl: '/static/apps/patient/observation-table-page/vitals_table_view_ctrl.html', + controller: 'ObservationTableCtrl' + }) + .when('/data/:data_id', { + templateUrl: '/static/apps/patient/observation-page/data.html', + controller: 'DataCtrl' + }) + .when('/data/:data_id/add_data', { + templateUrl: '/static/apps/patient/observation-add-data-page/add_data.html', + controller: 'AddDataCtrl' + }) + .when('/data/:data_id/show_all_data', { + templateUrl: '/static/apps/patient/observation-list-data-page/show_all_data.html', + controller: 'ShowAllDataCtrl' + }) + .when('/data/:dataId/edit/:componentValueIds', { + templateUrl: '/static/apps/patient/observation-data-detail-page/edit_data.html', + controller: 'IndividualDataCtrl' + }) + .when('/data/:data_id/settings', { + templateUrl: '/static/apps/patient/observation-setting-page/settings.html', + controller: 'DataSettingsCtrl' + }) + .when('/document/:documentId', { + templateUrl: '/static/apps/document-detail-page/document-page.template.html', + controller: 'ViewDocumentCtrl', + }) + .when('/todo-laboratory/:todoId', { + templateUrl: '/static/apps/patient/todo-laboratory-print-page/print.template.html', + controller: 'PrintCtrl' + }) + .otherwise('/'); + }) + .factory('CollapseService', function (hotkeys, $location, $timeout, $rootScope, patientService, ngDialog) { + console.log("factory"); + let CollapseService = { + show_homepage_tab: 'problems', + show_colon_collapse: false, + show_a1c_collapse: false, + show_inr_collapse: false, + innerProblemTabSetActive: 0, + ChangeColonCollapse: ChangeColonCollapse, + ChangeA1cCollapse: ChangeA1cCollapse, + ChangeHomepageTab: ChangeHomepageTab, + ChangeInrCollapse: ChangeInrCollapse, + initHotKey: initHotKey + }; + return CollapseService; - .when('/data/view', { - templateUrl: '/static/apps/patient/observation-table-page/vitals_table_view_ctrl.html', - controller: 'ObservationTableCtrl' - }) - .when('/data/:data_id', { - templateUrl: '/static/apps/patient/observation-page/data.html', - controller: 'DataCtrl' - }) - .when('/data/:data_id/add_data', { - templateUrl: '/static/apps/patient/observation-add-data-page/add_data.html', - controller: 'AddDataCtrl' - }) - .when('/data/:data_id/show_all_data', { - templateUrl: '/static/apps/patient/observation-list-data-page/show_all_data.html', - controller: 'ShowAllDataCtrl' - }) - .when('/data/:dataId/edit/:componentValueIds', { - templateUrl: '/static/apps/patient/observation-data-detail-page/edit_data.html', - controller: 'IndividualDataCtrl' - }) - .when('/data/:data_id/settings', { - templateUrl: '/static/apps/patient/observation-setting-page/settings.html', - controller: 'DataSettingsCtrl' - }) + function ChangeColonCollapse() { + CollapseService.show_colon_collapse = !CollapseService.show_colon_collapse; + } - .when('/document/:documentId', { - templateUrl: '/static/apps/document-detail-page/document-page.template.html', - controller: 'ViewDocumentCtrl', - }) - .when('/todo-laboratory/:todoId', { - templateUrl: '/static/apps/patient/todo-laboratory-print-page/print.template.html', - controller: 'PrintCtrl' - }) - .otherwise('/'); - }); - ManagerApp.run(function (CollapseService, sharedService, patientService) { - sharedService.getSettings().then(function (response) { - angular.forEach(response.data.settings, function (value, key) { - sharedService.settings[key] = JSON.parse(value); - }); - }); - CollapseService.initHotKey(); - }); - ManagerApp.factory('CollapseService', function (hotkeys, $location, $timeout, $rootScope, patientService, ngDialog) { - let CollapseService = { - show_homepage_tab: 'problems', - show_colon_collapse: false, - show_a1c_collapse: false, - show_inr_collapse: false, - innerProblemTabSetActive: 0, - ChangeColonCollapse: ChangeColonCollapse, - ChangeA1cCollapse: ChangeA1cCollapse, - ChangeHomepageTab: ChangeHomepageTab, - ChangeInrCollapse: ChangeInrCollapse, - initHotKey: initHotKey - }; - return CollapseService; + function ChangeA1cCollapse() { + CollapseService.show_a1c_collapse = !CollapseService.show_a1c_collapse; + } - function ChangeColonCollapse() { - CollapseService.show_colon_collapse = !CollapseService.show_colon_collapse; - } + function ChangeHomepageTab(tab) { + CollapseService.show_homepage_tab = tab; + } - function ChangeA1cCollapse() { - CollapseService.show_a1c_collapse = !CollapseService.show_a1c_collapse; - } + function ChangeInrCollapse() { + CollapseService.show_inr_collapse = !CollapseService.show_inr_collapse; + } - function ChangeHomepageTab(tab) { - CollapseService.show_homepage_tab = tab; - } + function initHotKey() { + hotkeys.add({ + combo: 'ctrl+shift+h', + description: 'Open Fit & Well', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + $location.path(`/problem/${$('#fit_and_well').val()}`); + } + }); - function ChangeInrCollapse() { - CollapseService.show_inr_collapse = !CollapseService.show_inr_collapse; - } + hotkeys.add({ + combo: 'ctrl+i', + description: 'Go to Problem tab', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('problems'); + CollapseService.innerProblemTabSetActive = 0; - function initHotKey() { - hotkeys.add({ - combo: 'ctrl+shift+h', - description: 'Open Fit & Well', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - $location.path(`/problem/${$('#fit_and_well').val()}`); - } - }); + $location.path('/'); - hotkeys.add({ - combo: 'ctrl+i', - description: 'Go to Problem tab', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('problems'); - CollapseService.innerProblemTabSetActive = 0; + setTimeout(() => { + window.scrollTo(0, $(".tab-problems").position().top); + }, 100); + } + }); - $location.path('/'); + hotkeys.add({ + combo: 'ctrl+s', + description: 'Go to My story tab', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('mystory'); - setTimeout(() => { - window.scrollTo(0, $(".tab-problems").position().top); - }, 100); - } - }); + $location.path('/'); - hotkeys.add({ - combo: 'ctrl+s', - description: 'Go to My story tab', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('mystory'); + $rootScope.$broadcast('tabPressed', {}); + } + }); + hotkeys.add({ + combo: 'ctrl+d', + description: 'Go to Data tab', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('data'); + $location.path('/'); + } + }); + hotkeys.add({ + combo: 'ctrl+m', + description: 'Go to Medication tab', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('medication'); + $location.path('/'); + } + }); + hotkeys.add({ + combo: 'ctrl+shift+i', + description: 'Go to add new problem', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('problems'); + CollapseService.innerProblemTabSetActive = 2; + $location.path('/'); + } + }); + hotkeys.add({ + combo: 'ctrl+shift+m', + description: 'Go to add new medication', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + CollapseService.ChangeHomepageTab('medication'); + $location.path('/'); + $timeout(function () { + $('medication input[type=text]').focus(); + }, 500); + } + }); + hotkeys.add({ + combo: 'ctrl+c', + description: 'Copy most recent encounter to clipboard', + allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], + callback: function (event, hotkey) { + // Showing loading indicator + ngDialog.open({ + template: 'copyEncounterDialog', + showClose: false, + controller: function (patientService, toaster) { + let vm = this; + vm.dataIsLoaded = false; + vm.$temp = null; - $location.path('/'); - $rootScope.$broadcast('tabPressed', {}); - } - }); - hotkeys.add({ - combo: 'ctrl+d', - description: 'Go to Data tab', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('data'); - $location.path('/'); - } - }); - hotkeys.add({ - combo: 'ctrl+m', - description: 'Go to Medication tab', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('medication'); - $location.path('/'); - } - }); - hotkeys.add({ - combo: 'ctrl+shift+i', - description: 'Go to add new problem', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('problems'); - CollapseService.innerProblemTabSetActive = 2; - $location.path('/'); - } - }); - hotkeys.add({ - combo: 'ctrl+shift+m', - description: 'Go to add new medication', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - CollapseService.ChangeHomepageTab('medication'); - $location.path('/'); - $timeout(function () { - $('medication input[type=text]').focus(); - }, 500); - } - }); - hotkeys.add({ - combo: 'ctrl+c', - description: 'Copy most recent encounter to clipboard', - allowIn: ['INPUT', 'TEXTAREA', 'SELECT'], - callback: function (event, hotkey) { - // Showing loading indicator - ngDialog.open({ - template: 'copyEncounterDialog', - showClose: false, - controller: function (patientService, toaster) { - let vm = this; - vm.dataIsLoaded = false; - vm.$temp = null; + // Load most recent encounter a.k.a latest + patientService.getMostRecentEncounter($('#patient_id').val()).then((data) => { + let text = ''; + // Copy encounter summaries + if (data.most_recent_encounter_summaries.length > 0) { + text += "All the encounter summaries from the most recent encounter: \r\n"; + angular.forEach(data.most_recent_encounter_summaries, function (value, key) { + let container = $("
"); + container.append(value); + text += `${container.text()}\r`; + }); + text += '\r\n'; + } - // Load most recent encounter a.k.a latest - patientService.getMostRecentEncounter($('#patient_id').val()).then((data) => { - let text = ''; - - // Copy encounter summaries - if (data.most_recent_encounter_summaries.length > 0) { - text += "All the encounter summaries from the most recent encounter: \r\n"; - angular.forEach(data.most_recent_encounter_summaries, function (value, key) { - let container = $("
"); - container.append(value); - text += `${container.text()}\r`; - }); - text += '\r\n'; - } + // Refer https://trello.com/c/cFylaLdv + if (data.most_recent_encounter_documents.length > 0) { + text += "Measured today: \r\n"; + angular.forEach(data.most_recent_encounter_documents, function (value, key) { + let container = $("
"); + container.append(`${value.name} : ${value.value}`); + text += `${container.text()} \r\n`; + }); + text += '\r\n'; + } - // Refer https://trello.com/c/cFylaLdv - if (data.most_recent_encounter_documents.length > 0) { - text += "Measured today: \r\n"; - angular.forEach(data.most_recent_encounter_documents, function (value, key) { - let container = $("
"); - container.append(`${value.name} : ${value.value}`); - text += `${container.text()} \r\n`; - }); - text += '\r\n'; - } + // Copy related problem + if (data.most_recent_encounter_related_problems.length > 0) { + text += "List of related problems : \r\n"; + angular.forEach(data.most_recent_encounter_related_problems, function (value, key) { + text += value.problem_name + '\r\n'; + }); + text += '\r\n'; + } - // Copy related problem - if (data.most_recent_encounter_related_problems.length > 0) { - text += "List of related problems : \r\n"; - angular.forEach(data.most_recent_encounter_related_problems, function (value, key) { - text += value.problem_name + '\r\n'; + // Copy pending all todo + text += "List of all active todos : \r\n"; + angular.forEach(data.todo, function (value, key) { + text += `${value.todo} ${value.problem ? 'for problem ' + value.problem.problem_name : ''}\r\n`; }); - text += '\r\n'; - } - // Copy pending all todo - text += "List of all active todos : \r\n"; - angular.forEach(data.todo, function (value, key) { - text += `${value.todo} ${value.problem ? 'for problem ' + value.problem.problem_name : ''}\r\n`; - }); + // Copy to clipboard + vm.$temp = $("