From 98a211ee90e508978b2f817ace26b46fbf3181a2 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 11 Dec 2016 12:35:13 +0000 Subject: [PATCH 001/124] chore(package): update ember-cli-stylelint to version 0.9.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f4f5d1199..bb8b0fa597 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "ember-cli-release": "^0.2.9", "ember-cli-sass": "^5.2.1", "ember-cli-sri": "^2.1.0", - "ember-cli-stylelint": "0.7.1", + "ember-cli-stylelint": "0.9.0", "ember-cli-template-lint": "0.4.12", "ember-cli-test-loader": "^1.1.0", "ember-cli-uglify": "^1.2.0", From 47ca076734de9b307a68431709706d063515d3a0 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 12 Dec 2016 09:15:53 +0000 Subject: [PATCH 002/124] chore(package): update stylelint-scss to version 1.4.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f4f5d1199..293a9d8203 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "stylelint": "7.6.0", "stylelint-config-concentric": "1.0.6", "stylelint-declaration-use-variable": "1.6.0", - "stylelint-scss": "1.3.4", + "stylelint-scss": "1.4.0", "uuid": "^3.0.0" }, "ember-addon": { From 1d198904d6cd21a68156919d3f0e6c848a836ed8 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 12 Dec 2016 18:02:27 +0000 Subject: [PATCH 003/124] chore(package): update ember-ajax to version 2.5.3 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f4f5d1199..1fee6616f2 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "broccoli-merge-trees": "^1.1.1", "broccoli-serviceworker": "0.1.4", "broccoli-stylelint": "billybonks/broccoli-stylelint", - "ember-ajax": "2.5.2", + "ember-ajax": "2.5.3", "ember-browserify": "^1.1.12", "ember-cli": "2.10.0", "ember-cli-active-link-wrapper": "0.3.2", From b61682d2cd050c2a1be04d6b5c62e32e0d0471a1 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 19 Dec 2016 18:19:37 +0000 Subject: [PATCH 004/124] chore(package): update ember-cli-fake-server to version 0.3.2 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 519ca9de8f..90c5ec9143 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "ember-cli-dependency-checker": "^1.3.0", "ember-cli-deprecation-workflow": "0.2.3", "ember-cli-eslint": "3.0.0", - "ember-cli-fake-server": "0.3.1", + "ember-cli-fake-server": "0.3.2", "ember-cli-htmlbars": "^1.0.10", "ember-cli-htmlbars-inline-precompile": "^0.3.3", "ember-cli-inject-live-reload": "^1.4.1", From a28fb60cdb572225911d0096156f17f9f19fbc09 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 23 Dec 2016 00:41:09 +0000 Subject: [PATCH 005/124] chore(package): update ember-cli-sass to version 6.0.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b641ce7bc1..12e01904ae 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "ember-cli-inject-live-reload": "^1.4.1", "ember-cli-qunit": "^3.0.1", "ember-cli-release": "^0.2.9", - "ember-cli-sass": "^5.2.1", + "ember-cli-sass": "^6.0.0", "ember-cli-sri": "^2.1.0", "ember-cli-stylelint": "0.7.1", "ember-cli-template-lint": "0.4.12", From c0078635adc4945025b18f5ac06882152b7e9ae4 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 30 Dec 2016 21:37:33 +0000 Subject: [PATCH 006/124] chore(package): update ember-truth-helpers to version 1.3.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 139e826b9c..7783317d21 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "ember-select-list": "0.9.5", "ember-simple-auth": "^1.1.0", "ember-sinon-qunit": "^1.4.0", - "ember-truth-helpers": "1.2.0", + "ember-truth-helpers": "1.3.0", "ember-validations": "2.0.0-alpha.5", "eslint-plugin-ember-suave": "^1.0.0", "express": "^4.8.5", From f6325f16029bdebbd2f9ff19569a71ce69a43a00 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 1 Jan 2017 03:26:04 +0000 Subject: [PATCH 007/124] chore(package): update ember-cli-eslint to version 3.0.1 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 139e826b9c..00b94f08a2 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "ember-cli-content-security-policy": "0.5.0", "ember-cli-dependency-checker": "^1.3.0", "ember-cli-deprecation-workflow": "0.2.3", - "ember-cli-eslint": "3.0.0", + "ember-cli-eslint": "3.0.1", "ember-cli-fake-server": "0.3.1", "ember-cli-htmlbars": "^1.0.10", "ember-cli-htmlbars-inline-precompile": "^0.3.3", From fed0f88767b2818e3153bfbdb45acfda6556da81 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 2 Jan 2017 18:48:22 +0000 Subject: [PATCH 008/124] chore(package): update stylelint-config-concentric to version 1.0.7 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 139e826b9c..af5634037c 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "pouchdb-list": "^1.1.0", "request": "2.79.0", "stylelint": "7.6.0", - "stylelint-config-concentric": "1.0.6", + "stylelint-config-concentric": "1.0.7", "stylelint-declaration-use-variable": "1.6.0", "stylelint-scss": "1.3.4", "uuid": "^3.0.0" From ce9b90d8c10e8eddebe821af8b0884e6e81aa78e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:23:42 +0100 Subject: [PATCH 009/124] added basic translations for report --- app/locales/en/translations.js | 18 ++++++++++++-- app/reports/edit/controller.js | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 app/reports/edit/controller.js diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 1e8750266f..5ffd0f8b52 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -853,7 +853,8 @@ export default { notes: 'Notes', orders: 'Orders', procedures: 'Procedures', - vitals: 'Vitals' + vitals: 'Vitals', + reports: 'Reports' } }, labs: { @@ -954,7 +955,8 @@ export default { newAppointment: 'New Appointment', backToPatients: 'Back to Patient List', newPatient: '+ new patient', - patientCheckIn: 'Patient Check In' + patientCheckIn: 'Patient Check In', + newOPDReport: 'New OPD Report' }, labels: { primaryDiagnosis: 'Primary Diagnoses', @@ -1080,6 +1082,18 @@ export default { addMedication: 'Add Medication' } }, + reports: { + titles: { + edit: 'Edit Report', + saved: 'Report Saved', + new: 'New Report' + }, + messages: { + deleteMedication: 'Are you sure you want to delete this medication?', + delete: 'Are you sure you wish to delete this report?', + saved: 'The report has been saved.' + } + }, components: { chargesByTypeTab: { charges: 'charges' diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js new file mode 100644 index 0000000000..9a10ecdf87 --- /dev/null +++ b/app/reports/edit/controller.js @@ -0,0 +1,44 @@ +import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller'; +import ChargeActions from 'hospitalrun/mixins/charge-actions'; +import Ember from 'ember'; +import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; + +export default AbstractEditController.extend(PatientSubmodule, { + visitsController: Ember.inject.controller('visits'), + + lookupListsToUpdate: [], + + editController: Ember.inject.controller('visits/edit'), + newReport: false, + + title: function() { + let isNew = this.get('model.isNew'); + if (isNew) { + return this.get('i18n').t('reports.titles.add'); + } + return this.get('i18n').t('reports.titles.edit'); + }.property('model.isNew'), + + updateCapability: 'add_report', + + actions: { + + }, + + beforeUpdate() { + return new Ember.RSVP.Promise(function(resolve, reject) { + if (this.get('model.isNew')) { + this.addChildToVisit(this.get('model'), 'reports').then(resolve, reject); + } else { + resolve(); + } + + }.bind(this)); + }, + + afterUpdate() { + let alertTitle = this.get('i18n').t('reports.titles.saved'); + let alertMessage = this.get('i18n').t('reports.messages.saved'); + this.saveVisitIfNeeded(alertTitle, alertMessage); + } +}); From 3dd403259591464d30ca1764e4b55ae6d745515d Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:25:20 +0100 Subject: [PATCH 010/124] feat: added report model --- app/models/report.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/models/report.js diff --git a/app/models/report.js b/app/models/report.js new file mode 100644 index 0000000000..0762dce9d5 --- /dev/null +++ b/app/models/report.js @@ -0,0 +1,26 @@ +import AbstractModel from 'hospitalrun/models/abstract'; +import DS from 'ember-data'; + +export default AbstractModel.extend({ + // Attributes + description: DS.attr('string'), + reportDate: DS.attr('date'), + + // Associations + visit: DS.belongsTo('visit', { async: false }), + + validations: { + description: { + presence: true + }, + + reportDate: { + presence: true + }, + display_reportDate: { + presence: { + message: 'Please select a valid date' + } + } + } +}); From e883089b5596493a7862bcc7c9a1199645721b7e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:27:06 +0100 Subject: [PATCH 011/124] feat: added report tabs to visit page --- app/visits/edit/controller.js | 12 ++++++++++++ app/visits/edit/template.hbs | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 434f217a2f..744e9427a8 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -64,6 +64,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return this.currentUserCan('add_vitals'); }.property(), + canAddReport: function() { + return this.currentUserCan('add_report'); + }.property(), + canDeleteImaging: function() { return this.currentUserCan('delete_imaging'); }.property(), @@ -84,6 +88,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return this.currentUserCan('delete_vitals'); }.property(), + canDeleteReport: function() { + return this.currentUserCan('delete_report'); + }.property(), + isAdmissionVisit: function() { let visitType = this.get('model.visitType'); let isAdmission = (visitType === 'Admission'); @@ -421,6 +429,10 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.send('openModal', 'patients.notes', model); }, + newReport() { + this._addChildObject('reports.edit'); + }, + newAppointment() { this._addChildObject('appointments.edit'); }, diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 49d6331c14..f56cfa5d87 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -129,6 +129,11 @@ {{t 'visits.navigation.charges'}} +
  • + + {{t 'visits.navigation.reports'}} + +
  • @@ -257,6 +262,18 @@ {{partial 'item-charges'}} {{/em-form}}
    +
    +
    +
    + {{#if canAddReport}} + + {{/if}} +
    +
    + Listing of reports +
    +
    +
    {{/unless}} From 0774d1cce0b8c0acf148aa15508329bb41cd20eb Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:28:07 +0100 Subject: [PATCH 012/124] feat: added report route to router --- app/router.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/router.js b/app/router.js index b61d95cc36..5f161daf32 100755 --- a/app/router.js +++ b/app/router.js @@ -101,6 +101,13 @@ Router.map(function() { }, function() { this.route('edit', { path: '/edit/:procedure_id' }); }); + + this.route('reports', { + resetNamespace: true + }, function() { + this.route('edit', { path: '/edit/:report_id' }); + }); + }); }); From 7d4d07a60368c79ef0b9ea840a6e3d6da57f8e4e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:29:20 +0100 Subject: [PATCH 013/124] feat: added report page --- app/reports/edit/route.js | 21 +++++++++++++++++++++ app/reports/edit/template.hbs | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 app/reports/edit/route.js create mode 100644 app/reports/edit/template.hbs diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js new file mode 100644 index 0000000000..d84c9a3d7e --- /dev/null +++ b/app/reports/edit/route.js @@ -0,0 +1,21 @@ +import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import ChargeRoute from 'hospitalrun/mixins/charge-route'; +import Ember from 'ember'; +import { translationMacro as t } from 'ember-i18n'; + +export default AbstractEditRoute.extend(ChargeRoute, { + editTitle: t('reports.titles.edit'), + modelName: 'report', + newTitle: t('reports.titles.new'), + database: Ember.inject.service(), + + getNewData() { + return Ember.RSVP.resolve({ + reportDate: new Date() + }); + }, + + setupController(controller, model) { + this._super(controller, model); + } +}); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs new file mode 100644 index 0000000000..5f9836f3ec --- /dev/null +++ b/app/reports/edit/template.hbs @@ -0,0 +1,5 @@ +{{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + + {{/em-form}} +{{/edit-panel}} \ No newline at end of file From 80de01fa88da85fb37a7a3b1bdf045f6c3b9eb9a Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:30:36 +0100 Subject: [PATCH 014/124] feat: reports to visits children --- app/mixins/patient-submodule.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/mixins/patient-submodule.js b/app/mixins/patient-submodule.js index 85e91d01a4..28aaf94db4 100644 --- a/app/mixins/patient-submodule.js +++ b/app/mixins/patient-submodule.js @@ -229,6 +229,7 @@ export default Ember.Mixin.create(PatientVisits, { promises.push(visit.get('medication')); promises.push(visit.get('procedures')); promises.push(visit.get('vitals')); + promises.push(visit.get('reports')); } return promises; }, From 1495e89092359832f467744c6b3f5a5b47e53ccf Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 16:31:37 +0100 Subject: [PATCH 015/124] feat: added add/delete report capabilities --- app/mixins/user-session.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/mixins/user-session.js b/app/mixins/user-session.js index fc9162a307..bac68cfed1 100644 --- a/app/mixins/user-session.js +++ b/app/mixins/user-session.js @@ -197,6 +197,15 @@ export default Ember.Mixin.create({ 'Nurse Manager', 'System Administrator' ], + add_report: [ + 'Data Entry', + 'Doctor', + 'Hospital Administrator', + 'Medical Records Officer', + 'Nurse', + 'Nurse Manager', + 'System Administrator' + ], admit_patient: [ 'Data Entry', 'Doctor', @@ -323,6 +332,14 @@ export default Ember.Mixin.create({ 'Nurse Manager', 'System Administrator' ], + delete_report: [ + 'Doctor', + 'Hospital Administrator', + 'Medical Records Officer', + 'Nurse', + 'Nurse Manager', + 'System Administrator' + ], delete_visit: [ 'Doctor', 'Hospital Administrator', From 7c466229fc75cba1c8e51dc9b698897366c3ab5c Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 26 Jan 2017 19:41:09 +0100 Subject: [PATCH 016/124] fix: fixed diagnosisContainer issue on browser back history button --- app/reports/edit/template.hbs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 5f9836f3ec..5c63bd18c6 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,5 +1,17 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - + {{#if model.patient}} + {{patient-summary + patient=model.patient + diagnosisContainer=model.visit + returnTo='visits.edit' + returnToContext=model.id + disablePatientLink=model.isNew + allowAddAllergy=true + allowAddDiagnosis=true + allowAddOperativePlan=true + diagnosisList=diagnosisList + }} + {{/if}} {{/em-form}} {{/edit-panel}} \ No newline at end of file From f24c59ef3294e2cbfa2d38efcfc6e1c2c4709b03 Mon Sep 17 00:00:00 2001 From: Chima Date: Mon, 30 Jan 2017 14:04:59 +0100 Subject: [PATCH 017/124] fix: display different report title based on type of visit --- app/locales/en/translations.js | 13 ++++++++++++- app/reports/edit/route.js | 4 ---- app/reports/edit/template.hbs | 11 +++-------- app/visits/edit/controller.js | 8 +++++++- app/visits/edit/template.hbs | 10 ++++++++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 5ffd0f8b52..241537a899 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -956,7 +956,8 @@ export default { backToPatients: 'Back to Patient List', newPatient: '+ new patient', patientCheckIn: 'Patient Check In', - newOPDReport: 'New OPD Report' + newOPDReport: 'New OPD Report', + newDischargeReport: 'New Discharge Report' }, labels: { primaryDiagnosis: 'Primary Diagnoses', @@ -1088,6 +1089,16 @@ export default { saved: 'Report Saved', new: 'New Report' }, + opd: { + titles: { + new: 'New OPD Report' + } + }, + discharge: { + titles: { + new: 'New Discharge Report' + } + }, messages: { deleteMedication: 'Are you sure you want to delete this medication?', delete: 'Are you sure you wish to delete this report?', diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index d84c9a3d7e..5b6686ae4c 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,14 +1,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; -import { translationMacro as t } from 'ember-i18n'; export default AbstractEditRoute.extend(ChargeRoute, { - editTitle: t('reports.titles.edit'), modelName: 'report', - newTitle: t('reports.titles.new'), database: Ember.inject.service(), - getNewData() { return Ember.RSVP.resolve({ reportDate: new Date() diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 5c63bd18c6..09f95f40e0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,16 +1,11 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if model.patient}} + {{#if model.visit}} {{patient-summary - patient=model.patient - diagnosisContainer=model.visit - returnTo='visits.edit' + patient=model.visit.patient + returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew - allowAddAllergy=true - allowAddDiagnosis=true - allowAddOperativePlan=true - diagnosisList=diagnosisList }} {{/if}} {{/em-form}} diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 744e9427a8..ec28e3a254 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -8,6 +8,7 @@ import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import UserSession from 'hospitalrun/mixins/user-session'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; import VisitTypes from 'hospitalrun/mixins/visit-types'; +import { translationMacro as t } from 'ember-i18n'; const { computed, @@ -430,7 +431,12 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { - this._addChildObject('reports.edit'); + let that = this; + this._addChildObject('reports.edit', (newRoute) => { + let controller = newRoute.controllerFor('visits'); + let isOutPatient = that.get('model').get('outPatient'); + controller.set('currentScreenTitle', isOutPatient ? t('reports.opd.titles.new') : t('reports.discharge.titles.new')); + }); }, newAppointment() { diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index f56cfa5d87..502c928195 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -266,11 +266,17 @@
    {{#if canAddReport}} - + {{/if}}
    - Listing of reports +
    From 733c2315c43a5a45c9798f4aecd21057add7ef9c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 31 Jan 2017 14:03:09 +0000 Subject: [PATCH 018/124] chore(package): update ember-cli-content-security-policy to version 0.6.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7bb5b753e..6f78c48168 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "ember-cli-active-link-wrapper": "0.3.2", "ember-cli-app-version": "^2.0.0", "ember-cli-babel": "^5.1.7", - "ember-cli-content-security-policy": "0.5.0", + "ember-cli-content-security-policy": "0.6.0", "ember-cli-dependency-checker": "^1.3.0", "ember-cli-deprecation-workflow": "0.2.3", "ember-cli-eslint": "3.0.0", From 8e8d1960b92dafa14cfd35ef287d70cb1fc65d19 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Fri, 3 Feb 2017 10:38:08 -0500 Subject: [PATCH 019/124] Added theater scheduling Resolves #761 --- app/appointments/calendar/route.js | 81 ++++++----- app/appointments/edit/controller.js | 96 ++++++++----- app/appointments/edit/route.js | 49 ++++++- app/appointments/edit/template.hbs | 64 +++++---- app/appointments/index/route.js | 1 + app/appointments/route.js | 3 + app/appointments/theater/controller.js | 21 +++ app/appointments/theater/route.js | 20 +++ app/appointments/theater/template.hbs | 39 ++++++ app/components/upcoming-appointments.js | 43 ++++++ app/locales/en/translations.js | 42 ++++-- app/mixins/navigation.js | 25 +++- app/models/appointment.js | 3 - app/models/operative-plan.js | 1 - app/patients/edit/controller.js | 10 ++ app/patients/edit/template.hbs | 11 +- app/patients/operation-report/route.js | 16 +-- app/patients/operation-report/template.hbs | 3 +- app/patients/operative-plan/controller.js | 4 +- app/patients/operative-plan/route.js | 32 ++++- app/patients/operative-plan/template.hbs | 2 +- app/router.js | 1 + app/templates/components/calendar-control.hbs | 4 + app/templates/components/date-time-picker.hbs | 10 +- .../components/upcoming-appointments.hbs | 17 +++ app/utils/pouch-views.js | 129 ++++++++++-------- config/environment.js | 4 + tests/acceptance/appointments-test.js | 125 ++++++++++++++--- tests/acceptance/operative-test.js | 4 - tests/fixtures/admin.txt | 12 +- tests/fixtures/appointments.txt | 14 +- tests/fixtures/billing.txt | 14 +- tests/fixtures/default.txt | 12 +- tests/fixtures/imaging.txt | 12 +- tests/fixtures/inventory.txt | 12 +- tests/fixtures/labs.txt | 14 +- tests/fixtures/medication.txt | 14 +- tests/fixtures/patient.txt | 14 +- tests/unit/models/appointment-test.js | 3 - 39 files changed, 697 insertions(+), 284 deletions(-) create mode 100644 app/appointments/theater/controller.js create mode 100644 app/appointments/theater/route.js create mode 100644 app/appointments/theater/template.hbs create mode 100644 app/components/upcoming-appointments.js create mode 100644 app/templates/components/upcoming-appointments.hbs diff --git a/app/appointments/calendar/route.js b/app/appointments/calendar/route.js index 38303d26bd..45c165e759 100644 --- a/app/appointments/calendar/route.js +++ b/app/appointments/calendar/route.js @@ -8,7 +8,6 @@ const { } = Ember; export default AppointmentIndexRoute.extend({ - dateIntervalEnd: null, dateIntervalStart: null, editReturn: 'appointments.calendar', @@ -27,48 +26,68 @@ export default AppointmentIndexRoute.extend({ }, model(params) { - function createCalendarEvent(appointment) { - let title = get(appointment, 'patient.displayName'); - let provider = get(appointment, 'provider'); - if (!isEmpty(provider)) { - title = `${title}\n${provider}`; - } - return { - allDay: get(appointment, 'allDay'), - title, - start: get(appointment, 'startDate'), - end: get(appointment, 'endDate'), - referencedAppointment: appointment - }; - } - - function createCalendarEvents(appointments) { - return appointments.map(createCalendarEvent); - } - return this._super(params) - .then(createCalendarEvents) + .then(this._createCalendarEvents.bind(this)) .then(function(calendarEvents) { - return { - events: calendarEvents, - selectedAppointmentType: params.appointmentType, - selectedProvider: params.provider, - selectedStatus: params.status, - selectedLocation: params.location - }; + calendarEvents.selectedAppointmentType = params.appointmentType; + calendarEvents.selectedProvider = params.provider; + calendarEvents.selectedStatus = params.status; + calendarEvents.selectedLocation = params.location; + return calendarEvents; }); }, + _createCalendarEvent(appointment) { + let title = get(appointment, 'patient.displayName'); + let provider = get(appointment, 'provider'); + if (!isEmpty(provider)) { + title = `${title}\n${provider}`; + } + let event = { + allDay: get(appointment, 'allDay'), + title, + start: get(appointment, 'startDate'), + end: get(appointment, 'endDate'), + referencedAppointment: appointment + }; + let location = get(appointment, 'location'); + if (isEmpty(location)) { + let i18n = get(this, 'i18n'); + location = i18n.t('appointments.labels.noLocation').toString(); + } + event.resourceId = location.toLowerCase(); + return event; + }, + + _createCalendarEvents(appointments) { + let events = []; + let resources = []; + appointments.forEach((appointment) => { + let event = this._createCalendarEvent(appointment); + events.push(event); + let resourceId = get(event, 'resourceId'); + if (!resources.findBy('id', resourceId)) { + resources.push({ + id: resourceId, + title: get(event, 'referencedAppointment.location') + }); + } + }); + return { + events, + resources + }; + }, + _modelQueryParams(params) { let { endDate, startDate } = params; if (endDate === null || startDate === null) { return this._super(params); } - let maxValue = get(this, 'maxValue'); let searchOptions = { - startkey: [parseInt(startDate), null, this._getMinPouchId()], - endkey: [parseInt(endDate), maxValue, this._getMaxPouchId()] + startkey: [parseInt(startDate), parseInt(startDate), this._getMinPouchId()], + endkey: [parseInt(endDate), parseInt(endDate), this._getMaxPouchId()] }; return { diff --git a/app/appointments/edit/controller.js b/app/appointments/edit/controller.js index 06c20e1439..121815626f 100644 --- a/app/appointments/edit/controller.js +++ b/app/appointments/edit/controller.js @@ -4,58 +4,86 @@ import Ember from 'ember'; import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import VisitTypes from 'hospitalrun/mixins/visit-types'; +const { + computed, + computed: { + alias + }, + get, + inject, + set +} = Ember; + export default AbstractEditController.extend(AppointmentStatuses, PatientSubmodule, VisitTypes, { - appointmentsController: Ember.inject.controller('appointments'), findPatientVisits: false, + updateCapability: 'add_appointment', - locationList: Ember.computed.alias('appointmentsController.locationList'), - - lookupListsToUpdate: [{ - name: 'physicianList', - property: 'model.provider', - id: 'physician_list' - }, { - name: 'locationList', - property: 'model.location', - id: 'visit_location_list' - }], - - physicianList: Ember.computed.alias('appointmentsController.physicianList'), - showTime: function() { - let allDay = this.get('model.allDay'); - let isAdmissionAppointment = this.get('isAdmissionAppointment'); - return (!allDay && isAdmissionAppointment); - }.property('model.allDay', 'isAdmissionAppointment'), - visitTypesList: Ember.computed.alias('appointmentsController.visitTypesList'), + appointmentsController: inject.controller('appointments'), + physicianList: alias('appointmentsController.physicianList'), + surgeryLocationList: alias('appointmentsController.surgeryLocationList'), + visitLocationList: alias('appointmentsController.locationList'), + visitTypesList: alias('appointmentsController.visitTypesList'), - cancelAction: function() { - let returnTo = this.get('model.returnTo'); + cancelAction: computed('model.returnTo', function() { + let returnTo = get(this, 'model.returnTo'); if (Ember.isEmpty(returnTo)) { return this._super(); } else { return 'returnTo'; } - }.property('model.returnTo'), + }), - isAdmissionAppointment: function() { - let model = this.get('model'); - let appointmentType = model.get('appointmentType'); + isAdmissionAppointment: computed('model.appointmentType', function() { + let model = get(this, 'model'); + let appointmentType = get(model, 'appointmentType'); let isAdmissionAppointment = (appointmentType === 'Admission'); return isAdmissionAppointment; - }.property('model.appointmentType'), + }), - updateCapability: 'add_appointment', + lookupListsToUpdate: computed('model.appointmentType', function() { + let appointmentType = get(this, 'model.appointmentType'); + let lists = [{ + name: 'physicianList', + property: 'model.provider', + id: 'physician_list' + }]; + if (appointmentType === 'Surgery') { + lists.push({ + name: 'visitLocationList', + property: 'model.location', + id: 'visit_location_list' + }); + } else { + lists.push({ + name: 'surgeryLocationList', + property: 'model.location', + id: 'procedure_locations' + }); + } + }), + + showTime: computed('model.allDay', 'isAdmissionAppointment', function() { + let allDay = get(this, 'model.allDay'); + let isAdmissionAppointment = get(this, 'isAdmissionAppointment'); + return (!allDay && isAdmissionAppointment); + }), - afterUpdate() { - this.send(this.get('cancelAction')); + afterUpdate(model) { + let i18n = get(this, 'i18n'); + let patientInfo = { + patient: get(model, 'patient.displayName') + }; + let message = i18n.t('appointments.messages.appointmentSaved', patientInfo); + let title = i18n.t('appointments.titles.appointmentSaved'); + this.displayAlert(title, message); }, actions: { appointmentTypeChanged(appointmentType) { - let model = this.get('model'); - model.set('appointmentType', appointmentType); - let isAdmissionAppointment = this.get('isAdmissionAppointment'); - model.set('allDay', isAdmissionAppointment); + let model = get(this, 'model'); + set(model, 'appointmentType', appointmentType); + let isAdmissionAppointment = get(this, 'isAdmissionAppointment'); + set(model, 'allDay', isAdmissionAppointment); } } }); diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index be20c36b46..d9f6433b6c 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,19 +1,62 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import Ember from 'ember'; +import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import { translationMacro as t } from 'ember-i18n'; +const { + get, + RSVP: { + resolve + } +} = Ember; + export default AbstractEditRoute.extend(PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', + newButtonText: t('appointments.buttons.newButton'), + newTitle: t('appointments.newTitle'), - getNewData() { - return Ember.RSVP.resolve({ + getNewData(params) { + let idParam = get(this, 'idParam'); + let newData = { appointmentType: 'Admission', allDay: true, selectPatient: true, startDate: new Date() - }); + }; + if (!Ember.isEmpty(idParam) && params[idParam] === 'newsurgery') { + newData.appointmentType = 'Surgery'; + newData.allDay = false; + newData.endDate = moment().add('1', 'hours').toDate(); + newData.returnTo = 'appointments.theater'; + } + return resolve(newData); + }, + + getScreenTitle(model) { + let appointmentType = get(model, 'appointmentType'); + if (appointmentType === 'Surgery') { + let i18n = get(this, 'i18n'); + let isNew = get(model, 'isNew'); + if (isNew) { + return i18n.t('appointments.titles.newSurgicalAppointment'); + } else { + return i18n.t('appointments.titles.editSurgicalAppointment'); + } + } else { + return this._super(model); + } + }, + + model(params) { + let idParam = this.get('idParam'); + let modelId = params[idParam]; + if (!Ember.isEmpty(idParam) && (modelId.indexOf('new') === 0)) { + return this._createNewRecord(params); + } else { + return this._super(params); + } } }); diff --git a/app/appointments/edit/template.hbs b/app/appointments/edit/template.hbs index 4c05523862..8f62114fac 100644 --- a/app/appointments/edit/template.hbs +++ b/app/appointments/edit/template.hbs @@ -14,33 +14,47 @@ {{/if}} {{em-checkbox label=(t 'labels.allDay') property="allDay" class="col-sm-2 appointment-all-day"}} -
    -
    - - {{select-list - content=visitTypes - optionLabelPath='value' - optionValuePath='id' - value=model.appointmentType - class='form-control' - id='appointmentType' - action=(action 'appointmentTypeChanged') + + {{#if (eq model.appointmentType 'Surgery')}} +
    + {{select-or-typeahead className="col-sm-6 test-appointment-with" property="provider" + label=(t 'labels.with') list=physicianList + selection=model.provider + }} + {{select-or-typeahead className="col-sm-6 test-appointment-location" property="location" + label=(t 'labels.location') list=surgeryLocationList + selection=model.location }}
    - {{select-or-typeahead className="col-sm-6 test-appointment-with" property="provider" - label=(t 'labels.with') list=physicianList - selection=model.provider - }} -
    -
    - {{select-or-typeahead className="col-sm-6 required test-appointment-location" property="location" - label=(t 'labels.location') list=locationList - selection=model.location - }} - {{em-select class="form-input-group col-sm-3 test-appointment-status" property="status" - label=(t 'labels.status') content=appointmentStatuses - }} -
    + {{else}} +
    +
    + + {{select-list + content=visitTypes + optionLabelPath='value' + optionValuePath='id' + value=model.appointmentType + class='form-control' + id='appointmentType' + action=(action 'appointmentTypeChanged') + }} +
    + {{select-or-typeahead className="col-sm-6 test-appointment-with" property="provider" + label=(t 'labels.with') list=physicianList + selection=model.provider + }} +
    +
    + {{select-or-typeahead className="col-sm-6 test-appointment-location" property="location" + label=(t 'labels.location') list=visitLocationList + selection=model.location + }} + {{em-select class="form-input-group col-sm-3 test-appointment-status" property="status" + label=(t 'labels.status') content=appointmentStatuses + }} +
    + {{/if}} {{em-text label=(t 'labels.notes') property="notes" rows=3 }} {{/em-form}} {{/edit-panel}} diff --git a/app/appointments/index/route.js b/app/appointments/index/route.js index 7a06da640c..30d0494aca 100644 --- a/app/appointments/index/route.js +++ b/app/appointments/index/route.js @@ -5,6 +5,7 @@ import { translationMacro as t } from 'ember-i18n'; export default AbstractIndexRoute.extend({ editReturn: 'appointments.index', modelName: 'appointment', + newButtonText: t('appointments.buttons.newButton'), pageTitle: t('appointments.thisWeek'), _getStartKeyFromItem(item) { diff --git a/app/appointments/route.js b/app/appointments/route.js index e50e345937..a16f69f3be 100644 --- a/app/appointments/route.js +++ b/app/appointments/route.js @@ -35,6 +35,9 @@ export default AbstractModuleRoute.extend(UserSession, { }, { name: 'locationList', findArgs: ['lookup', 'visit_location_list'] + }, { + name: 'surgeryLocationList', + findArgs: ['lookup', 'procedure_locations'] }, { name: 'visitTypesList', findArgs: ['lookup', 'visit_types'] diff --git a/app/appointments/theater/controller.js b/app/appointments/theater/controller.js new file mode 100644 index 0000000000..8582ec23ca --- /dev/null +++ b/app/appointments/theater/controller.js @@ -0,0 +1,21 @@ +import AppointmenCalendarController from 'hospitalrun/appointments/calendar/controller'; + +export default AppointmenCalendarController.extend({ + dayGroupByResource: { + day: { + groupByResource: true + } + }, + + actions: { + createNewAppointment(dateClicked) { + let newAppointment = this.store.createRecord('appointment', { + appointmentType: 'Surgery', + selectPatient: true, + startDate: dateClicked.local().toDate(), + endDate: dateClicked.add('1', 'hours').local().toDate() + }); + this.send('editAppointment', newAppointment); + } + } +}); diff --git a/app/appointments/theater/route.js b/app/appointments/theater/route.js new file mode 100644 index 0000000000..1c2b01af10 --- /dev/null +++ b/app/appointments/theater/route.js @@ -0,0 +1,20 @@ +import AppointmenCalendarRoute from 'hospitalrun/appointments/calendar/route'; +import { translationMacro as t } from 'ember-i18n'; + +export default AppointmenCalendarRoute.extend({ + editReturn: 'appointments.theater', + newButtonText: t('appointments.buttons.scheduleSurgery'), + pageTitle: t('appointments.titles.theaterSchedule'), + + _modelQueryParams(params) { + let queryParams = this._super(params); + queryParams.mapReduce = 'surgical_appointments_by_date'; + return queryParams; + }, + + actions: { + newItem() { + this.transitionTo('appointments.edit', 'newsurgery'); + } + } +}); diff --git a/app/appointments/theater/template.hbs b/app/appointments/theater/template.hbs new file mode 100644 index 0000000000..15309f8482 --- /dev/null +++ b/app/appointments/theater/template.hbs @@ -0,0 +1,39 @@ +
    +
    + {{#em-form model=model submitButton=false}} +
    + {{em-select class="col-sm-3 form-input-group" + label=(t "labels.status") + property="selectedStatus" + content=appointmentStatusesWithEmpty + }} + {{em-select class="col-sm-3 form-input-group" + label=(t 'labels.with') + property="selectedProvider" + content=physicianList + }} + {{em-select class="col-sm-3 form-input-group" + label=(t 'labels.location') + property="selectedLocation" + content=locationList + }} +
    + {{/em-form}} + + {{calendar-control events=model.events + defaultDate=calendarDate + defaultView=viewType + onDayClick=(action "createNewAppointment") + onEventClick=(action "navigateToAppointment") + onEventDrop=(action "updateAppointment") + onEventResize=(action "updateAppointment") + onVisualConfigurationChanged=(action "handleVisualConfigurationChanged") + resources=model.resources + userCanEdit=canEdit + views=dayGroupByResource + }} +
    +
    diff --git a/app/components/upcoming-appointments.js b/app/components/upcoming-appointments.js new file mode 100644 index 0000000000..7e082e37e7 --- /dev/null +++ b/app/components/upcoming-appointments.js @@ -0,0 +1,43 @@ +import DS from 'ember-data'; +import Ember from 'ember'; +import moment from 'moment'; + +const { PromiseArray } = DS; + +const { + Component, + computed, + get, + inject, + isEmpty +} = Ember; + +export default Component.extend({ + patient: null, + + database: inject.service(), + store: inject.service(), + + appointments: computed('patient', function() { + let patient = get(this, 'patient'); + if (!isEmpty(patient)) { + let database = get(this, 'database'); + let endDate = moment().add(10, 'years').toDate().getTime(); + let maxApptId = database.getMaxPouchId('appointment'); + let minApptId = database.getMinPouchId('appointment'); + let patientId = get(patient, 'id'); + let startDate = moment().toDate().getTime(); + let store = get(this, 'store'); + let appointmentPromise = store.query('appointment', { + options: { + startkey: [patientId, startDate, startDate, minApptId], + endkey: [patientId, endDate, endDate, maxApptId] + }, + mapReduce: 'appointments_by_patient' + }); + return PromiseArray.create({ + promise: appointmentPromise + }); + } + }) +}); diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 868883a7c6..472bfa93c7 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -41,7 +41,7 @@ export default { imaging: 'Imaging', inventory: 'Inventory', patients: 'Patients', - appointments: 'Appointments', + scheduling: 'Scheduling', medication: 'Medication', labs: 'Labs', billing: 'Billing', @@ -56,9 +56,9 @@ export default { reports: 'Reports', patientListing: 'Patient Listing', newPatient: 'New Patient', - thisWeek: 'This Week', - today: 'Today', - search: 'Search', + appointmentsThisWeek: 'Appointment This Week', + "today'sAppointments": 'Today\'s Appointments', + appointmentSearch: 'Appointment Search', addAppointment: 'Add Appointment', dispense: 'Dispense', returnMedication: 'Return Medication', @@ -72,12 +72,14 @@ export default { users: 'Users', newUser: 'New User', admittedPatients: 'Admitted Patients', - missed: 'Missed', + missedAppointments: 'Missed Appointments', userRoles: 'User Roles', workflow: 'Workflow', outpatient: 'Outpatient', customForms: 'Custom Forms', - calendar: 'Calendar' + appointmentsCalendar: 'Appointments Calendar', + theaterSchedule: 'Theater Schedule', + scheduleSurgery: 'Schedule Surgery' }, actions: { logout: 'Logout', @@ -768,14 +770,23 @@ export default { todayTitle: 'Today\'s Appointments', calendarTitle: 'Appointments Calendar', messages: { + appointmentSaved: 'The appointment for {{patient}} has been saved.', deleteAppointmentMessage: 'Are you sure you wish to delete this appointment?', endTimeLaterThanStart: 'Please select an end time later than the start time.' }, buttons: { - newButton: '+ new appointment' + newButton: '+ new appointment', + scheduleSurgery: '+ schedule surgery' }, labels: { + noLocation: 'No Location', selectedStartingDate: 'Show Appointments On Or After' + }, + titles: { + appointmentSaved: 'Appointment Saved', + editSurgicalAppointment: 'Edit Surgical Appointment', + newSurgicalAppointment: 'New Surgical Appointment', + theaterSchedule: 'Theater Schedule' } }, vitals: { @@ -957,7 +968,8 @@ export default { newAppointment: 'New Appointment', backToPatients: 'Back to Patient List', newPatient: '+ new patient', - patientCheckIn: 'Patient Check In' + patientCheckIn: 'Patient Check In', + scheduleSurgery: 'Schedule Surgery' }, labels: { primaryDiagnosis: 'Primary Diagnoses', @@ -1145,6 +1157,17 @@ export default { titles: { procedures: 'Procedures' } + }, + upcomingAppointments: { + labels: { + date: 'Date', + with: 'With', + location: 'Location', + type: 'Type' + }, + titles: { + upcomingAppointments: 'Upcoming Appointments' + } } }, customForms: { @@ -1196,8 +1219,7 @@ export default { operationDescription: 'Operation Description', plannedStatus: 'Planned', status: 'Status', - surgeon: 'Surgeon', - surgeryDate: 'Surgery Date' + surgeon: 'Surgeon' }, messages: { planSaved: 'The operative plan has been saved.', diff --git a/app/mixins/navigation.js b/app/mixins/navigation.js index 6c3f67e830..b6c7380402 100644 --- a/app/mixins/navigation.js +++ b/app/mixins/navigation.js @@ -77,37 +77,37 @@ export default Ember.Mixin.create({ ] }, { - title: 'Appointments', + title: 'Scheduling', iconClass: 'octicon-calendar', route: 'appointments.index', capability: 'appointments', subnav: [ { - title: 'This Week', + title: 'Appointments This Week', iconClass: 'octicon-chevron-right', route: 'appointments.index', capability: 'appointments' }, { - title: 'Today', + title: 'Today\'s Appointments', iconClass: 'octicon-chevron-right', route: 'appointments.today', capability: 'appointments' }, { - title: 'Missed', + title: 'Missed Appointments', iconClass: 'octicon-chevron-right', route: 'appointments.missed', capability: 'appointments' }, { - title: 'Search', + title: 'Appointment Search', iconClass: 'octicon-search', route: 'appointments.search', capability: 'appointments' }, { - title: 'Calendar', + title: 'Appointments Calendar', iconClass: 'octicon-calendar', route: 'appointments.calendar', capability: 'appointments' @@ -118,6 +118,19 @@ export default Ember.Mixin.create({ route: 'appointments.edit', subroute: 'new', capability: 'add_appointment' + }, + { + title: 'Theater Schedule', + iconClass: 'octicon-calendar', + route: 'appointments.theater', + capability: 'appointments' + }, + { + title: 'Schedule Surgery', + iconClass: 'octicon-plus', + route: 'appointments.edit', + subroute: 'newsurgery', + capability: 'add_appointment' } ] }, diff --git a/app/models/appointment.js b/app/models/appointment.js index 15bac8a0a6..a429a59414 100644 --- a/app/models/appointment.js +++ b/app/models/appointment.js @@ -85,9 +85,6 @@ export default AbstractModel.extend({ appointmentType: { presence: true }, - location: { - presence: true - }, startDate: { presence: true }, diff --git a/app/models/operative-plan.js b/app/models/operative-plan.js index 274563c6f2..8e456ed357 100644 --- a/app/models/operative-plan.js +++ b/app/models/operative-plan.js @@ -23,7 +23,6 @@ export default AbstractModel.extend({ procedures: DS.attr('operative-procedures', { defaultValue: defaultProcedures }), status: DS.attr('string', { defaultValue: PLANNED_STATUS }), surgeon: DS.attr('string'), - surgeryDate: DS.attr('date'), // Associations diagnoses: DS.hasMany('diagnosis'), diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index c4193cb328..93560580ae 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -379,6 +379,16 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur this._addChildObject('medication.edit'); }, + newSurgicalAppointment() { + this.transitionToRoute('appointments.edit', 'newsurgery').then((newRoute) => { + newRoute.currentModel.setProperties({ + patient: this.get('model'), + returnToPatient: this.get('model.id'), + selectPatient: false + }); + }); + }, + newVisit() { let patient = this.get('model'); this.send('createNewVisit', patient, true); diff --git a/app/patients/edit/template.hbs b/app/patients/edit/template.hbs index 59f8f234b2..501e638d3a 100644 --- a/app/patients/edit/template.hbs +++ b/app/patients/edit/template.hbs @@ -250,9 +250,14 @@
    {{#if canAddAppointment}}
    - +
    +   + +
    {{/if}}
    diff --git a/app/patients/operation-report/route.js b/app/patients/operation-report/route.js index 0ac948bdb5..831bab441b 100644 --- a/app/patients/operation-report/route.js +++ b/app/patients/operation-report/route.js @@ -1,18 +1,8 @@ -import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; -import Ember from 'ember'; +import OperativePlanRoute from 'hospitalrun/patients/operative-plan/route'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend({ - customForms: Ember.inject.service(), +export default OperativePlanRoute.extend({ editTitle: t('operationReport.titles.editTitle'), modelName: 'operation-report', - newTitle: t('operationReport.titles.newTitle'), - - getNewData() { - let customForms = this.get('customForms'); - let newData = { - customForms: Ember.Object.create() - }; - return customForms.setDefaultCustomForms(['operativePlan'], newData); - } + newTitle: t('operationReport.titles.newTitle') }); diff --git a/app/patients/operation-report/template.hbs b/app/patients/operation-report/template.hbs index d5f0244730..e51c5b5de3 100644 --- a/app/patients/operation-report/template.hbs +++ b/app/patients/operation-report/template.hbs @@ -7,7 +7,7 @@ disablePatientLink=true patient=model.patient }} -
    +
    {{patient-diagnosis diagnosisContainer=model diagnosisProperty="preOpDiagnoses" @@ -32,6 +32,7 @@
    {{operative-procedures model=model procedureList=procedureList}} {{em-text property="additionalNotes" label=(t 'operationReport.labels.additionalNotes')}} + {{upcoming-appointments patient=model.patient}} {{custom-form-manager model=model formType="operativePlan"}} {{/em-form}} {{/edit-panel}} diff --git a/app/patients/operative-plan/controller.js b/app/patients/operative-plan/controller.js index 1e795d9dfa..87ff02dcce 100644 --- a/app/patients/operative-plan/controller.js +++ b/app/patients/operative-plan/controller.js @@ -22,8 +22,7 @@ const PLAN_KEYS_TO_COPY = [ 'patient', 'procedures', 'operationDescription', - 'surgeon', - 'surgeryDate' + 'surgeon' ]; export default AbstractEditController.extend(OperativePlanStatuses, PatientSubmodule, { @@ -102,6 +101,7 @@ export default AbstractEditController.extend(OperativePlanStatuses, PatientSubmo let patient = get(operativePlan, 'patient'); set(propertiesToCopy, 'operativePlan', operativePlan); set(propertiesToCopy, 'preOpDiagnosis', diagnoses); + set(propertiesToCopy, 'surgeryDate', new Date()); set(propertiesToCopy, 'returnToPatient', get(patient, 'id')); let operationReport = store.createRecord('operation-report', propertiesToCopy); this.getPatientDiagnoses(patient, operationReport); diff --git a/app/patients/operative-plan/route.js b/app/patients/operative-plan/route.js index a9e098609f..96c292d465 100644 --- a/app/patients/operative-plan/route.js +++ b/app/patients/operative-plan/route.js @@ -1,21 +1,49 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import Ember from 'ember'; +import moment from 'moment'; import { translationMacro as t } from 'ember-i18n'; +const { + get, + inject +} = Ember; + export default AbstractEditRoute.extend({ - customForms: Ember.inject.service(), editTitle: t('operativePlan.titles.editTitle'), modelName: 'operative-plan', newTitle: t('operativePlan.titles.newTitle'), + customForms: inject.service(), + database: inject.service(), + getNewData() { - let customForms = this.get('customForms'); + let customForms = get(this, 'customForms'); let newData = { customForms: Ember.Object.create() }; return customForms.setDefaultCustomForms(['operativePlan'], newData); }, + setupController(controller, model) { + this._super(controller, model); + let database = get(this, 'database'); + let maxApptId = database.getMaxPouchId('appointment'); + let minApptId = database.getMinPouchId('appointment'); + let patientId = get(model, 'patient.id'); + let startDate = moment().toDate().getTime(); + let endDate = moment().add(10, 'years').toDate().getTime(); + + this.store.query('appointment', { + options: { + startkey: [patientId, startDate, startDate, minApptId], + endkey: [patientId, endDate, endDate, maxApptId] + }, + mapReduce: 'appointments_by_patient' + }).then(function(appointments) { + model.set('appointments', appointments); + }); + }, + actions: { showOperationReport(report) { this.transitionTo('patients.operation-report', report); diff --git a/app/patients/operative-plan/template.hbs b/app/patients/operative-plan/template.hbs index 2fd996b3de..915321a5fc 100644 --- a/app/patients/operative-plan/template.hbs +++ b/app/patients/operative-plan/template.hbs @@ -4,7 +4,6 @@ {{em-text property="operationDescription" label=(t 'operativePlan.labels.operationDescription') class="operation-description"}} {{operative-procedures model=model procedureList=procedureList}}
    - {{date-picker property="surgeryDate" label=(t 'operativePlan.labels.surgeryDate') class="form-input-group col-sm-4 surgery-date"}} {{select-or-typeahead className="col-sm-4" property="surgeon" label=(t "operativePlan.labels.surgeon") list=physicianList selection=model.surgeon @@ -21,6 +20,7 @@
    {{em-text property="admissionInstructions" label=(t 'operativePlan.labels.admissionInstructions') class="admission-instructions"}} {{em-text property="additionalNotes" label=(t 'operativePlan.labels.additionalNotes') class="additional-notes"}} + {{upcoming-appointments patient=model.patient}} {{custom-form-manager model=model formType="operativePlan"}} {{/em-form}} {{/edit-panel}} diff --git a/app/router.js b/app/router.js index 05aa4be9c3..64fa5d3d12 100755 --- a/app/router.js +++ b/app/router.js @@ -31,6 +31,7 @@ Router.map(function() { this.route('today'); this.route('missed'); this.route('calendar'); + this.route('theater'); }); this.route('finishgauth', { path: '/finishgauth/:s1/:s2/:k/:t/:i/:p' }); diff --git a/app/templates/components/calendar-control.hbs b/app/templates/components/calendar-control.hbs index f71ba32c7f..a8903824aa 100644 --- a/app/templates/components/calendar-control.hbs +++ b/app/templates/components/calendar-control.hbs @@ -6,7 +6,11 @@ eventClick=onEventClick eventDrop=onEventDrop eventResize=onEventResize + groupByDateAndResource=groupByDateAndResource + groupByResource=groupByResource header=calendarHeader height=height + resources=resources viewName=defaultView + views=views }} diff --git a/app/templates/components/date-time-picker.hbs b/app/templates/components/date-time-picker.hbs index 3476ccddfa..acb0f099b7 100644 --- a/app/templates/components/date-time-picker.hbs +++ b/app/templates/components/date-time-picker.hbs @@ -1,10 +1,10 @@ {{#em-form model=this submitButton=false}} - {{date-picker property="dateTimePickerDate" label=label class="col-sm-4 (datePickerClass)" dateSetAction="dateChanged"}} + {{date-picker property="dateTimePickerDate" label=label class=(concat 'col-sm-4 ' datePickerClass) dateSetAction="dateChanged"}} {{#unless isAllDay}}
    - {{#each hourList as |item|}}
    From 9d0c479b6292d1887f40086aa57f9e6696c1b7ef Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 15 Feb 2017 12:19:36 -0500 Subject: [PATCH 043/124] Make sure outPatient flag gets properly set. --- app/visits/edit/controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index bc5f78ab32..e163ec1f51 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -267,14 +267,19 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn message: 'creating new patient first' }); } + let outPatient = false; let visitType = newVisit.get('visitType'); let visitStatus; if (visitType === 'Admission') { visitStatus = VisitStatus.ADMITTED; } else { + outPatient = true; visitStatus = VisitStatus.CHECKED_IN; } - newVisit.set('status', visitStatus); + newVisit.setProperties({ + outPatient, + status: visitStatus + }); if (this.get('model.checkIn')) { this._saveAssociatedAppointment(newVisit).then(() => { this.saveNewDiagnoses().then(resolve, reject); From ccb0b059fec884f19bb000ad35343eec91dbf310 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 12:31:21 +0100 Subject: [PATCH 044/124] Remove preview functionality from OPD Reports --- app/reports/edit/controller.js | 36 +++--- app/reports/edit/route.js | 6 - app/reports/edit/template.hbs | 229 +++++++++++++++------------------ 3 files changed, 120 insertions(+), 151 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 6b5859668d..965cf613f2 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -7,19 +7,11 @@ import DS from 'ember-data'; import moment from 'moment'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { - queryParams: ['preview'], - preview: null, - - showPreview: Ember.computed('preview', function() { - let preview = this.get('preview'); - return preview; - }), - lookupListsToUpdate: [], newReport: false, - diagnosis: Ember.computed('model.patient', function() { + diagnosis: Ember.computed('model.patient', function () { let container = this.get('model.patient'); let result = { primary: this.getDiagnoses(container, true, false), @@ -28,19 +20,19 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function () { let patientId = this.get('model.patient.id'); let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); - let promise = this.store.query('appointment', { + let promise = this.store.query('appointment', { options: { startkey: [patientId, null, null, 'appointment_'], endkey: [patientId, maxValue, maxValue, maxValue] }, mapReduce: 'appointments_by_patient' - }).then(function(result) { - let futureAppointments = result.filter(function(data) { - let startDate = data.get('startDate'); + }).then(function (result) { + let futureAppointments = result.filter(function (data) { + let startDate = data.get('startDate'); return startDate && moment(startDate).isAfter(moment(visitDate), 'day'); }).sortBy('startDate'); if (!futureAppointments.length) { @@ -50,18 +42,18 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let res = appointment.get('startDate'); return res; }); - return DS.PromiseObject.create({ promise }); + return DS.PromiseObject.create({promise}); }), - additionalButtons: Ember.computed('model.{isNew}', function() { + additionalButtons: Ember.computed('model.{isNew}', function () { // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { return [{ class: 'btn btn-primary on-white', - buttonAction: 'previewReport', + buttonAction: 'printReport', buttonIcon: 'octicon octicon-check', - buttonText: 'Preview and Print' + buttonText: 'Print' }]; } }), @@ -69,7 +61,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, updateCapability: 'add_report', beforeUpdate() { - return new Ember.RSVP.Promise(function(resolve) { + return new Ember.RSVP.Promise(function (resolve) { if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { @@ -97,8 +89,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }, actions: { - previewReport() { - this.transitionToRoute('reports.edit', this.get('model.id'), { queryParams: { preview: true } }); + printReport() { + } } + + }); diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 38ebf49047..68a441e248 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -5,12 +5,6 @@ export default AbstractEditRoute.extend({ modelName: 'report', customForms: Ember.inject.service(), - queryParams: { - preview: { - refreshModel: true - } - }, - getNewData() { let newReportData = { reportDate: new Date(), diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 68daab70ae..4b92531197 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,129 +1,110 @@ - {{#if model.visit.outPatient}} - {{#if showPreview}} -
    - Show Preview for Out Patients Report -
    - {{else}} - {{#edit-panel editPanelProps=editPanelProps}} - {{#em-form model=model submitButton=false }} - {{#if model.visit}} - {{patient-summary - patient=model.visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew - }} - {{/if}} - {{#if model.visit.patient.displayPatientId}} -
    - - -
    - {{/if}} - {{#if model.visit.patient.dateOfBirth}} -
    - - -
    - {{/if}} - - {{#if diagnosis.primary.length}} -
    - -
      - {{#each diagnosis.primary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if diagnosis.secondary.length}} -
    - -
      - {{#each diagnosis.secondary as |item|}} -
    • {{item.diagnosis}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.procedures.length}} -
    - -
      - {{#each model.visit.procedures as |item|}} -
    • {{item.description}}
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.labs.length}} -
    - -
      - {{#each model.visit.labs as |item|}} -
    • {{item.labType.name}}-{{item.result}} ({{item.status}})
    • - {{/each}} -
    -
    - {{/if}} - - {{#if model.visit.imaging.length}} -
    - -
      - {{#each model.visit.imaging as |item|}} -
    • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
    • + {{#edit-panel editPanelProps=editPanelProps}} + {{#em-form model=model submitButton=false }} + {{#if model.visit}} + {{patient-summary + patient=model.visit.patient + returnTo='visit.edit' + returnToContext=model.id + disablePatientLink=model.isNew + }} + {{/if}} + {{#if model.visit.patient.displayPatientId}} +
      + + +
      + {{/if}} + {{#if model.visit.patient.dateOfBirth}} +
      + + +
      + {{/if}} + + {{#if diagnosis.primary.length}} +
      + +
        + {{#each diagnosis.primary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if diagnosis.secondary.length}} +
      + +
        + {{#each diagnosis.secondary as |item|}} +
      • {{item.diagnosis}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.procedures.length}} +
      + +
        + {{#each model.visit.procedures as |item|}} +
      • {{item.description}}
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.labs.length}} +
      + +
        + {{#each model.visit.labs as |item|}} +
      • {{item.labType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + {{#if model.visit.imaging.length}} +
      + +
        + {{#each model.visit.imaging as |item|}} +
      • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
      • + {{/each}} +
      +
      + {{/if}} + + + {{#if nextAppointment}} +
      + + +
      + {{/if}} + + {{#if model.visit.patient.operativePlans.length}} +
      + +
        + {{#each model.visit.patient.operativePlans as |item|}} + {{#each item.procedures as |p|}} +
      • {{p.description}} ({{item.status}})
      • {{/each}} -
      -
      - {{/if}} - - - {{#if nextAppointment}} -
      - - -
      - {{/if}} - - {{#if model.visit.patient.operativePlans.length}} -
      - -
        - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
      • {{p.description}} ({{item.status}})
      • - {{/each}} - {{/each}} -
      -
      - {{/if}} - - {{custom-form-manager model=model formType="opdReport"}} - - {{/em-form}} - {{/edit-panel}} - {{/if}} - - {{else}} - - {{#if showPreview}} -
      - Show Preview for Discharge report -
      - {{else}} -
      - Show Discharge Report Form -
      - {{/if}} - -{{/if}} - + {{/each}} +
    +
    + {{/if}} + {{custom-form-manager model=model formType="opdReport"}} + {{/em-form}} + {{/edit-panel}} +{{else}} +
    + Show Discharge Report Form +
    +{{/if}} \ No newline at end of file From 0e497681af30feafe1533df913fdb4668b8082ec Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 16:36:45 +0100 Subject: [PATCH 045/124] Implement print button --- app/reports/edit/controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 965cf613f2..88dab4de60 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -90,7 +90,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, actions: { printReport() { - + window.print(); } } From cfbbb351523d6769522dc54467ad79eb227bb3f8 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Thu, 16 Feb 2017 14:33:36 -0500 Subject: [PATCH 046/124] Fixed importing of lookup lists Fixes #921 --- app/admin/lookup/controller.js | 51 +++++++++++++++++++--------------- app/admin/lookup/route.js | 3 -- app/models/lookup.js | 11 ++++---- package.json | 1 + 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/admin/lookup/controller.js b/app/admin/lookup/controller.js index bb3d8143ed..87dba32530 100644 --- a/app/admin/lookup/controller.js +++ b/app/admin/lookup/controller.js @@ -1,5 +1,6 @@ import Ember from 'ember'; import BillingCategories from 'hospitalrun/mixins/billing-categories'; +import csvParse from 'npm:csv-parse'; import ModalHelper from 'hospitalrun/mixins/modal-helper'; import InventoryTypeList from 'hospitalrun/mixins/inventory-type-list'; import UnitTypes from 'hospitalrun/mixins/unit-types'; @@ -7,7 +8,7 @@ import VisitTypes from 'hospitalrun/mixins/visit-types'; import { EKMixin, keyDown } from 'ember-keyboard'; const { - computed + computed, get } = Ember; export default Ember.Controller.extend(BillingCategories, EKMixin, @@ -291,6 +292,31 @@ export default Ember.Controller.extend(BillingCategories, EKMixin, return true; }, + _importLookupList(file) { + let fileSystem = get(this, 'fileSystem'); + let lookupTypeList = get(this, 'lookupTypeList'); + let lookupValues = get(lookupTypeList, 'value'); + fileSystem.fileToString(file).then((values) => { + csvParse(values, { trim: true }, (err, data) =>{ + data.forEach((row) => { + let [newValue] = row; + if (!lookupValues.includes(newValue)) { + lookupValues.addObject(newValue); + } + }); + lookupValues.sort(); + let i18n = get(this, 'i18n'); + let message = i18n.t('admin.lookup.alertImportListSaveMessage'); + let title = i18n.t('admin.lookup.alertImportListSaveTitle'); + lookupTypeList.save().then(() => { + this.displayAlert(title, message); + this.set('importFile'); + this.set('model.importFileName'); + }); + }); + }); + }, + _sortValues(a, b) { return Ember.compare(a.toLowerCase(), b.toLowerCase()); }, @@ -335,35 +361,14 @@ export default Ember.Controller.extend(BillingCategories, EKMixin, } }, importList() { - let fileSystem = this.get('fileSystem'); let fileToImport = this.get('importFile'); - let lookupTypeList = this.get('lookupTypeList'); if (!fileToImport || !fileToImport.type) { this.displayAlert( this.get('i18n').t('admin.lookup.alertImportListTitle'), this.get('i18n').t('admin.lookup.alertImportListMessage') ); } else { - fileSystem.fileToDataURL(fileToImport).then(function(fileDataUrl) { - let dataUrlParts = fileDataUrl.split(','); - lookupTypeList.setProperties({ - _attachments: { - file: { - content_type: fileToImport.type, - data: dataUrlParts[1] - } - }, - importFile: true - }); - lookupTypeList.save().then(function() { - this.displayAlert( - this.get('i18n').t('admin.lookup.alertImportListSaveTitle'), - this.get('i18n').t('admin.lookup.alertImportListSaveMessage'), - 'refreshLookupLists'); - this.set('importFile'); - this.set('model.importFileName'); - }.bind(this)); - }.bind(this)); + this._importLookupList(fileToImport); } }, updateList() { diff --git a/app/admin/lookup/route.js b/app/admin/lookup/route.js index 7676703b14..59449a8fb9 100644 --- a/app/admin/lookup/route.js +++ b/app/admin/lookup/route.js @@ -14,9 +14,6 @@ export default AbstractIndexRoute.extend({ actions: { deleteValue(value) { this.controller.send('deleteValue', value); - }, - refreshLookupLists() { - this.refresh(); } } }); diff --git a/app/models/lookup.js b/app/models/lookup.js index 4f0d21c6dc..9c0433770f 100644 --- a/app/models/lookup.js +++ b/app/models/lookup.js @@ -1,9 +1,10 @@ import { Model } from 'ember-pouch'; import DS from 'ember-data'; + +const { attr } = DS; + export default Model.extend({ - _attachments: DS.attr(), // Temporarily store file as attachment until it gets uploaded to the server - importFile: DS.attr('boolean', { defaultValue: false }), - value: DS.attr(''), - organizeByType: DS.attr('boolean'), - userCanAdd: DS.attr('boolean') + organizeByType: attr('boolean'), + userCanAdd: attr('boolean'), + value: attr('') }); diff --git a/package.json b/package.json index 5264ab99bd..0ce269bc24 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "broccoli-manifest": "0.0.7", "broccoli-merge-trees": "^1.1.1", "broccoli-serviceworker": "0.1.4", + "csv-parse": "^1.2.0", "ember-ajax": "2.5.4", "ember-browserify": "^1.1.12", "ember-cli": "2.10.0", From bac66a6cbe09c54ba0360b6cb9aa19563d91881f Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 16 Feb 2017 21:43:25 +0100 Subject: [PATCH 047/124] Remove print section header --- app/templates/section.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/app/templates/section.hbs b/app/templates/section.hbs index 7deaed121b..7c89d7f305 100644 --- a/app/templates/section.hbs +++ b/app/templates/section.hbs @@ -2,7 +2,6 @@

    {{currentScreenTitle}}

    -
    {{#if newButtonAction}} From 5b2efbb349f741c445ed6cdffa67e8b61e966553 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:18:03 +0100 Subject: [PATCH 048/124] Write styles and markup for print page --- app/reports/edit/template.hbs | 7 ++++-- app/styles/_print.scss | 45 +++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 4b92531197..7d20230766 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,5 +1,7 @@ {{#if model.visit.outPatient}} - {{#edit-panel editPanelProps=editPanelProps}} +
    + {{partial "report-header"}} + {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} {{patient-summary @@ -10,7 +12,7 @@ }} {{/if}} {{#if model.visit.patient.displayPatientId}} -
    + @@ -102,6 +104,7 @@ {{/em-form}} {{/edit-panel}} +
    {{else}}
    diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 2816743972..22db9a3b0e 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -1,4 +1,4 @@ -.print-section { +.report-header { display: none; } @@ -17,9 +17,11 @@ width: 90%; } - .print-section { + .report-header { display: block; text-align: center; + padding: 10px 0; + border-bottom: 1px solid #d2dae3; } .panel-footer, @@ -32,4 +34,43 @@ .patient-history-heading { border-bottom: 1px solid $black; } + + .report-logo { + height: 80px; + } + + .opd-report { + font-size: 0.8em; + } + + .opd-report .patient-summary { + margin-bottom: 20px; + border-bottom: 1px solid #d2dae3; + } + + .opd-report input { + padding: 5px; + font-size: 0.8em; + border: none; + } + + .opd-report .panel-primary { + position: absolute; + left: 0; + margin: 0; + width: 100%; + } + + .print-hide { + display: none; + } + + .view-top-bar { + display: none; + } + + .view-sub-bar { + display: none; + } + } From 6d6e851bbcb642dcc60dbee6150238372a91d864 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:18:49 +0100 Subject: [PATCH 049/124] Refactor report header into partial --- app/templates/report-header.hbs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/templates/report-header.hbs diff --git a/app/templates/report-header.hbs b/app/templates/report-header.hbs new file mode 100644 index 0000000000..36b184ffea --- /dev/null +++ b/app/templates/report-header.hbs @@ -0,0 +1,5 @@ +
    + +

    Hospital Name

    + Hospital Address, No 23, 4th Avenue, Gwarimpa Abuja. +
    \ No newline at end of file From 1f85452012b33ddd94ace2f39fc8279699eef5ee Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 00:52:44 +0100 Subject: [PATCH 050/124] Rename report types --- app/reports/edit/controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 965cf613f2..9a5cd3ed7f 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -65,13 +65,13 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { - this.get('model').set('reportType', 'OutPatient'); + this.get('model').set('reportType', 'OPD Report'); let appointmentDate = this.get('nextAppointment').get('content'); this.get('model').set('nextAppointment', appointmentDate); this.get('model').set('diagnosis', this.get('diagnosis')); } else { // update discharge report properties - this.get('model').set('reportType', 'Discharge'); + this.get('model').set('reportType', 'Discharge Report'); } } resolve(); From a9a3159cdf55202ce2bbf9c2ebab72fdc6596284 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 17 Feb 2017 01:17:45 +0100 Subject: [PATCH 051/124] fix style lint errors --- app/styles/_print.scss | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 22db9a3b0e..b287f87dde 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -19,9 +19,9 @@ .report-header { display: block; - text-align: center; - padding: 10px 0; border-bottom: 1px solid #d2dae3; + padding: 10px 0; + text-align: center; } .panel-footer, @@ -40,7 +40,7 @@ } .opd-report { - font-size: 0.8em; + font-size: .8em; } .opd-report .patient-summary { @@ -49,9 +49,9 @@ } .opd-report input { + border: 0; padding: 5px; - font-size: 0.8em; - border: none; + font-size: .8em; } .opd-report .panel-primary { @@ -72,5 +72,4 @@ .view-sub-bar { display: none; } - } From 64583f201c035f775f558ab0cb3f257a468fc40d Mon Sep 17 00:00:00 2001 From: Chima Date: Fri, 17 Feb 2017 13:09:09 +0100 Subject: [PATCH 052/124] fix: completed internationalization and lint fix --- app/locales/en/translations.js | 14 +++++++++++++- app/reports/edit/controller.js | 15 +++++++-------- app/reports/edit/template.hbs | 24 +++++++++++------------- app/visits/edit/template.hbs | 4 ++-- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index dceb09a0a8..48459fd5c3 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -861,7 +861,8 @@ export default { statusDischarged: 'Discharged', statusCheckedIn: 'Checked In', statusCheckedOut: 'Checked Out', - createNewPatient: 'Create New Patient' + createNewPatient: 'Create New Patient', + reportType: 'Report type' }, navigation: { charges: 'Charges', @@ -1106,6 +1107,17 @@ export default { preview: 'Preview Report', saved: 'The report has been saved' }, + form: { + patientId: 'Patient Id', + visitDate: 'Date of Visit', + primaryDiagnosis: 'Primary Diagnosis', + secondaryDiagnosis: 'Secondary Diagnosis', + procedures: 'Procedures', + labs: 'Labs', + images: 'Images', + nextAppointmentDate: 'Date Of Next Appointment', + operativePlan: 'Operative Plans' + }, opd: { titles: { new: 'New OPD Report', diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 9a0fa4ec62..f58adb726e 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -11,7 +11,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, - diagnosis: Ember.computed('model.patient', function () { + diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); let result = { primary: this.getDiagnoses(container, true, false), @@ -20,7 +20,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function () { + nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { let patientId = this.get('model.patient.id'); let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); @@ -30,8 +30,8 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, endkey: [patientId, maxValue, maxValue, maxValue] }, mapReduce: 'appointments_by_patient' - }).then(function (result) { - let futureAppointments = result.filter(function (data) { + }).then(function(result) { + let futureAppointments = result.filter(function(data) { let startDate = data.get('startDate'); return startDate && moment(startDate).isAfter(moment(visitDate), 'day'); }).sortBy('startDate'); @@ -42,10 +42,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, let res = appointment.get('startDate'); return res; }); - return DS.PromiseObject.create({promise}); + return DS.PromiseObject.create({ promise }); }), - additionalButtons: Ember.computed('model.{isNew}', function () { + additionalButtons: Ember.computed('model.{isNew}', function() { // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { @@ -61,7 +61,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, updateCapability: 'add_report', beforeUpdate() { - return new Ember.RSVP.Promise(function (resolve) { + return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { if (this.get('model.visit.outPatient')) { @@ -94,5 +94,4 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, } } - }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7d20230766..eed9faf8f1 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -13,20 +13,20 @@ {{/if}} {{#if model.visit.patient.displayPatientId}} {{/if}} - {{#if model.visit.patient.dateOfBirth}} + {{#if model.visit.startDate}}
    - +
    {{/if}} {{#if diagnosis.primary.length}}
    - +
      {{#each diagnosis.primary as |item|}}
    • {{item.diagnosis}}
    • @@ -37,7 +37,7 @@ {{#if diagnosis.secondary.length}}
      - +
        {{#each diagnosis.secondary as |item|}}
      • {{item.diagnosis}}
      • @@ -48,7 +48,7 @@ {{#if model.visit.procedures.length}}
        - +
          {{#each model.visit.procedures as |item|}}
        • {{item.description}}
        • @@ -59,7 +59,7 @@ {{#if model.visit.labs.length}}
          - +
            {{#each model.visit.labs as |item|}}
          • {{item.labType.name}}-{{item.result}} ({{item.status}})
          • @@ -70,7 +70,7 @@ {{#if model.visit.imaging.length}}
            - +
              {{#each model.visit.imaging as |item|}}
            • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
            • @@ -82,14 +82,14 @@ {{#if nextAppointment}}
              - +
              {{/if}} {{#if model.visit.patient.operativePlans.length}}
              - +
                {{#each model.visit.patient.operativePlans as |item|}} {{#each item.procedures as |p|}} @@ -107,7 +107,5 @@
              {{else}} -
              - Show Discharge Report Form -
              + {{/if}} \ No newline at end of file diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 072a75e088..3d4a7b25af 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -284,8 +284,8 @@ - - + + From a7ad7f4e4632741bd2a0e5a32192e54f2f6d5243 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Fri, 17 Feb 2017 14:11:43 +0100 Subject: [PATCH 053/124] 0.9.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5264ab99bd..00c1d117e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hospitalrun", - "version": "0.9.17", + "version": "0.9.18", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { From 177f5b4f7e1ba9ce7f7f46ba7c6020f1e956e508 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Fri, 17 Feb 2017 14:13:18 +0100 Subject: [PATCH 054/124] Incremented version number, added scope --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 00c1d117e3..5fab3b7f51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "hospitalrun", - "version": "0.9.18", + "name": "@ehealth-ci/hospitalrun", + "version": "0.9.19", "description": "Ember front end for HospitalRun", "homepage": "http://hospitalrun.io", "directories": { From b6b70f1e3f6737b39932b2bbf98228157fef7a97 Mon Sep 17 00:00:00 2001 From: Chima Date: Fri, 17 Feb 2017 16:54:13 +0100 Subject: [PATCH 055/124] fix: remove patientId field, fixed next appointment bug, removed unused translation --- app/locales/en/translations.js | 3 +-- app/reports/edit/controller.js | 6 +++--- app/reports/edit/template.hbs | 11 +++-------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 48459fd5c3..feab068832 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1108,7 +1108,6 @@ export default { saved: 'The report has been saved' }, form: { - patientId: 'Patient Id', visitDate: 'Date of Visit', primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', @@ -1116,7 +1115,7 @@ export default { labs: 'Labs', images: 'Images', nextAppointmentDate: 'Date Of Next Appointment', - operativePlan: 'Operative Plans' + operativePlan: 'Planned Procedures' }, opd: { titles: { diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index f58adb726e..0f300dee03 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -20,8 +20,8 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return result; }), - nextAppointment: Ember.computed('model.patient.id', 'model.visit.startDate', function() { - let patientId = this.get('model.patient.id'); + nextAppointment: Ember.computed('model', function() { + let patientId = this.get('model.visit.patient.id'); let visitDate = this.get('model.visit.startDate'); let maxValue = this.get('maxValue'); let promise = this.store.query('appointment', { @@ -38,7 +38,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, if (!futureAppointments.length) { return ''; } - let [appointment] = [futureAppointments]; + let [appointment] = futureAppointments; let res = appointment.get('startDate'); return res; }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index eed9faf8f1..336d0fa89f 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -11,16 +11,11 @@ disablePatientLink=model.isNew }} {{/if}} - {{#if model.visit.patient.displayPatientId}} - - {{/if}} + {{#if model.visit.startDate}}
              - +
              {{/if}} @@ -83,7 +78,7 @@ {{#if nextAppointment}}
              - +
              {{/if}} From 2d8c5c930a7864c538602954b65110eca3d96de0 Mon Sep 17 00:00:00 2001 From: Chima Date: Tue, 21 Feb 2017 10:24:11 +0100 Subject: [PATCH 056/124] fix: change date fields to simple text --- app/reports/edit/template.hbs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 336d0fa89f..20a3761064 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -14,8 +14,8 @@ {{#if model.visit.startDate}}
              - - +

              {{t 'reports.form.visitDate' }}

              + {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -77,8 +77,8 @@ {{#if nextAppointment}}
              - - +

              {{t 'reports.form.nextAppointmentDate' }}

              + {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}
              {{/if}} From bf79a5c24b0a96adda29db3c6926f21df236e575 Mon Sep 17 00:00:00 2001 From: Chima Date: Tue, 21 Feb 2017 14:48:20 +0100 Subject: [PATCH 057/124] fix: fixed bug that has to do with page header title --- app/reports/edit/route.js | 18 ++++++++++++++++++ app/visits/edit/controller.js | 18 ++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 68a441e248..54749b2ece 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,5 +1,6 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import Ember from 'ember'; +import { translationMacro as t } from 'ember-i18n'; export default AbstractEditRoute.extend({ modelName: 'report', @@ -14,6 +15,23 @@ export default AbstractEditRoute.extend({ return customForms.setDefaultCustomForms(['opdReport'], newReportData); }, + afterModel(model) { + if (model.get('isNew')) { + let visit = this.modelFor('visits.edit'); + if (!visit) { + return this.transitionTo('patients'); + } + model.set('visit', visit); + } + model.setProperties({ returnToVisit: model.get('visit.id') }); + }, + + getScreenTitle(model) { + let state = model.get('isNew') ? 'new' : 'edit'; + let type = model.get('visit.outPatient') ? 'opd' : 'discharge'; + return t(`reports.${type}.titles.${state}`); + }, + setupController(controller, model) { this._super(controller, model); } diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 979631d3b4..dc7ecab838 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -9,7 +9,6 @@ import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import UserSession from 'hospitalrun/mixins/user-session'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; import VisitTypes from 'hospitalrun/mixins/visit-types'; -import { translationMacro as t } from 'ember-i18n'; const { computed, @@ -437,24 +436,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { - let that = this; - this._addChildObject('reports.edit', (newRoute) => { - let controller = newRoute.controllerFor('visits'); - let isOutPatient = that.get('model').get('outPatient'); - controller.set('currentScreenTitle', isOutPatient ? t('reports.opd.titles.new') : t('reports.discharge.titles.new')); - }); + this._addChildObject('reports.edit'); }, editReport() { - let that = this; - this.transitionToRoute('reports.edit', this.get('report.id')) - .then(function(newRoute) { - let controller = newRoute.controllerFor('visits'); - newRoute.currentModel.setProperties({ returnToVisit: that.get('model.id') - }); - let isOutPatient = that.get('model').get('outPatient'); - controller.set('currentScreenTitle', isOutPatient ? t('reports.opd.titles.edit') : t('reports.discharge.titles.edit')); - }); + this.transitionToRoute('reports.edit', this.get('report.id')); }, newAppointment() { From 9334afb3cd2cd7e53b813dfce1ba1e14359627af Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:05:08 +0100 Subject: [PATCH 058/124] Added .travis.yml file for building and deploying to npm --- .travis.yml | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c2e18bea3..ff2d5a030e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,31 @@ ---- language: node_js node_js: - - "4" - +- '4' branches: only: - - "master" - + - master sudo: false - -cache: - directories - - $HOME/.npm - - $HOME/.cache # includes bowers cache - +cache: directories - $HOME/.npm - $HOME/.cache before_install: - - npm config set spin false - - npm install -g bower - - bower --version - - npm install phantomjs-prebuilt - - node_modules/phantomjs-prebuilt/bin/phantomjs --version - +- npm config set spin false +- npm install -g bower +- npm install -g ember +- npm install -g npm-cli-login +- bower --version +- npm install phantomjs-prebuilt +- node_modules/phantomjs-prebuilt/bin/phantomjs --version install: - - npm install - - bower install - +- npm install +- bower install script: - - npm test +- npm test +- ember test +deploy: + provider: npm + email: mofesola.babalola@ehealthafrica.org + api_key: + secure: G13Wfjt+5lzPmc/4M4669Q+htK389oglI/JDTYDDH1v0ZaWOtvAc2Zvu2BvMGy9IMJ5f66ICJLxcWIg0gP2SMxvkQgUYaGFkVCRbaAwxfhcbSLJ2H/AGaanV1qRFeLQQRmNXg/yK0tW+biOsLXKvDXqazaueh/hP64uJmzAr3L1Y26q6QjL2iMEczEUi9Z02Gl5u5rCWsdM8c0oZ872FR8QWkSR4fb6vaKIyItfcUCN0nbJ4RhIncCCJLja7NHbeaxGh9rXVaO6F6oTiuuuJj863ATSBO670dmWGbscZQWxIRJPko3IAn6dQD4Q9FaJZR1pyS2+pkGSuGbjdYjMfj0vh73Hf6wmCwve/i9cA8du0qDEKqMetdsMIAS4XKoR2jQyWCivGOhOHizjoH7xezyj9K469IEugTFoyENoASW3ADYL3YGFpKn0Xs2i0MuSS8MGmSLw6QfEDzLvmxJeGnNQFXKtXyOOJlmyoTcIcviMr26jOmWINBWzNFp6B1wqcWpPy2TJyoQFL8Fnd4uadc5i4mxv9hPKLbbpV72+EuWiPqNX+rvgMxuFfMogIVB6R7GIMrk+MVmLlr9O4jYcsNcEW5Pw5rcxw/OCSw/mReMNFyRWhscpgpWcYwOzQHXMFKusSzITJLNjtwL40JH4i90U2jDwEZTUXT8E/IJVuYmY= + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: master From da5668f91eeabdf6002fc2eb8b2686077bc65d61 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:23:32 +0100 Subject: [PATCH 059/124] Removed ember test. Pretty much does the same as npm test --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff2d5a030e..af345a0980 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ before_install: - npm config set spin false - npm install -g bower - npm install -g ember -- npm install -g npm-cli-login - bower --version - npm install phantomjs-prebuilt - node_modules/phantomjs-prebuilt/bin/phantomjs --version @@ -19,7 +18,6 @@ install: - bower install script: - npm test -- ember test deploy: provider: npm email: mofesola.babalola@ehealthafrica.org From fdfa21e677951a3561737a317487e4b6e4216884 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Tue, 21 Feb 2017 20:35:50 +0100 Subject: [PATCH 060/124] Allowing all branches to be tested and built --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index af345a0980..c1ae4b11d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: node_js node_js: - '4' -branches: - only: - - master sudo: false cache: directories - $HOME/.npm - $HOME/.cache before_install: From e023b78ecd80236575a7aaebea609f8fb0461dfe Mon Sep 17 00:00:00 2001 From: Sebastien Stettler Date: Wed, 22 Feb 2017 05:13:44 +0800 Subject: [PATCH 061/124] refactor patients model translation (#951) --- app/appointments/calendar/template.hbs | 8 ++++---- app/appointments/edit/template.hbs | 22 +++++++++++----------- app/appointments/index/template.hbs | 12 ++++++------ app/appointments/search/template.hbs | 18 +++++++++--------- app/appointments/theater/template.hbs | 6 +++--- app/locales/en/translations.js | 25 +++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 33 deletions(-) diff --git a/app/appointments/calendar/template.hbs b/app/appointments/calendar/template.hbs index 081002a286..57e7182e3c 100644 --- a/app/appointments/calendar/template.hbs +++ b/app/appointments/calendar/template.hbs @@ -3,22 +3,22 @@ {{#em-form model=model submitButton=false}}
              {{em-select class="col-sm-3 form-input-group" - label=(t "labels.status") + label=(t "models.appointment.labels.status") property="selectedStatus" content=appointmentStatusesWithEmpty }} {{em-select class="col-sm-3 form-input-group" - label=(t "labels.type") + label=(t "models.appointment.labels.type") property="selectedAppointmentType" content=visitTypesWithEmpty }} {{em-select class="col-sm-3 form-input-group" - label=(t 'labels.with') + label=(t 'models.appointment.labels.provider') property="selectedProvider" content=physicianList }} {{em-select class="col-sm-3 form-input-group" - label=(t 'labels.location') + label=(t 'models.appointment.labels.location') property="selectedLocation" content=locationList }} diff --git a/app/appointments/edit/template.hbs b/app/appointments/edit/template.hbs index 8f62114fac..fdb84b30ce 100644 --- a/app/appointments/edit/template.hbs +++ b/app/appointments/edit/template.hbs @@ -1,35 +1,35 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.selectPatient}} - {{patient-typeahead property="patientTypeAhead" label=(t 'labels.patient') content=patientList selection=selectedPatient class="required test-patient-input"}} + {{patient-typeahead property="patientTypeAhead" label=(t 'models.patient.names.singular') content=patientList selection=selectedPatient class="required test-patient-input"}} {{else}} {{patient-summary patient=model.patient returnTo='appointments.edit' returnToContext=model.id disablePatientLink=model.isNew }} {{/if}}
              {{#if isAdmissionAppointment}} - {{date-picker property="startDate" label=(t 'labels.startDate') showTime=showTime class="col-sm-4 required test-appointment-start"}} - {{date-picker property="endDate" label=(t 'labels.endDate') showTime=showTime class="col-sm-4 required test-appointment-end"}} + {{date-picker property="startDate" label=(t 'models.appointment.labels.startDate') showTime=showTime class="col-sm-4 required test-appointment-start"}} + {{date-picker property="endDate" label=(t 'models.appointment.labels.endDate') showTime=showTime class="col-sm-4 required test-appointment-end"}} {{else}} {{date-time-picker datePickerClass="required test-appointment-date" label=(t 'labels.date') model=model}} {{/if}} - {{em-checkbox label=(t 'labels.allDay') property="allDay" class="col-sm-2 appointment-all-day"}} + {{em-checkbox label=(t 'models.appointment.labels.allDay') property="allDay" class="col-sm-2 appointment-all-day"}}
              {{#if (eq model.appointmentType 'Surgery')}}
              {{select-or-typeahead className="col-sm-6 test-appointment-with" property="provider" - label=(t 'labels.with') list=physicianList + label=(t 'models.appointment.labels.provider') list=physicianList selection=model.provider }} {{select-or-typeahead className="col-sm-6 test-appointment-location" property="location" - label=(t 'labels.location') list=surgeryLocationList + label=(t 'models.appointment.labels.location') list=surgeryLocationList selection=model.location }}
              {{else}}
              - + {{select-list content=visitTypes optionLabelPath='value' @@ -41,20 +41,20 @@ }}
              {{select-or-typeahead className="col-sm-6 test-appointment-with" property="provider" - label=(t 'labels.with') list=physicianList + label=(t 'models.appointment.labels.provider') list=physicianList selection=model.provider }}
              {{select-or-typeahead className="col-sm-6 test-appointment-location" property="location" - label=(t 'labels.location') list=visitLocationList + label=(t 'models.appointment.labels.location') list=visitLocationList selection=model.location }} {{em-select class="form-input-group col-sm-3 test-appointment-status" property="status" - label=(t 'labels.status') content=appointmentStatuses + label=(t 'models.appointment.labels.status') content=appointmentStatuses }}
              {{/if}} - {{em-text label=(t 'labels.notes') property="notes" rows=3 }} + {{em-text label=(t 'models.appointment.labels.notes') property="notes" rows=3 }} {{/em-form}} {{/edit-panel}} diff --git a/app/appointments/index/template.hbs b/app/appointments/index/template.hbs index 092239d10a..9a5acf21e4 100644 --- a/app/appointments/index/template.hbs +++ b/app/appointments/index/template.hbs @@ -1,12 +1,12 @@ {{#item-listing paginationProps=paginationProps }}
              {{t 'labels.date'}}Created ByReport type{{t 'visits.labels.authoredBy'}}{{t 'visits.labels.reportType'}} {{t 'labels.actions'}}
              - - - - - - + + + + + + {{#each model as |appointment|}} diff --git a/app/appointments/search/template.hbs b/app/appointments/search/template.hbs index aaa2ca7909..aab4aa0090 100644 --- a/app/appointments/search/template.hbs +++ b/app/appointments/search/template.hbs @@ -5,13 +5,13 @@
              {{date-picker property="selectedStartingDate" label=(t "appointments.labels.selectedStartingDate")class="col-sm-3"}} {{em-select class="col-sm-3 form-input-group" property="selectedStatus" - label=(t "labels.status") content=appointmentStatusesWithEmpty + label=(t "models.appointment.labels.status") content=appointmentStatusesWithEmpty }} - {{em-select class="col-sm-3 form-input-group" label=(t "labels.type") + {{em-select class="col-sm-3 form-input-group" label=(t "models.appointment.labels.type") property="selectedAppointmentType" content=visitTypesWithEmpty }} {{em-select class="col-sm-3 form-input-group" property="selectedProvider" - label=(t 'labels.with') content=physicianList + label=(t 'models.appointment.labels.provider') content=physicianList }}
              {{/em-form}} @@ -22,12 +22,12 @@
              {{t 'labels.date'}}{{t 'labels.name'}}{{t 'labels.type'}}{{t 'labels.location'}}{{t 'labels.provider'}}{{t 'labels.status'}}{{t 'models.appointment.labels.appointmentDate'}}{{t 'models.patient.labels.name'}}{{t 'models.appointment.labels.type'}}{{t 'models.appointment.labels.location'}}{{t 'models.appointment.labels.provider'}}{{t 'models.appointment.labels.status'}} {{t 'labels.actions'}}
              - {{#sortable-column sortBy='date' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.date'}}{{/sortable-column}} - - {{#sortable-column sortBy='appointmentType' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.type'}}{{/sortable-column}} - {{#sortable-column sortBy='location' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.location'}}{{/sortable-column}} - {{#sortable-column sortBy='provider' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.with'}}{{/sortable-column}} - {{#sortable-column sortBy='status' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.status'}}{{/sortable-column}} + {{#sortable-column sortBy='date' sortDesc=sortDesc sortKey=sortKey }}{{t 'models.appointment.labels.appointmentDate'}}{{/sortable-column}} + + {{#sortable-column sortBy='appointmentType' sortDesc=sortDesc sortKey=sortKey }}{{t 'models.appointment.labels.type'}}{{/sortable-column}} + {{#sortable-column sortBy='location' sortDesc=sortDesc sortKey=sortKey }}{{t 'models.appointment.labels.location'}}{{/sortable-column}} + {{#sortable-column sortBy='provider' sortDesc=sortDesc sortKey=sortKey }}{{t 'models.appointment.labels.provider'}}{{/sortable-column}} + {{#sortable-column sortBy='status' sortDesc=sortDesc sortKey=sortKey }}{{t 'models.appointment.labels.status'}}{{/sortable-column}} {{#each model as |appointment|}} diff --git a/app/appointments/theater/template.hbs b/app/appointments/theater/template.hbs index 15309f8482..bf8d755263 100644 --- a/app/appointments/theater/template.hbs +++ b/app/appointments/theater/template.hbs @@ -3,17 +3,17 @@ {{#em-form model=model submitButton=false}}
              {{em-select class="col-sm-3 form-input-group" - label=(t "labels.status") + label=(t "models.appointment.labels.status") property="selectedStatus" content=appointmentStatusesWithEmpty }} {{em-select class="col-sm-3 form-input-group" - label=(t 'labels.with') + label=(t 'models.appointment.labels.provider') property="selectedProvider" content=physicianList }} {{em-select class="col-sm-3 form-input-group" - label=(t 'labels.location') + label=(t 'models.appointment.labels.location') property="selectedLocation" content=locationList }} diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 10cb731278..c6ef2d7eb1 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1261,5 +1261,30 @@ export default { titles: { sessionExpired: 'Session Expired' } + }, + models: { + appointment: { + labels: { + status: 'First Name', + appointmentType: 'Type', + provider: 'With', + location: 'Location', + patient: 'Patient', + startDate: 'Start Date', + endDate: 'End Date', + allDay: 'All Day', + type: 'Type', + notes: 'Notes', + appointmentDate: 'Date' + } + }, + patient: { + labels: { + name: 'Name' + }, + names: { + singular: 'Patient' + } + } } }; From 0b0b7614d8b19b7a3bd7ee2850ba0d4258cd654d Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:31:00 +0100 Subject: [PATCH 062/124] fix: added translations for discharge report --- app/locales/en/translations.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index feab068832..a2c267763e 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1109,6 +1109,8 @@ export default { }, form: { visitDate: 'Date of Visit', + dischargeDate: 'Date of Discharge', + notes: 'Notes', primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', From 6a2e48015175508f177015c09250a18ace9fe507 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:31:54 +0100 Subject: [PATCH 063/124] fix: modified report model to accommodate discharge report --- app/models/report.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/report.js b/app/models/report.js index f6516dd802..ac12420641 100644 --- a/app/models/report.js +++ b/app/models/report.js @@ -7,7 +7,7 @@ export default AbstractModel.extend({ customForms: DS.attr('custom-forms'), reportType: DS.attr('string'), nextAppointment: DS.attr('date'), - diagnosis: DS.attr(), + surgeon: DS.attr('string'), // Associations visit: DS.belongsTo('visit', { async: false }), @@ -19,6 +19,15 @@ export default AbstractModel.extend({ reportDate: { presence: true + }, + + surgeon: { + presence: { + 'if'(object) { + return !object.get('visit.outPatient'); + }, + message: 'Please select a surgeon' + } } } }); From 3c6cb9e9b74160d26b2efb7fd68003e50bb74efe Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:32:24 +0100 Subject: [PATCH 064/124] fix: added discharge report --- app/reports/edit/controller.js | 11 +++++++- app/reports/edit/template.hbs | 48 ++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 0f300dee03..3fe00c4b36 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -7,9 +7,15 @@ import DS from 'ember-data'; import moment from 'moment'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { - lookupListsToUpdate: [], + lookupListsToUpdate: [{ + name: 'physicianList', + property: 'model.surgeon', + id: 'physician_list' + }], + visitsController: Ember.inject.controller('visits'), newReport: false, + physicianList: Ember.computed.alias('visitsController.physicianList'), diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); @@ -72,6 +78,9 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, } else { // update discharge report properties this.get('model').set('reportType', 'Discharge Report'); + // check that doctor exists + // check that next appointment exist + // } } resolve(); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 20a3761064..0f00d54aa0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,6 +1,5 @@ -{{#if model.visit.outPatient}} +{{partial "report-header"}}
              - {{partial "report-header"}} {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} @@ -19,6 +18,37 @@
              {{/if}} + {{#if model.visit.outPatient}} + {{else}} +
              +

              {{t 'reports.form.dischargeDate' }}

              + {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}} +
              + {{/if}} + + {{#if model.visit.outPatient}} + {{else}} +
              + {{select-or-typeahead className="col-sm-4" property="surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" + }} +
              + {{/if}} + + {{#if model.visit.outPatient}} + {{else}} + {{#if model.visit.notes}} +
              + +
                +
              • {{model.visit.notes}}
              • +
              +
              + {{/if}} + {{/if}} + {{#if diagnosis.primary.length}}
              @@ -46,7 +76,7 @@
                {{#each model.visit.procedures as |item|}} -
              • {{item.description}}
              • +
              • {{item.description}} {{#if item.procedureDate }} - {{date-format item.procedureDate format="DD/MM/YYYY"}} {{/if}}
              • {{/each}}
              @@ -95,12 +125,14 @@
              {{/if}} - {{custom-form-manager model=model formType="opdReport"}} + {{#if model.visit.outPatient}} + {{custom-form-manager model=model formType="opdReport"}} + {{else}} + + {{/if}} + + {{/em-form}} {{/edit-panel}} - -{{else}} - -{{/if}} \ No newline at end of file From a0c3ddf5d4030a3ed4f9d1490b694cd85eaf2e87 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 10:35:12 +0100 Subject: [PATCH 065/124] fix: added next appointment date to discharge report on save --- app/reports/edit/controller.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 3fe00c4b36..b3d1dae79e 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -69,18 +69,12 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, beforeUpdate() { return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { - + let appointmentDate = this.get('nextAppointment').get('content'); + this.get('model').set('nextAppointment', appointmentDate); if (this.get('model.visit.outPatient')) { this.get('model').set('reportType', 'OPD Report'); - let appointmentDate = this.get('nextAppointment').get('content'); - this.get('model').set('nextAppointment', appointmentDate); - this.get('model').set('diagnosis', this.get('diagnosis')); } else { - // update discharge report properties this.get('model').set('reportType', 'Discharge Report'); - // check that doctor exists - // check that next appointment exist - // } } resolve(); From bd2b0d431a4cbd4f491f2988f54ee47c860704d2 Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 11:24:07 +0100 Subject: [PATCH 066/124] fix: implemented next appointment as a mixin --- app/mixins/patient-visits.js | 28 +++++++++++++++++++++++++++- app/reports/edit/controller.js | 29 +++-------------------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index aee87fa98b..a32a880bc3 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -1,7 +1,8 @@ import Ember from 'ember'; import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; - +import DS from 'ember-data'; +import moment from 'moment'; const { isEmpty } = Ember; @@ -20,6 +21,31 @@ export default Ember.Mixin.create(PouchDbMixin, { }); }, + getPatientFutureAppointment (visit) { + let patientId = visit.get('patient.id'); + let visitDate = visit.get('startDate'); + let maxValue = this.get('maxValue'); + let promise = this.store.query('appointment', { + options: { + startkey: [patientId, null, null, 'appointment_'], + endkey: [patientId, maxValue, maxValue, maxValue] + }, + mapReduce: 'appointments_by_patient' + }).then(function(result) { + let futureAppointments = result.filter(function(data) { + let startDate = data.get('startDate'); + return startDate && moment(startDate).isAfter(moment(visitDate), 'day'); + }).sortBy('startDate'); + if (!futureAppointments.length) { + return ''; + } + let [appointment] = futureAppointments; + let res = appointment.get('startDate'); + return res; + }); + return DS.PromiseObject.create({ promise }); + }, + checkoutVisit(visit, status) { visit.set('status', status); visit.set('endDate', new Date()); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index b3d1dae79e..16c2e24b6a 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,10 +3,9 @@ import Ember from 'ember'; import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import PatientDiagnosis from 'hospitalrun/mixins/patient-diagnosis'; import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; -import DS from 'ember-data'; -import moment from 'moment'; +import PatientVisit from 'hospitalrun/mixins/patient-visits' -export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { +export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { lookupListsToUpdate: [{ name: 'physicianList', property: 'model.surgeon', @@ -27,32 +26,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }), nextAppointment: Ember.computed('model', function() { - let patientId = this.get('model.visit.patient.id'); - let visitDate = this.get('model.visit.startDate'); - let maxValue = this.get('maxValue'); - let promise = this.store.query('appointment', { - options: { - startkey: [patientId, null, null, 'appointment_'], - endkey: [patientId, maxValue, maxValue, maxValue] - }, - mapReduce: 'appointments_by_patient' - }).then(function(result) { - let futureAppointments = result.filter(function(data) { - let startDate = data.get('startDate'); - return startDate && moment(startDate).isAfter(moment(visitDate), 'day'); - }).sortBy('startDate'); - if (!futureAppointments.length) { - return ''; - } - let [appointment] = futureAppointments; - let res = appointment.get('startDate'); - return res; - }); - return DS.PromiseObject.create({ promise }); + return this.getPatientFutureAppointment(this.get('model.visit')) }), additionalButtons: Ember.computed('model.{isNew}', function() { - // let i18n = get(this, 'i18n'); let isNew = this.get('model.isNew'); if (!isNew) { return [{ From 1cf8534a32310e25b5be4ddd6ce0e1c87f76d2bd Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 17:17:33 +0100 Subject: [PATCH 067/124] fix: added translations for followup appointment message --- app/locales/en/translations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index a2c267763e..25033aa2ef 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1104,7 +1104,7 @@ export default { }, reports: { titles: { - preview: 'Preview Report', + followup: 'Create Followup appointment', saved: 'The report has been saved' }, form: { @@ -1132,7 +1132,7 @@ export default { } }, messages: { - deleteMedication: 'Are you sure you want to delete this medication?', + followup: 'Create new followup appointment for the discharge report', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } From d0140b30cf85b122912a98ff5a607da04a048f6a Mon Sep 17 00:00:00 2001 From: Chima Date: Wed, 22 Feb 2017 17:18:30 +0100 Subject: [PATCH 068/124] fix: made sure a followup appointment exists before you generate discharge report --- app/mixins/patient-visits.js | 2 +- app/reports/edit/controller.js | 4 ++-- app/visits/edit/controller.js | 9 +++++++++ app/visits/edit/route.js | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index a32a880bc3..bf1dc2bc06 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -21,7 +21,7 @@ export default Ember.Mixin.create(PouchDbMixin, { }); }, - getPatientFutureAppointment (visit) { + getPatientFutureAppointment(visit) { let patientId = visit.get('patient.id'); let visitDate = visit.get('startDate'); let maxValue = this.get('maxValue'); diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 16c2e24b6a..9cf5d41f37 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,7 +3,7 @@ import Ember from 'ember'; import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import PatientDiagnosis from 'hospitalrun/mixins/patient-diagnosis'; import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; -import PatientVisit from 'hospitalrun/mixins/patient-visits' +import PatientVisit from 'hospitalrun/mixins/patient-visits'; export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { lookupListsToUpdate: [{ @@ -26,7 +26,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, }), nextAppointment: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit')) + return this.getPatientFutureAppointment(this.get('model.visit')); }), additionalButtons: Ember.computed('model.{isNew}', function() { diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index dc7ecab838..cc31422291 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -37,6 +37,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn } }), noReport: false, + nextAppointment: null, canAddAppointment: computed('model.isNew', function() { return (!this.get('model.isNew') && this.currentUserCan('add_appointment')); }), @@ -436,6 +437,14 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newReport() { + let next = this.get('nextAppointment.content'); + if (!this.get('model.outPatient') && !next) { + let i18n = this.get('i18n'); + let updateMesage = i18n.t('reports.messages.followup'); + let updateTitle = i18n.t('reports.titles.followup'); + this.displayAlert(updateTitle, updateMesage); + return false; + } this._addChildObject('reports.edit'); }, diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index b1f2e4cf38..da57946c31 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -3,9 +3,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; +import PatientVisit from 'hospitalrun/mixins/patient-visits'; import DS from 'ember-data'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVisit, { customForms: Ember.inject.service(), editTitle: t('visits.titles.editVisit'), modelName: 'visit', @@ -58,6 +59,7 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { return Ember.isEmpty(reports) ? '' : reports.get('firstObject'); }); controller.set('report', DS.PromiseObject.create({ promise })); + controller.set('nextAppointment', this.getPatientFutureAppointment(model)); this._super(controller, model); }, From 0990ad1919c6ff2666dd767260cec78185204001 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 22 Feb 2017 12:05:53 -0500 Subject: [PATCH 069/124] Change how "new" routes work Makes sure that if user redirects to url the patient is properly selected. --- app/appointments/edit/route.js | 16 +++++++++---- app/imaging/edit/route.js | 3 ++- app/labs/edit/route.js | 5 ++-- app/medication/edit/route.js | 13 ++++++++-- app/mixins/add-to-patient-route.js | 36 ++++++++++++++++++++++++++++ app/patients/edit/controller.js | 14 +++++------ app/patients/operative-plan/route.js | 3 ++- tests/acceptance/operative-test.js | 2 +- 8 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 app/mixins/add-to-patient-route.js diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index d9f6433b6c..bd5c5c7055 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; @@ -6,12 +7,13 @@ import { translationMacro as t } from 'ember-i18n'; const { get, + isEmpty, RSVP: { resolve } } = Ember; -export default AbstractEditRoute.extend(PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', newButtonText: t('appointments.buttons.newButton'), @@ -26,7 +28,7 @@ export default AbstractEditRoute.extend(PatientListRoute, { selectPatient: true, startDate: new Date() }; - if (!Ember.isEmpty(idParam) && params[idParam] === 'newsurgery') { + if (!isEmpty(idParam) && params[idParam] === 'newsurgery') { newData.appointmentType = 'Surgery'; newData.allDay = false; newData.endDate = moment().add('1', 'hours').toDate(); @@ -53,10 +55,16 @@ export default AbstractEditRoute.extend(PatientListRoute, { model(params) { let idParam = this.get('idParam'); let modelId = params[idParam]; - if (!Ember.isEmpty(idParam) && (modelId.indexOf('new') === 0)) { - return this._createNewRecord(params); + if (!isEmpty(idParam) && (modelId.indexOf('new') === 0)) { + if (!isEmpty(params.forPatientId)) { + let modelPromise = this._super(params); + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } } + }); diff --git a/app/imaging/edit/route.js b/app/imaging/edit/route.js index e84f3a243b..4d5bab420d 100644 --- a/app/imaging/edit/route.js +++ b/app/imaging/edit/route.js @@ -1,10 +1,11 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('imaging.titles.editTitle'), modelName: 'imaging', newTitle: t('imaging.titles.editTitle'), diff --git a/app/labs/edit/route.js b/app/labs/edit/route.js index 9b654c7e37..0338bbc9ab 100644 --- a/app/labs/edit/route.js +++ b/app/labs/edit/route.js @@ -1,11 +1,12 @@ -import Ember from 'ember'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; +import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('labs.editTitle'), modelName: 'lab', newTitle: t('labs.newTitle'), diff --git a/app/medication/edit/route.js b/app/medication/edit/route.js index 2f8c7f131a..7cdbed5d87 100644 --- a/app/medication/edit/route.js +++ b/app/medication/edit/route.js @@ -1,12 +1,16 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import FulfillRequest from 'hospitalrun/mixins/fulfill-request'; import InventoryLocations from 'hospitalrun/mixins/inventory-locations'; // inventory-locations mixin is needed for fulfill-request mixin! import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import uuid from 'npm:uuid'; -export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, PatientListRoute, { + +const { isEmpty } = Ember; + +export default AbstractEditRoute.extend(AddToPatientRoute, FulfillRequest, InventoryLocations, PatientListRoute, { editTitle: t('medication.titles.editMedicationRequest'), modelName: 'medication', newTitle: t('medication.titles.newMedicationRequest'), @@ -27,8 +31,13 @@ export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, Pati model(params) { let idParam = this.get('idParam'); + let modelPromise = this._super(params); if (!Ember.isEmpty(idParam) && params[idParam] === 'new' || params[idParam] === 'dispense') { - return this._createNewRecord(params); + if (!isEmpty(params.forPatientId)) { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js new file mode 100644 index 0000000000..c1f79dfe39 --- /dev/null +++ b/app/mixins/add-to-patient-route.js @@ -0,0 +1,36 @@ +import Ember from 'ember'; + +const { get, isEmpty, Mixin } = Ember; + +export default Mixin.create({ + queryParams: { + forPatientId: { + refreshModel: false + } + }, + + model(params) { + let idParam = get(this, 'idParam'); + let modelPromise = this._super(params); + if (!isEmpty(params.forPatientId) && params[idParam] === 'new') { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return modelPromise; + } + }, + + /** + * Resolves the model promise and then sets the patient information on the model. + */ + _setPatientOnModel(modelPromise, patientId) { + let store = get(this, 'store'); + return modelPromise.then((model) => { + return store.find('patient', patientId).then((patient) => { + model.set('patient', patient); + model.set('returnToPatient', patientId); + model.set('selectPatient', false); + return model; + }); + }); + } +}); diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index 0e7eacddc9..45e854b78b 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -540,16 +540,16 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur }, _addChildObject(route, afterTransition) { - this.transitionToRoute(route, 'new').then(function(newRoute) { - newRoute.currentModel.setProperties({ - patient: this.get('model'), - returnToPatient: this.get('model.id'), - selectPatient: false - }); + let options = { + queryParams: { + forPatientId: this.get('model.id') + } + }; + this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); } - }.bind(this)); + }); }, _showEditSocial(editAttributes, modelName, route) { diff --git a/app/patients/operative-plan/route.js b/app/patients/operative-plan/route.js index 96c292d465..f3f0fde73b 100644 --- a/app/patients/operative-plan/route.js +++ b/app/patients/operative-plan/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import { translationMacro as t } from 'ember-i18n'; @@ -8,7 +9,7 @@ const { inject } = Ember; -export default AbstractEditRoute.extend({ +export default AbstractEditRoute.extend(AddToPatientRoute, { editTitle: t('operativePlan.titles.editTitle'), modelName: 'operative-plan', newTitle: t('operativePlan.titles.newTitle'), diff --git a/tests/acceptance/operative-test.js b/tests/acceptance/operative-test.js index 8c424bc39d..054665fd44 100644 --- a/tests/acceptance/operative-test.js +++ b/tests/acceptance/operative-test.js @@ -56,7 +56,7 @@ test('Plan and report creation', function(assert) { waitToAppear('span.secondary-diagnosis:contains(Tennis Elbow)'); }); andThen(() =>{ - assert.equal(currentURL(), '/patients/operative-plan/new', 'New operative plan URL is correct'); + assert.equal(currentURL(), '/patients/operative-plan/new?forPatientId=C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'New operative plan URL is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient header displays'); assert.equal(find('.view-current-title').text(), 'New Operative Plan', 'New operative plan title is correct'); assert.equal(find('span.primary-diagnosis:contains(Broken Arm)').length, 1, 'Primary diagnosis appears as read only'); From 917cfdf301cf9b1c2b565f4264e141eb9fdf5359 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 22 Feb 2017 12:06:10 -0500 Subject: [PATCH 070/124] Move back to official release of ember-rapid-forms. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ce269bc24..67dda4a852 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "ember-load-initializers": "^0.6.0", "ember-pouch": "4.2.1", "ember-radio-buttons": "^4.0.1", - "ember-rapid-forms": "GCorbel/ember-rapid-forms#26229804a2c430bbdf1ffb6bab8fb53af17bb3a4", + "ember-rapid-forms": "1.0.0-beta10", "ember-resolver": "^2.0.3", "ember-select-list": "0.9.5", "ember-simple-auth": "^1.1.0", From 29795ace8b801c09268bb8823af3a6810ce95fb3 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Wed, 22 Feb 2017 23:22:04 +0100 Subject: [PATCH 071/124] Add Hospital Info report header as option config --- app/reports/edit/controller.js | 8 ++++++++ app/reports/edit/template.hbs | 18 +++++++++++++++++- app/styles/_print.scss | 2 +- app/templates/report-header.hbs | 5 ----- app/visits/route.js | 3 +++ 5 files changed, 29 insertions(+), 7 deletions(-) delete mode 100644 app/templates/report-header.hbs diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 0f300dee03..fa20effc92 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -11,6 +11,14 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, + visitController: Ember.inject.controller('visits'), + + logoURL: Ember.computed.alias('visitController.printHeader.value.logoURL'), + facilityName: Ember.computed.alias('visitController.printHeader.value.facilityName'), + headerLine1: Ember.computed.alias('visitController.printHeader.value.headerLine1'), + headerLine2: Ember.computed.alias('visitController.printHeader.value.headerLine2'), + headerLine3: Ember.computed.alias('visitController.printHeader.value.headerLine3'), + diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); let result = { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 20a3761064..c876383eac 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -1,6 +1,22 @@ +
              + {{#if logoURL}} + + {{/if}} + {{#if facilityName }} +

              {{facilityName}}

              + {{/if}} + {{#if headerLine1}} + {{headerLine1}}
              + {{/if}} + {{#if headerLine2}} + {{headerLine2}}
              + {{/if}} + {{#if headerLine3}} + {{headerLine3}}
              + {{/if}} +
              {{#if model.visit.outPatient}}
              - {{partial "report-header"}} {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index b287f87dde..79591157fc 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -36,7 +36,7 @@ } .report-logo { - height: 80px; + height: 60px; } .opd-report { diff --git a/app/templates/report-header.hbs b/app/templates/report-header.hbs deleted file mode 100644 index 36b184ffea..0000000000 --- a/app/templates/report-header.hbs +++ /dev/null @@ -1,5 +0,0 @@ -
              - -

              Hospital Name

              - Hospital Address, No 23, 4th Avenue, Gwarimpa Abuja. -
              \ No newline at end of file diff --git a/app/visits/route.js b/app/visits/route.js index d397fb2d74..3c66313539 100644 --- a/app/visits/route.js +++ b/app/visits/route.js @@ -37,6 +37,9 @@ export default AbstractModuleRoute.extend({ }, { name: 'wardPricingTypes', findArgs: ['lookup', 'ward_pricing_types'] + }, { + name: 'printHeader', + findArgs: ['option', 'print_header'] }], moduleName: 'visits', newButtonAction: null, // No new button From 20775326c554bad30845a0c9a77b66a9ed2ff17d Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 01:58:35 +0100 Subject: [PATCH 072/124] Add report model to patient-diagnosis and visit unit tests --- tests/unit/mixins/patient-diagnosis-test.js | 1 + tests/unit/models/visit-test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/unit/mixins/patient-diagnosis-test.js b/tests/unit/mixins/patient-diagnosis-test.js index 8001771292..11fdf1714e 100644 --- a/tests/unit/mixins/patient-diagnosis-test.js +++ b/tests/unit/mixins/patient-diagnosis-test.js @@ -22,6 +22,7 @@ moduleFor('mixin:patient-diagnosis', 'Unit | Mixin | patient-diagnosis', { 'model:patient-note', 'model:procedure', 'model:diagnosis', + 'model:report', 'ember-validations@validator:local/acceptance', 'ember-validations@validator:local/presence' ], diff --git a/tests/unit/models/visit-test.js b/tests/unit/models/visit-test.js index 601379d135..50db6d0be0 100644 --- a/tests/unit/models/visit-test.js +++ b/tests/unit/models/visit-test.js @@ -16,6 +16,7 @@ moduleForModel('visit', 'Unit | Model | visit', { 'model:proc-charge', 'model:vital', 'model:visit', + 'model:report', 'service:validations' ] }); From d35a8a9b312c848acf8757c337d23bb6ee55e72e Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 10:32:49 +0100 Subject: [PATCH 073/124] fix: fixed report header conflict --- app/reports/edit/template.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 21d473ed55..ca0c31a372 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,7 +15,6 @@ {{headerLine3}}
              {{/if}}
              -{{#if model.visit.outPatient}}
              {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} From edb0ef3037b468285bfb0409970321b194bab2f4 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 12:03:05 +0100 Subject: [PATCH 074/124] Refactor report template --- app/reports/edit/template.hbs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index ca0c31a372..2b14d1b779 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -34,16 +34,14 @@
              {{/if}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}}

              {{t 'reports.form.dischargeDate' }}

              {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}}
              - {{/if}} + {{/unless}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}}
              {{select-or-typeahead className="col-sm-4" property="surgeon" label=(t "operativePlan.labels.surgeon") list=physicianList @@ -51,10 +49,9 @@ class="plan-surgeon" }}
              - {{/if}} + {{/unless}} - {{#if model.visit.outPatient}} - {{else}} + {{#unless model.visit.outPatient}} {{#if model.visit.notes}}
              @@ -63,7 +60,7 @@
              {{/if}} - {{/if}} + {{/unless}} {{#if diagnosis.primary.length}}
              From 2db7c323a419a964b7fb94114814767373d99846 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 23 Feb 2017 12:05:46 +0100 Subject: [PATCH 075/124] Add custom forms to discharge report --- app/admin/custom-forms/edit/controller.js | 3 ++- app/locales/en/translations.js | 3 ++- app/reports/edit/route.js | 2 +- app/reports/edit/template.hbs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/admin/custom-forms/edit/controller.js b/app/admin/custom-forms/edit/controller.js index 295418802d..63b0607044 100644 --- a/app/admin/custom-forms/edit/controller.js +++ b/app/admin/custom-forms/edit/controller.js @@ -79,7 +79,8 @@ export default AbstractEditController.extend({ 'patient', 'socialwork', 'visit', - 'opdReport' + 'opdReport', + 'dischargeReport' ], formTypes: computed(function() { diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 25033aa2ef..b0dbdf3875 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -147,7 +147,8 @@ export default { text: 'Text', textarea: 'Large Text', visitFormType: 'Visit', - opdReportFormType: 'Outpatient Report' + opdReportFormType: 'Outpatient Report', + dischargeReportFormType: 'Discharge Report' }, messages: { deleteForm: 'Are you sure you want to delete this custom form?', diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 54749b2ece..1aa5943735 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -12,7 +12,7 @@ export default AbstractEditRoute.extend({ customForms: Ember.Object.create() }; let customForms = this.get('customForms'); - return customForms.setDefaultCustomForms(['opdReport'], newReportData); + return customForms.setDefaultCustomForms(['opdReport', 'dischargeReport'], newReportData); }, afterModel(model) { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 2b14d1b779..7bdf08c846 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -141,7 +141,7 @@ {{#if model.visit.outPatient}} {{custom-form-manager model=model formType="opdReport"}} {{else}} - + {{custom-form-manager model=model formType="dischargeReport"}} {{/if}} From 4662424f6fe7bade2932ef6769dc694e523e07de Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 13:19:13 +0100 Subject: [PATCH 076/124] fix: added hospital info doc to environment --- config/environment.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/environment.js b/config/environment.js index ae20b6bbcc..ede0572321 100644 --- a/config/environment.js +++ b/config/environment.js @@ -70,5 +70,18 @@ module.exports = function(environment) { schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source' }; + ENV.hospitalInfoDoc = { + "_id": "option_2_print_header", + "_rev": "1-4457555eacb405267c6d3b7a53d8521d", + "data": { + "value": { + "facilityName": "Beit CURE International Hospital", + "headerLine1": "PO Box 31236", + "headerLine2": "Blantyre 3", + "headerLine3": "+265 (0) 1 871 900 / +265 (0) 1 875 015 /+265 (0) 1 873 694 / +265 (0) 999 505 212", + "logoURL": "https://curehospital.mw/wp-content/uploads/4/2012/11/CURE-Malawi-Logo_rgb_280_89.jpg" + } + } + } return ENV; }; From d98df0d0599aa9d0d8ce289090818810abe4c516 Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 13:20:07 +0100 Subject: [PATCH 077/124] fix: create sample docs on couchdb --- app/services/database.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/services/database.js b/app/services/database.js index e04e25c424..71b0f22ff7 100644 --- a/app/services/database.js +++ b/app/services/database.js @@ -3,6 +3,7 @@ import createPouchViews from 'hospitalrun/utils/pouch-views'; import List from 'npm:pouchdb-list'; import PouchAdapterMemory from 'npm:pouchdb-adapter-memory'; import UnauthorizedError from 'hospitalrun/utils/unauthorized-error'; +import enviroment from './../config/environment'; const { isEmpty @@ -20,9 +21,42 @@ export default Ember.Service.extend({ .then((db) => { this.set('mainDB', db); this.set('setMainDB', true); + }) + .then(() => { + this.createSampleDocs([enviroment.hospitalInfoDoc]); }); }, + createSampleDocs(docs) { + return new Ember.RSVP.Promise((resolve, reject) => { + let mainDB = this.get('mainDB'); + let ids = docs.map((doc) => { + return doc._id; + }); + return mainDB.allDocs({ keys: ids }) + .then((res) => { + if (res.rows) { + let docsToCreate = res.rows.filter((row) => { + return row.error && row.error === 'not_found'; + }).map((row) => { + return docs.find((doc) => { + return doc._id === row.key; + }); + }); + if (docsToCreate.length) { + return mainDB.bulkDocs(docsToCreate); + } + } + }) + .then((res) => { + resolve(res); + }) + .catch((err) => { + reject(err); + }); + }); + }, + createDB(configs) { return new Ember.RSVP.Promise((resolve, reject) => { let pouchOptions = {}; From ed34c53507fbf4dc8deb1f21d9299841dfe5cc31 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 22 Feb 2017 12:05:53 -0500 Subject: [PATCH 078/124] Change how "new" routes work Makes sure that if user redirects to url the patient is properly selected. --- app/appointments/edit/route.js | 16 +++++++++---- app/imaging/edit/route.js | 3 ++- app/labs/edit/route.js | 5 ++-- app/medication/edit/route.js | 13 ++++++++-- app/mixins/add-to-patient-route.js | 36 ++++++++++++++++++++++++++++ app/patients/edit/controller.js | 14 +++++------ app/patients/operative-plan/route.js | 3 ++- tests/acceptance/operative-test.js | 2 +- 8 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 app/mixins/add-to-patient-route.js diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index d9f6433b6c..bd5c5c7055 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; @@ -6,12 +7,13 @@ import { translationMacro as t } from 'ember-i18n'; const { get, + isEmpty, RSVP: { resolve } } = Ember; -export default AbstractEditRoute.extend(PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', newButtonText: t('appointments.buttons.newButton'), @@ -26,7 +28,7 @@ export default AbstractEditRoute.extend(PatientListRoute, { selectPatient: true, startDate: new Date() }; - if (!Ember.isEmpty(idParam) && params[idParam] === 'newsurgery') { + if (!isEmpty(idParam) && params[idParam] === 'newsurgery') { newData.appointmentType = 'Surgery'; newData.allDay = false; newData.endDate = moment().add('1', 'hours').toDate(); @@ -53,10 +55,16 @@ export default AbstractEditRoute.extend(PatientListRoute, { model(params) { let idParam = this.get('idParam'); let modelId = params[idParam]; - if (!Ember.isEmpty(idParam) && (modelId.indexOf('new') === 0)) { - return this._createNewRecord(params); + if (!isEmpty(idParam) && (modelId.indexOf('new') === 0)) { + if (!isEmpty(params.forPatientId)) { + let modelPromise = this._super(params); + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } } + }); diff --git a/app/imaging/edit/route.js b/app/imaging/edit/route.js index e84f3a243b..4d5bab420d 100644 --- a/app/imaging/edit/route.js +++ b/app/imaging/edit/route.js @@ -1,10 +1,11 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('imaging.titles.editTitle'), modelName: 'imaging', newTitle: t('imaging.titles.editTitle'), diff --git a/app/labs/edit/route.js b/app/labs/edit/route.js index 9b654c7e37..0338bbc9ab 100644 --- a/app/labs/edit/route.js +++ b/app/labs/edit/route.js @@ -1,11 +1,12 @@ -import Ember from 'ember'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; +import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, ChargeRoute, PatientListRoute, { editTitle: t('labs.editTitle'), modelName: 'lab', newTitle: t('labs.newTitle'), diff --git a/app/medication/edit/route.js b/app/medication/edit/route.js index 2f8c7f131a..7cdbed5d87 100644 --- a/app/medication/edit/route.js +++ b/app/medication/edit/route.js @@ -1,12 +1,16 @@ import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import FulfillRequest from 'hospitalrun/mixins/fulfill-request'; import InventoryLocations from 'hospitalrun/mixins/inventory-locations'; // inventory-locations mixin is needed for fulfill-request mixin! import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; import uuid from 'npm:uuid'; -export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, PatientListRoute, { + +const { isEmpty } = Ember; + +export default AbstractEditRoute.extend(AddToPatientRoute, FulfillRequest, InventoryLocations, PatientListRoute, { editTitle: t('medication.titles.editMedicationRequest'), modelName: 'medication', newTitle: t('medication.titles.newMedicationRequest'), @@ -27,8 +31,13 @@ export default AbstractEditRoute.extend(FulfillRequest, InventoryLocations, Pati model(params) { let idParam = this.get('idParam'); + let modelPromise = this._super(params); if (!Ember.isEmpty(idParam) && params[idParam] === 'new' || params[idParam] === 'dispense') { - return this._createNewRecord(params); + if (!isEmpty(params.forPatientId)) { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return this._createNewRecord(params); + } } else { return this._super(params); } diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js new file mode 100644 index 0000000000..c1f79dfe39 --- /dev/null +++ b/app/mixins/add-to-patient-route.js @@ -0,0 +1,36 @@ +import Ember from 'ember'; + +const { get, isEmpty, Mixin } = Ember; + +export default Mixin.create({ + queryParams: { + forPatientId: { + refreshModel: false + } + }, + + model(params) { + let idParam = get(this, 'idParam'); + let modelPromise = this._super(params); + if (!isEmpty(params.forPatientId) && params[idParam] === 'new') { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else { + return modelPromise; + } + }, + + /** + * Resolves the model promise and then sets the patient information on the model. + */ + _setPatientOnModel(modelPromise, patientId) { + let store = get(this, 'store'); + return modelPromise.then((model) => { + return store.find('patient', patientId).then((patient) => { + model.set('patient', patient); + model.set('returnToPatient', patientId); + model.set('selectPatient', false); + return model; + }); + }); + } +}); diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index 0e7eacddc9..45e854b78b 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -540,16 +540,16 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur }, _addChildObject(route, afterTransition) { - this.transitionToRoute(route, 'new').then(function(newRoute) { - newRoute.currentModel.setProperties({ - patient: this.get('model'), - returnToPatient: this.get('model.id'), - selectPatient: false - }); + let options = { + queryParams: { + forPatientId: this.get('model.id') + } + }; + this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); } - }.bind(this)); + }); }, _showEditSocial(editAttributes, modelName, route) { diff --git a/app/patients/operative-plan/route.js b/app/patients/operative-plan/route.js index 96c292d465..f3f0fde73b 100644 --- a/app/patients/operative-plan/route.js +++ b/app/patients/operative-plan/route.js @@ -1,4 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import { translationMacro as t } from 'ember-i18n'; @@ -8,7 +9,7 @@ const { inject } = Ember; -export default AbstractEditRoute.extend({ +export default AbstractEditRoute.extend(AddToPatientRoute, { editTitle: t('operativePlan.titles.editTitle'), modelName: 'operative-plan', newTitle: t('operativePlan.titles.newTitle'), diff --git a/tests/acceptance/operative-test.js b/tests/acceptance/operative-test.js index 8c424bc39d..054665fd44 100644 --- a/tests/acceptance/operative-test.js +++ b/tests/acceptance/operative-test.js @@ -56,7 +56,7 @@ test('Plan and report creation', function(assert) { waitToAppear('span.secondary-diagnosis:contains(Tennis Elbow)'); }); andThen(() =>{ - assert.equal(currentURL(), '/patients/operative-plan/new', 'New operative plan URL is correct'); + assert.equal(currentURL(), '/patients/operative-plan/new?forPatientId=C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'New operative plan URL is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient header displays'); assert.equal(find('.view-current-title').text(), 'New Operative Plan', 'New operative plan title is correct'); assert.equal(find('span.primary-diagnosis:contains(Broken Arm)').length, 1, 'Primary diagnosis appears as read only'); From 4a2070948d77737a188ca0886ebf0e6c8c9b112f Mon Sep 17 00:00:00 2001 From: Chima Date: Thu, 23 Feb 2017 15:29:13 +0100 Subject: [PATCH 079/124] fix: made sure sample docs are created when deleted --- app/services/database.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/services/database.js b/app/services/database.js index 71b0f22ff7..7297713aea 100644 --- a/app/services/database.js +++ b/app/services/database.js @@ -37,10 +37,15 @@ export default Ember.Service.extend({ .then((res) => { if (res.rows) { let docsToCreate = res.rows.filter((row) => { - return row.error && row.error === 'not_found'; + return (row.error && row.error === 'not_found') || (row.value && row.value.deleted); }).map((row) => { return docs.find((doc) => { - return doc._id === row.key; + if (doc._id === row.key) { + if (row.value && row.value.deleted && row.value.rev !== doc._rev) { + doc._rev = row.value.rev; + } + return true; + } }); }); if (docsToCreate.length) { From 59b3b30273b37b7b76490f6c7761823a86f10f71 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 11:23:31 +0100 Subject: [PATCH 080/124] Add query parameters to improve app navigation experience --- app/mixins/add-to-patient-route.js | 26 ++++++++++++++++++++-- app/reports/edit/route.js | 14 ++---------- app/visits/edit/controller.js | 35 ++++++++++++++++-------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js index c1f79dfe39..f3979f70f5 100644 --- a/app/mixins/add-to-patient-route.js +++ b/app/mixins/add-to-patient-route.js @@ -6,14 +6,21 @@ export default Mixin.create({ queryParams: { forPatientId: { refreshModel: false + }, + forVisitId: { + refreshModel: false } }, model(params) { let idParam = get(this, 'idParam'); let modelPromise = this._super(params); - if (!isEmpty(params.forPatientId) && params[idParam] === 'new') { - return this._setPatientOnModel(modelPromise, params.forPatientId); + if (params[idParam] === 'new') { + if (!isEmpty(params.forPatientId)) { + return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + return this._setVisitOnModel(modelPromise, params.forVisitId); + } } else { return modelPromise; } @@ -32,5 +39,20 @@ export default Mixin.create({ return model; }); }); + }, + + /** + * Resolves the model promise and then sets the visit information on the model. + */ + _setVisitOnModel(modelPromise, visitId) { + let store = get(this, 'store'); + return modelPromise.then((model) => { + return store.find('visit', visitId).then((visit) => { + model.set('visit', visit); + model.set('returnToVisit', visitId); + model.set('selectPatient', false); + return model; + }); + }); } }); diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 1aa5943735..6dfa98e12a 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,8 +1,9 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend({ +export default AbstractEditRoute.extend(AddToPatientRoute, { modelName: 'report', customForms: Ember.inject.service(), @@ -15,17 +16,6 @@ export default AbstractEditRoute.extend({ return customForms.setDefaultCustomForms(['opdReport', 'dischargeReport'], newReportData); }, - afterModel(model) { - if (model.get('isNew')) { - let visit = this.modelFor('visits.edit'); - if (!visit) { - return this.transitionTo('patients'); - } - model.set('visit', visit); - } - model.setProperties({ returnToVisit: model.get('visit.id') }); - }, - getScreenTitle(model) { let state = model.get('isNew') ? 'new' : 'edit'; let type = model.get('visit.outPatient') ? 'opd' : 'discharge'; diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index cc31422291..865ac74062 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -170,18 +170,21 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return visitTypes; }.property('visitTypes', 'model.outPatient'), - _addChildObject(route, afterTransition) { - this.transitionToRoute(route, 'new').then(function(newRoute) { - newRoute.currentModel.setProperties({ - patient: this.get('model.patient'), - visit: this.get('model'), - selectPatient: false, - returnToVisit: this.get('model.id') - }); + _addChildObject(route, queryParamType, afterTransition) { + let queryParams = {}; + if (queryParamType) { + if (queryParamType == 'patient') { + queryParams.forPatientId = this.get('model.patient.id'); + } else if (queryParamType == 'visit') { + queryParams.forVisitId = this.get('model.id'); + } + } + let options = { queryParams }; + this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); } - }.bind(this)); + }); }, _finishAfterUpdate() { @@ -398,7 +401,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn editOperativePlan(operativePlan) { let model = operativePlan; if (isEmpty(model)) { - this._addChildObject('patients.operative-plan', (route) =>{ + this._addChildObject('patients.operative-plan', 'patient', (route) =>{ route.controller.getPatientDiagnoses(this.get('model.patient'), route.currentModel); }); } else { @@ -445,7 +448,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.displayAlert(updateTitle, updateMesage); return false; } - this._addChildObject('reports.edit'); + this._addChildObject('reports.edit', 'visit'); }, editReport() { @@ -453,23 +456,23 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newAppointment() { - this._addChildObject('appointments.edit'); + this._addChildObject('appointments.edit', 'patient'); }, newImaging() { - this._addChildObject('imaging.edit'); + this._addChildObject('imaging.edit', 'patient'); }, newLab() { - this._addChildObject('labs.edit'); + this._addChildObject('labs.edit', 'patient'); }, newMedication() { - this._addChildObject('medication.edit'); + this._addChildObject('medication.edit', 'patient'); }, showAddProcedure() { - this._addChildObject('procedures.edit'); + this._addChildObject('procedures.edit', 'patient'); }, showDeleteImaging(imaging) { From dd9ce6b7785e8aa2d24bd5bb10f185fadd2a9b69 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:04:13 +0100 Subject: [PATCH 081/124] set patient on visit models --- app/mixins/add-to-patient-route.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/mixins/add-to-patient-route.js b/app/mixins/add-to-patient-route.js index f3979f70f5..865816d2c7 100644 --- a/app/mixins/add-to-patient-route.js +++ b/app/mixins/add-to-patient-route.js @@ -20,6 +20,8 @@ export default Mixin.create({ return this._setPatientOnModel(modelPromise, params.forPatientId); } else if (!isEmpty(params.forVisitId)) { return this._setVisitOnModel(modelPromise, params.forVisitId); + } else { + return this._createNewRecord(params); } } else { return modelPromise; @@ -51,6 +53,7 @@ export default Mixin.create({ model.set('visit', visit); model.set('returnToVisit', visitId); model.set('selectPatient', false); + model.set('patient', visit.get('patient')); return model; }); }); From 7d439f0be23c3c44195ca6bd89bd7041b9d7515b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:05:46 +0100 Subject: [PATCH 082/124] Redirect reports/new to patients when no visit model --- app/reports/edit/route.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 6dfa98e12a..19ac6dd505 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -22,6 +22,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, { return t(`reports.${type}.titles.${state}`); }, + afterModel(model) { + if (!model.get('visit')) { + return this.transitionTo('patients'); + } + }, + setupController(controller, model) { this._super(controller, model); } From dd895560d6b755045ca0a7b946281839e546305c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:08:40 +0100 Subject: [PATCH 083/124] Clean up visit controller --- app/visits/edit/controller.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 865ac74062..dabd6a47f7 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -170,16 +170,12 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn return visitTypes; }.property('visitTypes', 'model.outPatient'), - _addChildObject(route, queryParamType, afterTransition) { - let queryParams = {}; - if (queryParamType) { - if (queryParamType == 'patient') { - queryParams.forPatientId = this.get('model.patient.id'); - } else if (queryParamType == 'visit') { - queryParams.forVisitId = this.get('model.id'); + _addChildObject(route, afterTransition) { + let options = { + queryParams: { + forVisitId: this.get('model.id') } - } - let options = { queryParams }; + }; this.transitionToRoute(route, 'new', options).then((newRoute) => { if (afterTransition) { afterTransition(newRoute); @@ -401,7 +397,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn editOperativePlan(operativePlan) { let model = operativePlan; if (isEmpty(model)) { - this._addChildObject('patients.operative-plan', 'patient', (route) =>{ + this._addChildObject('patients.operative-plan', (route) =>{ route.controller.getPatientDiagnoses(this.get('model.patient'), route.currentModel); }); } else { @@ -448,7 +444,7 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.displayAlert(updateTitle, updateMesage); return false; } - this._addChildObject('reports.edit', 'visit'); + this._addChildObject('reports.edit'); }, editReport() { @@ -456,23 +452,23 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn }, newAppointment() { - this._addChildObject('appointments.edit', 'patient'); + this._addChildObject('appointments.edit'); }, newImaging() { - this._addChildObject('imaging.edit', 'patient'); + this._addChildObject('imaging.edit'); }, newLab() { - this._addChildObject('labs.edit', 'patient'); + this._addChildObject('labs.edit'); }, newMedication() { - this._addChildObject('medication.edit', 'patient'); + this._addChildObject('medication.edit'); }, showAddProcedure() { - this._addChildObject('procedures.edit', 'patient'); + this._addChildObject('procedures.edit'); }, showDeleteImaging(imaging) { From 012f7d51a160146707dc1cbd3eb8768913df9b43 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:10:02 +0100 Subject: [PATCH 084/124] Set visit on models --- app/appointments/edit/route.js | 3 +++ app/medication/edit/route.js | 2 ++ app/procedures/edit/route.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index bd5c5c7055..f1b47bc561 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -59,6 +59,9 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { if (!isEmpty(params.forPatientId)) { let modelPromise = this._super(params); return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + let modelPromise = this._super(params); + return this._setVisitOnModel(modelPromise, params.forforVisitId); } else { return this._createNewRecord(params); } diff --git a/app/medication/edit/route.js b/app/medication/edit/route.js index 7cdbed5d87..e8ae0b4b0d 100644 --- a/app/medication/edit/route.js +++ b/app/medication/edit/route.js @@ -35,6 +35,8 @@ export default AbstractEditRoute.extend(AddToPatientRoute, FulfillRequest, Inven if (!Ember.isEmpty(idParam) && params[idParam] === 'new' || params[idParam] === 'dispense') { if (!isEmpty(params.forPatientId)) { return this._setPatientOnModel(modelPromise, params.forPatientId); + } else if (!isEmpty(params.forVisitId)) { + return this._setVisitOnModel(modelPromise, params.forVisitId); } else { return this._createNewRecord(params); } diff --git a/app/procedures/edit/route.js b/app/procedures/edit/route.js index cfac071baf..b2e54299ce 100644 --- a/app/procedures/edit/route.js +++ b/app/procedures/edit/route.js @@ -1,9 +1,10 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import AddToPatient from 'hospitalrun/mixins/add-to-patient-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; -export default AbstractEditRoute.extend(ChargeRoute, { +export default AbstractEditRoute.extend(AddToPatient, ChargeRoute, { editTitle: t('procedures.titles.edit'), modelName: 'procedure', newTitle: t('procedures.titles.new'), From 4834a44eacaaddb714e968f748f03f75f7e4d679 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 19:11:17 +0100 Subject: [PATCH 085/124] Update visit acceptance tests --- tests/acceptance/visit-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/visit-test.js b/tests/acceptance/visit-test.js index b3fe28c347..97edebdb5b 100644 --- a/tests/acceptance/visit-test.js +++ b/tests/acceptance/visit-test.js @@ -68,7 +68,7 @@ test('Edit visit', function(assert) { click('button:contains(New Medication)'); }); andThen(function() { - assert.equal(currentURL(), '/medication/edit/new', 'New medication url is correct'); + assert.equal(currentURL(), '/medication/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New medication url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New medication prepopulates with patient'); click('button:contains(Cancel)'); }); @@ -76,7 +76,7 @@ test('Edit visit', function(assert) { click('button:contains(New Lab)'); }); andThen(function() { - assert.equal(currentURL(), '/labs/edit/new', 'New lab url is correct'); + assert.equal(currentURL(), '/labs/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New lab url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New lab prepopulates with patient'); click('button:contains(Cancel)'); }); @@ -84,7 +84,7 @@ test('Edit visit', function(assert) { click('button:contains(New Imaging)'); }); andThen(function() { - assert.equal(currentURL(), '/imaging/edit/new', 'New imaging url is correct'); + assert.equal(currentURL(), '/imaging/edit/new?forVisitId=03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'New imaging url is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New imaging prepopulates with patient'); click('button:contains(Cancel)'); }); From 67670f64277b0f6185826a799c1508bfda4e304c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 24 Feb 2017 21:02:44 +0100 Subject: [PATCH 086/124] Fix appointments new surgery test error --- app/appointments/edit/route.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/appointments/edit/route.js b/app/appointments/edit/route.js index f1b47bc561..aae30ff91d 100644 --- a/app/appointments/edit/route.js +++ b/app/appointments/edit/route.js @@ -1,5 +1,5 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; -import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; +import AddToPatient from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import moment from 'moment'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; @@ -13,7 +13,7 @@ const { } } = Ember; -export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { +export default AbstractEditRoute.extend(AddToPatient, PatientListRoute, { editTitle: t('appointments.editTitle'), modelName: 'appointment', newButtonText: t('appointments.buttons.newButton'), @@ -61,7 +61,7 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientListRoute, { return this._setPatientOnModel(modelPromise, params.forPatientId); } else if (!isEmpty(params.forVisitId)) { let modelPromise = this._super(params); - return this._setVisitOnModel(modelPromise, params.forforVisitId); + return this._setVisitOnModel(modelPromise, params.forVisitId); } else { return this._createNewRecord(params); } From 55daf75748aca4862c50bb02d9dd0d5c908928fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Bias=C3=A3o?= Date: Sat, 25 Feb 2017 23:51:55 -0300 Subject: [PATCH 087/124] Fix typo on README.md ## Running with Docker section (#963) * Fix typo on README.md ## Running with Docker section -> cd hosptialrun-frontend * Fix typo on Running with Docker section from - Build the HosptialRun image with `docker build -t hospitalrun-frontend . to - Build the HospitalRun image with `docker build -t hospitalrun-frontend . --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 55726cc8f7..1ee7bfecf2 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ To start the frontend please do the following: To run HospitalRun with Docker please do the following: - Goto [https://docs.docker.com/engine/installation](https://docs.docker.com/engine/installation) to download and install Docker. - Clone the repository with the command `git clone https://github.com/HospitalRun/hospitalrun-frontend.git`. -- Change to the hospitalrun-frontend directory `cd hosptialrun-frontend`. -- Build the HosptialRun image with `docker build -t hospitalrun-frontend .` +- Change to the hospitalrun-frontend directory `cd hospitalrun-frontend`. +- Build the HospitalRun image with `docker build -t hospitalrun-frontend .` - Execute `docker run -it --name couchdb -d couchdb` to create the couchdb container. - Execute `docker run -it --name hospitalrun-frontend -p 4200:4200 --link couchdb:couchdb -d hospitalrun-frontend` to create the HospitalRun container. From 8c0387a7b0e170fa1696a9a5f81c370c933bb6f1 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 15:02:00 +0100 Subject: [PATCH 088/124] Remove double reference to visits controller --- app/reports/edit/controller.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index ff67d4e9da..f927d94db5 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -16,13 +16,11 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, newReport: false, physicianList: Ember.computed.alias('visitsController.physicianList'), - visitController: Ember.inject.controller('visits'), - - logoURL: Ember.computed.alias('visitController.printHeader.value.logoURL'), - facilityName: Ember.computed.alias('visitController.printHeader.value.facilityName'), - headerLine1: Ember.computed.alias('visitController.printHeader.value.headerLine1'), - headerLine2: Ember.computed.alias('visitController.printHeader.value.headerLine2'), - headerLine3: Ember.computed.alias('visitController.printHeader.value.headerLine3'), + logoURL: Ember.computed.alias('visitsController.printHeader.value.logoURL'), + facilityName: Ember.computed.alias('visitsController.printHeader.value.facilityName'), + headerLine1: Ember.computed.alias('visitsController.printHeader.value.headerLine1'), + headerLine2: Ember.computed.alias('visitsController.printHeader.value.headerLine2'), + headerLine3: Ember.computed.alias('visitsController.printHeader.value.headerLine3'), diagnosis: Ember.computed('model.patient', function() { let container = this.get('model.patient'); From a38f060ad0f428f4335bc4646b82af4f54f4a4f1 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 15:41:02 +0100 Subject: [PATCH 089/124] Display visit diagnosis appropriately --- app/reports/edit/controller.js | 13 ++++--------- app/reports/edit/template.hbs | 24 ++---------------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index f927d94db5..719b082992 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -12,8 +12,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, id: 'physician_list' }], - visitsController: Ember.inject.controller('visits'), newReport: false, + + visitsController: Ember.inject.controller('visits'), + physicianList: Ember.computed.alias('visitsController.physicianList'), logoURL: Ember.computed.alias('visitsController.printHeader.value.logoURL'), @@ -22,14 +24,7 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, headerLine2: Ember.computed.alias('visitsController.printHeader.value.headerLine2'), headerLine3: Ember.computed.alias('visitsController.printHeader.value.headerLine3'), - diagnosis: Ember.computed('model.patient', function() { - let container = this.get('model.patient'); - let result = { - primary: this.getDiagnoses(container, true, false), - secondary: this.getDiagnoses(container, true, true) - }; - return result; - }), + diagnosisList: Ember.computed.alias('visitsController.diagnosisList'), nextAppointment: Ember.computed('model', function() { return this.getPatientFutureAppointment(this.get('model.visit')); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7bdf08c846..6c50aeb9fe 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -24,6 +24,8 @@ returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew + diagnosisContainer=model.visit + diagnosisList=diagnosisList }} {{/if}} @@ -62,28 +64,6 @@ {{/if}} {{/unless}} - {{#if diagnosis.primary.length}} -
              - -
                - {{#each diagnosis.primary as |item|}} -
              • {{item.diagnosis}}
              • - {{/each}} -
              -
              - {{/if}} - - {{#if diagnosis.secondary.length}} -
              - -
                - {{#each diagnosis.secondary as |item|}} -
              • {{item.diagnosis}}
              • - {{/each}} -
              -
              - {{/if}} - {{#if model.visit.procedures.length}}
              From 62c4dcef1aa1c9f007754d983572721744bef6bd Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Sun, 26 Feb 2017 22:18:04 +0100 Subject: [PATCH 090/124] Fix Operative Plans display --- app/locales/en/translations.js | 8 ++++++- app/reports/edit/template.hbs | 42 +++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index b0dbdf3875..444619422d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1117,8 +1117,14 @@ export default { procedures: 'Procedures', labs: 'Labs', images: 'Images', + medications: 'Medications', nextAppointmentDate: 'Date Of Next Appointment', - operativePlan: 'Planned Procedures' + operativePlan: { + title: 'Operative Plans', + description: 'Operation Description', + procedures: 'Planned Procedures', + instructions: 'Instructions upon Admission' + } }, opd: { titles: { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7bdf08c846..d74136452c 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -29,7 +29,7 @@ {{#if model.visit.startDate}}
              -

              {{t 'reports.form.visitDate' }}

              + {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -89,7 +89,7 @@
                {{#each model.visit.procedures as |item|}} -
              • {{item.description}} {{#if item.procedureDate }} - {{date-format item.procedureDate format="DD/MM/YYYY"}} {{/if}}
              • +
              • {{item.description}}
              • {{/each}}
              @@ -117,23 +117,49 @@
              {{/if}} + {{#if model.visit.medication.length}} +
              + +
                + {{#each model.visit.medication as |medication|}} +
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • + {{/each}} +
              +
              + {{/if}} {{#if nextAppointment}}
              -

              {{t 'reports.form.nextAppointmentDate' }}

              + {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}}
              {{/if}} {{#if model.visit.patient.operativePlans.length}}
              - +
                - {{#each model.visit.patient.operativePlans as |item|}} - {{#each item.procedures as |p|}} -
              • {{p.description}} ({{item.status}})
              • + {{#each model.visit.patient.operativePlans as |operativePlan|}} +
              • +

                {{t 'reports.form.operativePlan.description' }}:
                + {{operativePlan.operationDescription}}

                +
              • + +
              • +

                {{t 'reports.form.operativePlan.procedures' }}:

                +
                  + {{#each operativePlan.procedures as |procedure|}} +
                • {{procedure.description}}
                • + {{/each}} +
                +
              • + +
              • +

                {{t 'reports.form.operativePlan.instructions' }}:
                + {{operativePlan.admissionInstructions}} +

                +
              • {{/each}} - {{/each}}
              {{/if}} From df81a13370cee25a406a89e18a760b812abde5c8 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:13:39 +0100 Subject: [PATCH 091/124] fix: fixed translation lables for next appointments --- app/locales/en/translations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 444619422d..aa101a46fe 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1118,7 +1118,8 @@ export default { labs: 'Labs', images: 'Images', medications: 'Medications', - nextAppointmentDate: 'Date Of Next Appointment', + nextAppointment: 'Next Appointment', + nextAppointments: 'Next Appointments', operativePlan: { title: 'Operative Plans', description: 'Operation Description', From de35e4432ab63c98731e3c416665680a28822364 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:14:59 +0100 Subject: [PATCH 092/124] fix: modified get futureAppointment to work for list of appointments --- app/mixins/patient-visits.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index bf1dc2bc06..1f244935bd 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -21,7 +21,7 @@ export default Ember.Mixin.create(PouchDbMixin, { }); }, - getPatientFutureAppointment(visit) { + getPatientFutureAppointment(visit, outPatient) { let patientId = visit.get('patient.id'); let visitDate = visit.get('startDate'); let maxValue = this.get('maxValue'); @@ -39,11 +39,16 @@ export default Ember.Mixin.create(PouchDbMixin, { if (!futureAppointments.length) { return ''; } - let [appointment] = futureAppointments; - let res = appointment.get('startDate'); - return res; + if (!outPatient) { + let [appointment] = futureAppointments; + return appointment; + } else { + let res = futureAppointments.slice(0, 3); + return res; + } + }); - return DS.PromiseObject.create({ promise }); + return (outPatient) ? DS.PromiseArray.create({ promise}) : DS.PromiseObject.create({ promise }); }, checkoutVisit(visit, status) { From bbdbd654d2ff1e173f74d9aea273a73b92f8258d Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:15:56 +0100 Subject: [PATCH 093/124] fix: implemented next appointments on both template and controller --- app/reports/edit/controller.js | 6 ++++-- app/reports/edit/template.hbs | 35 ++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 719b082992..00607cba5c 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -30,6 +30,10 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, return this.getPatientFutureAppointment(this.get('model.visit')); }), + nextAppointments: Ember.computed('model', function() { + return this.getPatientFutureAppointment(this.get('model.visit'), true); + }), + additionalButtons: Ember.computed('model.{isNew}', function() { let isNew = this.get('model.isNew'); if (!isNew) { @@ -47,8 +51,6 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, beforeUpdate() { return new Ember.RSVP.Promise(function(resolve) { if (this.get('model.isNew')) { - let appointmentDate = this.get('nextAppointment').get('content'); - this.get('model').set('nextAppointment', appointmentDate); if (this.get('model.visit.outPatient')) { this.get('model').set('reportType', 'OPD Report'); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index cca704e8e3..b2f77d2378 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -108,12 +108,35 @@ {{/if}} - {{#if nextAppointment}} -
              - - {{date-format nextAppointment format="DD/MM/YYYY hh:mm a"}} -
              - {{/if}} + {{log nextAppointment}} + {{#if model.visit.outPatient}} + {{#if nextAppointments.length}} +
              + + {{#each nextAppointments as |appointment|}} + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}}, + {{/each}} +
              + {{/if}} + + {{else}} + + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + + {{/if}} + + {{#if model.visit.patient.operativePlans.length}}
              From f91deccd223e08f4ab5fc72a07bdd2ce57cdc4a9 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 2 Mar 2017 12:18:44 +0100 Subject: [PATCH 094/124] fix: fix lint --- app/mixins/patient-visits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index 1f244935bd..4e93a6a12d 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -48,7 +48,7 @@ export default Ember.Mixin.create(PouchDbMixin, { } }); - return (outPatient) ? DS.PromiseArray.create({ promise}) : DS.PromiseObject.create({ promise }); + return (outPatient) ? DS.PromiseArray.create({ promise }) : DS.PromiseObject.create({ promise }); }, checkoutVisit(visit, status) { From 9765327483425e890ff80683d14b3b5fb901471c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 13:05:20 +0100 Subject: [PATCH 095/124] FIx next appointments display --- app/reports/edit/template.hbs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index b2f77d2378..01d1c37e8b 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -108,17 +108,20 @@
              {{/if}} - {{log nextAppointment}} {{#if model.visit.outPatient}} {{#if nextAppointments.length}}
              - - {{#each nextAppointments as |appointment|}} - {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if appointment.appointmentType}} - ({{appointment.appointmentType}}) - {{/if}}, - {{/each}} + +
                + {{#each nextAppointments as |appointment|}} +
              • + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}} +
              • + {{/each}} +
              {{/if}} From cc260dd19142f635e6e1836a5b1376428df781b7 Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Thu, 2 Mar 2017 17:14:44 +0100 Subject: [PATCH 096/124] Added auto trigger hospitalrun-server refresh script on successful build --- .travis.yml | 4 +++- script/server_build.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 script/server_build.sh diff --git a/.travis.yml b/.travis.yml index c1ae4b11d5..e14b1b3076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,12 @@ script: - npm test deploy: provider: npm - email: mofesola.babalola@ehealthafrica.org + email: devops@ehealthafrica.org api_key: secure: G13Wfjt+5lzPmc/4M4669Q+htK389oglI/JDTYDDH1v0ZaWOtvAc2Zvu2BvMGy9IMJ5f66ICJLxcWIg0gP2SMxvkQgUYaGFkVCRbaAwxfhcbSLJ2H/AGaanV1qRFeLQQRmNXg/yK0tW+biOsLXKvDXqazaueh/hP64uJmzAr3L1Y26q6QjL2iMEczEUi9Z02Gl5u5rCWsdM8c0oZ872FR8QWkSR4fb6vaKIyItfcUCN0nbJ4RhIncCCJLja7NHbeaxGh9rXVaO6F6oTiuuuJj863ATSBO670dmWGbscZQWxIRJPko3IAn6dQD4Q9FaJZR1pyS2+pkGSuGbjdYjMfj0vh73Hf6wmCwve/i9cA8du0qDEKqMetdsMIAS4XKoR2jQyWCivGOhOHizjoH7xezyj9K469IEugTFoyENoASW3ADYL3YGFpKn0Xs2i0MuSS8MGmSLw6QfEDzLvmxJeGnNQFXKtXyOOJlmyoTcIcviMr26jOmWINBWzNFp6B1wqcWpPy2TJyoQFL8Fnd4uadc5i4mxv9hPKLbbpV72+EuWiPqNX+rvgMxuFfMogIVB6R7GIMrk+MVmLlr9O4jYcsNcEW5Pw5rcxw/OCSw/mReMNFyRWhscpgpWcYwOzQHXMFKusSzITJLNjtwL40JH4i90U2jDwEZTUXT8E/IJVuYmY= on: tags: true repo: eHealthAfrica/hospitalrun-frontend branch: master +after_deploy: + - script/server_build.sh diff --git a/script/server_build.sh b/script/server_build.sh new file mode 100755 index 0000000000..7cd6403366 --- /dev/null +++ b/script/server_build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +BRANCH="${TRAVIS_BRANCH}" + +body='{ +"request": { + "branch":"${BRANCH}" +}}' + +curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Travis-API-Version: 3" \ + -H "Authorization: token ${BUILD_TRIGGER_TOKEN}" \ + -d "$body" \ + https://api.travis-ci.org/repo/eHealthAfrica%2Fhospitalrun-server/requests From cda47994c375eedfd67878af5770d12e9a85a601 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 21:39:44 +0100 Subject: [PATCH 097/124] Fix reports controller bug --- app/reports/edit/controller.js | 11 +-- app/reports/edit/route.js | 10 ++- app/reports/edit/template.hbs | 130 ++++++++++++++++----------------- 3 files changed, 73 insertions(+), 78 deletions(-) diff --git a/app/reports/edit/controller.js b/app/reports/edit/controller.js index 00607cba5c..fd7662ba1d 100644 --- a/app/reports/edit/controller.js +++ b/app/reports/edit/controller.js @@ -3,9 +3,8 @@ import Ember from 'ember'; import PatientSubmodule from 'hospitalrun/mixins/patient-submodule'; import PatientDiagnosis from 'hospitalrun/mixins/patient-diagnosis'; import PouchDbMixin from 'hospitalrun/mixins/pouchdb'; -import PatientVisit from 'hospitalrun/mixins/patient-visits'; -export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, PatientVisit, { +export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, PouchDbMixin, { lookupListsToUpdate: [{ name: 'physicianList', property: 'model.surgeon', @@ -26,14 +25,6 @@ export default AbstractEditController.extend(PatientSubmodule, PatientDiagnosis, diagnosisList: Ember.computed.alias('visitsController.diagnosisList'), - nextAppointment: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit')); - }), - - nextAppointments: Ember.computed('model', function() { - return this.getPatientFutureAppointment(this.get('model.visit'), true); - }), - additionalButtons: Ember.computed('model.{isNew}', function() { let isNew = this.get('model.isNew'); if (!isNew) { diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 19ac6dd505..8b122b36bc 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -2,8 +2,9 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; import { translationMacro as t } from 'ember-i18n'; +import PatientVisits from 'hospitalrun/mixins/patient-visits'; -export default AbstractEditRoute.extend(AddToPatientRoute, { +export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { modelName: 'report', customForms: Ember.inject.service(), @@ -30,5 +31,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, { setupController(controller, model) { this._super(controller, model); + let isOutPatient = model.get('visit.outPatient'); + controller.set('isOutPatient', isOutPatient); + if (isOutPatient) { + controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); + } else { + controller.set('nextAppointment', this.getPatientFutureAppointment(model.get('visit'))); + } } }); diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 01d1c37e8b..684514599b 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,8 +15,8 @@ {{headerLine3}}
              {{/if}} -
              - {{#edit-panel editPanelProps=editPanelProps}} +
              + {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.visit}} {{patient-summary @@ -36,35 +36,35 @@
              {{/if}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}}

              {{t 'reports.form.dischargeDate' }}

              {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}}
              {{/unless}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}}
              {{select-or-typeahead className="col-sm-4" property="surgeon" - label=(t "operativePlan.labels.surgeon") list=physicianList - selection=model.surgeon - class="plan-surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" }}
              {{/unless}} - {{#unless model.visit.outPatient}} + {{#unless isOutPatient}} {{#if model.visit.notes}}
                -
              • {{model.visit.notes}}
              • +
              • {{model.visit.notes}}
              {{/if}} {{/unless}} - {{#if model.visit.procedures.length}} + {{#if model.visit.procedures}}
                @@ -75,7 +75,7 @@
              {{/if}} - {{#if model.visit.labs.length}} + {{#if model.visit.labs}}
                @@ -86,7 +86,7 @@
              {{/if}} - {{#if model.visit.imaging.length}} + {{#if model.visit.imaging}}
                @@ -97,7 +97,7 @@
              {{/if}} - {{#if model.visit.medication.length}} + {{#if model.visit.medication}}
                @@ -108,76 +108,72 @@
              {{/if}} - {{#if model.visit.outPatient}} - {{#if nextAppointments.length}} -
              - -
                - {{#each nextAppointments as |appointment|}} -
              • - {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if appointment.appointmentType}} - ({{appointment.appointmentType}}) - {{/if}} -
              • - {{/each}} -
              -
              - {{/if}} - - {{else}} - - {{#if nextAppointment}} -
              - - {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if nextAppointment.location}} - ({{nextAppointment.location}}) - {{/if}} -
              - {{/if}} + {{#if isOutPatient}} + {{#if nextAppointments}} +
              + +
                + {{#each nextAppointments as |appointment|}} +
              • + {{date-format appointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if appointment.appointmentType}} + ({{appointment.appointmentType}}) + {{/if}} +
              • + {{/each}} +
              +
              + {{/if}} - {{/if}} + {{else}} + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + {{/if}} - {{#if model.visit.patient.operativePlans.length}} + {{#if model.visit.patient.operativePlans}}
                - {{#each model.visit.patient.operativePlans as |operativePlan|}} -
              • -

                {{t 'reports.form.operativePlan.description' }}:
                + {{#each model.visit.patient.operativePlans as |operativePlan|}} +

              • +

                {{t 'reports.form.operativePlan.description' }}:
                {{operativePlan.operationDescription}}

                -
              • - -
              • -

                {{t 'reports.form.operativePlan.procedures' }}:

                -
                  - {{#each operativePlan.procedures as |procedure|}} -
                • {{procedure.description}}
                • - {{/each}} -
                -
              • - -
              • -

                {{t 'reports.form.operativePlan.instructions' }}:
                - {{operativePlan.admissionInstructions}} -

                -
              • - {{/each}} + + +
              • +

                {{t 'reports.form.operativePlan.procedures' }}:

                +
                  + {{#each operativePlan.procedures as |procedure|}} +
                • {{procedure.description}}
                • + {{/each}} +
                +
              • + +
              • +

                {{t 'reports.form.operativePlan.instructions' }}:
                + {{operativePlan.admissionInstructions}} +

                +
              • + {{/each}}
              {{/if}} - {{#if model.visit.outPatient}} + {{#if isOutPatient}} {{custom-form-manager model=model formType="opdReport"}} {{else}} {{custom-form-manager model=model formType="dischargeReport"}} {{/if}} - - {{/em-form}} {{/edit-panel}} -
              + From 397fb9acf73ea2f244b4e2478a1efa9a5742e89b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:00:00 +0100 Subject: [PATCH 098/124] Add diagnosis container --- app/reports/edit/route.js | 13 +++++++++++-- app/reports/edit/template.hbs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 8b122b36bc..3d85be619c 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,7 +1,7 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; -import { translationMacro as t } from 'ember-i18n'; +import {translationMacro as t} from 'ember-i18n'; import PatientVisits from 'hospitalrun/mixins/patient-visits'; export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { @@ -23,6 +23,13 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { return t(`reports.${type}.titles.${state}`); }, + getDiagnosisContainer(visit) { + if (visit.get('outPatient')) { + return visit; + } + return null; + }, + afterModel(model) { if (!model.get('visit')) { return this.transitionTo('patients'); @@ -31,8 +38,10 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { setupController(controller, model) { this._super(controller, model); - let isOutPatient = model.get('visit.outPatient'); + let visit = model.get('visit'); + let isOutPatient = visit.get('outPatient'); controller.set('isOutPatient', isOutPatient); + controller.set('diagnosisContainer', this.getDiagnosisContainer(visit)); if (isOutPatient) { controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 684514599b..19d3782763 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -24,7 +24,7 @@ returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew - diagnosisContainer=model.visit + diagnosisContainer=diagnosisContainer diagnosisList=diagnosisList }} {{/if}} From 897e380aa680b35ace7b4461b765667d2af33d2b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:07:12 +0100 Subject: [PATCH 099/124] Set patient on model if model is not new --- app/reports/edit/route.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 3d85be619c..437b7ad7bd 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -31,6 +31,10 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { }, afterModel(model) { + if (!model.get('isNew')) { + let patient = model.get('visit.patient'); + model.set('patient', patient); + } if (!model.get('visit')) { return this.transitionTo('patients'); } From 1d3302a6921a3f6390bcfe561f0105e68e063bf0 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:47:20 +0100 Subject: [PATCH 100/124] Set visit on controller and add display current operative plan --- app/locales/en/translations.js | 2 +- app/reports/edit/route.js | 8 ++++++ app/reports/edit/template.hbs | 50 +++++++++++++++++----------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index aa101a46fe..8bbda486cf 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1121,7 +1121,7 @@ export default { nextAppointment: 'Next Appointment', nextAppointments: 'Next Appointments', operativePlan: { - title: 'Operative Plans', + title: 'Operative Plan', description: 'Operation Description', procedures: 'Planned Procedures', instructions: 'Instructions upon Admission' diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 437b7ad7bd..636cd04cd1 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -30,6 +30,11 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { return null; }, + getCurrentOperativePlan(patient) { + let operativePlans = patient.get('operativePlans'); + return operativePlans.findBy('isPlanned', true); + }, + afterModel(model) { if (!model.get('isNew')) { let patient = model.get('visit.patient'); @@ -43,9 +48,12 @@ export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { setupController(controller, model) { this._super(controller, model); let visit = model.get('visit'); + let patient = model.get('patient'); let isOutPatient = visit.get('outPatient'); + controller.set('visit', visit); controller.set('isOutPatient', isOutPatient); controller.set('diagnosisContainer', this.getDiagnosisContainer(visit)); + controller.set('currentOperativePlan', this.getCurrentOperativePlan(patient)); if (isOutPatient) { controller.set('nextAppointments', this.getPatientFutureAppointment(model.get('visit'), true)); } else { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 19d3782763..7f457a3ceb 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -18,9 +18,9 @@
              {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if model.visit}} + {{#if visit}} {{patient-summary - patient=model.visit.patient + patient=visit.patient returnTo='visit.edit' returnToContext=model.id disablePatientLink=model.isNew @@ -29,10 +29,10 @@ }} {{/if}} - {{#if model.visit.startDate}} + {{#if visit.startDate}}
              - {{date-format model.visit.startDate format="DD/MM/YYYY hh:mm a"}} + {{date-format visit.startDate format="DD/MM/YYYY hh:mm a"}}
              {{/if}} @@ -54,54 +54,54 @@ {{/unless}} {{#unless isOutPatient}} - {{#if model.visit.notes}} + {{#if visit.notes}}
                -
              • {{model.visit.notes}}
              • +
              • {{visit.notes}}
              {{/if}} {{/unless}} - {{#if model.visit.procedures}} + {{#if visit.procedures}}
                - {{#each model.visit.procedures as |item|}} + {{#each visit.procedures as |item|}}
              • {{item.description}}
              • {{/each}}
              {{/if}} - {{#if model.visit.labs}} + {{#if visit.labs}}
                - {{#each model.visit.labs as |item|}} + {{#each visit.labs as |item|}}
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • {{/each}}
              {{/if}} - {{#if model.visit.imaging}} + {{#if visit.imaging}}
                - {{#each model.visit.imaging as |item|}} + {{#each visit.imaging as |item|}}
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • {{/each}}
              {{/if}} - {{#if model.visit.medication}} + {{#if visit.medication}}
                - {{#each model.visit.medication as |medication|}} + {{#each visit.medication as |medication|}}
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • {{/each}}
              @@ -139,20 +139,20 @@ {{/if}} - {{#if model.visit.patient.operativePlans}} -
              - -
                - {{#each model.visit.patient.operativePlans as |operativePlan|}} + {{#if isOutPatient}} + {{#if currentOperativePlan}} +
                + +
                • {{t 'reports.form.operativePlan.description' }}:
                  - {{operativePlan.operationDescription}}

                  + {{currentOperativePlan.operationDescription}}

                • {{t 'reports.form.operativePlan.procedures' }}:

                    - {{#each operativePlan.procedures as |procedure|}} + {{#each currentOperativePlan.procedures as |procedure|}}
                  • {{procedure.description}}
                  • {{/each}}
                  @@ -160,12 +160,12 @@
                • {{t 'reports.form.operativePlan.instructions' }}:
                  - {{operativePlan.admissionInstructions}} + {{currentOperativePlan.admissionInstructions}}

                • - {{/each}} -
                -
                +
              +
              + {{/if}} {{/if}} {{#if isOutPatient}} From fbfa8b78ad6b25690e543d8d3659de669a824685 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 22:54:00 +0100 Subject: [PATCH 101/124] Add `Completed By` field to report --- app/locales/en/translations.js | 3 ++- app/reports/edit/template.hbs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 8bbda486cf..6a06fc68c1 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1125,7 +1125,8 @@ export default { description: 'Operation Description', procedures: 'Planned Procedures', instructions: 'Instructions upon Admission' - } + }, + completedBy: 'Completed By' }, opd: { titles: { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 7f457a3ceb..01e7b6c2f6 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -174,6 +174,13 @@ {{custom-form-manager model=model formType="dischargeReport"}} {{/if}} + {{#unless isOutPatient}} +
              + + {{model.modifiedBy}} +
              + {{/unless}} + {{/em-form}} {{/edit-panel}}
              From c276e9ca23b2aa304ed209fde504976df834392c Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Thu, 2 Mar 2017 23:57:46 +0100 Subject: [PATCH 102/124] Refactor reports template --- app/locales/en/translations.js | 13 ++- app/reports/edit/template.hbs | 206 ++++++++++++++++----------------- app/styles/_print.scss | 10 +- 3 files changed, 114 insertions(+), 115 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 6a06fc68c1..85923be6af 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,13 +1105,18 @@ export default { }, reports: { titles: { - followup: 'Create Followup appointment', + followup: 'Create Followup Appointment', saved: 'The report has been saved' }, form: { visitDate: 'Date of Visit', - dischargeDate: 'Date of Discharge', - notes: 'Notes', + admissionDate: 'Admission Date', + dischargeDate: 'Discharge Date', + notes: { + title: 'Notes', + date: 'Date', + author: 'Author' + }, primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', @@ -1141,7 +1146,7 @@ export default { } }, messages: { - followup: 'Create new followup appointment for the discharge report', + followup: 'There is no follow up appointment for this patient.', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 01e7b6c2f6..f13ef25927 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -15,100 +15,75 @@ {{headerLine3}}
              {{/if}}
              -
              +
              {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} - {{#if visit}} + {{#if model.patient}} {{patient-summary - patient=visit.patient - returnTo='visit.edit' - returnToContext=model.id - disablePatientLink=model.isNew + patient=model.patient + disablePatientLink=true diagnosisContainer=diagnosisContainer diagnosisList=diagnosisList }} {{/if}} - {{#if visit.startDate}} -
              - - {{date-format visit.startDate format="DD/MM/YYYY hh:mm a"}} -
              - {{/if}} - - {{#unless isOutPatient}} -
              -

              {{t 'reports.form.dischargeDate' }}

              - {{date-format model.reportDate format="DD/MM/YYYY hh:mm a"}} -
              - {{/unless}} +
              + + {{date-format visit.startDate format="DD/MM/YYYY"}} +
              - {{#unless isOutPatient}} -
              - {{select-or-typeahead className="col-sm-4" property="surgeon" - label=(t "operativePlan.labels.surgeon") list=physicianList - selection=model.surgeon - class="plan-surgeon" - }} -
              - {{/unless}} + {{#if isOutPatient}} - {{#unless isOutPatient}} - {{#if visit.notes}} + {{#if visit.procedures}}
              - +
                -
              • {{visit.notes}}
              • + {{#each visit.procedures as |item|}} +
              • {{item.description}}
              • + {{/each}}
              {{/if}} - {{/unless}} - {{#if visit.procedures}} -
              - -
                - {{#each visit.procedures as |item|}} -
              • {{item.description}}
              • - {{/each}} -
              -
              - {{/if}} - - {{#if visit.labs}} -
              - -
                - {{#each visit.labs as |item|}} -
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.labs}} +
              + +
                + {{#each visit.labs as |item|}} +
              • {{item.labType.name}}-{{item.result}} ({{item.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if visit.imaging}} -
              - -
                - {{#each visit.imaging as |item|}} -
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.imaging}} +
              + +
                + {{#each visit.imaging as |item|}} +
              • {{item.imagingType.name}}-{{item.result}} ({{item.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if visit.medication}} -
              - -
                - {{#each visit.medication as |medication|}} -
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • - {{/each}} -
              -
              - {{/if}} + {{#if visit.medication}} +
              + +
                + {{#each visit.medication as |medication|}} +
              • {{medication.medicationName}} - {{medication.prescription}} ({{medication.status}})
              • + {{/each}} +
              +
              + {{/if}} - {{#if isOutPatient}} {{#if nextAppointments}}
              @@ -125,29 +100,16 @@
              {{/if}} - {{else}} - - {{#if nextAppointment}} -
              - - {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} - {{#if nextAppointment.location}} - ({{nextAppointment.location}}) - {{/if}} -
              - {{/if}} - - {{/if}} - - {{#if isOutPatient}} {{#if currentOperativePlan}}
                -
              • -

                {{t 'reports.form.operativePlan.description' }}:
                - {{currentOperativePlan.operationDescription}}

                -
              • + {{#if currentOperativePlan.operationDescription}} +
              • +

                {{t 'reports.form.operativePlan.description' }}:
                + {{currentOperativePlan.operationDescription}}

                +
              • + {{/if}}
              • {{t 'reports.form.operativePlan.procedures' }}:

                @@ -158,28 +120,64 @@
              -
            • -

              {{t 'reports.form.operativePlan.instructions' }}:
              - {{currentOperativePlan.admissionInstructions}} -

              -
            • + {{#if currentOperativePlan.admissionInstructions}} +
            • +

              {{t 'reports.form.operativePlan.instructions' }}:
              + {{currentOperativePlan.admissionInstructions}}

              +
            • + {{/if}}
              {{/if}} - {{/if}} - {{#if isOutPatient}} {{custom-form-manager model=model formType="opdReport"}} + {{else}} + +
              + + {{date-format model.reportDate format="DD/MM/YYYY"}} +
              + +
              + {{select-or-typeahead className="col-sm-4" property="surgeon" + label=(t "operativePlan.labels.surgeon") list=physicianList + selection=model.surgeon + class="plan-surgeon" + }} +
              + + {{#if visit.patientNotes}} + +
                + {{#each visit.patientNotes as |note|}} +
              • + {{t 'reports.form.notes.date' }}: {{date-format note.date}}
                + {{t 'reports.form.notes.author' }}: {{note.authoredBy}}
                + {{note.noteType}}: {{note.content}} +
              • + {{/each}} +
              + {{/if}} + + {{#if nextAppointment}} +
              + + {{date-format nextAppointment.startDate format="DD/MM/YYYY hh:mm a"}} + {{#if nextAppointment.location}} + ({{nextAppointment.location}}) + {{/if}} +
              + {{/if}} + {{custom-form-manager model=model formType="dischargeReport"}} - {{/if}} - {{#unless isOutPatient}}
              {{model.modifiedBy}}
              - {{/unless}} + + {{/if}} {{/em-form}} {{/edit-panel}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 79591157fc..67337bde3e 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -39,22 +39,18 @@ height: 60px; } - .opd-report { - font-size: .8em; - } - - .opd-report .patient-summary { + .report .patient-summary { margin-bottom: 20px; border-bottom: 1px solid #d2dae3; } - .opd-report input { + .report input { border: 0; padding: 5px; font-size: .8em; } - .opd-report .panel-primary { + .report .panel-primary { position: absolute; left: 0; margin: 0; From 31d8c337012d948c6ab912f6a107ed39751970b3 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 3 Mar 2017 00:04:38 +0100 Subject: [PATCH 103/124] Ensure reports.edit returns to visits.edit --- app/visits/edit/controller.js | 5 +++-- app/visits/edit/route.js | 4 ---- app/visits/edit/template.hbs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index dabd6a47f7..0c1f1485c0 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -447,8 +447,9 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('reports.edit'); }, - editReport() { - this.transitionToRoute('reports.edit', this.get('report.id')); + editReport(report) { + report.set('returnToVisit', this.get('model.id')); + this.transitionToRoute('reports.edit', report); }, newAppointment() { diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index da57946c31..9b6932b5e0 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -44,10 +44,6 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVi } }, - report: function() { - - }.property('model'), - setupController(controller, model) { let promise = this.store.query('report', { options: { diff --git a/app/visits/edit/template.hbs b/app/visits/edit/template.hbs index 3d4a7b25af..714b9514f0 100644 --- a/app/visits/edit/template.hbs +++ b/app/visits/edit/template.hbs @@ -294,7 +294,7 @@
              {{t 'labels.name'}}{{t 'models.patient.labels.name'}}{{t 'labels.actions'}}
              {{report.modifiedBy}} {{report.reportType}} - +
              From ac20a24bc7c4c807c213dacf837c0e3f2b14688b Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Fri, 3 Mar 2017 01:34:53 +0100 Subject: [PATCH 104/124] Display patient procedures on report --- app/locales/en/translations.js | 1 + app/mixins/patient-submodule.js | 11 ++++++++++ app/mixins/patient-visits.js | 31 +++++++++++++++++++++++++++- app/patients/edit/controller.js | 36 +++++++++------------------------ app/reports/edit/route.js | 2 +- app/reports/edit/template.hbs | 12 +++++++++++ 6 files changed, 64 insertions(+), 29 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 85923be6af..74f9563b3d 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1120,6 +1120,7 @@ export default { primaryDiagnosis: 'Primary Diagnosis', secondaryDiagnosis: 'Secondary Diagnosis', procedures: 'Procedures', + allProcedures: 'All Procedures Performed', labs: 'Labs', images: 'Images', medications: 'Medications', diff --git a/app/mixins/patient-submodule.js b/app/mixins/patient-submodule.js index 28aaf94db4..e85c6f0eb4 100644 --- a/app/mixins/patient-submodule.js +++ b/app/mixins/patient-submodule.js @@ -185,6 +185,17 @@ export default Ember.Mixin.create(PatientVisits, { }); }.property('model.patient.id', 'newVisitAdded'), + patientProcedures: Ember.computed('patientVisits.[]', function() { + let patient = this.get('model.patient'); + return DS.PromiseArray.create({ + promise: this.get('patientVisits').then((patientVisits) => { + return patient.get('operationReports').then((operationReports) => { + return this._getPatientProcedures(operationReports, patientVisits); + }); + }) + }); + }), + patientVisitsForSelect: function() { return DS.PromiseArray.create({ promise: this.get('patientVisits').then(function(patientVisits) { diff --git a/app/mixins/patient-visits.js b/app/mixins/patient-visits.js index 4e93a6a12d..d5197ed910 100644 --- a/app/mixins/patient-visits.js +++ b/app/mixins/patient-visits.js @@ -4,7 +4,8 @@ import VisitStatus from 'hospitalrun/utils/visit-statuses'; import DS from 'ember-data'; import moment from 'moment'; const { - isEmpty + isEmpty, + get } = Ember; export default Ember.Mixin.create(PouchDbMixin, { @@ -51,6 +52,34 @@ export default Ember.Mixin.create(PouchDbMixin, { return (outPatient) ? DS.PromiseArray.create({ promise }) : DS.PromiseObject.create({ promise }); }, + _getVisitCollection(visits, name) { + let returnList = []; + if (!Ember.isEmpty(visits)) { + visits.forEach(function(visit) { + visit.get(name).then(function(items) { + returnList.addObjects(items); + }); + }); + } + return returnList; + }, + + _getPatientProcedures(operationReports, visits) { + let patientProcedures = this._getVisitCollection(visits, 'procedures'); + operationReports.forEach((report) => { + let reportedProcedures = get(report, 'procedures'); + let surgeryDate = get(report, 'surgeryDate'); + reportedProcedures.forEach((procedure) => { + patientProcedures.addObject({ + description: get(procedure, 'description'), + procedureDate: surgeryDate, + report + }); + }); + }); + return patientProcedures; + }, + checkoutVisit(visit, status) { visit.set('status', status); visit.set('endDate', new Date()); diff --git a/app/patients/edit/controller.js b/app/patients/edit/controller.js index 45e854b78b..df32d32e9a 100644 --- a/app/patients/edit/controller.js +++ b/app/patients/edit/controller.js @@ -8,13 +8,14 @@ import ReturnTo from 'hospitalrun/mixins/return-to'; import SelectValues from 'hospitalrun/utils/select-values'; import UserSession from 'hospitalrun/mixins/user-session'; import VisitStatus from 'hospitalrun/utils/visit-statuses'; +import PatientVisits from 'hospitalrun/mixins/patient-visits'; const { get, isEmpty } = Ember; -export default AbstractEditController.extend(BloodTypes, DiagnosisActions, ReturnTo, UserSession, PatientId, PatientNotes, { +export default AbstractEditController.extend(BloodTypes, DiagnosisActions, ReturnTo, UserSession, PatientId, PatientNotes, PatientVisits, { canAddAppointment: function() { return this.currentUserCan('add_appointment'); @@ -144,32 +145,21 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur }], patientImaging: function() { - return this._getVisitCollection('imaging'); + return this.getVisitCollection('imaging'); }.property('model.visits.[].imaging'), patientLabs: function() { - return this._getVisitCollection('labs'); + return this.getVisitCollection('labs'); }.property('model.visits.[].labs'), patientMedications: function() { - return this._getVisitCollection('medication'); + return this.getVisitCollection('medication'); }.property('model.visits.[].medication'), patientProcedures: function() { - let patientProcedures = this._getVisitCollection('procedures'); + let visits = this.get('model.visits'); let operationReports = get(this, 'model.operationReports'); - operationReports.forEach((report) => { - let reportedProcedures = get(report, 'procedures'); - let surgeryDate = get(report, 'surgeryDate'); - reportedProcedures.forEach((procedure) => { - patientProcedures.addObject({ - description: get(procedure, 'description'), - procedureDate: surgeryDate, - report - }); - }); - }); - return patientProcedures; + return this._getPatientProcedures(operationReports, visits); }.property('model.visits.[].procedures', 'model.operationReports.[].procedures'), showExpenseTotal: function() { @@ -570,17 +560,9 @@ export default AbstractEditController.extend(BloodTypes, DiagnosisActions, Retur this.send('openModal', `patients.socialwork.${route}`, model); }, - _getVisitCollection(name) { - let returnList = []; + getVisitCollection(name) { let visits = this.get('model.visits'); - if (!Ember.isEmpty(visits)) { - visits.forEach(function(visit) { - visit.get(name).then(function(items) { - returnList.addObjects(items); - }); - }); - } - return returnList; + return this._getVisitCollection(visits, name); }, _updateSocialRecord(recordToUpdate, name) { diff --git a/app/reports/edit/route.js b/app/reports/edit/route.js index 636cd04cd1..5b00ddafce 100644 --- a/app/reports/edit/route.js +++ b/app/reports/edit/route.js @@ -1,7 +1,7 @@ import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import AddToPatientRoute from 'hospitalrun/mixins/add-to-patient-route'; import Ember from 'ember'; -import {translationMacro as t} from 'ember-i18n'; +import { translationMacro as t } from 'ember-i18n'; import PatientVisits from 'hospitalrun/mixins/patient-visits'; export default AbstractEditRoute.extend(AddToPatientRoute, PatientVisits, { diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index f13ef25927..c22284fef0 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -147,6 +147,18 @@ }}
            + {{#if patientProcedures}} + +
              + {{#each patientProcedures as |procedure|}} +
            • {{procedure.description}} - + {{#if procedure.procedureDate }} + {{date-format procedure.procedureDate format="DD/MM/YYYY"}} + {{/if}}
            • + {{/each}} +
            + {{/if}} + {{#if visit.patientNotes}}
              From 25aed98e4db0cc512df998de119f0991ee34474c Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 6 Mar 2017 16:18:26 -0500 Subject: [PATCH 105/124] Testing improvements. --- app/controllers/abstract-edit-controller.js | 11 +++++- app/dialog/controller.js | 5 ++- app/invoices/payment/controller.js | 2 +- app/mixins/charge-actions.js | 19 +++++----- app/mixins/diagnosis-actions.js | 3 +- app/mixins/medication-details.js | 9 ++++- app/mixins/patient-diagnosis.js | 1 + app/mixins/patient-submodule.js | 6 ++-- app/models/abstract.js | 2 +- app/procedures/charge/controller.js | 7 ++-- app/procedures/edit/controller.js | 1 + config/environment.js | 8 +++-- tests/acceptance/invoices-test.js | 2 ++ tests/acceptance/operative-test.js | 8 ++++- tests/acceptance/procedure-test.js | 39 +++++++++++++++++---- tests/acceptance/visit-test.js | 19 +++++++++- tests/fixtures/billing.txt | 10 +++--- tests/helpers/run-with-pouch-dump.js | 1 + 18 files changed, 114 insertions(+), 39 deletions(-) diff --git a/app/controllers/abstract-edit-controller.js b/app/controllers/abstract-edit-controller.js index e19dae079d..1b9c2d2759 100644 --- a/app/controllers/abstract-edit-controller.js +++ b/app/controllers/abstract-edit-controller.js @@ -60,6 +60,15 @@ export default Ember.Controller.extend(EditPanelProps, IsUpdateDisabled, ModalHe }.property('model.isNew'), updateCapability: null, + /* Silently update and then fire the specified action. */ + silentUpdate(action, whereFrom) { + this.beforeUpdate().then(() => { + return this.saveModel(true); + }).then(() => { + this.send(action, whereFrom); + }); + }, + /** * Add the specified value to the lookup list if it doesn't already exist in the list. * @param lookupList array the lookup list to add to. @@ -161,7 +170,7 @@ export default Ember.Controller.extend(EditPanelProps, IsUpdateDisabled, ModalHe * to skip the afterUpdate call. */ saveModel(skipAfterUpdate) { - get(this, 'model').save().then((record) => { + return get(this, 'model').save().then((record) => { this.updateLookupLists(); if (!skipAfterUpdate) { this.afterUpdate(record); diff --git a/app/dialog/controller.js b/app/dialog/controller.js index 33efa0164a..2a025e591d 100644 --- a/app/dialog/controller.js +++ b/app/dialog/controller.js @@ -20,9 +20,12 @@ export default Ember.Controller.extend({ }, confirm() { + let closeModalOnConfirm = this.getWithDefault('model.closeModalOnConfirm', true); let confirmAction = this.getWithDefault('model.confirmAction', 'model.confirm'); this.send(confirmAction, get(this, 'model')); - this.send('closeModal'); + if (closeModalOnConfirm) { + this.send('closeModal'); + } }, ok() { diff --git a/app/invoices/payment/controller.js b/app/invoices/payment/controller.js index 072c42ddfa..f61c4cd8a3 100644 --- a/app/invoices/payment/controller.js +++ b/app/invoices/payment/controller.js @@ -54,7 +54,7 @@ export default AbstractEditController.extend(PatientSubmodule, { afterUpdate() { this.get('model').save().then(function(record) { - if (this.get('newPayment')) { + if (this.get('newPayment') === true) { let patient = this.get('currentPatient'); patient.get('payments').then(function(payments) { payments.addObject(record); diff --git a/app/mixins/charge-actions.js b/app/mixins/charge-actions.js index c16f1044b7..2e1370c779 100644 --- a/app/mixins/charge-actions.js +++ b/app/mixins/charge-actions.js @@ -25,17 +25,20 @@ export default Ember.Mixin.create({ addCharge(charge) { let charges = this.get('model.charges'); charges.addObject(charge); - this.send('update', true); - this.send('closeModal'); + let from = `addCharge_${charge.get('id')}`; + if (charge.get('medicationCharge')) { + from = `addMedication_${charge.get('id')}`; + } + this.silentUpdate('closeModal', from); }, deleteCharge(model) { let chargeToDelete = model.get('chargeToDelete'); let charges = this.get('model.charges'); charges.removeObject(chargeToDelete); - chargeToDelete.destroyRecord(); - this.send('update', true); - this.send('closeModal'); + chargeToDelete.destroyRecord().then(() => { + this.silentUpdate('closeModal', 'deleteCharge'); + }); }, showAddCharge() { @@ -55,6 +58,7 @@ export default Ember.Mixin.create({ showDeleteCharge(charge) { this.send('openModal', 'dialog', Ember.Object.create({ + closeModalOnConfirm: false, confirmAction: 'deleteCharge', title: 'Delete Charge Item', message: 'Are you sure you want to delete this charged item?', @@ -263,16 +267,15 @@ export default Ember.Mixin.create({ * When using organizeByType charges need to be mapped over from the price lists */ updateCharges() { - let charges = this.get('model.charges'); let organizeByType = this.get('organizeByType'); - let pricingList = this.get('pricingList'); - if (!organizeByType) { return Ember.RSVP.resolve(); } return new Ember.RSVP.Promise(function(resolve, reject) { + let charges = this.get('model.charges'); let chargePromises = []; let model = this.get('model'); + let pricingList = this.get('pricingList'); pricingList.forEach(function(pricingItem) { let currentCharge = this.findChargeForPricingItem(pricingItem, model.get('charges')); let quantityCharged = model.get(pricingItem.id); diff --git a/app/mixins/diagnosis-actions.js b/app/mixins/diagnosis-actions.js index f0bcd50a47..0162d038da 100644 --- a/app/mixins/diagnosis-actions.js +++ b/app/mixins/diagnosis-actions.js @@ -12,8 +12,7 @@ export default Ember.Mixin.create({ diagnoses.removeObject(diagnosis); diagnosis.set('archived', true); diagnosis.save().then(() => { - this.send('closeModal'); - this.send('update', true); + this.silentUpdate('closeModal'); }); }, diff --git a/app/mixins/medication-details.js b/app/mixins/medication-details.js index 8a5880ccde..d86111fca5 100644 --- a/app/mixins/medication-details.js +++ b/app/mixins/medication-details.js @@ -1,5 +1,8 @@ import Ember from 'ember'; import DS from 'ember-data'; + +const { isEmpty } = Ember; + export default Ember.Mixin.create({ // Denormalized medication details so that inventory records do not need to be retrieved @@ -17,7 +20,11 @@ export default Ember.Mixin.create({ let inventoryObject = this.get(inventoryAttribute); if (inventoryObject.then) { inventoryObject.then((inventoryItem) => { - this.set('medicationTitle', inventoryItem.get('name')); + if (!isEmpty(inventoryItem)) { + this.set('medicationTitle', inventoryItem.get('name')); + } + }).catch((err) => { + console.log('error getting inventory item for medication name:', err); }); } else { this.set('medicationTitle', inventoryObject.get('name')); diff --git a/app/mixins/patient-diagnosis.js b/app/mixins/patient-diagnosis.js index 316078aefb..df8c40462f 100644 --- a/app/mixins/patient-diagnosis.js +++ b/app/mixins/patient-diagnosis.js @@ -17,6 +17,7 @@ export default Ember.Mixin.create({ let diagnosesList = []; if (!isEmpty(diagnosisContainer)) { let diagnoses = diagnosisContainer.get(diagnosisProperty); + diagnoses = diagnoses.filterBy('archived', false); if (hideInActiveDiagnoses) { diagnoses = diagnoses.filterBy('active', true); } diff --git a/app/mixins/patient-submodule.js b/app/mixins/patient-submodule.js index 85e91d01a4..999c342fb1 100644 --- a/app/mixins/patient-submodule.js +++ b/app/mixins/patient-submodule.js @@ -82,12 +82,10 @@ export default Ember.Mixin.create(PatientVisits, { patientDiagnoses.addObject(newDiagnosis); let patient = this.get('model.patient'); patient.save().then(() => { - this.send('update', true); - this.send('closeModal'); + this.silentUpdate('closeModal'); }); } else { - this.send('update', true); - this.send('closeModal'); + this.silentUpdate('closeModal'); } }, diff --git a/app/models/abstract.js b/app/models/abstract.js index 8594db5cdd..38d4a0c3a9 100644 --- a/app/models/abstract.js +++ b/app/models/abstract.js @@ -12,7 +12,7 @@ const { export default Model.extend(UserSession, EmberValidations, { session: inject.service(), - archived: DS.attr('boolean'), + archived: DS.attr('boolean', { defaultValue: false }), lastModified: DS.attr('date'), modifiedBy: DS.attr(), modifiedFields: DS.attr(), diff --git a/app/procedures/charge/controller.js b/app/procedures/charge/controller.js index 6f0103c33f..20a0d3c9a0 100644 --- a/app/procedures/charge/controller.js +++ b/app/procedures/charge/controller.js @@ -20,10 +20,7 @@ export default AbstractEditController.extend({ }.property('model.isNew'), beforeUpdate() { - let isNew = this.get('model.isNew'); - if (isNew) { - this.set('newCharge', true); - } + this.set('newCharge', this.get('model.isNew')); return new Ember.RSVP.Promise((resolve, reject) => { let model = this.get('model'); let pricingItem = model.get('pricingItem'); @@ -72,7 +69,7 @@ export default AbstractEditController.extend({ }, afterUpdate(record) { - if (this.get('newCharge')) { + if (this.get('newCharge') === true) { this.get('requestingController').send('addCharge', record); } else { this.send('closeModal'); diff --git a/app/procedures/edit/controller.js b/app/procedures/edit/controller.js index d4f7aa3d23..7e38db1f11 100644 --- a/app/procedures/edit/controller.js +++ b/app/procedures/edit/controller.js @@ -80,6 +80,7 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, { showDeleteMedication(charge) { this.send('openModal', 'dialog', Ember.Object.create({ + closeModalOnConfirm: false, confirmAction: 'deleteCharge', title: this.get('i18n').t('procedures.titles.deleteMedicationUsed'), message: this.get('i18n').t('procedures.messages.deleteMedication'), diff --git a/config/environment.js b/config/environment.js index ae20b6bbcc..19a4ebcc91 100644 --- a/config/environment.js +++ b/config/environment.js @@ -1,9 +1,10 @@ /* jshint node: true */ +/* eslint-env node */ module.exports = function(environment) { - var ENV = { + let ENV = { modulePrefix: 'hospitalrun', - environment: environment, + environment, rootURL: '/', locationType: 'hash', // Using hash location type because it is more friendly for offline. EmberENV: { @@ -65,6 +66,9 @@ module.exports = function(environment) { if (environment === 'production') { ENV.serviceWorker.debug = false; } + if (environment === 'test') { + ENV.serviceWorker.includeRegistration = false; + } ENV.emberFullCalendar = { schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source' diff --git a/tests/acceptance/invoices-test.js b/tests/acceptance/invoices-test.js index e967f978a8..2e9406d034 100644 --- a/tests/acceptance/invoices-test.js +++ b/tests/acceptance/invoices-test.js @@ -106,6 +106,8 @@ test('add payment', function(assert) { waitToAppear('.modal-title:contains(Payment Added)'); andThen(() => { assert.equal(find('.modal-title').text(), 'Payment Added', 'Payment was saved successfully'); + click('.modal-footer button:contains(Ok)'); + waitToDisappear('.modal-dialog'); }); }); }); diff --git a/tests/acceptance/operative-test.js b/tests/acceptance/operative-test.js index 054665fd44..51c8202c4c 100644 --- a/tests/acceptance/operative-test.js +++ b/tests/acceptance/operative-test.js @@ -36,6 +36,9 @@ test('Plan and report creation', function(assert) { assert.equal(find('.modal-title').text(), 'Add Diagnosis', 'Add Diagnosis dialog displays'); fillIn('.diagnosis-text input', 'Broken Arm'); click('.modal-footer button:contains(Add)'); + }); + andThen(() => { + waitToDisappear('.modal-dialog'); waitToAppear('a.primary-diagnosis'); }); andThen(() =>{ @@ -48,7 +51,10 @@ test('Plan and report creation', function(assert) { fillIn('.diagnosis-text input', 'Tennis Elbow'); click('.secondary-diagnosis input'); click('.modal-footer button:contains(Add)'); - waitToAppear('a.secondary-diagnosis'); + }); + andThen(() => { + waitToDisappear('.modal-dialog'); + waitToAppear('a.secondary-diagnosis:contains(Tennis Elbow)'); }); andThen(() =>{ assert.equal(find('a.secondary-diagnosis:contains(Tennis Elbow)').length, 1, 'New secondary diagnosis appears'); diff --git a/tests/acceptance/procedure-test.js b/tests/acceptance/procedure-test.js index 991e67ad6e..a137d2782b 100644 --- a/tests/acceptance/procedure-test.js +++ b/tests/acceptance/procedure-test.js @@ -44,22 +44,29 @@ testWithVisit('Edit procedure', function(assert) { assert.equal(find('.modal-title').text(), 'Add Charge Item', 'Add Charge Item modal appears'); typeAheadFillIn('.charge-item-name', 'Gauze pad'); click('.modal-footer button:contains(Add)'); - waitToAppear('td.charge-item-name'); }); andThen(function() { - assert.equal(find('td.charge-item-name').text(), 'Gauze pad', 'New charge item appears'); - click('.charge-items button:contains(Edit)'); + waitToDisappear('.modal-dialog'); + waitToAppear('td.charge-item-name:contains(Gauze pad)'); + }); + andThen(function() { + assert.equal(find('td.charge-item-name:contains(Gauze pad)').length, 1, 'New charge item appears'); + click('.charge-items tr:last button:contains(Edit)'); waitToAppear('.modal-dialog'); }); andThen(function() { assert.equal(find('.modal-title').text(), 'Edit Charge Item', 'Edit Charge Item modal appears'); typeAheadFillIn('.charge-item-name', 'Gauze padding'); + }); + andThen(function() { click('.modal-footer button:contains(Update)'); + }); + andThen(function() { waitToAppear('td.charge-item-name:contains(Gauze padding)'); waitToDisappear('.modal-dialog'); }); andThen(function() { - assert.equal(find('td.charge-item-name').text(), 'Gauze padding', 'Updated charge item appears'); + assert.equal(find('td.charge-item-name:contains(Gauze padding)').length, 1, 'Updated charge item appears'); assert.equal(find('.medication-charges tr').length, 2, 'One medication charge exists'); assert.equal(find('.medication-charges button:contains(Add Medication)').length, 1, 'Add medication button exists'); click('button:contains(Add Medication)'); @@ -72,18 +79,26 @@ testWithVisit('Edit procedure', function(assert) { }); andThen(function() { click('.modal-footer button:contains(Add)'); + }); + andThen(function() { waitToDisappear('.modal-dialog'); }); + andThen(function() { + updateProcedure(assert, 'Update'); + }); andThen(function() { assert.equal(find('.medication-charges td:contains(Cefazolin 500mg vial)').length, 2, 'Two medication charges exists'); - click('.medication-charges button:contains(Edit)'); + click('.medication-charges button:contains(Edit):first'); waitToAppear('.modal-dialog'); }); andThen(function() { assert.equal(find('.modal-title').text(), 'Edit Medication Used', 'Edit Medication Used modal appears here'); fillIn('.medication-quantity input', 2); click('.modal-footer button:contains(Update)'); + }); + andThen(function() { waitToDisappear('.modal-dialog'); + waitToAppear('.medication-charge-quantity:contains(2)'); }); andThen(function() { assert.equal(find('.medication-charge-quantity:first').text(), '2', 'Updated medication quantity appears'); @@ -98,12 +113,24 @@ testWithVisit('Edit procedure', function(assert) { click('.modal-footer button:contains(Ok)'); }); andThen(function() { - click('.medication-charges button:contains(Delete)'); + waitToDisappear('.modal-dialog'); + waitToDisappear('.charge-items tr:last button:contains(Delete)'); + }); + andThen(function() { + click('.medication-charges tr:last button:contains(Delete)'); waitToAppear('.modal-dialog'); }); andThen(function() { assert.equal(find('.modal-title').text(), 'Delete Medication Used', 'Delete Medication Used dialog displays'); click('.modal-footer button:contains(Ok)'); + }); + andThen(function() { + waitToDisappear('.modal-dialog'); + }); + andThen(function() { + updateProcedure(assert, 'Update'); + }); + andThen(function() { waitToAppear('button:contains(Return)'); }); andThen(function() { diff --git a/tests/acceptance/visit-test.js b/tests/acceptance/visit-test.js index b3fe28c347..29dfdc895c 100644 --- a/tests/acceptance/visit-test.js +++ b/tests/acceptance/visit-test.js @@ -111,20 +111,31 @@ test('Edit visit', function(assert) { andThen(function() { typeAheadFillIn('.charge-item-name', 'Gauze pad'); click('.modal-footer button:contains(Add)'); + }); + andThen(function() { + waitToDisappear('.modal-dialog'); waitToAppear('td.charge-item-name'); }); andThen(function() { assert.equal(find('td.charge-item-name').text(), 'Gauze pad', 'New charge item appears'); }); - updateVisit(assert, 'Update'); + andThen(function() { + updateVisit(assert, 'Update'); + }); andThen(function() { click('a.primary-diagnosis:contains(Broken Arm)'); waitToAppear('.modal-dialog'); }); andThen(function() { assert.equal(find('.modal-title').text(), 'Edit Diagnosis', 'Edit Diagnosis modal appears'); + assert.equal(find('.modal-footer button:contains(Delete)').length, 1, 'Delete button appears'); + }); + andThen(function() { click('.modal-footer button:contains(Delete)'); }); + andThen(function() { + waitToDisappear('.modal-dialog'); + }); andThen(function() { click('#visit-vitals tr:last button:contains(Delete)'); waitToAppear('.modal-dialog'); @@ -142,6 +153,9 @@ test('Edit visit', function(assert) { assert.equal(find('.modal-title').text(), 'Delete Charge Item', 'Delete Charge Item dialog displays'); click('.modal-footer button:contains(Ok)'); }); + andThen(function() { + waitToDisappear('.modal-dialog'); + }); andThen(function() { assert.equal(find('a.primary-diagnosis:contains(Broken Arm)').length, 0, 'New primary diagnosis is deleted'); assert.equal(find('#visit-vitals tr:last td:contains(34.56)').length, 0, 'Vital is deleted'); @@ -171,6 +185,9 @@ test('Delete visit', function(assert) { andThen(function() { assert.equal(find('.modal-title').text(), 'Delete Visit', 'Delete Visit confirmation displays'); click('.modal-footer button:contains(Delete)'); + }); + andThen(function() { + waitToDisappear('.modal-dialog'); waitToDisappear('#visits td:contains(Fall from in-line roller-skates, initial encounter)'); }); andThen(function() { diff --git a/tests/fixtures/billing.txt b/tests/fixtures/billing.txt index d8d35ebd6e..f36504b02d 100644 --- a/tests/fixtures/billing.txt +++ b/tests/fixtures/billing.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:22:00.385Z","db_info":{"db_name":"main","doc_count":82,"doc_del_count":5,"update_seq":112,"purge_seq":0,"compact_running":false,"disk_size":118888,"data_size":57068,"instance_start_time":"1486135264104152","disk_format_version":6,"committed_update_seq":112,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-01T20:43:23.432Z","db_info":{"db_name":"main","doc_count":82,"doc_del_count":5,"update_seq":112,"purge_seq":0,"compact_running":false,"disk_size":127080,"data_size":56943,"instance_start_time":"1488400469951231","disk_format_version":6,"committed_update_seq":112,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} -{"seq":7} +{"seq":5} {"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} {"seq":23} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"2-eae82996b36349ac1fce13b33546eaec","_deleted":true,"_revisions":{"start":2,"ids":["eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"billingLineItem_2_0CCADC1E-1A14-AD66-8423-7A3E6819AEBA","_rev":"2-11ec581b8c2c2f6c0a7dc18033f4e5fb","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Test","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T21:17:00.771Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T21:17:00.771Z","category":"2015-11-12T21:17:00.771Z"}},"_revisions":{"start":2,"ids":["11ec581b8c2c2f6c0a7dc18033f4e5fb","90fbdae0cfe722dbf01223fd001b95ab"]}},{"_id":"billingLineItem_2_5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","_rev":"5-1cbc6b21ccf94b7e42246c75c6bce181","data":{"amountOwed":120,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.846Z","modifiedBy":"Admin User","details":["41A8F093-D8F1-30AD-A070-E9881F072F4C"],"modifiedFields":{"name":"2015-11-13T16:38:20.043Z","category":"2015-11-13T16:38:20.043Z","amountOwed":"2015-11-13T16:38:51.846Z"}},"_revisions":{"start":5,"ids":["1cbc6b21ccf94b7e42246c75c6bce181","e2f88432d42e3d68230146173e579b26","a9c69d3126d8f23d1de7ca2362997b0a","635b22c6bd2bebfb41d59375d4a26cc6","cbe1b2c0c29230d741875d4ae3cd46c1"]}},{"_id":"billingLineItem_2_7481C877-BCB1-EB99-BBCA-5E5DC4DADF7A","_rev":"1-b41fc57519199df35943d9c24fd047d7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.424Z","modifiedBy":"Admin User","details":["BAFBDD02-6953-5E5F-A7F6-59839997B2FC"],"modifiedFields":{"category":"2015-11-12T22:00:59.424Z","name":"2015-11-12T22:00:59.424Z"}}},{"_id":"billingLineItem_2_83D54C80-6493-9A02-9940-325B25A8C2B5","_rev":"1-063aa7e251503a018e8d3616f8e4f1f2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.430Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.430Z","category":"2015-11-12T22:00:59.430Z"}}},{"_id":"billingLineItem_2_87DA9B12-9822-ACA4-A5C4-1FFDD559635C","_rev":"1-e3d62a3ecceebeb32449b7aba49e24ad","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.429Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.429Z","category":"2015-11-12T22:00:59.429Z"}}},{"_id":"billingLineItem_2_9733361B-5A85-9F2E-B9D5-F5C85872F7B9","_rev":"1-0e1922e2b361e48a37c6acd5f09dc417","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.426Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.426Z","category":"2015-11-12T22:00:59.426Z"}}},{"_id":"billingLineItem_2_9F1F38EA-168E-9F84-9F1D-C544D64DCD3D","_rev":"5-1c7e8423336ced251445be9ab2415e9a","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.049Z","category":"2015-11-13T16:38:20.049Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1c7e8423336ced251445be9ab2415e9a","5fd56534f9568ebbfedd24d87556c0f2","9a26cbbdec1ee0343e2fe4b7a77980c3","b70a6ee94f406a0b62f77b664819f193","4b741f261e7d842e66966d0878992a38"]}},{"_id":"billingLineItem_2_C193854D-A0D6-5E6B-A900-870904FE92DD","_rev":"5-c3555b12802aff9426590916449368d6","data":{"amountOwed":36,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.849Z","modifiedBy":"Admin User","details":["04A406D0-EB6B-7BD6-A328-4505150D5A70"],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.849Z"}},"_revisions":{"start":5,"ids":["c3555b12802aff9426590916449368d6","1857509859d8571c5e8c2cdc43de07ee","72437bd56ae7108eda0e66a11206f47c","d14d5f368af87d9f33338d31419bd855","9dfba0cdf988336e95ecd5e1eb15cda6"]}},{"_id":"billingLineItem_2_CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","_rev":"5-1292a509ab23929242728137587fbef6","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1292a509ab23929242728137587fbef6","6e8688e35c955a02bbfc595bda9ef10b","1955501435b44646703efaee24fe2b3b","3e169aeec3ba153a20ab6ac4de2f5423","1fb4106fed478276f3c3c5019e4c1022"]}},{"_id":"billingLineItem_2_D33B74D7-87A0-96F8-AAA1-8455635581A9","_rev":"5-7dbae08e82a6c48b6e46fa2d4baeed6a","data":{"amountOwed":495,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.844Z","modifiedBy":"Admin User","details":["89E9DCF0-E5FD-F0FA-A34F-8A80A2892934"],"modifiedFields":{"category":"2015-11-13T16:38:20.041Z","name":"2015-11-13T16:38:20.041Z","amountOwed":"2015-11-13T16:38:51.844Z"}},"_revisions":{"start":5,"ids":["7dbae08e82a6c48b6e46fa2d4baeed6a","e54a02cebf64641ee0ee72d8ccc2e861","0e3bc753d21631cea51c1ba64965bb2a","72041c92e27af1a896ff8bf42592e8c7","6acbb6d7dae522de5c588959cda1279e"]}},{"_id":"billingLineItem_2_D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","_rev":"5-c7c6ba06c51bb71ff990f8032e238d89","data":{"amountOwed":14,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.848Z","modifiedBy":"Admin User","details":["EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","0195CE1B-EA11-CB34-8970-BD6378C11C0B"],"modifiedFields":{"name":"2015-11-13T16:38:20.047Z","category":"2015-11-13T16:38:20.047Z","amountOwed":"2015-11-13T16:38:51.848Z"}},"_revisions":{"start":5,"ids":["c7c6ba06c51bb71ff990f8032e238d89","d36d74e5e324a3fbfc2e9ff6f51204cf","ba5ece37936ad9017a6c225584f7e735","91075517952345cce4ca5d7106374174","83cf4f5966bdff2903a22158d1ff923e"]}},{"_id":"billingLineItem_2_E0882D10-63E3-024B-A8CF-9010FE23C75B","_rev":"1-3df9822ea1a19faeb0dbaf1aa00641e2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.428Z","modifiedBy":"Admin User","details":["6006AE5D-5B16-4665-BF2A-0549CFA18B05"],"modifiedFields":{"name":"2015-11-12T22:00:59.428Z","category":"2015-11-12T22:00:59.428Z"}}},{"_id":"billingLineItem_2_FF5F6DA8-0359-1712-9E6E-AF50385E07A4","_rev":"1-9f11c1a15fdb9211cf994777d2ebffc7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.431Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.431Z","category":"2015-11-12T22:00:59.431Z"}}},{"_id":"imaging_2_9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9","_rev":"2-ee8faaf2563a1aff848c3f1ac5c5eef4","data":{"imagingDate":"2015-11-12T21:54:33.372Z","notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-11-12T21:54:30.514Z","result":null,"status":"Completed","lastModified":"2015-11-12T21:54:33.372Z","modifiedBy":"Admin User","imagingType":"5931700E-7965-23B1-9835-2D1615E7E755","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"radiologist":"2015-11-12T21:54:30.580Z","status":"2015-11-12T21:54:33.372Z","requestedBy":"2015-11-12T21:54:30.580Z","requestedDate":"2015-11-12T21:54:30.580Z","imagingDate":"2015-11-12T21:54:33.372Z"}},"_revisions":{"start":2,"ids":["ee8faaf2563a1aff848c3f1ac5c5eef4","86e7b70254a3e8d0d37cada4fe2c2dd5"]}},{"_id":"invLocation_2_871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF","_rev":"3-05c0170c92691e4cec16eaa5fd870093","data":{"quantity":14390,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-11-13T16:22:40.565Z","quantity":"2015-11-13T16:23:27.174Z"}},"_revisions":{"start":3,"ids":["05c0170c92691e4cec16eaa5fd870093","b12149871eb3a15641ed6288033fafc7","8ed685da9b4f64d6f1700feefd146c00"]}},{"_id":"invPurchase_2_C28F1C3D-2963-B8EB-903E-78913E9E2B32","_rev":"2-730d39d0cb831606ff5d92371b0e2ddf","data":{"purchaseCost":532,"lotNumber":null,"dateReceived":"2015-11-13T05:00:00.000Z","originalQuantity":14400,"currentQuantity":14390,"expirationDate":null,"expired":false,"location":"Pharmacy","aisleLocation":null,"giftInKind":false,"inventoryItem":"igxvfw26_lh","vendor":"ACME","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-11-13T16:22:40.557Z","purchaseCost":"2015-11-13T16:22:40.557Z","location":"2015-11-13T16:22:40.557Z","vendor":"2015-11-13T16:22:40.557Z","originalQuantity":"2015-11-13T16:22:40.557Z","currentQuantity":"2015-11-13T16:23:27.174Z","inventoryItem":"2015-11-13T16:22:40.557Z"}},"_revisions":{"start":2,"ids":["730d39d0cb831606ff5d92371b0e2ddf","fc582e29abb009231245cb59fdd2ccee"]}},{"_id":"invRequest_2_D3C66D97-6371-9453-94EC-8610D69A7152","_rev":"1-886cc49f90ce562971dad25d3fb8de65","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.04,"dateCompleted":"2015-11-13T16:23:27.165Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":10,"quantityAtCompletion":14400,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-11-13T16:23:27.346Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":null,"modifiedFields":{"dateCompleted":"2015-11-13T16:23:27.346Z","quantity":"2015-11-13T16:23:27.346Z","transactionType":"2015-11-13T16:23:27.346Z","markAsConsumed":"2015-11-13T16:23:27.346Z","adjustPurchases":"2015-11-13T16:23:27.346Z","costPerUnit":"2015-11-13T16:23:27.346Z","quantityAtCompletion":"2015-11-13T16:23:27.346Z","purchasesAffected":"2015-11-13T16:23:27.346Z","locationsAffected":"2015-11-13T16:23:27.346Z","status":"2015-11-13T16:23:27.346Z","completedBy":"2015-11-13T16:23:27.346Z"},"purchasesAffected":[{"id":"C28F1C3D-2963-B8EB-903E-78913E9E2B32","quantity":10}],"locationsAffected":[{"name":"Pharmacy","quantity":10}]}},{"_id":"inventory_2_igxvfw26_lh","_rev":"3-386a7bd74bfb2bbb81f1c5e9b599d2b9","data":{"description":null,"friendlyId":"m00001","name":"Acetaminophen 500 MG","quantity":14390,"crossReference":null,"inventoryType":"Medication","price":12,"reorderPoint":null,"distributionUnit":"tablet","lastModified":"2015-11-13T16:23:27.345Z","modifiedBy":"Admin User","locations":["871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF"],"purchases":["C28F1C3D-2963-B8EB-903E-78913E9E2B32"],"modifiedFields":{"name":"2015-11-13T16:22:40.649Z","inventoryType":"2015-11-13T16:22:40.649Z","distributionUnit":"2015-11-13T16:22:40.649Z","quantity":"2015-11-13T16:23:27.345Z","friendlyId":"2015-11-13T16:22:40.649Z","price":"2015-11-13T16:22:52.229Z"}},"_revisions":{"start":3,"ids":["386a7bd74bfb2bbb81f1c5e9b599d2b9","1c30ca3a4b102090fc0598cd7bbdf3ae","391bee3a85ef66bda23c89cabdd67956"]}},{"_id":"invoice_2_6414F250-C6F0-9B1F-94D7-621A539737AF","_rev":"2-e1898aa278789e1d7c91c4e59289344d","_deleted":true,"_revisions":{"start":2,"ids":["e1898aa278789e1d7c91c4e59289344d","8fad9853ba8f801a3375fb0149c140bf"]}},{"_id":"invoice_2_7596419D-F512-29A0-81EE-346D6D42BB54","_rev":"2-31502fbbe7a5e4ec4f56bc4c7abd1fe3","_deleted":true,"_revisions":{"start":2,"ids":["31502fbbe7a5e4ec4f56bc4c7abd1fe3","dba012716b2add05d20b765a72bca9bd"]}},{"_id":"invoice_2_8929C38C-B621-B2FB-ABB7-DE15C61DFCC8","_rev":"5-7a7d93b820b6085c5beea49fc3efb520","data":{"externalInvoiceNumber":"inv00001","patientInfo":"Joe Bagadonuts - TCH 00001","status":"Billed","remarks":null,"billDate":"2015-11-13T05:00:00.000Z","paidTotal":0,"lastModified":"2015-11-13T16:50:24.904Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","paymentProfile":null,"lineItems":["D33B74D7-87A0-96F8-AAA1-8455635581A9","5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","C193854D-A0D6-5E6B-A900-870904FE92DD","CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","9F1F38EA-168E-9F84-9F1D-C544D64DCD3D"],"payments":[],"modifiedFields":{"billDate":"2015-11-13T16:38:21.206Z","status":"2015-11-13T16:50:24.904Z","patientInfo":"2015-11-13T16:38:21.206Z","externalInvoiceNumber":"2015-11-13T16:44:21.692Z","paidTotal":"2015-11-13T16:50:24.904Z"}},"_revisions":{"start":5,"ids":["7a7d93b820b6085c5beea49fc3efb520","dd0fbb2e7a00eb9ee9be70696621571a","831c42f1a919ec0ad0592bc301c3f48f","db6828f498d4ec6147ef996cfb4b809a","3aeae1614fd7caa7178cf470bc62c366"]}},{"_id":"lab_2_0762040A-CAC7-130F-8D0C-E3DE9245EE38","_rev":"1-f7d92c5e72cc67fc22c1e7634ca08881","data":{"labDate":"2015-11-12T21:46:23.129Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-11-12T21:46:24.462Z","result":"Good","status":"Completed","lastModified":"2015-11-12T21:46:50.177Z","modifiedBy":"Admin User","labType":"F71A1788-3407-515B-8006-F9CC788CA8EA","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"result":"2015-11-12T21:46:50.177Z","status":"2015-11-12T21:46:50.177Z","labDate":"2015-11-12T21:46:50.177Z","requestedBy":"2015-11-12T21:46:50.177Z","requestedDate":"2015-11-12T21:46:50.177Z"}}},{"_id":"lineItemDetail_2_0195CE1B-EA11-CB34-8970-BD6378C11C0B","_rev":"5-50e91d40fbef6f01247cdc2c797df755","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.046Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-13T16:38:20.046Z","expenseAccount":"2015-11-13T16:38:20.046Z","quantity":"2015-11-13T16:38:20.046Z","price":"2015-11-13T16:38:20.046Z","department":"2015-11-13T16:38:20.046Z"}},"_revisions":{"start":5,"ids":["50e91d40fbef6f01247cdc2c797df755","b784cb137af68027834c22b372b7abab","0694194f05c3b79c026ff540d9736043","5cbe22057ba23a8ee0f81d8526d8fc8b","91688cbe5d5da849ea8d4cc2516bd0e6"]}},{"_id":"lineItemDetail_2_04A406D0-EB6B-7BD6-A328-4505150D5A70","_rev":"5-3c5cfebc1004ba1adc877f79101943b9","data":{"department":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"quantity":12,"total":null,"lastModified":"2015-11-13T16:38:20.047Z","modifiedBy":"Admin User","pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"name":"2015-11-13T16:38:20.047Z","expenseAccount":"2015-11-13T16:38:20.047Z","quantity":"2015-11-13T16:38:20.047Z","price":"2015-11-13T16:38:20.047Z","department":"2015-11-13T16:38:20.047Z"}},"_revisions":{"start":5,"ids":["3c5cfebc1004ba1adc877f79101943b9","aa24b7d5f6f4be91b9f148bb3c090e5e","442c20d22e8ee94f549dbcd12f86f5db","4ee7bf808212cbaefddbcb1e6cd4bd16","46a4da005639ebeefc736b3cc305354c"]}},{"_id":"lineItemDetail_2_41A8F093-D8F1-30AD-A070-E9881F072F4C","_rev":"5-bb70abfec5de06d15fdc8bddb0153c50","data":{"department":"Pharmacy","expenseAccount":null,"name":"Acetaminophen 500 MG","price":12,"quantity":10,"total":null,"lastModified":"2015-11-13T16:38:20.042Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.042Z","quantity":"2015-11-13T16:38:20.042Z","price":"2015-11-13T16:38:20.042Z","department":"2015-11-13T16:38:20.042Z"}},"_revisions":{"start":5,"ids":["bb70abfec5de06d15fdc8bddb0153c50","4da37ad0ef6925a3838db19d86c306e7","d7d4a2a5502c92b6225a354639f503d2","882434ab090177ffc5da7f5a20ec1663","f189693c2c4fac5b634b703dc3e253d7"]}},{"_id":"lineItemDetail_2_6006AE5D-5B16-4665-BF2A-0549CFA18B05","_rev":"1-b16638cf08bbd83f98e84c1b682249f9","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-12T22:00:59.427Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-12T22:00:59.427Z","expenseAccount":"2015-11-12T22:00:59.427Z","quantity":"2015-11-12T22:00:59.427Z","price":"2015-11-12T22:00:59.427Z","department":"2015-11-12T22:00:59.427Z"}}}]} -{"seq":75} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"lineItemDetail_2_89E9DCF0-E5FD-F0FA-A34F-8A80A2892934","_rev":"5-4008862e1efdded3cc2c5e77e445f214","data":{"department":null,"expenseAccount":null,"name":"Days","price":45,"quantity":11,"total":null,"lastModified":"2015-11-13T16:38:51.843Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.039Z","quantity":"2015-11-13T16:38:20.039Z","price":"2015-11-13T16:38:51.843Z"}},"_revisions":{"start":5,"ids":["4008862e1efdded3cc2c5e77e445f214","03d46eaecd46f6336d0ccc07f6881cfd","376b97227567079e8dfd82bad223e1de","d18636e346ef69fa1d9617e177148704","74f4293f387b050c85e3a520eccfeb1a"]}},{"_id":"lineItemDetail_2_BAFBDD02-6953-5E5F-A7F6-59839997B2FC","_rev":"1-461b69d47c783b5fddc3e697d42d0764","data":{"department":null,"expenseAccount":null,"name":"Days","price":null,"quantity":11,"total":null,"lastModified":"2015-11-12T22:00:59.422Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-12T22:00:59.422Z","quantity":"2015-11-12T22:00:59.422Z"}}},{"_id":"lineItemDetail_2_EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","_rev":"5-b4ecd3a3ca2ec72abb2b265aa6a865a0","data":{"department":"O.R.","expenseAccount":null,"name":"Leg Casting","price":2,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.044Z","modifiedBy":"Admin User","pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"name":"2015-11-13T16:38:20.044Z","expenseAccount":"2015-11-13T16:38:20.044Z","quantity":"2015-11-13T16:38:20.044Z","price":"2015-11-13T16:38:20.044Z","department":"2015-11-13T16:38:20.044Z"}},"_revisions":{"start":5,"ids":["b4ecd3a3ca2ec72abb2b265aa6a865a0","88e87af8cff7a93b0d14ad1152dc40bf","d9d966a397398a53cf66ad2452e904e2","48400862e9be71150140585017cf0b3e","a2a39c01032abf83c945fc5dcbfa1fdc"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-13d3772f546b5c7a9dfcbb9ad8c27a63","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Leg casting"]}},{"_id":"lookup_2_imaging_pricing_types","_rev":"1-508f1018b1af1f65de250cd110e8ae4a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Imaging Procedure"]}},{"_id":"lookup_2_lab_pricing_types","_rev":"1-f64bac71fc698147e7b5802e38d326ec","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Lab Procedure"]}},{"_id":"lookup_2_physician_list","_rev":"1-fe60344a75c70341b869b5211a85d89c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Watson"]}},{"_id":"lookup_2_procedure_list","_rev":"2-5818e879a750999f9f317d262b70cabd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fix broken leg","Leg casting"]},"_revisions":{"start":2,"ids":["5818e879a750999f9f317d262b70cabd","13d3772f546b5c7a9dfcbb9ad8c27a63"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-e4823048fbfcefa1b230c38548dd6465","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-4f316909ed8500d0f80cf20a684ce343","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy"]}},{"_id":"medication_2_7F51BB93-6086-49D0-A284-FEB6C6690C95","_rev":"2-c438baf544b44547413edf90837cab1a","data":{"notes":null,"prescription":"Take two once a day for 5 days","prescriptionDate":"2015-11-13T05:00:00.000Z","quantity":10,"refills":null,"requestedDate":"2015-11-13T16:23:27.163Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-11-13T16:23:27.176Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","medicationTitle":"Acetaminophen 500 MG","priceOfMedication":null,"modifiedFields":{"prescriptionDate":"2015-11-13T16:23:27.176Z","prescription":"2015-11-13T16:23:27.176Z","quantity":"2015-11-13T16:23:27.176Z","status":"2015-11-13T16:23:27.176Z","requestedBy":"2015-11-13T16:23:27.176Z","requestedDate":"2015-11-13T16:23:27.176Z"}},"_revisions":{"start":2,"ids":["c438baf544b44547413edf90837cab1a","f441e894d0aaaab3c3c394186e0cad67"]}},{"_id":"overridePrice_2_9C4DC6CF-EC9B-B303-A483-6B80930CC658","_rev":"1-73b042aa49125ce4f3961ed9316756f7","data":{"price":4,"lastModified":"2015-11-11T21:52:55.514Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:52:55.514Z"}}},{"_id":"overridePrice_2_FBF5B1A6-BBEE-6D17-99C8-EB4A91358183","_rev":"1-87dc3dc101c2d1b1a122e74de183281a","data":{"price":2,"lastModified":"2015-11-11T21:06:20.663Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:06:20.663Z"}}},{"_id":"patient_2_8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","_rev":"3-63565b6c7b01bbb4af8dbd37a6cd7ca2","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"TCH 00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:51:59.117Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-11-12T21:13:52.796Z","firstName":"2015-11-12T21:13:52.796Z","middleName":"2015-11-12T21:13:52.796Z","lastName":"2015-11-12T21:13:52.796Z","admitted":"2015-11-12T21:15:12.204Z","sex":"2016-02-22T21:51:59.117Z"}},"_revisions":{"start":3,"ids":["63565b6c7b01bbb4af8dbd37a6cd7ca2","7ab83617d991bfa730e55757d90c35ad","d5bb9506d7ebd07a2fd7e2bd8a9afc03"]}},{"_id":"priceProfile_2_5331626A-EF59-E723-AC44-A063049201DC","_rev":"1-c9ede1cd1775d2ccc9e0bcc5d099d614","data":{"name":"Half off","discountAmount":null,"discountPercentage":50,"lastModified":"2015-11-11T21:05:25.047Z","modifiedBy":"Admin User","modifiedFields":{"name":"2015-11-11T21:05:25.047Z","discountPercentage":"2015-11-11T21:05:25.047Z"}}},{"_id":"pricing_2_1D198B41-338B-6E49-8BB1-4696D5DAD715","_rev":"1-5fd5619f2cc1dcf4e7c051add2deaf5d","data":{"category":"Procedure","expenseAccount":null,"name":"Leg Casting","price":2,"pricingType":null,"lastModified":"2015-11-11T21:53:29.953Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:29.953Z","name":"2015-11-11T21:53:29.953Z","price":"2015-11-11T21:53:29.953Z"}}},{"_id":"pricing_2_5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","_rev":"1-7f85b8fb293360badee861fb4a685721","data":{"category":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"pricingType":null,"lastModified":"2015-11-11T21:53:52.661Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:52.661Z","name":"2015-11-11T21:53:52.661Z","price":"2015-11-11T21:53:52.661Z"}}},{"_id":"pricing_2_5931700E-7965-23B1-9835-2D1615E7E755","_rev":"2-300f644f420f7f76581093329a9aa519","data":{"category":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"pricingType":"Imaging Procedure","lastModified":"2015-11-11T21:52:55.549Z","modifiedBy":"Admin User","pricingOverrides":["9C4DC6CF-EC9B-B303-A483-6B80930CC658"],"modifiedFields":{"category":"2015-11-11T21:52:55.549Z","name":"2015-11-11T21:52:55.549Z","price":"2015-11-11T21:52:55.549Z","pricingType":"2015-11-11T21:52:55.549Z"}},"_revisions":{"start":2,"ids":["300f644f420f7f76581093329a9aa519","9f00f9d6a35374e7d7fcbeffd8d4697b"]}},{"_id":"pricing_2_F71A1788-3407-515B-8006-F9CC788CA8EA","_rev":"2-9762d8a2d76d242671a3bea610a0904f","data":{"category":"Lab","expenseAccount":null,"name":"Blood test","price":123,"pricingType":"Lab Procedure","lastModified":"2015-11-11T21:06:20.719Z","modifiedBy":"Admin User","pricingOverrides":["FBF5B1A6-BBEE-6D17-99C8-EB4A91358183"],"modifiedFields":{"category":"2015-11-11T21:06:20.719Z","name":"2015-11-11T21:06:20.719Z","price":"2015-11-11T21:06:20.719Z","pricingType":"2015-11-11T21:06:20.719Z"}},"_revisions":{"start":2,"ids":["9762d8a2d76d242671a3bea610a0904f","e6eada16de79ddba78e890c01837a3f5"]}},{"_id":"procCharge_2_0834BF27-A2E0-5ADD-9509-B97CA547E532","_rev":"1-0bb58d85915b11cbcb1547ba44b86f5f","data":{"quantity":1,"dateCharged":"2015-11-13T05:00:00.000Z","lastModified":"2015-11-13T16:11:54.012Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-13T16:11:54.012Z","quantity":"2015-11-13T16:11:54.012Z"}}},{"_id":"procCharge_2_17BC9913-E49F-FB8A-AA42-4F617D839510","_rev":"1-2917bd58af0d9cbb9e3835013c857d2f","data":{"quantity":1,"dateCharged":"2015-11-12T05:00:00.000Z","lastModified":"2015-11-12T21:53:52.879Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-12T21:53:52.879Z","quantity":"2015-11-12T21:53:52.879Z"}}},{"_id":"procCharge_2_2648E500-C287-2EE4-B569-99D6291FB46C","_rev":"2-1875764ed6d4a41e96277d678bcda2b3","_deleted":true,"_revisions":{"start":2,"ids":["1875764ed6d4a41e96277d678bcda2b3","f0554786c3ad14c941dced65e1df8649"]}},{"_id":"procCharge_2_412AD48B-EDD4-E5E2-8134-BB3B5E459972","_rev":"1-2cdee6e8d8fd1207c073b5e6f33b4c6e","data":{"quantity":12,"dateCharged":"2015-11-03T05:00:00.000Z","lastModified":"2015-11-12T21:18:30.366Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-12T21:18:30.366Z","quantity":"2015-11-12T21:18:30.366Z"}}},{"_id":"procCharge_2_561AD584-144B-D21F-840A-8600B8D900CF","_rev":"1-8f30246e0bba661deeb2c08617ec1128","data":{"quantity":12,"dateCharged":"2015-11-11T05:00:00.000Z","lastModified":"2015-11-13T16:24:24.528Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-13T16:24:24.528Z","quantity":"2015-11-13T16:24:24.528Z"}}},{"_id":"procCharge_2_704FA289-CA15-A178-B571-D0ECCE8229F3","_rev":"2-6d00bf1656e7ef89bc6ba38c3711982b","_deleted":true,"_revisions":{"start":2,"ids":["6d00bf1656e7ef89bc6ba38c3711982b","2103b76190a412ab081bae469ef27dee"]}},{"_id":"procCharge_2_A28911F7-FC62-9F3D-A82E-8EB0D43B9B68","_rev":"2-3959e9c3eb93a0fd7bc1d36ece0dbcd9","_deleted":true,"_revisions":{"start":2,"ids":["3959e9c3eb93a0fd7bc1d36ece0dbcd9","b5b4fd9fa56d91b689be62a9fc0506ae"]}},{"_id":"procCharge_2_A2F0320B-AFD0-BB29-AFFE-6470FD537D05","_rev":"1-d29a0c613aa6282b87a3e3eb37278453","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"quantity":12,"dateCharged":"2016-02-09T20:18:54.966Z","lastModified":"2016-02-09T20:18:59.012Z","modifiedBy":"Admin User","medication":"igxvfw26_lh","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T20:18:59.012Z","quantity":"2016-02-09T20:18:59.012Z","medicationTitle":"2016-02-09T20:18:59.012Z","priceOfMedication":"2016-02-09T20:18:59.012Z"}}},{"_id":"procCharge_2_BDAC9E94-96A0-1994-9196-BD3F56F891CA","_rev":"1-090a8baf0cf5219ab842f6a5f85c98b2","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:20:16.119Z","lastModified":"2016-02-09T19:20:22.089Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:20:22.089Z","quantity":"2016-02-09T19:20:22.089Z","medication":"2016-02-09T19:20:22.089Z","medicationTitle":"2016-02-09T19:20:22.089Z","priceOfMedication":"2016-02-09T19:20:22.089Z"}}},{"_id":"procCharge_2_F632124D-557D-0B35-8213-F7054DE6AFB0","_rev":"1-f88672a41bab0bf53f3d744944b623e5","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:16:13.269Z","lastModified":"2016-02-09T19:16:22.209Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:16:22.209Z","quantity":"2016-02-09T19:16:22.209Z","medication":"2016-02-09T19:16:22.209Z","medicationTitle":"2016-02-09T19:16:22.209Z","priceOfMedication":"2016-02-09T19:16:22.209Z"}}},{"_id":"procedure_2_539C4B9B-B275-EF14-8BA2-9CAC6403424A","_rev":"1-e4a243fe73d67885206ff1d406beba1a","data":{"anesthesiaType":null,"anesthesiologist":null,"assistant":null,"description":"Leg casting","cptCode":"Leg casting","location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-12T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-12T21:54:00.381Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["17BC9913-E49F-FB8A-AA42-4F617D839510"],"modifiedFields":{"procedureDate":"2015-11-12T21:54:00.381Z","description":"2015-11-12T21:54:00.381Z","cptCode":"2015-11-12T21:54:00.381Z","timeStarted":"2015-11-12T21:54:00.381Z","timeEnded":"2015-11-12T21:54:00.381Z","physician":"2015-11-12T21:54:00.381Z"}}},{"_id":"procedure_2_653A07CE-66E2-1DC8-A83C-4A25934559F0","_rev":"11-9852c642c6108359ec3d1a1915be7d77","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"Fix broken leg","cptCode":null,"location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-13T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-13T16:11:57.940Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["0834BF27-A2E0-5ADD-9509-B97CA547E532","A2F0320B-AFD0-BB29-AFFE-6470FD537D05"],"modifiedFields":{"procedureDate":"2015-11-13T16:11:57.940Z","description":"2015-11-13T16:11:57.940Z","timeStarted":"2015-11-13T16:11:57.940Z","timeEnded":"2015-11-13T16:11:57.940Z","physician":"2015-11-13T16:11:57.940Z","anesthesiaType":"2015-11-13T16:11:57.940Z"}},"_revisions":{"start":11,"ids":["9852c642c6108359ec3d1a1915be7d77","32f7b134f4a1489bad30b20b41a402b7","79317aa8224c831799a41588c9c00572","25edbe7f3e8f872997aec5b8e57959c0","53e45632484af05ac967f6af430bced9","8700b634cefddb7c2ef0b810e4d8241a","e0abfee94018abcefb7b541c6bb7b242","715ed4e72deba043868bfbe500f964a0","483b770e04706f935dc6275abf496a3a","0f22a93f70def208660a024b0fa6a6c6","b078e6e7004154529f8fd0901b60ed19"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_invoice","_rev":"3-f0ef6923c78e739d9228517a4813b646","data":{"prefix":null,"value":3},"_revisions":{"start":3,"ids":["f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"sequence_2_patient","_rev":"1-5bc31ffefa482f2e66299cf0704623c8","data":{"prefix":null,"value":1}},{"_id":"visit_2_666DFC61-3230-A865-A145-C7D9139DA1CA","_rev":"12-9f26178fcda83e39cc9df1950035a7fc","data":{"dischargeInfo":null,"endDate":"2015-11-12T05:00:00.000Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-01T04:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-12T21:47:53.994Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","vitals":[],"procedures":["653A07CE-66E2-1DC8-A83C-4A25934559F0"],"medication":["7F51BB93-6086-49D0-A284-FEB6C6690C95"],"labs":["0762040A-CAC7-130F-8D0C-E3DE9245EE38"],"imaging":["9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9"],"charges":["561AD584-144B-D21F-840A-8600B8D900CF"],"modifiedFields":{"visitType":"2015-11-12T21:15:12.160Z","startDate":"2015-11-12T21:15:12.160Z","status":"2015-11-12T21:47:53.994Z","outPatient":"2015-11-12T21:15:12.160Z","endDate":"2015-11-12T21:47:53.994Z"}},"_revisions":{"start":12,"ids":["9f26178fcda83e39cc9df1950035a7fc","64ef0abb729090bd64b948f9ca2318de","19a1560274f7e5dc07c3b6b0543278a1","793cb2bc5919ef9ced471818f5e7c3b5","8201fa77027c3929455f4c9368ce1c32","4f345e06fefbc87fa23fa1a0d194d1ee","e82f9737c00c8b9004653355ed0cb743","03b09430dde4f6d3c5b62f1c5c6b1378","1db70a4f91b8ed3da25df05dcc91713d","5745b4455c849281c543b2c447feb480","37ad5eae5583240c5143012937658d48","c35ad6c0332fc471d3a8fa485a48d1de"]}}]} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"2-eae82996b36349ac1fce13b33546eaec","_deleted":true,"_revisions":{"start":2,"ids":["eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"billingLineItem_2_0CCADC1E-1A14-AD66-8423-7A3E6819AEBA","_rev":"2-11ec581b8c2c2f6c0a7dc18033f4e5fb","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Test","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T21:17:00.771Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T21:17:00.771Z","category":"2015-11-12T21:17:00.771Z"}},"_revisions":{"start":2,"ids":["11ec581b8c2c2f6c0a7dc18033f4e5fb","90fbdae0cfe722dbf01223fd001b95ab"]}},{"_id":"billingLineItem_2_5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","_rev":"5-1cbc6b21ccf94b7e42246c75c6bce181","data":{"amountOwed":120,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.846Z","modifiedBy":"Admin User","details":["41A8F093-D8F1-30AD-A070-E9881F072F4C"],"modifiedFields":{"name":"2015-11-13T16:38:20.043Z","category":"2015-11-13T16:38:20.043Z","amountOwed":"2015-11-13T16:38:51.846Z"}},"_revisions":{"start":5,"ids":["1cbc6b21ccf94b7e42246c75c6bce181","e2f88432d42e3d68230146173e579b26","a9c69d3126d8f23d1de7ca2362997b0a","635b22c6bd2bebfb41d59375d4a26cc6","cbe1b2c0c29230d741875d4ae3cd46c1"]}},{"_id":"billingLineItem_2_7481C877-BCB1-EB99-BBCA-5E5DC4DADF7A","_rev":"1-b41fc57519199df35943d9c24fd047d7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.424Z","modifiedBy":"Admin User","details":["BAFBDD02-6953-5E5F-A7F6-59839997B2FC"],"modifiedFields":{"category":"2015-11-12T22:00:59.424Z","name":"2015-11-12T22:00:59.424Z"}}},{"_id":"billingLineItem_2_83D54C80-6493-9A02-9940-325B25A8C2B5","_rev":"1-063aa7e251503a018e8d3616f8e4f1f2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.430Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.430Z","category":"2015-11-12T22:00:59.430Z"}}},{"_id":"billingLineItem_2_87DA9B12-9822-ACA4-A5C4-1FFDD559635C","_rev":"1-e3d62a3ecceebeb32449b7aba49e24ad","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.429Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.429Z","category":"2015-11-12T22:00:59.429Z"}}},{"_id":"billingLineItem_2_9733361B-5A85-9F2E-B9D5-F5C85872F7B9","_rev":"1-0e1922e2b361e48a37c6acd5f09dc417","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.426Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.426Z","category":"2015-11-12T22:00:59.426Z"}}},{"_id":"billingLineItem_2_9F1F38EA-168E-9F84-9F1D-C544D64DCD3D","_rev":"5-1c7e8423336ced251445be9ab2415e9a","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.049Z","category":"2015-11-13T16:38:20.049Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1c7e8423336ced251445be9ab2415e9a","5fd56534f9568ebbfedd24d87556c0f2","9a26cbbdec1ee0343e2fe4b7a77980c3","b70a6ee94f406a0b62f77b664819f193","4b741f261e7d842e66966d0878992a38"]}},{"_id":"billingLineItem_2_C193854D-A0D6-5E6B-A900-870904FE92DD","_rev":"5-c3555b12802aff9426590916449368d6","data":{"amountOwed":36,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.849Z","modifiedBy":"Admin User","details":["04A406D0-EB6B-7BD6-A328-4505150D5A70"],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.849Z"}},"_revisions":{"start":5,"ids":["c3555b12802aff9426590916449368d6","1857509859d8571c5e8c2cdc43de07ee","72437bd56ae7108eda0e66a11206f47c","d14d5f368af87d9f33338d31419bd855","9dfba0cdf988336e95ecd5e1eb15cda6"]}},{"_id":"billingLineItem_2_CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","_rev":"5-1292a509ab23929242728137587fbef6","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1292a509ab23929242728137587fbef6","6e8688e35c955a02bbfc595bda9ef10b","1955501435b44646703efaee24fe2b3b","3e169aeec3ba153a20ab6ac4de2f5423","1fb4106fed478276f3c3c5019e4c1022"]}},{"_id":"billingLineItem_2_D33B74D7-87A0-96F8-AAA1-8455635581A9","_rev":"5-7dbae08e82a6c48b6e46fa2d4baeed6a","data":{"amountOwed":495,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.844Z","modifiedBy":"Admin User","details":["89E9DCF0-E5FD-F0FA-A34F-8A80A2892934"],"modifiedFields":{"category":"2015-11-13T16:38:20.041Z","name":"2015-11-13T16:38:20.041Z","amountOwed":"2015-11-13T16:38:51.844Z"}},"_revisions":{"start":5,"ids":["7dbae08e82a6c48b6e46fa2d4baeed6a","e54a02cebf64641ee0ee72d8ccc2e861","0e3bc753d21631cea51c1ba64965bb2a","72041c92e27af1a896ff8bf42592e8c7","6acbb6d7dae522de5c588959cda1279e"]}},{"_id":"billingLineItem_2_D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","_rev":"5-c7c6ba06c51bb71ff990f8032e238d89","data":{"amountOwed":14,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.848Z","modifiedBy":"Admin User","details":["EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","0195CE1B-EA11-CB34-8970-BD6378C11C0B"],"modifiedFields":{"name":"2015-11-13T16:38:20.047Z","category":"2015-11-13T16:38:20.047Z","amountOwed":"2015-11-13T16:38:51.848Z"}},"_revisions":{"start":5,"ids":["c7c6ba06c51bb71ff990f8032e238d89","d36d74e5e324a3fbfc2e9ff6f51204cf","ba5ece37936ad9017a6c225584f7e735","91075517952345cce4ca5d7106374174","83cf4f5966bdff2903a22158d1ff923e"]}},{"_id":"billingLineItem_2_E0882D10-63E3-024B-A8CF-9010FE23C75B","_rev":"1-3df9822ea1a19faeb0dbaf1aa00641e2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.428Z","modifiedBy":"Admin User","details":["6006AE5D-5B16-4665-BF2A-0549CFA18B05"],"modifiedFields":{"name":"2015-11-12T22:00:59.428Z","category":"2015-11-12T22:00:59.428Z"}}},{"_id":"billingLineItem_2_FF5F6DA8-0359-1712-9E6E-AF50385E07A4","_rev":"1-9f11c1a15fdb9211cf994777d2ebffc7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.431Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.431Z","category":"2015-11-12T22:00:59.431Z"}}},{"_id":"imaging_2_9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9","_rev":"2-ee8faaf2563a1aff848c3f1ac5c5eef4","data":{"imagingDate":"2015-11-12T21:54:33.372Z","notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-11-12T21:54:30.514Z","result":null,"status":"Completed","lastModified":"2015-11-12T21:54:33.372Z","modifiedBy":"Admin User","imagingType":"5931700E-7965-23B1-9835-2D1615E7E755","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"radiologist":"2015-11-12T21:54:30.580Z","status":"2015-11-12T21:54:33.372Z","requestedBy":"2015-11-12T21:54:30.580Z","requestedDate":"2015-11-12T21:54:30.580Z","imagingDate":"2015-11-12T21:54:33.372Z"}},"_revisions":{"start":2,"ids":["ee8faaf2563a1aff848c3f1ac5c5eef4","86e7b70254a3e8d0d37cada4fe2c2dd5"]}},{"_id":"invLocation_2_871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF","_rev":"3-05c0170c92691e4cec16eaa5fd870093","data":{"quantity":14390,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-11-13T16:22:40.565Z","quantity":"2015-11-13T16:23:27.174Z"}},"_revisions":{"start":3,"ids":["05c0170c92691e4cec16eaa5fd870093","b12149871eb3a15641ed6288033fafc7","8ed685da9b4f64d6f1700feefd146c00"]}},{"_id":"invPurchase_2_C28F1C3D-2963-B8EB-903E-78913E9E2B32","_rev":"2-730d39d0cb831606ff5d92371b0e2ddf","data":{"purchaseCost":532,"lotNumber":null,"dateReceived":"2015-11-13T05:00:00.000Z","originalQuantity":14400,"currentQuantity":14390,"expirationDate":null,"expired":false,"location":"Pharmacy","aisleLocation":null,"giftInKind":false,"inventoryItem":"igxvfw26_lh","vendor":"ACME","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-11-13T16:22:40.557Z","purchaseCost":"2015-11-13T16:22:40.557Z","location":"2015-11-13T16:22:40.557Z","vendor":"2015-11-13T16:22:40.557Z","originalQuantity":"2015-11-13T16:22:40.557Z","currentQuantity":"2015-11-13T16:23:27.174Z","inventoryItem":"2015-11-13T16:22:40.557Z"}},"_revisions":{"start":2,"ids":["730d39d0cb831606ff5d92371b0e2ddf","fc582e29abb009231245cb59fdd2ccee"]}},{"_id":"invRequest_2_D3C66D97-6371-9453-94EC-8610D69A7152","_rev":"1-886cc49f90ce562971dad25d3fb8de65","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.04,"dateCompleted":"2015-11-13T16:23:27.165Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":10,"quantityAtCompletion":14400,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-11-13T16:23:27.346Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":null,"modifiedFields":{"dateCompleted":"2015-11-13T16:23:27.346Z","quantity":"2015-11-13T16:23:27.346Z","transactionType":"2015-11-13T16:23:27.346Z","markAsConsumed":"2015-11-13T16:23:27.346Z","adjustPurchases":"2015-11-13T16:23:27.346Z","costPerUnit":"2015-11-13T16:23:27.346Z","quantityAtCompletion":"2015-11-13T16:23:27.346Z","purchasesAffected":"2015-11-13T16:23:27.346Z","locationsAffected":"2015-11-13T16:23:27.346Z","status":"2015-11-13T16:23:27.346Z","completedBy":"2015-11-13T16:23:27.346Z"},"purchasesAffected":[{"id":"C28F1C3D-2963-B8EB-903E-78913E9E2B32","quantity":10}],"locationsAffected":[{"name":"Pharmacy","quantity":10}]}},{"_id":"inventory_2_igxvfw26_lh","_rev":"3-386a7bd74bfb2bbb81f1c5e9b599d2b9","data":{"description":null,"friendlyId":"m00001","name":"Acetaminophen 500 MG","quantity":14390,"crossReference":null,"inventoryType":"Medication","price":12,"reorderPoint":null,"distributionUnit":"tablet","lastModified":"2015-11-13T16:23:27.345Z","modifiedBy":"Admin User","locations":["871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF"],"purchases":["C28F1C3D-2963-B8EB-903E-78913E9E2B32"],"modifiedFields":{"name":"2015-11-13T16:22:40.649Z","inventoryType":"2015-11-13T16:22:40.649Z","distributionUnit":"2015-11-13T16:22:40.649Z","quantity":"2015-11-13T16:23:27.345Z","friendlyId":"2015-11-13T16:22:40.649Z","price":"2015-11-13T16:22:52.229Z"}},"_revisions":{"start":3,"ids":["386a7bd74bfb2bbb81f1c5e9b599d2b9","1c30ca3a4b102090fc0598cd7bbdf3ae","391bee3a85ef66bda23c89cabdd67956"]}},{"_id":"invoice_2_6414F250-C6F0-9B1F-94D7-621A539737AF","_rev":"2-e1898aa278789e1d7c91c4e59289344d","_deleted":true,"_revisions":{"start":2,"ids":["e1898aa278789e1d7c91c4e59289344d","8fad9853ba8f801a3375fb0149c140bf"]}},{"_id":"invoice_2_7596419D-F512-29A0-81EE-346D6D42BB54","_rev":"2-31502fbbe7a5e4ec4f56bc4c7abd1fe3","_deleted":true,"_revisions":{"start":2,"ids":["31502fbbe7a5e4ec4f56bc4c7abd1fe3","dba012716b2add05d20b765a72bca9bd"]}},{"_id":"invoice_2_8929C38C-B621-B2FB-ABB7-DE15C61DFCC8","_rev":"5-7a7d93b820b6085c5beea49fc3efb520","data":{"externalInvoiceNumber":"inv00001","patientInfo":"Joe Bagadonuts - TCH 00001","status":"Billed","remarks":null,"billDate":"2015-11-13T05:00:00.000Z","paidTotal":0,"lastModified":"2015-11-13T16:50:24.904Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","paymentProfile":null,"lineItems":["D33B74D7-87A0-96F8-AAA1-8455635581A9","5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","C193854D-A0D6-5E6B-A900-870904FE92DD","CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","9F1F38EA-168E-9F84-9F1D-C544D64DCD3D"],"payments":[],"modifiedFields":{"billDate":"2015-11-13T16:38:21.206Z","status":"2015-11-13T16:50:24.904Z","patientInfo":"2015-11-13T16:38:21.206Z","externalInvoiceNumber":"2015-11-13T16:44:21.692Z","paidTotal":"2015-11-13T16:50:24.904Z"}},"_revisions":{"start":5,"ids":["7a7d93b820b6085c5beea49fc3efb520","dd0fbb2e7a00eb9ee9be70696621571a","831c42f1a919ec0ad0592bc301c3f48f","db6828f498d4ec6147ef996cfb4b809a","3aeae1614fd7caa7178cf470bc62c366"]}},{"_id":"lab_2_0762040A-CAC7-130F-8D0C-E3DE9245EE38","_rev":"1-f7d92c5e72cc67fc22c1e7634ca08881","data":{"labDate":"2015-11-12T21:46:23.129Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-11-12T21:46:24.462Z","result":"Good","status":"Completed","lastModified":"2015-11-12T21:46:50.177Z","modifiedBy":"Admin User","labType":"F71A1788-3407-515B-8006-F9CC788CA8EA","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"result":"2015-11-12T21:46:50.177Z","status":"2015-11-12T21:46:50.177Z","labDate":"2015-11-12T21:46:50.177Z","requestedBy":"2015-11-12T21:46:50.177Z","requestedDate":"2015-11-12T21:46:50.177Z"}}},{"_id":"lineItemDetail_2_0195CE1B-EA11-CB34-8970-BD6378C11C0B","_rev":"5-50e91d40fbef6f01247cdc2c797df755","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.046Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-13T16:38:20.046Z","expenseAccount":"2015-11-13T16:38:20.046Z","quantity":"2015-11-13T16:38:20.046Z","price":"2015-11-13T16:38:20.046Z","department":"2015-11-13T16:38:20.046Z"}},"_revisions":{"start":5,"ids":["50e91d40fbef6f01247cdc2c797df755","b784cb137af68027834c22b372b7abab","0694194f05c3b79c026ff540d9736043","5cbe22057ba23a8ee0f81d8526d8fc8b","91688cbe5d5da849ea8d4cc2516bd0e6"]}},{"_id":"lineItemDetail_2_04A406D0-EB6B-7BD6-A328-4505150D5A70","_rev":"5-3c5cfebc1004ba1adc877f79101943b9","data":{"department":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"quantity":12,"total":null,"lastModified":"2015-11-13T16:38:20.047Z","modifiedBy":"Admin User","pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"name":"2015-11-13T16:38:20.047Z","expenseAccount":"2015-11-13T16:38:20.047Z","quantity":"2015-11-13T16:38:20.047Z","price":"2015-11-13T16:38:20.047Z","department":"2015-11-13T16:38:20.047Z"}},"_revisions":{"start":5,"ids":["3c5cfebc1004ba1adc877f79101943b9","aa24b7d5f6f4be91b9f148bb3c090e5e","442c20d22e8ee94f549dbcd12f86f5db","4ee7bf808212cbaefddbcb1e6cd4bd16","46a4da005639ebeefc736b3cc305354c"]}},{"_id":"lineItemDetail_2_41A8F093-D8F1-30AD-A070-E9881F072F4C","_rev":"5-bb70abfec5de06d15fdc8bddb0153c50","data":{"department":"Pharmacy","expenseAccount":null,"name":"Acetaminophen 500 MG","price":12,"quantity":10,"total":null,"lastModified":"2015-11-13T16:38:20.042Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.042Z","quantity":"2015-11-13T16:38:20.042Z","price":"2015-11-13T16:38:20.042Z","department":"2015-11-13T16:38:20.042Z"}},"_revisions":{"start":5,"ids":["bb70abfec5de06d15fdc8bddb0153c50","4da37ad0ef6925a3838db19d86c306e7","d7d4a2a5502c92b6225a354639f503d2","882434ab090177ffc5da7f5a20ec1663","f189693c2c4fac5b634b703dc3e253d7"]}}]} +{"seq":74} +{"docs":[{"_id":"lineItemDetail_2_6006AE5D-5B16-4665-BF2A-0549CFA18B05","_rev":"1-b16638cf08bbd83f98e84c1b682249f9","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-12T22:00:59.427Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-12T22:00:59.427Z","expenseAccount":"2015-11-12T22:00:59.427Z","quantity":"2015-11-12T22:00:59.427Z","price":"2015-11-12T22:00:59.427Z","department":"2015-11-12T22:00:59.427Z"}}},{"_id":"lineItemDetail_2_89E9DCF0-E5FD-F0FA-A34F-8A80A2892934","_rev":"5-4008862e1efdded3cc2c5e77e445f214","data":{"department":null,"expenseAccount":null,"name":"Days","price":45,"quantity":11,"total":null,"lastModified":"2015-11-13T16:38:51.843Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.039Z","quantity":"2015-11-13T16:38:20.039Z","price":"2015-11-13T16:38:51.843Z"}},"_revisions":{"start":5,"ids":["4008862e1efdded3cc2c5e77e445f214","03d46eaecd46f6336d0ccc07f6881cfd","376b97227567079e8dfd82bad223e1de","d18636e346ef69fa1d9617e177148704","74f4293f387b050c85e3a520eccfeb1a"]}},{"_id":"lineItemDetail_2_BAFBDD02-6953-5E5F-A7F6-59839997B2FC","_rev":"1-461b69d47c783b5fddc3e697d42d0764","data":{"department":null,"expenseAccount":null,"name":"Days","price":null,"quantity":11,"total":null,"lastModified":"2015-11-12T22:00:59.422Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-12T22:00:59.422Z","quantity":"2015-11-12T22:00:59.422Z"}}},{"_id":"lineItemDetail_2_EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","_rev":"5-b4ecd3a3ca2ec72abb2b265aa6a865a0","data":{"department":"O.R.","expenseAccount":null,"name":"Leg Casting","price":2,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.044Z","modifiedBy":"Admin User","pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"name":"2015-11-13T16:38:20.044Z","expenseAccount":"2015-11-13T16:38:20.044Z","quantity":"2015-11-13T16:38:20.044Z","price":"2015-11-13T16:38:20.044Z","department":"2015-11-13T16:38:20.044Z"}},"_revisions":{"start":5,"ids":["b4ecd3a3ca2ec72abb2b265aa6a865a0","88e87af8cff7a93b0d14ad1152dc40bf","d9d966a397398a53cf66ad2452e904e2","48400862e9be71150140585017cf0b3e","a2a39c01032abf83c945fc5dcbfa1fdc"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-13d3772f546b5c7a9dfcbb9ad8c27a63","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Leg casting"]}},{"_id":"lookup_2_imaging_pricing_types","_rev":"1-508f1018b1af1f65de250cd110e8ae4a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Imaging Procedure"]}},{"_id":"lookup_2_lab_pricing_types","_rev":"1-f64bac71fc698147e7b5802e38d326ec","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Lab Procedure"]}},{"_id":"lookup_2_physician_list","_rev":"1-fe60344a75c70341b869b5211a85d89c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Watson"]}},{"_id":"lookup_2_procedure_list","_rev":"2-5818e879a750999f9f317d262b70cabd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fix broken leg","Leg casting"]},"_revisions":{"start":2,"ids":["5818e879a750999f9f317d262b70cabd","13d3772f546b5c7a9dfcbb9ad8c27a63"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-e4823048fbfcefa1b230c38548dd6465","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-4f316909ed8500d0f80cf20a684ce343","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy"]}},{"_id":"medication_2_7F51BB93-6086-49D0-A284-FEB6C6690C95","_rev":"2-c438baf544b44547413edf90837cab1a","data":{"notes":null,"prescription":"Take two once a day for 5 days","prescriptionDate":"2015-11-13T05:00:00.000Z","quantity":10,"refills":null,"requestedDate":"2015-11-13T16:23:27.163Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-11-13T16:23:27.176Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","medicationTitle":"Acetaminophen 500 MG","priceOfMedication":null,"modifiedFields":{"prescriptionDate":"2015-11-13T16:23:27.176Z","prescription":"2015-11-13T16:23:27.176Z","quantity":"2015-11-13T16:23:27.176Z","status":"2015-11-13T16:23:27.176Z","requestedBy":"2015-11-13T16:23:27.176Z","requestedDate":"2015-11-13T16:23:27.176Z"}},"_revisions":{"start":2,"ids":["c438baf544b44547413edf90837cab1a","f441e894d0aaaab3c3c394186e0cad67"]}},{"_id":"overridePrice_2_9C4DC6CF-EC9B-B303-A483-6B80930CC658","_rev":"1-73b042aa49125ce4f3961ed9316756f7","data":{"price":4,"lastModified":"2015-11-11T21:52:55.514Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:52:55.514Z"}}},{"_id":"overridePrice_2_FBF5B1A6-BBEE-6D17-99C8-EB4A91358183","_rev":"1-87dc3dc101c2d1b1a122e74de183281a","data":{"price":2,"lastModified":"2015-11-11T21:06:20.663Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:06:20.663Z"}}},{"_id":"patient_2_8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","_rev":"4-c630f25455e20c41f394ac77f0f7a73c","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"TCH 00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:51:59.117Z","modifiedBy":"Admin User","payments":[],"modifiedFields":{"friendlyId":"2015-11-12T21:13:52.796Z","firstName":"2015-11-12T21:13:52.796Z","middleName":"2015-11-12T21:13:52.796Z","lastName":"2015-11-12T21:13:52.796Z","admitted":"2015-11-12T21:15:12.204Z","sex":"2016-02-22T21:51:59.117Z"}},"_revisions":{"start":4,"ids":["c630f25455e20c41f394ac77f0f7a73c","63565b6c7b01bbb4af8dbd37a6cd7ca2","7ab83617d991bfa730e55757d90c35ad","d5bb9506d7ebd07a2fd7e2bd8a9afc03"]}},{"_id":"priceProfile_2_5331626A-EF59-E723-AC44-A063049201DC","_rev":"1-c9ede1cd1775d2ccc9e0bcc5d099d614","data":{"name":"Half off","discountAmount":null,"discountPercentage":50,"lastModified":"2015-11-11T21:05:25.047Z","modifiedBy":"Admin User","modifiedFields":{"name":"2015-11-11T21:05:25.047Z","discountPercentage":"2015-11-11T21:05:25.047Z"}}},{"_id":"pricing_2_1D198B41-338B-6E49-8BB1-4696D5DAD715","_rev":"1-5fd5619f2cc1dcf4e7c051add2deaf5d","data":{"category":"Procedure","expenseAccount":null,"name":"Leg Casting","price":2,"pricingType":null,"lastModified":"2015-11-11T21:53:29.953Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:29.953Z","name":"2015-11-11T21:53:29.953Z","price":"2015-11-11T21:53:29.953Z"}}},{"_id":"pricing_2_5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","_rev":"1-7f85b8fb293360badee861fb4a685721","data":{"category":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"pricingType":null,"lastModified":"2015-11-11T21:53:52.661Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:52.661Z","name":"2015-11-11T21:53:52.661Z","price":"2015-11-11T21:53:52.661Z"}}},{"_id":"pricing_2_5931700E-7965-23B1-9835-2D1615E7E755","_rev":"2-300f644f420f7f76581093329a9aa519","data":{"category":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"pricingType":"Imaging Procedure","lastModified":"2015-11-11T21:52:55.549Z","modifiedBy":"Admin User","pricingOverrides":["9C4DC6CF-EC9B-B303-A483-6B80930CC658"],"modifiedFields":{"category":"2015-11-11T21:52:55.549Z","name":"2015-11-11T21:52:55.549Z","price":"2015-11-11T21:52:55.549Z","pricingType":"2015-11-11T21:52:55.549Z"}},"_revisions":{"start":2,"ids":["300f644f420f7f76581093329a9aa519","9f00f9d6a35374e7d7fcbeffd8d4697b"]}},{"_id":"pricing_2_F71A1788-3407-515B-8006-F9CC788CA8EA","_rev":"2-9762d8a2d76d242671a3bea610a0904f","data":{"category":"Lab","expenseAccount":null,"name":"Blood test","price":123,"pricingType":"Lab Procedure","lastModified":"2015-11-11T21:06:20.719Z","modifiedBy":"Admin User","pricingOverrides":["FBF5B1A6-BBEE-6D17-99C8-EB4A91358183"],"modifiedFields":{"category":"2015-11-11T21:06:20.719Z","name":"2015-11-11T21:06:20.719Z","price":"2015-11-11T21:06:20.719Z","pricingType":"2015-11-11T21:06:20.719Z"}},"_revisions":{"start":2,"ids":["9762d8a2d76d242671a3bea610a0904f","e6eada16de79ddba78e890c01837a3f5"]}},{"_id":"procCharge_2_0834BF27-A2E0-5ADD-9509-B97CA547E532","_rev":"1-0bb58d85915b11cbcb1547ba44b86f5f","data":{"quantity":1,"dateCharged":"2015-11-13T05:00:00.000Z","lastModified":"2015-11-13T16:11:54.012Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-13T16:11:54.012Z","quantity":"2015-11-13T16:11:54.012Z"}}},{"_id":"procCharge_2_17BC9913-E49F-FB8A-AA42-4F617D839510","_rev":"1-2917bd58af0d9cbb9e3835013c857d2f","data":{"quantity":1,"dateCharged":"2015-11-12T05:00:00.000Z","lastModified":"2015-11-12T21:53:52.879Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-12T21:53:52.879Z","quantity":"2015-11-12T21:53:52.879Z"}}},{"_id":"procCharge_2_2648E500-C287-2EE4-B569-99D6291FB46C","_rev":"2-1875764ed6d4a41e96277d678bcda2b3","_deleted":true,"_revisions":{"start":2,"ids":["1875764ed6d4a41e96277d678bcda2b3","f0554786c3ad14c941dced65e1df8649"]}},{"_id":"procCharge_2_412AD48B-EDD4-E5E2-8134-BB3B5E459972","_rev":"1-2cdee6e8d8fd1207c073b5e6f33b4c6e","data":{"quantity":12,"dateCharged":"2015-11-03T05:00:00.000Z","lastModified":"2015-11-12T21:18:30.366Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-12T21:18:30.366Z","quantity":"2015-11-12T21:18:30.366Z"}}},{"_id":"procCharge_2_561AD584-144B-D21F-840A-8600B8D900CF","_rev":"1-8f30246e0bba661deeb2c08617ec1128","data":{"quantity":12,"dateCharged":"2015-11-11T05:00:00.000Z","lastModified":"2015-11-13T16:24:24.528Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-13T16:24:24.528Z","quantity":"2015-11-13T16:24:24.528Z"}}},{"_id":"procCharge_2_704FA289-CA15-A178-B571-D0ECCE8229F3","_rev":"2-6d00bf1656e7ef89bc6ba38c3711982b","_deleted":true,"_revisions":{"start":2,"ids":["6d00bf1656e7ef89bc6ba38c3711982b","2103b76190a412ab081bae469ef27dee"]}},{"_id":"procCharge_2_A28911F7-FC62-9F3D-A82E-8EB0D43B9B68","_rev":"2-3959e9c3eb93a0fd7bc1d36ece0dbcd9","_deleted":true,"_revisions":{"start":2,"ids":["3959e9c3eb93a0fd7bc1d36ece0dbcd9","b5b4fd9fa56d91b689be62a9fc0506ae"]}},{"_id":"procCharge_2_A2F0320B-AFD0-BB29-AFFE-6470FD537D05","_rev":"1-d29a0c613aa6282b87a3e3eb37278453","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"quantity":12,"dateCharged":"2016-02-09T20:18:54.966Z","lastModified":"2016-02-09T20:18:59.012Z","modifiedBy":"Admin User","medication":"igxvfw26_lh","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T20:18:59.012Z","quantity":"2016-02-09T20:18:59.012Z","medicationTitle":"2016-02-09T20:18:59.012Z","priceOfMedication":"2016-02-09T20:18:59.012Z"}}},{"_id":"procCharge_2_BDAC9E94-96A0-1994-9196-BD3F56F891CA","_rev":"1-090a8baf0cf5219ab842f6a5f85c98b2","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:20:16.119Z","lastModified":"2016-02-09T19:20:22.089Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:20:22.089Z","quantity":"2016-02-09T19:20:22.089Z","medication":"2016-02-09T19:20:22.089Z","medicationTitle":"2016-02-09T19:20:22.089Z","priceOfMedication":"2016-02-09T19:20:22.089Z"}}},{"_id":"procCharge_2_F632124D-557D-0B35-8213-F7054DE6AFB0","_rev":"1-f88672a41bab0bf53f3d744944b623e5","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:16:13.269Z","lastModified":"2016-02-09T19:16:22.209Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:16:22.209Z","quantity":"2016-02-09T19:16:22.209Z","medication":"2016-02-09T19:16:22.209Z","medicationTitle":"2016-02-09T19:16:22.209Z","priceOfMedication":"2016-02-09T19:16:22.209Z"}}},{"_id":"procedure_2_539C4B9B-B275-EF14-8BA2-9CAC6403424A","_rev":"1-e4a243fe73d67885206ff1d406beba1a","data":{"anesthesiaType":null,"anesthesiologist":null,"assistant":null,"description":"Leg casting","cptCode":"Leg casting","location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-12T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-12T21:54:00.381Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["17BC9913-E49F-FB8A-AA42-4F617D839510"],"modifiedFields":{"procedureDate":"2015-11-12T21:54:00.381Z","description":"2015-11-12T21:54:00.381Z","cptCode":"2015-11-12T21:54:00.381Z","timeStarted":"2015-11-12T21:54:00.381Z","timeEnded":"2015-11-12T21:54:00.381Z","physician":"2015-11-12T21:54:00.381Z"}}},{"_id":"procedure_2_653A07CE-66E2-1DC8-A83C-4A25934559F0","_rev":"11-9852c642c6108359ec3d1a1915be7d77","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"Fix broken leg","cptCode":null,"location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-13T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-13T16:11:57.940Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["0834BF27-A2E0-5ADD-9509-B97CA547E532","A2F0320B-AFD0-BB29-AFFE-6470FD537D05"],"modifiedFields":{"procedureDate":"2015-11-13T16:11:57.940Z","description":"2015-11-13T16:11:57.940Z","timeStarted":"2015-11-13T16:11:57.940Z","timeEnded":"2015-11-13T16:11:57.940Z","physician":"2015-11-13T16:11:57.940Z","anesthesiaType":"2015-11-13T16:11:57.940Z"}},"_revisions":{"start":11,"ids":["9852c642c6108359ec3d1a1915be7d77","32f7b134f4a1489bad30b20b41a402b7","79317aa8224c831799a41588c9c00572","25edbe7f3e8f872997aec5b8e57959c0","53e45632484af05ac967f6af430bced9","8700b634cefddb7c2ef0b810e4d8241a","e0abfee94018abcefb7b541c6bb7b242","715ed4e72deba043868bfbe500f964a0","483b770e04706f935dc6275abf496a3a","0f22a93f70def208660a024b0fa6a6c6","b078e6e7004154529f8fd0901b60ed19"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_invoice","_rev":"3-f0ef6923c78e739d9228517a4813b646","data":{"prefix":null,"value":3},"_revisions":{"start":3,"ids":["f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"sequence_2_patient","_rev":"1-5bc31ffefa482f2e66299cf0704623c8","data":{"prefix":null,"value":1}},{"_id":"visit_2_666DFC61-3230-A865-A145-C7D9139DA1CA","_rev":"12-9f26178fcda83e39cc9df1950035a7fc","data":{"dischargeInfo":null,"endDate":"2015-11-12T05:00:00.000Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-01T04:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-12T21:47:53.994Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","vitals":[],"procedures":["653A07CE-66E2-1DC8-A83C-4A25934559F0"],"medication":["7F51BB93-6086-49D0-A284-FEB6C6690C95"],"labs":["0762040A-CAC7-130F-8D0C-E3DE9245EE38"],"imaging":["9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9"],"charges":["561AD584-144B-D21F-840A-8600B8D900CF"],"modifiedFields":{"visitType":"2015-11-12T21:15:12.160Z","startDate":"2015-11-12T21:15:12.160Z","status":"2015-11-12T21:47:53.994Z","outPatient":"2015-11-12T21:15:12.160Z","endDate":"2015-11-12T21:47:53.994Z"}},"_revisions":{"start":12,"ids":["9f26178fcda83e39cc9df1950035a7fc","64ef0abb729090bd64b948f9ca2318de","19a1560274f7e5dc07c3b6b0543278a1","793cb2bc5919ef9ced471818f5e7c3b5","8201fa77027c3929455f4c9368ce1c32","4f345e06fefbc87fa23fa1a0d194d1ee","e82f9737c00c8b9004653355ed0cb743","03b09430dde4f6d3c5b62f1c5c6b1378","1db70a4f91b8ed3da25df05dcc91713d","5745b4455c849281c543b2c447feb480","37ad5eae5583240c5143012937658d48","c35ad6c0332fc471d3a8fa485a48d1de"]}}]} {"seq":112} diff --git a/tests/helpers/run-with-pouch-dump.js b/tests/helpers/run-with-pouch-dump.js index 9a0fbc497c..7441651b8d 100644 --- a/tests/helpers/run-with-pouch-dump.js +++ b/tests/helpers/run-with-pouch-dump.js @@ -75,6 +75,7 @@ function runWithPouchDumpAsyncHelper(app, dumpName, functionToRun) { return new Ember.RSVP.Promise(function(resolve) { promise.then(function() { + db.setMaxListeners(30); createPouchViews(db, true, dumpName).then(function() { functionToRun(); andThen(function() { From 6af3e2c559038644e915ee7f0e2dc2e0a1edd60b Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 6 Mar 2017 16:37:54 -0500 Subject: [PATCH 106/124] Fixed build error --- config/environment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environment.js b/config/environment.js index 19a4ebcc91..28b5996fb5 100644 --- a/config/environment.js +++ b/config/environment.js @@ -1,8 +1,8 @@ -/* jshint node: true */ /* eslint-env node */ +/* eslint no-var: 0 */ module.exports = function(environment) { - let ENV = { + var ENV = { modulePrefix: 'hospitalrun', environment, rootURL: '/', From d4bbd83af830706fed9e62ea5be9ed5e68403505 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 09:28:07 +0100 Subject: [PATCH 107/124] Remove discharge report compulsory next appointment modal --- app/locales/en/translations.js | 2 -- app/visits/edit/controller.js | 28 ++++++++++------------------ app/visits/edit/route.js | 1 - 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 74f9563b3d..87c8762fd8 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,7 +1105,6 @@ export default { }, reports: { titles: { - followup: 'Create Followup Appointment', saved: 'The report has been saved' }, form: { @@ -1147,7 +1146,6 @@ export default { } }, messages: { - followup: 'There is no follow up appointment for this patient.', delete: 'Are you sure you wish to delete this report?', saved: 'The report has been saved.' } diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 0c1f1485c0..58ed40ff3f 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -37,7 +37,6 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn } }), noReport: false, - nextAppointment: null, canAddAppointment: computed('model.isNew', function() { return (!this.get('model.isNew') && this.currentUserCan('add_appointment')); }), @@ -406,6 +405,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn } }, + editReport(report) { + report.set('returnToVisit', this.get('model.id')); + this.transitionToRoute('reports.edit', report); + }, + newPatientChanged(createNewPatient) { set(this, 'model.createNewPatient', createNewPatient); let model = this.get('model'); @@ -435,23 +439,6 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this.send('openModal', 'patients.notes', model); }, - newReport() { - let next = this.get('nextAppointment.content'); - if (!this.get('model.outPatient') && !next) { - let i18n = this.get('i18n'); - let updateMesage = i18n.t('reports.messages.followup'); - let updateTitle = i18n.t('reports.titles.followup'); - this.displayAlert(updateTitle, updateMesage); - return false; - } - this._addChildObject('reports.edit'); - }, - - editReport(report) { - report.set('returnToVisit', this.get('model.id')); - this.transitionToRoute('reports.edit', report); - }, - newAppointment() { this._addChildObject('appointments.edit'); }, @@ -468,6 +455,11 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('medication.edit'); }, + newReport() { + this._addChildObject('reports.edit'); + }, + + showAddProcedure() { this._addChildObject('procedures.edit'); }, diff --git a/app/visits/edit/route.js b/app/visits/edit/route.js index 9b6932b5e0..27700d5901 100644 --- a/app/visits/edit/route.js +++ b/app/visits/edit/route.js @@ -55,7 +55,6 @@ export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, PatientVi return Ember.isEmpty(reports) ? '' : reports.get('firstObject'); }); controller.set('report', DS.PromiseObject.create({ promise })); - controller.set('nextAppointment', this.getPatientFutureAppointment(model)); this._super(controller, model); }, From f0ee0b384537d3f3bf4baaacf35084beb85a9ac6 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 09:46:54 +0100 Subject: [PATCH 108/124] Fix `completed by` on report page --- app/reports/edit/template.hbs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index c22284fef0..a7ec5840fa 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -184,13 +184,14 @@ {{custom-form-manager model=model formType="dischargeReport"}} -
              - - {{model.modifiedBy}} -
              + {{#if model.modifiedBy}} +
              + + {{model.modifiedBy}} +
              + {{/if}} {{/if}} - {{/em-form}} {{/edit-panel}}
          From c1f82b016d4fc918cd963481a379debc6f8be593 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 7 Mar 2017 10:52:05 +0100 Subject: [PATCH 109/124] Style select element properly; Add titles to report --- app/locales/en/translations.js | 4 +++- app/reports/edit/template.hbs | 5 +++++ app/styles/_print.scss | 8 ++++++++ app/visits/edit/controller.js | 1 - 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 87c8762fd8..290fd5d9d4 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -1105,7 +1105,9 @@ export default { }, reports: { titles: { - saved: 'The report has been saved' + saved: 'Report saved', + opdTitle: 'OPD Report', + dischargeReport: 'Discharge Report' }, form: { visitDate: 'Date of Visit', diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index a7ec5840fa..1789130db3 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -14,6 +14,11 @@ {{#if headerLine3}} {{headerLine3}}
          {{/if}} + {{#if isOutPatient}} +

          {{t 'reports.titles.opdTitle' }}

          + {{else}} +

          {{t 'reports.titles.dischargeReport' }}

          + {{/if}}
        {{#edit-panel editPanelProps=editPanelProps}} diff --git a/app/styles/_print.scss b/app/styles/_print.scss index 67337bde3e..750c1e367c 100644 --- a/app/styles/_print.scss +++ b/app/styles/_print.scss @@ -50,6 +50,14 @@ font-size: .8em; } + .report select { + outline: 0; + border: 0; + text-overflow: ''; + -moz-appearance: none; + -webkit-appearance: none; + } + .report .panel-primary { position: absolute; left: 0; diff --git a/app/visits/edit/controller.js b/app/visits/edit/controller.js index 58ed40ff3f..b05c6cf017 100644 --- a/app/visits/edit/controller.js +++ b/app/visits/edit/controller.js @@ -459,7 +459,6 @@ export default AbstractEditController.extend(AddNewPatient, ChargeActions, Diagn this._addChildObject('reports.edit'); }, - showAddProcedure() { this._addChildObject('procedures.edit'); }, From ac35a25f6450b9a5c4f981af786caa8fc51f0c54 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Tue, 7 Mar 2017 12:47:55 +0100 Subject: [PATCH 110/124] fix: fix new user title bug after a new user has been added --- app/users/edit/controller.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/users/edit/controller.js b/app/users/edit/controller.js index b2d0733f2e..84e472f01b 100644 --- a/app/users/edit/controller.js +++ b/app/users/edit/controller.js @@ -40,6 +40,10 @@ export default AbstractEditController.extend(UserRoles, { } updateModel.save().then(() => { this.displayAlert(this.get('i18n').t('messages.userSaved'), this.get('i18n').t('messages.userHasBeenSaved')); + let editTitle = this.get('i18n').t('labels.editUser'); + let sectionDetails = {}; + sectionDetails.currentScreenTitle = editTitle; + this.send('setSectionHeader', sectionDetails); }).catch((error) => this.send('error', error)); } } From 3241938c70227771a3a5276cdf0444da21b5904d Mon Sep 17 00:00:00 2001 From: Mofesola Babalola Date: Wed, 8 Mar 2017 15:06:59 +0100 Subject: [PATCH 111/124] Added deploy branches to .travis.yml --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index e14b1b3076..82dc8deaa4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,5 +24,18 @@ deploy: tags: true repo: eHealthAfrica/hospitalrun-frontend branch: master + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: develop + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: stage + on: + tags: true + repo: eHealthAfrica/hospitalrun-frontend + branch: eHA/Polyclinic + after_deploy: - script/server_build.sh From cab65ea3332668dfb1407f8bc368a2b1b1e3164f Mon Sep 17 00:00:00 2001 From: ANISHA SWAIN Date: Wed, 8 Mar 2017 22:32:56 +0530 Subject: [PATCH 112/124] Solved issue #313 - Button not visible properly (#971) * changed button style * travis error resolved * button colour fixed for hover state --- app/styles/_variables_mixins.scss | 2 ++ app/styles/components/_buttons.scss | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/styles/_variables_mixins.scss b/app/styles/_variables_mixins.scss index 5285626e8c..8809ea9ca8 100644 --- a/app/styles/_variables_mixins.scss +++ b/app/styles/_variables_mixins.scss @@ -21,6 +21,7 @@ $blue_lightest: #eff2f5; $blue_lightest2: #dee2e7; $red: #ff6d6f; $red_light: rgba($red,.3); +$red_lighter: rgba($red,.75); $red_dark: #c3124e; $gray_light: #d9d9d9; $gray: rgba($navy,.65); @@ -31,6 +32,7 @@ $sidebar_icon_lighter: $navy_light; $sidebar_sublink_text: #c2d2e3; $view_sub_nav: #6784a2; $content_border: $blue_lightest; +$brown: #711214; // from misc diff --git a/app/styles/components/_buttons.scss b/app/styles/components/_buttons.scss index 8ffddc3120..27d137fa3e 100644 --- a/app/styles/components/_buttons.scss +++ b/app/styles/components/_buttons.scss @@ -1,17 +1,17 @@ .btn { &.on-white { - background-color: $blue_light; - color: $navy; + background-color: #00c4a2; + color: $white; } &.warning { - background-color: $red_light; - color: $red; + background-color: #ff6d6f; + color: $white; &:hover, &:focus { - background-color: $red; - color: $white; + background-color: $red_lighter; + color: $brown; } } @@ -50,7 +50,7 @@ // needs converted to variable &:hover, - &:focus { background-color: #00c4a2; } + &:focus { background-color: #08987f; } // needs converted to variable &:active, @@ -64,8 +64,8 @@ &.disabled:active, &[disabled]:active { opacity: .7; - background-color: $green; - color: $white; + background-color: #dbebff; + color: $black; } } From b7bbbc711161de2a9a06c9f9fd4473c5ef262629 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Thu, 9 Mar 2017 12:02:49 +0100 Subject: [PATCH 113/124] fix: fix test for new user title bug --- tests/acceptance/users-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/users-test.js b/tests/acceptance/users-test.js index d1105e6db1..00993a5929 100644 --- a/tests/acceptance/users-test.js +++ b/tests/acceptance/users-test.js @@ -119,6 +119,7 @@ test('create new user', function(assert) { waitToAppear('.modal-dialog'); andThen(() => { assert.equal(find('.modal-title').text(), 'User Saved', 'User was saved successfully'); + assert.equal(find('.view-current-title').text(), 'Edit User', 'Page title changed to Edit User'); }); click('button:contains(Ok)'); }); From 3d127823080461487b3fc916430071f9bc410234 Mon Sep 17 00:00:00 2001 From: chima1707 Date: Fri, 10 Mar 2017 11:48:24 +0100 Subject: [PATCH 114/124] fix: updated report template with testing attributes on fields --- app/reports/edit/template.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 1789130db3..78da867d8a 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -33,7 +33,7 @@ {{/if}}
        -
      {{/if}} diff --git a/app/templates/components/take-photo.hbs b/app/templates/components/take-photo.hbs index 3dc2cfe7ea..05f2a3239d 100644 --- a/app/templates/components/take-photo.hbs +++ b/app/templates/components/take-photo.hbs @@ -1,11 +1,13 @@ {{#if canCaptureVideo}}
      - + {{select-list - action=photoSourceChange + action=(action 'photoSourceChange') class='form-control' content=photoSources id='photo-source' + optionLabelPath="label" + optionValuePath="value" value=photoSource }}
      @@ -13,7 +15,7 @@
      {{select-list - action=cameraChange + action=(action 'cameraChange') class='form-control' content=videoSources id='camera' @@ -42,7 +44,6 @@
      {{/if}} -
      -

      {{t 'components.takePhoto.uploadPhoto'}}

      - {{image-upload label=(t 'components.takePhoto.uploadFile') property="fileName" selectedFile=photoFile }} -
      +{{#if showFileUpload}} + {{image-upload label=(t 'components.takePhoto.uploadFile') property="fileName" selectedFile=photoFile isImage=isImage}} +{{/if}} diff --git a/app/utils/pouch-views.js b/app/utils/pouch-views.js index db13bf86be..4f229dccf3 100644 --- a/app/utils/pouch-views.js +++ b/app/utils/pouch-views.js @@ -266,6 +266,12 @@ let designDocs = [{ emit([doc.data.status, requestedDate, imagingDate, doc._id]);` ), version: 4 +}, { + name: 'inventory_by_friendly_id', + function: generateView('inventory', + 'emit([doc.data.friendlyId, doc._id]);' + ), + version: 1 }, { name: 'inventory_by_name', function: generateView('inventory', @@ -292,6 +298,43 @@ let designDocs = [{ } }.toString()), version: 5 +}, { + name: 'incident_by_friendly_id', + function: generateView('incident', + 'emit([doc.data.friendlyId, doc._id]);' + ), + version: 1 +}, { + name: 'incident_by_date', + function: generateView('incident', + `${generateDateForView('dateOfIncident')} + emit([dateOfIncident, doc._id]);` + ), + version: 1 +}, { + name: 'open_incidents_by_user', + function: generateView('incident', + `if (doc.data.status !== "Closed") { + emit([doc.data.reportedBy, doc._id]); + }` + ), + sort: generateSortFunction(function(a, b) { + let sortBy = ''; + if (req.query && req.query.sortKey) { + sortBy = req.query.sortKey; + return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]); + } + return 0; // Don't sort + }.toString()), + version: 1 +}, { + name: 'closed_incidents_by_user', + function: generateView('incident', + `if (doc.data.status === "Closed") { + emit([doc.data.reportedBy, doc._id]); + }` + ), + version: 1 }, { name: 'inventory_by_type', function: generateView('inventory', diff --git a/bower.json b/bower.json index 8eda592c34..e51b8b50b3 100644 --- a/bower.json +++ b/bower.json @@ -16,6 +16,7 @@ "fullcalendar-scheduler": "^1.4.0" }, "devDependencies": { - "timekeeper": "^1.0.0" + "timekeeper": "^1.0.0", + "webrtc-adapter": "^3.1.3" } } diff --git a/config/environment.js b/config/environment.js index 28b5996fb5..54cd1a20c6 100644 --- a/config/environment.js +++ b/config/environment.js @@ -28,7 +28,7 @@ module.exports = function(environment) { 'connect-src': "'self'", 'default-src': "'self'", 'frame-src': "'self'", - 'img-src': "'self' filesystem: data:", + 'img-src': "'self' filesystem: data: blob:", 'script-src': "'self' 'unsafe-inline' 'unsafe-eval'", 'style-src': "'self' 'unsafe-inline'" }; diff --git a/ember-cli-build.js b/ember-cli-build.js index 5bbbe882a8..9999734a8a 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -30,6 +30,7 @@ module.exports = function(defaults) { app.import('bower_components/pikaday/css/pikaday.css'); app.import('vendor/octicons/octicons/octicons.css'); app.import('bower_components/pouchdb-load/dist/pouchdb.load.js'); + app.import('bower_components/webrtc-adapter/release/adapter.js'); if (EmberApp.env() !== 'production') { app.import('bower_components/timekeeper/lib/timekeeper.js', { type: 'test' }); diff --git a/package.json b/package.json index 67dda4a852..3a5b95d30b 100644 --- a/package.json +++ b/package.json @@ -79,8 +79,8 @@ "eslint-plugin-ember-suave": "^1.0.0", "express": "^4.8.5", "glob": "^7.1.0", - "hospitalrun-dblisteners": "0.9.5", - "hospitalrun-server-routes": "0.9.9", + "hospitalrun-dblisteners": "0.9.6", + "hospitalrun-server-routes": "0.9.10", "loader.js": "^4.0.11", "nano": "6.2.0", "pouchdb": "5.4.5", diff --git a/server/config-example.js b/server/config-example.js index 83af41bada..4ad07b0271 100644 --- a/server/config-example.js +++ b/server/config-example.js @@ -1,3 +1,4 @@ +/* eslint-disable */ var config = { couchDbServer: 'localhost', couchDbPort: '5984', @@ -10,7 +11,9 @@ var config = { serverPort: '4200', server: 'localhost', useGoogleAuth: false, - useSSL: false + useSSL: false, + imagesdir: '/tmp/patientimages', + attachmentsDir: 'tmp/attachments', }; config.couchCredentials = function() { diff --git a/tests/acceptance/incident-test.js b/tests/acceptance/incident-test.js new file mode 100644 index 0000000000..4adb4ee614 --- /dev/null +++ b/tests/acceptance/incident-test.js @@ -0,0 +1,294 @@ +import Ember from 'ember'; +import { module, test } from 'qunit'; +import moment from 'moment'; +import startApp from 'hospitalrun/tests/helpers/start-app'; + +const DATE_FORMAT = 'l'; +const DATE_TIME_FORMAT = 'l h:mm A'; +const DEPARTMENT = 'Pharmacy'; +const INCIDENT_CATEGORY = 'Patient Falls'; +const INCIDENT_CATEGORY_ITEM = 'Ambulating'; +const INCIDENT_DESCRIPTION = 'Patient fell on wet floor that was recently mopped.'; +const INCIDENT_NOTES = 'Additional Notes here'; +const EDIT_INCIDENT_NOTE = 'The wet floor sign had fallen down and was no longer visible.'; +const REPORTED_TO = 'Jack Bridges'; + +module('Acceptance | Incidents', { + beforeEach() { + this.application = startApp(); + }, + + afterEach() { + Ember.run(this.application, 'destroy'); + } +}); + +test('Incident category management', function(assert) { + runWithPouchDump('incident', function() { + authenticateUser(); + visit('/admin/inc-category'); + andThen(() => { + assert.equal(currentURL(), '/admin/inc-category', 'Incident Categories url is correct'); + click('button:contains(+ new category)'); + }); + andThen(() => { + assert.equal(currentURL(), '/admin/inc-category/edit/new', 'New incident category URL is correct'); + fillIn('.incident-category-name input', 'Infection Control'); + addItem(assert, 'Surgical Site Infection'); + }); + andThen(() => { + addItem(assert, 'Hospital Acquired Infection'); + }); + andThen(() => { + click('button:contains(Delete)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Delete Item', 'Delete Item modal appears'); + click('.modal-footer button:contains(Ok)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.incident-category-item:contains(Surgical Site Infection)').length, + 0, 'Deleted incident category item disappears'); + click('.panel-footer button:contains(Update)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Incident Category Saved', + 'Incident Category saved modal appears'); + click('button:contains(Return)'); + }); + andThen(() => { + assert.equal(currentURL(), '/admin/inc-category', 'Incident Categories url is correct'); + assert.equal(find('td.incident-catergory-name:contains(Infection Control)').length, + 1, 'New incident category displays in listing'); + }); + }); +}); + +test('Incident creation and editing', function(assert) { + runWithPouchDump('incident', function() { + let now = moment(); + authenticateUser(); + visit('/incident'); + andThen(() => { + assert.equal(currentURL(), '/incident', 'Incident listing url is correct'); + click('button:contains(+ new incident)'); + }); + andThen(() => { + assert.equal(currentURL(), '/incident/edit/new', 'Incident edit url is correct'); + click('.sentinel-event input'); + fillIn('.incident-date input', now.format(DATE_TIME_FORMAT)); + typeAheadFillIn('.incident-department', DEPARTMENT); + fillIn('.reported-to', REPORTED_TO); + select('.incident-category', INCIDENT_CATEGORY); + waitToAppear(`.incident-category-item option:contains(${INCIDENT_CATEGORY_ITEM})`); + }); + andThen(() => { + select('.incident-category-item', INCIDENT_CATEGORY_ITEM); + typeAheadFillIn('.patient-name', 'Joe Bagadonuts - P00001'); + waitToAppear('.patient-id:contains(P00001)'); + }); + andThen(() => { + assert.equal(find('.patient-id').text(), 'P00001', 'Selected patient id appears'); + fillIn('.incident-description textarea', 'Patient blacked out and fell down.'); + }); + andThen(() => { + click('.panel-footer button:contains(Add)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Incident Saved', ' Incident Saved modal appears'); + click('.modal-footer button:contains(Ok)'); + }); + andThen(() => { + assert.equal(find('.tab-nav li a:contains(Notes)').length, 1, 'Notes tab appears'); + assert.equal(find('.tab-nav li a:contains(Attachment)').length, 1, 'Attachment tab appears'); + assert.equal(find('.tab-nav li a:contains(Harm Score)').length, 1, 'Harm Score custom form tab appears'); + assert.equal(find('.tab-nav li a:contains(+ Add Form)').length, 1, 'Add Custom form tab appears'); + click('button:contains(+ New Note)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + fillIn('.note-description textarea', INCIDENT_NOTES); + click('.modal-footer button:contains(Add)'); + }); + andThen(() => { + waitToDisappear('.modal-dialog'); + waitToAppear(`.note-description:contains(${INCIDENT_NOTES})`); + }); + andThen(() => { + assert.equal(find(`.note-description:contains(${INCIDENT_NOTES})`).length, 1, 'Added note appears in listing'); + click('.tab-nav li a:contains(Attachment)'); + }); + andThen(() => { + click('button:contains(+ New Attachment)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Add Attachment', 'Add attachment dialog appears'); + // Right now we don't have a good way to test adding attachments. + click('.modal-footer button:contains(Cancel)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + click('.tab-nav li a:contains(Harm Score)'); + }); + andThen(() => { + assert.equal(find('#customForm0 label:contains(No Actual Event)').length, 1, 'Always add custom form renders'); + click('.tab-nav li a:contains(+ Add Form)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Add Custom Form', 'Add custom form dialog appears'); + select('.form-to-add', 'Incident'); + }); + andThen(() => { + click('.modal-footer button:contains(Add Form)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.tab-nav li a:contains(Pre-Incident Risk Assessment)').length, 1, 'Pre-Incident Risk Assessment form tab now appears'); + assert.equal(find('.tab-nav li a:contains(+ Add Form)').length, 0, 'Add Custom form tab disappears'); + click('.tab-nav li a:contains(Pre-Incident Risk Assessment)'); + }); + andThen(() => { + assert.equal(find('#customForm1 label:contains(Minimum No injuries, low financial loss)').length, 1, 'Pre-Incident Risk Assessment custom form renders'); + click('.panel-footer button:contains(Update)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Incident Saved', ' Incident Saved modal appears'); + click('.modal-footer button:contains(Ok)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + click('.panel-footer button:contains(Return)'); + }); + andThen(() => { + assert.equal(currentURL(), '/incident', 'Incident listing url is correct'); + assert.equal(find('.incident-row').length, 2, 'Two incidents appears'); + assert.equal(find(`.incident-row td.incident-date:contains(${now.format(DATE_FORMAT)})`).length, 1, 'Incident date appears in listing'); + assert.equal(find(`.incident-row td.incident-department:contains(${DEPARTMENT})`).length, 1, 'Incident department appears in listing'); + assert.equal(find(`.incident-row td.incident-category:contains(${INCIDENT_CATEGORY})`).length, 1, 'Incident category appears in listing'); + assert.equal(find(`.incident-row td.incident-category-item:contains(${INCIDENT_CATEGORY_ITEM})`).length, 1, 'Incident category item appears in listing'); + assert.equal(find('.incident-row td.incident-status:last').text(), 'Reported', 'Incident status of reported appears in listing'); + visit('/incident/edit/56c64d71-ba30-4271-b899-f6f6b031f589'); + }); + andThen(() => { + assert.equal(currentURL(), '/incident/edit/56c64d71-ba30-4271-b899-f6f6b031f589', 'Incident edit url is correct'); + assert.equal(find('.sentinel-event input:checked').length, 1, 'Sentinel Event checkbox is checked'); + assert.equal(find('.incident-date input').val(), '3/8/2017 3:20 PM', 'Date of incident displays'); + assert.equal(find('.incident-department .tt-input').val(), 'Reception', 'Incident department displays'); + assert.equal(find('.reported-to input').val(), 'Jane Bagadonuts', 'Reported to displays.'); + assert.equal(find('.incident-category option:selected').text().trim(), 'Accident or Injury', 'Category displays'); + assert.equal(find('.incident-category-item option:selected').text().trim(), 'Patient', 'Category item displays'); + assert.equal(find('.patient-name .tt-input').val(), 'Joe Bagadonuts - P00001', 'Patient impacted name displays'); + assert.equal(find('.patient-id').text(), 'P00001', 'Patient id displays'); + assert.equal(find('.incident-description textarea').val(), 'Patient fell on wet floor.', 'Description displays'); + fillIn('.incident-description textarea', INCIDENT_DESCRIPTION); + }); + andThen(() => { + assert.equal(find('.incident-description textarea').val(), INCIDENT_DESCRIPTION, 'Updated description displays'); + click('.panel-footer button:contains(Update)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Incident Saved', ' Incident Saved modal appears'); + click('.modal-footer button:contains(Ok)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + click('#notes tr button:contains(Edit)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Edit Note', ' Edit Note modal appears'); + fillIn('.note-description textarea', EDIT_INCIDENT_NOTE); + }); + andThen(() => { + click('.modal-footer button:contains(Update)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.note-description').text(), EDIT_INCIDENT_NOTE, 'Note is updated'); + click('#notes tr button:contains(Delete)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Delete Note', ' Delete Note modal appears'); + click('.modal-footer button:contains(Delete)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.note-description').length, 0, 'Note has been deleted'); + click('.tab-nav li a:contains(Attachment)'); + waitToAppear('#attachments td a:contains(Download)'); + }); + andThen(() => { + assert.equal(find('#attachments td a:contains(Download)').length, 1, 'Download button appears for attachment'); + click('#attachments td button:contains(Edit)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Edit Attachment', ' Edit Attachment modal appears'); + fillIn('.attachment-title input', 'Incident Report Form'); + }); + andThen(() => { + click('.modal-footer button:contains(Update)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('#attachments td:contains(Incident Report Form)').length, 1, 'Updated attachment title appears'); + click('#attachments td button:contains(Delete)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Delete Attachment', ' Delete Attachment modal appears'); + click('.modal-footer button:contains(Ok)'); + }); + andThen(() => { + assert.equal(find('#attachments td:contains(Incident Report Form)').length, 0, 'Deleted attachment disappears'); + }); + }); +}); + +test('Incident deletion', function(assert) { + runWithPouchDump('incident', function() { + authenticateUser(); + visit('/incident'); + andThen(() => { + assert.equal(currentURL(), '/incident', 'Incident listing url is correct'); + assert.equal(find('.incident-row').length, 1, 'One incident appears'); + click('.incident-row button:contains(Delete)'); + waitToAppear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Delete Incident', ' Delete Incident modal appears'); + click('.modal-footer button:contains(Delete)'); + waitToDisappear('.modal-dialog'); + }); + andThen(() => { + assert.equal(find('.incident-row').length, 0, 'Incident diappears from list'); + }); + }); +}); + +function addItem(assert, itemName) { + click('button:contains(Add Item)'); + waitToAppear('.modal-dialog'); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Add Category Item', + 'Add Category Item modal appears'); + fillIn('.incident-category-item input', itemName); + }); + andThen(() => { + click('.modal-footer button:contains(Add)'); + waitToAppear(`.incident-category-item:contains(${itemName})`); + }); + andThen(() => { + assert.equal(find(`.incident-category-item:contains(${itemName})`).length, + 1, 'New incident category item appears'); + }); +} diff --git a/tests/acceptance/operative-test.js b/tests/acceptance/operative-test.js index 98b978497d..2ad1307c4f 100644 --- a/tests/acceptance/operative-test.js +++ b/tests/acceptance/operative-test.js @@ -20,7 +20,7 @@ module('Acceptance | Operative Plan and Operation Report', { }); test('Plan and report creation', function(assert) { - runWithPouchDump('patient', function() { + runWithPouchDump('operative', function() { authenticateUser(); visit('/patients'); andThen(() => { @@ -28,45 +28,14 @@ test('Plan and report creation', function(assert) { click('button:contains(Edit)'); }); andThen(() => { - assert.equal(currentURL(), '/patients/edit/C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'Patient edit URL is correct'); - click('a:contains(Add Diagnosis)'); - waitToAppear('.modal-dialog'); - }); - andThen(() => { - assert.equal(find('.modal-title').text(), 'Add Diagnosis', 'Add Diagnosis dialog displays'); - fillIn('.diagnosis-text input', 'Broken Arm'); - }); - andThen(() => { - click('.modal-footer button:contains(Add)'); - }); - andThen(() => { - waitToDisappear('.modal-dialog'); - waitToAppear('a.primary-diagnosis'); - }); - andThen(() => { - assert.equal(find('a.primary-diagnosis:contains(Broken Arm)').length, 1, 'New primary diagnosis appears'); - click('a:contains(Add Diagnosis)'); - waitToAppear('.modal-dialog'); - }); - andThen(() => { - assert.equal(find('.modal-title').text(), 'Add Diagnosis', 'Add Diagnosis dialog displays'); - fillIn('.diagnosis-text input', 'Tennis Elbow'); - click('.secondary-diagnosis input'); - }); - andThen(() => { - click('.modal-footer button:contains(Add)'); - }); - andThen(() => { - waitToDisappear('.modal-dialog'); - waitToAppear('a.secondary-diagnosis:contains(Tennis Elbow)'); - }); - andThen(() => { - assert.equal(find('a.secondary-diagnosis:contains(Tennis Elbow)').length, 1, 'New secondary diagnosis appears'); + assert.equal(currentURL(), '/patients/edit/cd572865-dcc0-441e-a2ad-be400dc256da', 'Patient edit URL is correct'); + assert.equal(find('a.primary-diagnosis:contains(Broken Arm)').length, 1, 'Primary diagnosis appears'); + assert.equal(find('a.secondary-diagnosis:contains(Tennis Elbow)').length, 1, 'Secondary diagnosis appears'); click('a:contains(Add Operative Plan)'); waitToAppear('span.secondary-diagnosis:contains(Tennis Elbow)'); }); andThen(() => { - assert.equal(currentURL(), '/patients/operative-plan/new?forPatientId=C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'New operative plan URL is correct'); + assert.equal(currentURL(), '/patients/operative-plan/new?forPatientId=cd572865-dcc0-441e-a2ad-be400dc256da', 'New operative plan URL is correct'); assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient header displays'); assert.equal(find('.view-current-title').text(), 'New Operative Plan', 'New operative plan title is correct'); assert.equal(find('span.primary-diagnosis:contains(Broken Arm)').length, 1, 'Primary diagnosis appears as read only'); @@ -112,7 +81,7 @@ test('Plan and report creation', function(assert) { click('button:contains(Return)'); }); andThen(() => { - assert.equal(currentURL(), '/patients/edit/C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'Return goes back to patient screen'); + assert.equal(currentURL(), '/patients/edit/cd572865-dcc0-441e-a2ad-be400dc256da', 'Return goes back to patient screen'); assert.equal(find('a:contains(Current Operative Plan)').length, 1, 'Link to newly created plan appears'); click('a:contains(Current Operative Plan)'); }); @@ -150,7 +119,7 @@ test('Plan and report creation', function(assert) { click('button:contains(Return)'); }); andThen(() => { - assert.equal(currentURL(), '/patients/edit/C87BFCB2-F772-7A7B-8FC7-AD00C018C32A', 'Patient edit URL is correct'); + assert.equal(currentURL(), '/patients/edit/cd572865-dcc0-441e-a2ad-be400dc256da', 'Patient edit URL is correct'); assert.equal(find('a.patient-procedure:contains(fix broken arm)').length, 1, 'Procedure/operative report shows on patient header'); click('a.patient-procedure:contains(fix broken arm)'); }); diff --git a/tests/fixtures/admin.txt b/tests/fixtures/admin.txt index 0021d1f07b..492a63d6df 100644 --- a/tests/fixtures/admin.txt +++ b/tests/fixtures/admin.txt @@ -1,7 +1,7 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:19:14.024Z","db_info":{"db_name":"main","doc_count":32,"doc_del_count":0,"update_seq":57,"purge_seq":0,"compact_running":false,"disk_size":102504,"data_size":28709,"instance_start_time":"1486135060613613","disk_format_version":6,"committed_update_seq":57,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} -{"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} -{"seq":2} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":24} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-5250950488663a397583dfe34240c4f3","version":2,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var status = doc.data.statusOfIncident;if (status && status === \"Closed\") { emit([doc.data.reportedBy, doc._id]);}\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/incident_by_date","_rev":"1-c7499a4c007e736e1da794397ae627ac","version":2,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_reviewers","_rev":"1-8ef52cda8ddd504acf6c76752ed6da03","version":2,"views":{"incident_by_reviewers":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incReviewer') {\n var inc = doc.data.incident;if (inc) { emit([doc.data.reviewerEmail, doc._id], { _id: doc.data.incident });}\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-ca0e7f9b3378f58be85f176c80a3c23b","version":2,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var status = doc.data.statusOfIncident;if (status && status !== \"Closed\") { emit([doc.data.reportedBy, doc._id]);}\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"lookup_2_anesthesia_types","_rev":"9-d77994ca90296681be7de203fea0430a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Epidural"]},"_revisions":{"start":9,"ids":["d77994ca90296681be7de203fea0430a","1d1ae87c72651a279f4d2c1538bdc098","35208a178d11903681c43f9b98ec6513","575acff9e89f60a3ac9df9f4e22e3e04","66570c168285e90d2b69a114f56a648e","281f6900e4c336126ea848f4629312d6","b6a2997fdff472cc26879f1e2c7fb534","739c522ef659467bceea962699319751","f44ab6ebc23a2e0fabdae6239f2c9aa5"]}},{"_id":"lookup_2_anesthesiologists","_rev":"2-15912b0c0e68bb5e33a3a1f6a3e6b9e4","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":[]},"_revisions":{"start":2,"ids":["15912b0c0e68bb5e33a3a1f6a3e6b9e4","1dcbe81d2cdb89574a56ab17f3f0f26c"]}},{"_id":"lookup_2_visit_types","_rev":"1-52a2e0e0211f6cbdb55e97318d8fc790","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Admission","Clinic","Imaging","Lab","Pharmacy"]}}]} -{"seq":57} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:45:40.453Z","db_info":{"db_name":"main","doc_count":34,"doc_del_count":0,"update_seq":67,"purge_seq":0,"compact_running":false,"disk_size":118888,"data_size":28632,"instance_start_time":"1488836348916021","disk_format_version":6,"committed_update_seq":67,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"docs":[{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":3} +{"docs":[{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":6} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"2-1c77e85fa63d80716da7ac836c981daa","_deleted":true,"_revisions":{"start":2,"ids":["1c77e85fa63d80716da7ac836c981daa","5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"_revisions":{"start":1,"ids":["bf16176c13be57af9a4f1a0980710190"]}},{"_id":"_design/closed_incidents_by_user","_rev":"2-43dbd6661048f122110a7bbd4d2af45e","_deleted":true,"_revisions":{"start":2,"ids":["43dbd6661048f122110a7bbd4d2af45e","5250950488663a397583dfe34240c4f3"]}},{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"2-8384943355d3e24c14622b00c86a0985","_deleted":true,"_revisions":{"start":2,"ids":["8384943355d3e24c14622b00c86a0985","59fa59734ee129cff0560b20a95d2d4e"]}},{"_id":"_design/incident_by_date","_rev":"2-75cfce2f961c68be72b9ce8b0b44f49e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}},"_revisions":{"start":2,"ids":["75cfce2f961c68be72b9ce8b0b44f49e","c7499a4c007e736e1da794397ae627ac"]}},{"_id":"_design/incident_by_reviewers","_rev":"1-8ef52cda8ddd504acf6c76752ed6da03","version":2,"views":{"incident_by_reviewers":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incReviewer') {\n var inc = doc.data.incident;if (inc) { emit([doc.data.reviewerEmail, doc._id], { _id: doc.data.incident });}\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/open_incidents_by_user","_rev":"2-d564bf4c24a2cb54da07044a77d0184d","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["d564bf4c24a2cb54da07044a77d0184d","ca0e7f9b3378f58be85f176c80a3c23b"]}},{"_id":"_design/open_incidents_by_user","_rev":"2-05984c30c0ffb50b2823e8805ed9444d","_deleted":true,"_revisions":{"start":2,"ids":["05984c30c0ffb50b2823e8805ed9444d","34770efd210920a30c96d3787521e8a5"]}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"lookup_2_anesthesia_types","_rev":"9-d77994ca90296681be7de203fea0430a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Epidural"]},"_revisions":{"start":9,"ids":["d77994ca90296681be7de203fea0430a","1d1ae87c72651a279f4d2c1538bdc098","35208a178d11903681c43f9b98ec6513","575acff9e89f60a3ac9df9f4e22e3e04","66570c168285e90d2b69a114f56a648e","281f6900e4c336126ea848f4629312d6","b6a2997fdff472cc26879f1e2c7fb534","739c522ef659467bceea962699319751","f44ab6ebc23a2e0fabdae6239f2c9aa5"]}},{"_id":"lookup_2_anesthesiologists","_rev":"2-15912b0c0e68bb5e33a3a1f6a3e6b9e4","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":[]},"_revisions":{"start":2,"ids":["15912b0c0e68bb5e33a3a1f6a3e6b9e4","1dcbe81d2cdb89574a56ab17f3f0f26c"]}},{"_id":"lookup_2_visit_types","_rev":"1-52a2e0e0211f6cbdb55e97318d8fc790","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Admission","Clinic","Imaging","Lab","Pharmacy"]}}]} +{"seq":67} diff --git a/tests/fixtures/appointments.txt b/tests/fixtures/appointments.txt index f32bb1ce6d..587ea4b8e1 100644 --- a/tests/fixtures/appointments.txt +++ b/tests/fixtures/appointments.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:20:44.043Z","db_info":{"db_name":"main","doc_count":64,"doc_del_count":21,"update_seq":110,"purge_seq":0,"compact_running":false,"disk_size":131176,"data_size":77983,"instance_start_time":"1486135177170308","disk_format_version":6,"committed_update_seq":110,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:47:04.256Z","db_info":{"db_name":"main","doc_count":69,"doc_del_count":21,"update_seq":114,"purge_seq":0,"compact_running":false,"disk_size":131176,"data_size":80834,"instance_start_time":"1488836770140466","disk_format_version":6,"committed_update_seq":114,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} +{"seq":3} +{"docs":[{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} {"seq":6} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":23} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}}]} -{"seq":75} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"2-fdce7421d92a349d7b613a90d86dbef1","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:32:30.568Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","sex":"2016-02-22T21:32:30.568Z"}},"_revisions":{"start":2,"ids":["fdce7421d92a349d7b613a90d86dbef1","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}}]} -{"seq":110} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}}]} +{"seq":74} +{"docs":[{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"2-fdce7421d92a349d7b613a90d86dbef1","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:32:30.568Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","sex":"2016-02-22T21:32:30.568Z"}},"_revisions":{"start":2,"ids":["fdce7421d92a349d7b613a90d86dbef1","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}}]} +{"seq":114} diff --git a/tests/fixtures/billing.txt b/tests/fixtures/billing.txt index f36504b02d..5ceb7980b4 100644 --- a/tests/fixtures/billing.txt +++ b/tests/fixtures/billing.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-03-01T20:43:23.432Z","db_info":{"db_name":"main","doc_count":82,"doc_del_count":5,"update_seq":112,"purge_seq":0,"compact_running":false,"disk_size":127080,"data_size":56943,"instance_start_time":"1488400469951231","disk_format_version":6,"committed_update_seq":112,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:48:32.559Z","db_info":{"db_name":"main","doc_count":87,"doc_del_count":5,"update_seq":116,"purge_seq":0,"compact_running":false,"disk_size":131176,"data_size":59989,"instance_start_time":"1488836850507220","disk_format_version":6,"committed_update_seq":116,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} -{"seq":5} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":23} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"2-eae82996b36349ac1fce13b33546eaec","_deleted":true,"_revisions":{"start":2,"ids":["eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"billingLineItem_2_0CCADC1E-1A14-AD66-8423-7A3E6819AEBA","_rev":"2-11ec581b8c2c2f6c0a7dc18033f4e5fb","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Test","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T21:17:00.771Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T21:17:00.771Z","category":"2015-11-12T21:17:00.771Z"}},"_revisions":{"start":2,"ids":["11ec581b8c2c2f6c0a7dc18033f4e5fb","90fbdae0cfe722dbf01223fd001b95ab"]}},{"_id":"billingLineItem_2_5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","_rev":"5-1cbc6b21ccf94b7e42246c75c6bce181","data":{"amountOwed":120,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.846Z","modifiedBy":"Admin User","details":["41A8F093-D8F1-30AD-A070-E9881F072F4C"],"modifiedFields":{"name":"2015-11-13T16:38:20.043Z","category":"2015-11-13T16:38:20.043Z","amountOwed":"2015-11-13T16:38:51.846Z"}},"_revisions":{"start":5,"ids":["1cbc6b21ccf94b7e42246c75c6bce181","e2f88432d42e3d68230146173e579b26","a9c69d3126d8f23d1de7ca2362997b0a","635b22c6bd2bebfb41d59375d4a26cc6","cbe1b2c0c29230d741875d4ae3cd46c1"]}},{"_id":"billingLineItem_2_7481C877-BCB1-EB99-BBCA-5E5DC4DADF7A","_rev":"1-b41fc57519199df35943d9c24fd047d7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.424Z","modifiedBy":"Admin User","details":["BAFBDD02-6953-5E5F-A7F6-59839997B2FC"],"modifiedFields":{"category":"2015-11-12T22:00:59.424Z","name":"2015-11-12T22:00:59.424Z"}}},{"_id":"billingLineItem_2_83D54C80-6493-9A02-9940-325B25A8C2B5","_rev":"1-063aa7e251503a018e8d3616f8e4f1f2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.430Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.430Z","category":"2015-11-12T22:00:59.430Z"}}},{"_id":"billingLineItem_2_87DA9B12-9822-ACA4-A5C4-1FFDD559635C","_rev":"1-e3d62a3ecceebeb32449b7aba49e24ad","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.429Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.429Z","category":"2015-11-12T22:00:59.429Z"}}},{"_id":"billingLineItem_2_9733361B-5A85-9F2E-B9D5-F5C85872F7B9","_rev":"1-0e1922e2b361e48a37c6acd5f09dc417","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.426Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.426Z","category":"2015-11-12T22:00:59.426Z"}}},{"_id":"billingLineItem_2_9F1F38EA-168E-9F84-9F1D-C544D64DCD3D","_rev":"5-1c7e8423336ced251445be9ab2415e9a","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.049Z","category":"2015-11-13T16:38:20.049Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1c7e8423336ced251445be9ab2415e9a","5fd56534f9568ebbfedd24d87556c0f2","9a26cbbdec1ee0343e2fe4b7a77980c3","b70a6ee94f406a0b62f77b664819f193","4b741f261e7d842e66966d0878992a38"]}},{"_id":"billingLineItem_2_C193854D-A0D6-5E6B-A900-870904FE92DD","_rev":"5-c3555b12802aff9426590916449368d6","data":{"amountOwed":36,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.849Z","modifiedBy":"Admin User","details":["04A406D0-EB6B-7BD6-A328-4505150D5A70"],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.849Z"}},"_revisions":{"start":5,"ids":["c3555b12802aff9426590916449368d6","1857509859d8571c5e8c2cdc43de07ee","72437bd56ae7108eda0e66a11206f47c","d14d5f368af87d9f33338d31419bd855","9dfba0cdf988336e95ecd5e1eb15cda6"]}},{"_id":"billingLineItem_2_CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","_rev":"5-1292a509ab23929242728137587fbef6","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1292a509ab23929242728137587fbef6","6e8688e35c955a02bbfc595bda9ef10b","1955501435b44646703efaee24fe2b3b","3e169aeec3ba153a20ab6ac4de2f5423","1fb4106fed478276f3c3c5019e4c1022"]}},{"_id":"billingLineItem_2_D33B74D7-87A0-96F8-AAA1-8455635581A9","_rev":"5-7dbae08e82a6c48b6e46fa2d4baeed6a","data":{"amountOwed":495,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.844Z","modifiedBy":"Admin User","details":["89E9DCF0-E5FD-F0FA-A34F-8A80A2892934"],"modifiedFields":{"category":"2015-11-13T16:38:20.041Z","name":"2015-11-13T16:38:20.041Z","amountOwed":"2015-11-13T16:38:51.844Z"}},"_revisions":{"start":5,"ids":["7dbae08e82a6c48b6e46fa2d4baeed6a","e54a02cebf64641ee0ee72d8ccc2e861","0e3bc753d21631cea51c1ba64965bb2a","72041c92e27af1a896ff8bf42592e8c7","6acbb6d7dae522de5c588959cda1279e"]}},{"_id":"billingLineItem_2_D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","_rev":"5-c7c6ba06c51bb71ff990f8032e238d89","data":{"amountOwed":14,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.848Z","modifiedBy":"Admin User","details":["EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","0195CE1B-EA11-CB34-8970-BD6378C11C0B"],"modifiedFields":{"name":"2015-11-13T16:38:20.047Z","category":"2015-11-13T16:38:20.047Z","amountOwed":"2015-11-13T16:38:51.848Z"}},"_revisions":{"start":5,"ids":["c7c6ba06c51bb71ff990f8032e238d89","d36d74e5e324a3fbfc2e9ff6f51204cf","ba5ece37936ad9017a6c225584f7e735","91075517952345cce4ca5d7106374174","83cf4f5966bdff2903a22158d1ff923e"]}},{"_id":"billingLineItem_2_E0882D10-63E3-024B-A8CF-9010FE23C75B","_rev":"1-3df9822ea1a19faeb0dbaf1aa00641e2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.428Z","modifiedBy":"Admin User","details":["6006AE5D-5B16-4665-BF2A-0549CFA18B05"],"modifiedFields":{"name":"2015-11-12T22:00:59.428Z","category":"2015-11-12T22:00:59.428Z"}}},{"_id":"billingLineItem_2_FF5F6DA8-0359-1712-9E6E-AF50385E07A4","_rev":"1-9f11c1a15fdb9211cf994777d2ebffc7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.431Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.431Z","category":"2015-11-12T22:00:59.431Z"}}},{"_id":"imaging_2_9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9","_rev":"2-ee8faaf2563a1aff848c3f1ac5c5eef4","data":{"imagingDate":"2015-11-12T21:54:33.372Z","notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-11-12T21:54:30.514Z","result":null,"status":"Completed","lastModified":"2015-11-12T21:54:33.372Z","modifiedBy":"Admin User","imagingType":"5931700E-7965-23B1-9835-2D1615E7E755","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"radiologist":"2015-11-12T21:54:30.580Z","status":"2015-11-12T21:54:33.372Z","requestedBy":"2015-11-12T21:54:30.580Z","requestedDate":"2015-11-12T21:54:30.580Z","imagingDate":"2015-11-12T21:54:33.372Z"}},"_revisions":{"start":2,"ids":["ee8faaf2563a1aff848c3f1ac5c5eef4","86e7b70254a3e8d0d37cada4fe2c2dd5"]}},{"_id":"invLocation_2_871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF","_rev":"3-05c0170c92691e4cec16eaa5fd870093","data":{"quantity":14390,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-11-13T16:22:40.565Z","quantity":"2015-11-13T16:23:27.174Z"}},"_revisions":{"start":3,"ids":["05c0170c92691e4cec16eaa5fd870093","b12149871eb3a15641ed6288033fafc7","8ed685da9b4f64d6f1700feefd146c00"]}},{"_id":"invPurchase_2_C28F1C3D-2963-B8EB-903E-78913E9E2B32","_rev":"2-730d39d0cb831606ff5d92371b0e2ddf","data":{"purchaseCost":532,"lotNumber":null,"dateReceived":"2015-11-13T05:00:00.000Z","originalQuantity":14400,"currentQuantity":14390,"expirationDate":null,"expired":false,"location":"Pharmacy","aisleLocation":null,"giftInKind":false,"inventoryItem":"igxvfw26_lh","vendor":"ACME","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-11-13T16:22:40.557Z","purchaseCost":"2015-11-13T16:22:40.557Z","location":"2015-11-13T16:22:40.557Z","vendor":"2015-11-13T16:22:40.557Z","originalQuantity":"2015-11-13T16:22:40.557Z","currentQuantity":"2015-11-13T16:23:27.174Z","inventoryItem":"2015-11-13T16:22:40.557Z"}},"_revisions":{"start":2,"ids":["730d39d0cb831606ff5d92371b0e2ddf","fc582e29abb009231245cb59fdd2ccee"]}},{"_id":"invRequest_2_D3C66D97-6371-9453-94EC-8610D69A7152","_rev":"1-886cc49f90ce562971dad25d3fb8de65","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.04,"dateCompleted":"2015-11-13T16:23:27.165Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":10,"quantityAtCompletion":14400,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-11-13T16:23:27.346Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":null,"modifiedFields":{"dateCompleted":"2015-11-13T16:23:27.346Z","quantity":"2015-11-13T16:23:27.346Z","transactionType":"2015-11-13T16:23:27.346Z","markAsConsumed":"2015-11-13T16:23:27.346Z","adjustPurchases":"2015-11-13T16:23:27.346Z","costPerUnit":"2015-11-13T16:23:27.346Z","quantityAtCompletion":"2015-11-13T16:23:27.346Z","purchasesAffected":"2015-11-13T16:23:27.346Z","locationsAffected":"2015-11-13T16:23:27.346Z","status":"2015-11-13T16:23:27.346Z","completedBy":"2015-11-13T16:23:27.346Z"},"purchasesAffected":[{"id":"C28F1C3D-2963-B8EB-903E-78913E9E2B32","quantity":10}],"locationsAffected":[{"name":"Pharmacy","quantity":10}]}},{"_id":"inventory_2_igxvfw26_lh","_rev":"3-386a7bd74bfb2bbb81f1c5e9b599d2b9","data":{"description":null,"friendlyId":"m00001","name":"Acetaminophen 500 MG","quantity":14390,"crossReference":null,"inventoryType":"Medication","price":12,"reorderPoint":null,"distributionUnit":"tablet","lastModified":"2015-11-13T16:23:27.345Z","modifiedBy":"Admin User","locations":["871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF"],"purchases":["C28F1C3D-2963-B8EB-903E-78913E9E2B32"],"modifiedFields":{"name":"2015-11-13T16:22:40.649Z","inventoryType":"2015-11-13T16:22:40.649Z","distributionUnit":"2015-11-13T16:22:40.649Z","quantity":"2015-11-13T16:23:27.345Z","friendlyId":"2015-11-13T16:22:40.649Z","price":"2015-11-13T16:22:52.229Z"}},"_revisions":{"start":3,"ids":["386a7bd74bfb2bbb81f1c5e9b599d2b9","1c30ca3a4b102090fc0598cd7bbdf3ae","391bee3a85ef66bda23c89cabdd67956"]}},{"_id":"invoice_2_6414F250-C6F0-9B1F-94D7-621A539737AF","_rev":"2-e1898aa278789e1d7c91c4e59289344d","_deleted":true,"_revisions":{"start":2,"ids":["e1898aa278789e1d7c91c4e59289344d","8fad9853ba8f801a3375fb0149c140bf"]}},{"_id":"invoice_2_7596419D-F512-29A0-81EE-346D6D42BB54","_rev":"2-31502fbbe7a5e4ec4f56bc4c7abd1fe3","_deleted":true,"_revisions":{"start":2,"ids":["31502fbbe7a5e4ec4f56bc4c7abd1fe3","dba012716b2add05d20b765a72bca9bd"]}},{"_id":"invoice_2_8929C38C-B621-B2FB-ABB7-DE15C61DFCC8","_rev":"5-7a7d93b820b6085c5beea49fc3efb520","data":{"externalInvoiceNumber":"inv00001","patientInfo":"Joe Bagadonuts - TCH 00001","status":"Billed","remarks":null,"billDate":"2015-11-13T05:00:00.000Z","paidTotal":0,"lastModified":"2015-11-13T16:50:24.904Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","paymentProfile":null,"lineItems":["D33B74D7-87A0-96F8-AAA1-8455635581A9","5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","C193854D-A0D6-5E6B-A900-870904FE92DD","CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","9F1F38EA-168E-9F84-9F1D-C544D64DCD3D"],"payments":[],"modifiedFields":{"billDate":"2015-11-13T16:38:21.206Z","status":"2015-11-13T16:50:24.904Z","patientInfo":"2015-11-13T16:38:21.206Z","externalInvoiceNumber":"2015-11-13T16:44:21.692Z","paidTotal":"2015-11-13T16:50:24.904Z"}},"_revisions":{"start":5,"ids":["7a7d93b820b6085c5beea49fc3efb520","dd0fbb2e7a00eb9ee9be70696621571a","831c42f1a919ec0ad0592bc301c3f48f","db6828f498d4ec6147ef996cfb4b809a","3aeae1614fd7caa7178cf470bc62c366"]}},{"_id":"lab_2_0762040A-CAC7-130F-8D0C-E3DE9245EE38","_rev":"1-f7d92c5e72cc67fc22c1e7634ca08881","data":{"labDate":"2015-11-12T21:46:23.129Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-11-12T21:46:24.462Z","result":"Good","status":"Completed","lastModified":"2015-11-12T21:46:50.177Z","modifiedBy":"Admin User","labType":"F71A1788-3407-515B-8006-F9CC788CA8EA","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"result":"2015-11-12T21:46:50.177Z","status":"2015-11-12T21:46:50.177Z","labDate":"2015-11-12T21:46:50.177Z","requestedBy":"2015-11-12T21:46:50.177Z","requestedDate":"2015-11-12T21:46:50.177Z"}}},{"_id":"lineItemDetail_2_0195CE1B-EA11-CB34-8970-BD6378C11C0B","_rev":"5-50e91d40fbef6f01247cdc2c797df755","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.046Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-13T16:38:20.046Z","expenseAccount":"2015-11-13T16:38:20.046Z","quantity":"2015-11-13T16:38:20.046Z","price":"2015-11-13T16:38:20.046Z","department":"2015-11-13T16:38:20.046Z"}},"_revisions":{"start":5,"ids":["50e91d40fbef6f01247cdc2c797df755","b784cb137af68027834c22b372b7abab","0694194f05c3b79c026ff540d9736043","5cbe22057ba23a8ee0f81d8526d8fc8b","91688cbe5d5da849ea8d4cc2516bd0e6"]}},{"_id":"lineItemDetail_2_04A406D0-EB6B-7BD6-A328-4505150D5A70","_rev":"5-3c5cfebc1004ba1adc877f79101943b9","data":{"department":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"quantity":12,"total":null,"lastModified":"2015-11-13T16:38:20.047Z","modifiedBy":"Admin User","pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"name":"2015-11-13T16:38:20.047Z","expenseAccount":"2015-11-13T16:38:20.047Z","quantity":"2015-11-13T16:38:20.047Z","price":"2015-11-13T16:38:20.047Z","department":"2015-11-13T16:38:20.047Z"}},"_revisions":{"start":5,"ids":["3c5cfebc1004ba1adc877f79101943b9","aa24b7d5f6f4be91b9f148bb3c090e5e","442c20d22e8ee94f549dbcd12f86f5db","4ee7bf808212cbaefddbcb1e6cd4bd16","46a4da005639ebeefc736b3cc305354c"]}},{"_id":"lineItemDetail_2_41A8F093-D8F1-30AD-A070-E9881F072F4C","_rev":"5-bb70abfec5de06d15fdc8bddb0153c50","data":{"department":"Pharmacy","expenseAccount":null,"name":"Acetaminophen 500 MG","price":12,"quantity":10,"total":null,"lastModified":"2015-11-13T16:38:20.042Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.042Z","quantity":"2015-11-13T16:38:20.042Z","price":"2015-11-13T16:38:20.042Z","department":"2015-11-13T16:38:20.042Z"}},"_revisions":{"start":5,"ids":["bb70abfec5de06d15fdc8bddb0153c50","4da37ad0ef6925a3838db19d86c306e7","d7d4a2a5502c92b6225a354639f503d2","882434ab090177ffc5da7f5a20ec1663","f189693c2c4fac5b634b703dc3e253d7"]}}]} +{"seq":3} +{"docs":[{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":4} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"2-28b4bff0597e8254f67140d44550b806","_deleted":true,"_revisions":{"start":2,"ids":["28b4bff0597e8254f67140d44550b806","178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"2-3f36f32ad4537056da92d236724bcbe9","_deleted":true,"_revisions":{"start":2,"ids":["3f36f32ad4537056da92d236724bcbe9","7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/appointments_by_patient","_rev":"2-f03ac9b51ff8ff5d0ac0c2dcbf275311","_deleted":true,"_revisions":{"start":2,"ids":["f03ac9b51ff8ff5d0ac0c2dcbf275311","9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"2-416ed7687768844c4164283d01161e16","_deleted":true,"_revisions":{"start":2,"ids":["416ed7687768844c4164283d01161e16","2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/imaging_by_status","_rev":"2-c13cdf46b0ada4601e71c65353dae3df","_deleted":true,"_revisions":{"start":2,"ids":["c13cdf46b0ada4601e71c65353dae3df","1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"2-6970ab89b44af8c2703a89d6dea9b20b","_deleted":true,"_revisions":{"start":2,"ids":["6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-434f4cb5ef0baef4dddaf2c1914d2f0e","_deleted":true,"_revisions":{"start":2,"ids":["434f4cb5ef0baef4dddaf2c1914d2f0e","91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"2-2f0df4e3dc8ba6d384f896efd4a272cf","_deleted":true,"_revisions":{"start":2,"ids":["2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"2-a5cd4eb9d62940627bd99b9e73cd7b15","_deleted":true,"_revisions":{"start":2,"ids":["a5cd4eb9d62940627bd99b9e73cd7b15","18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-65f020065c11403193b02742a05b91ae","_deleted":true,"_revisions":{"start":2,"ids":["65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"2-392c104e0d9eac6f20948f0d97dd192d","_deleted":true,"_revisions":{"start":2,"ids":["392c104e0d9eac6f20948f0d97dd192d","0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-d900cddd5fcc673d77fbd2f6d783475d","_deleted":true,"_revisions":{"start":2,"ids":["d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"2-9da617bbfd6e7355864c21be36c690c4","_deleted":true,"_revisions":{"start":2,"ids":["9da617bbfd6e7355864c21be36c690c4","1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-c2f0efb7a0a9b3ece1cf9b7b0e88d37f","_deleted":true,"_revisions":{"start":2,"ids":["c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"2-81a90ac8fc850741d7f64b4fbd9df7e0","_deleted":true,"_revisions":{"start":2,"ids":["81a90ac8fc850741d7f64b4fbd9df7e0","021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-0338b756f9c3471052577cadc4ed9505","_deleted":true,"_revisions":{"start":2,"ids":["0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"2-530bd2809cbceb7392fdb758d496fd29","_deleted":true,"_revisions":{"start":2,"ids":["530bd2809cbceb7392fdb758d496fd29","cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"2-6f4cea4e5d7ba4aa3ed8d0ab6bb052af","_deleted":true,"_revisions":{"start":2,"ids":["6f4cea4e5d7ba4aa3ed8d0ab6bb052af","9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"2-d88d6c08ad0c49ed6d2b3a55a0268931","_deleted":true,"_revisions":{"start":2,"ids":["d88d6c08ad0c49ed6d2b3a55a0268931","25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/invoice_by_status","_rev":"2-7850ddbe88cf85231bfe32a1f996f093","_deleted":true,"_revisions":{"start":2,"ids":["7850ddbe88cf85231bfe32a1f996f093","d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/lab_by_status","_rev":"2-9a69b9bd5a85bd3ae2a6659abbb13d83","_deleted":true,"_revisions":{"start":2,"ids":["9a69b9bd5a85bd3ae2a6659abbb13d83","16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-a3e2e3df161e7880986b81f873a974d5","_deleted":true,"_revisions":{"start":2,"ids":["a3e2e3df161e7880986b81f873a974d5","7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"2-79762c4d3cd11ead2ca9150d49b87908","_deleted":true,"_revisions":{"start":2,"ids":["79762c4d3cd11ead2ca9150d49b87908","09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-05c7746b86e7abeadba7b3b5b512a03f","_deleted":true,"_revisions":{"start":2,"ids":["05c7746b86e7abeadba7b3b5b512a03f","a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_admission","_rev":"2-0c4a20f605b836224bc438f1bca26c9b","_deleted":true,"_revisions":{"start":2,"ids":["0c4a20f605b836224bc438f1bca26c9b","3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_display_id","_rev":"2-eae82996b36349ac1fce13b33546eaec","_deleted":true,"_revisions":{"start":2,"ids":["eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"2-04967bcb87fd6a7fffc0d779044dd0b8","_deleted":true,"_revisions":{"start":2,"ids":["04967bcb87fd6a7fffc0d779044dd0b8","6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"2-0d054f7b541c310fdc1c7994ee2ccd49","_deleted":true,"_revisions":{"start":2,"ids":["0d054f7b541c310fdc1c7994ee2ccd49","8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_status","_rev":"2-28bbabc89f372c977f8f25a2dc4748e8","_deleted":true,"_revisions":{"start":2,"ids":["28bbabc89f372c977f8f25a2dc4748e8","49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"2-01f23790dd42e69b4ed27f04d61f1adf","_deleted":true,"_revisions":{"start":2,"ids":["01f23790dd42e69b4ed27f04d61f1adf","54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/photo_by_patient","_rev":"2-5fc163e6b59fe7fe49ea0d0b07f5b78c","_deleted":true,"_revisions":{"start":2,"ids":["5fc163e6b59fe7fe49ea0d0b07f5b78c","6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-29a6fd37f05e4fdd0563837230cf1664","_deleted":true,"_revisions":{"start":2,"ids":["29a6fd37f05e4fdd0563837230cf1664","727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"2-b410254aa19dffe8ec92ad1aa5253030","_deleted":true,"_revisions":{"start":2,"ids":["b410254aa19dffe8ec92ad1aa5253030","3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"2-68d447e856a6194de82dcd9e506569ae","_deleted":true,"_revisions":{"start":2,"ids":["68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"2-876a312fff8d17933d798db8d69e9938","_deleted":true,"_revisions":{"start":2,"ids":["876a312fff8d17933d798db8d69e9938","7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"2-5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","_deleted":true,"_revisions":{"start":2,"ids":["5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-2ab8142fd9e3bdfd7b4d6444fe9afa4f","_deleted":true,"_revisions":{"start":2,"ids":["2ab8142fd9e3bdfd7b4d6444fe9afa4f","4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-dcfc7e63d8ab52146460bd36ff0d5555","_deleted":true,"_revisions":{"start":2,"ids":["dcfc7e63d8ab52146460bd36ff0d5555","10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"2-add6c18db9db449d2af501f6f3fc9a68","_deleted":true,"_revisions":{"start":2,"ids":["add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"2-db03c0d562a1ae49095d68c63bc3d68f","_deleted":true,"_revisions":{"start":2,"ids":["db03c0d562a1ae49095d68c63bc3d68f","db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-a14fd5cb9029d2e114f084d7ce01d874","_deleted":true,"_revisions":{"start":2,"ids":["a14fd5cb9029d2e114f084d7ce01d874","b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-ed42fc360c36cf527a4fdb67fc0d81ee","_deleted":true,"_revisions":{"start":2,"ids":["ed42fc360c36cf527a4fdb67fc0d81ee","57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"2-048bd179b127054d3279071160a6f314","_deleted":true,"_revisions":{"start":2,"ids":["048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"2-15d7d524e104be716e8c93fbf367a28e","_deleted":true,"_revisions":{"start":2,"ids":["15d7d524e104be716e8c93fbf367a28e","bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"billingLineItem_2_0CCADC1E-1A14-AD66-8423-7A3E6819AEBA","_rev":"2-11ec581b8c2c2f6c0a7dc18033f4e5fb","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Test","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T21:17:00.771Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T21:17:00.771Z","category":"2015-11-12T21:17:00.771Z"}},"_revisions":{"start":2,"ids":["11ec581b8c2c2f6c0a7dc18033f4e5fb","90fbdae0cfe722dbf01223fd001b95ab"]}},{"_id":"billingLineItem_2_5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","_rev":"5-1cbc6b21ccf94b7e42246c75c6bce181","data":{"amountOwed":120,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.846Z","modifiedBy":"Admin User","details":["41A8F093-D8F1-30AD-A070-E9881F072F4C"],"modifiedFields":{"name":"2015-11-13T16:38:20.043Z","category":"2015-11-13T16:38:20.043Z","amountOwed":"2015-11-13T16:38:51.846Z"}},"_revisions":{"start":5,"ids":["1cbc6b21ccf94b7e42246c75c6bce181","e2f88432d42e3d68230146173e579b26","a9c69d3126d8f23d1de7ca2362997b0a","635b22c6bd2bebfb41d59375d4a26cc6","cbe1b2c0c29230d741875d4ae3cd46c1"]}},{"_id":"billingLineItem_2_7481C877-BCB1-EB99-BBCA-5E5DC4DADF7A","_rev":"1-b41fc57519199df35943d9c24fd047d7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.424Z","modifiedBy":"Admin User","details":["BAFBDD02-6953-5E5F-A7F6-59839997B2FC"],"modifiedFields":{"category":"2015-11-12T22:00:59.424Z","name":"2015-11-12T22:00:59.424Z"}}},{"_id":"billingLineItem_2_83D54C80-6493-9A02-9940-325B25A8C2B5","_rev":"1-063aa7e251503a018e8d3616f8e4f1f2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.430Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.430Z","category":"2015-11-12T22:00:59.430Z"}}},{"_id":"billingLineItem_2_87DA9B12-9822-ACA4-A5C4-1FFDD559635C","_rev":"1-e3d62a3ecceebeb32449b7aba49e24ad","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.429Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.429Z","category":"2015-11-12T22:00:59.429Z"}}},{"_id":"billingLineItem_2_9733361B-5A85-9F2E-B9D5-F5C85872F7B9","_rev":"1-0e1922e2b361e48a37c6acd5f09dc417","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Pharmacy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.426Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.426Z","category":"2015-11-12T22:00:59.426Z"}}},{"_id":"billingLineItem_2_9F1F38EA-168E-9F84-9F1D-C544D64DCD3D","_rev":"5-1c7e8423336ced251445be9ab2415e9a","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.049Z","category":"2015-11-13T16:38:20.049Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1c7e8423336ced251445be9ab2415e9a","5fd56534f9568ebbfedd24d87556c0f2","9a26cbbdec1ee0343e2fe4b7a77980c3","b70a6ee94f406a0b62f77b664819f193","4b741f261e7d842e66966d0878992a38"]}},{"_id":"billingLineItem_2_C193854D-A0D6-5E6B-A900-870904FE92DD","_rev":"5-c3555b12802aff9426590916449368d6","data":{"amountOwed":36,"category":"Hospital Charges","description":null,"discount":null,"name":"Ward Items","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.849Z","modifiedBy":"Admin User","details":["04A406D0-EB6B-7BD6-A328-4505150D5A70"],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.849Z"}},"_revisions":{"start":5,"ids":["c3555b12802aff9426590916449368d6","1857509859d8571c5e8c2cdc43de07ee","72437bd56ae7108eda0e66a11206f47c","d14d5f368af87d9f33338d31419bd855","9dfba0cdf988336e95ecd5e1eb15cda6"]}},{"_id":"billingLineItem_2_CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","_rev":"5-1292a509ab23929242728137587fbef6","data":{"amountOwed":0,"category":"Hospital Charges","description":null,"discount":null,"name":"Physical Therapy","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.850Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-13T16:38:20.048Z","category":"2015-11-13T16:38:20.048Z","amountOwed":"2015-11-13T16:38:51.850Z"}},"_revisions":{"start":5,"ids":["1292a509ab23929242728137587fbef6","6e8688e35c955a02bbfc595bda9ef10b","1955501435b44646703efaee24fe2b3b","3e169aeec3ba153a20ab6ac4de2f5423","1fb4106fed478276f3c3c5019e4c1022"]}},{"_id":"billingLineItem_2_D33B74D7-87A0-96F8-AAA1-8455635581A9","_rev":"5-7dbae08e82a6c48b6e46fa2d4baeed6a","data":{"amountOwed":495,"category":"Hospital Charges","description":null,"discount":null,"name":"Room/Accomodation","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.844Z","modifiedBy":"Admin User","details":["89E9DCF0-E5FD-F0FA-A34F-8A80A2892934"],"modifiedFields":{"category":"2015-11-13T16:38:20.041Z","name":"2015-11-13T16:38:20.041Z","amountOwed":"2015-11-13T16:38:51.844Z"}},"_revisions":{"start":5,"ids":["7dbae08e82a6c48b6e46fa2d4baeed6a","e54a02cebf64641ee0ee72d8ccc2e861","0e3bc753d21631cea51c1ba64965bb2a","72041c92e27af1a896ff8bf42592e8c7","6acbb6d7dae522de5c588959cda1279e"]}},{"_id":"billingLineItem_2_D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","_rev":"5-c7c6ba06c51bb71ff990f8032e238d89","data":{"amountOwed":14,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-13T16:38:51.848Z","modifiedBy":"Admin User","details":["EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","0195CE1B-EA11-CB34-8970-BD6378C11C0B"],"modifiedFields":{"name":"2015-11-13T16:38:20.047Z","category":"2015-11-13T16:38:20.047Z","amountOwed":"2015-11-13T16:38:51.848Z"}},"_revisions":{"start":5,"ids":["c7c6ba06c51bb71ff990f8032e238d89","d36d74e5e324a3fbfc2e9ff6f51204cf","ba5ece37936ad9017a6c225584f7e735","91075517952345cce4ca5d7106374174","83cf4f5966bdff2903a22158d1ff923e"]}},{"_id":"billingLineItem_2_E0882D10-63E3-024B-A8CF-9010FE23C75B","_rev":"1-3df9822ea1a19faeb0dbaf1aa00641e2","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"X-ray/Lab/Supplies","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.428Z","modifiedBy":"Admin User","details":["6006AE5D-5B16-4665-BF2A-0549CFA18B05"],"modifiedFields":{"name":"2015-11-12T22:00:59.428Z","category":"2015-11-12T22:00:59.428Z"}}},{"_id":"billingLineItem_2_FF5F6DA8-0359-1712-9E6E-AF50385E07A4","_rev":"1-9f11c1a15fdb9211cf994777d2ebffc7","data":{"amountOwed":null,"category":"Hospital Charges","description":null,"discount":null,"name":"Others/Misc","nationalInsurance":null,"privateInsurance":null,"lastModified":"2015-11-12T22:00:59.431Z","modifiedBy":"Admin User","details":[],"modifiedFields":{"name":"2015-11-12T22:00:59.431Z","category":"2015-11-12T22:00:59.431Z"}}},{"_id":"imaging_2_9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9","_rev":"2-ee8faaf2563a1aff848c3f1ac5c5eef4","data":{"imagingDate":"2015-11-12T21:54:33.372Z","notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-11-12T21:54:30.514Z","result":null,"status":"Completed","lastModified":"2015-11-12T21:54:33.372Z","modifiedBy":"Admin User","imagingType":"5931700E-7965-23B1-9835-2D1615E7E755","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"radiologist":"2015-11-12T21:54:30.580Z","status":"2015-11-12T21:54:33.372Z","requestedBy":"2015-11-12T21:54:30.580Z","requestedDate":"2015-11-12T21:54:30.580Z","imagingDate":"2015-11-12T21:54:33.372Z"}},"_revisions":{"start":2,"ids":["ee8faaf2563a1aff848c3f1ac5c5eef4","86e7b70254a3e8d0d37cada4fe2c2dd5"]}},{"_id":"invLocation_2_871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF","_rev":"3-05c0170c92691e4cec16eaa5fd870093","data":{"quantity":14390,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-11-13T16:22:40.565Z","quantity":"2015-11-13T16:23:27.174Z"}},"_revisions":{"start":3,"ids":["05c0170c92691e4cec16eaa5fd870093","b12149871eb3a15641ed6288033fafc7","8ed685da9b4f64d6f1700feefd146c00"]}},{"_id":"invPurchase_2_C28F1C3D-2963-B8EB-903E-78913E9E2B32","_rev":"2-730d39d0cb831606ff5d92371b0e2ddf","data":{"purchaseCost":532,"lotNumber":null,"dateReceived":"2015-11-13T05:00:00.000Z","originalQuantity":14400,"currentQuantity":14390,"expirationDate":null,"expired":false,"location":"Pharmacy","aisleLocation":null,"giftInKind":false,"inventoryItem":"igxvfw26_lh","vendor":"ACME","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-11-13T16:23:27.174Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-11-13T16:22:40.557Z","purchaseCost":"2015-11-13T16:22:40.557Z","location":"2015-11-13T16:22:40.557Z","vendor":"2015-11-13T16:22:40.557Z","originalQuantity":"2015-11-13T16:22:40.557Z","currentQuantity":"2015-11-13T16:23:27.174Z","inventoryItem":"2015-11-13T16:22:40.557Z"}},"_revisions":{"start":2,"ids":["730d39d0cb831606ff5d92371b0e2ddf","fc582e29abb009231245cb59fdd2ccee"]}},{"_id":"invRequest_2_D3C66D97-6371-9453-94EC-8610D69A7152","_rev":"1-886cc49f90ce562971dad25d3fb8de65","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.04,"dateCompleted":"2015-11-13T16:23:27.165Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":10,"quantityAtCompletion":14400,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-11-13T16:23:27.346Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":null,"modifiedFields":{"dateCompleted":"2015-11-13T16:23:27.346Z","quantity":"2015-11-13T16:23:27.346Z","transactionType":"2015-11-13T16:23:27.346Z","markAsConsumed":"2015-11-13T16:23:27.346Z","adjustPurchases":"2015-11-13T16:23:27.346Z","costPerUnit":"2015-11-13T16:23:27.346Z","quantityAtCompletion":"2015-11-13T16:23:27.346Z","purchasesAffected":"2015-11-13T16:23:27.346Z","locationsAffected":"2015-11-13T16:23:27.346Z","status":"2015-11-13T16:23:27.346Z","completedBy":"2015-11-13T16:23:27.346Z"},"purchasesAffected":[{"id":"C28F1C3D-2963-B8EB-903E-78913E9E2B32","quantity":10}],"locationsAffected":[{"name":"Pharmacy","quantity":10}]}},{"_id":"inventory_2_igxvfw26_lh","_rev":"3-386a7bd74bfb2bbb81f1c5e9b599d2b9","data":{"description":null,"friendlyId":"m00001","name":"Acetaminophen 500 MG","quantity":14390,"crossReference":null,"inventoryType":"Medication","price":12,"reorderPoint":null,"distributionUnit":"tablet","lastModified":"2015-11-13T16:23:27.345Z","modifiedBy":"Admin User","locations":["871EBB5C-6F7A-8D53-A4D4-051E3AA3FFCF"],"purchases":["C28F1C3D-2963-B8EB-903E-78913E9E2B32"],"modifiedFields":{"name":"2015-11-13T16:22:40.649Z","inventoryType":"2015-11-13T16:22:40.649Z","distributionUnit":"2015-11-13T16:22:40.649Z","quantity":"2015-11-13T16:23:27.345Z","friendlyId":"2015-11-13T16:22:40.649Z","price":"2015-11-13T16:22:52.229Z"}},"_revisions":{"start":3,"ids":["386a7bd74bfb2bbb81f1c5e9b599d2b9","1c30ca3a4b102090fc0598cd7bbdf3ae","391bee3a85ef66bda23c89cabdd67956"]}},{"_id":"invoice_2_6414F250-C6F0-9B1F-94D7-621A539737AF","_rev":"2-e1898aa278789e1d7c91c4e59289344d","_deleted":true,"_revisions":{"start":2,"ids":["e1898aa278789e1d7c91c4e59289344d","8fad9853ba8f801a3375fb0149c140bf"]}},{"_id":"invoice_2_7596419D-F512-29A0-81EE-346D6D42BB54","_rev":"2-31502fbbe7a5e4ec4f56bc4c7abd1fe3","_deleted":true,"_revisions":{"start":2,"ids":["31502fbbe7a5e4ec4f56bc4c7abd1fe3","dba012716b2add05d20b765a72bca9bd"]}}]} {"seq":74} -{"docs":[{"_id":"lineItemDetail_2_6006AE5D-5B16-4665-BF2A-0549CFA18B05","_rev":"1-b16638cf08bbd83f98e84c1b682249f9","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-12T22:00:59.427Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-12T22:00:59.427Z","expenseAccount":"2015-11-12T22:00:59.427Z","quantity":"2015-11-12T22:00:59.427Z","price":"2015-11-12T22:00:59.427Z","department":"2015-11-12T22:00:59.427Z"}}},{"_id":"lineItemDetail_2_89E9DCF0-E5FD-F0FA-A34F-8A80A2892934","_rev":"5-4008862e1efdded3cc2c5e77e445f214","data":{"department":null,"expenseAccount":null,"name":"Days","price":45,"quantity":11,"total":null,"lastModified":"2015-11-13T16:38:51.843Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.039Z","quantity":"2015-11-13T16:38:20.039Z","price":"2015-11-13T16:38:51.843Z"}},"_revisions":{"start":5,"ids":["4008862e1efdded3cc2c5e77e445f214","03d46eaecd46f6336d0ccc07f6881cfd","376b97227567079e8dfd82bad223e1de","d18636e346ef69fa1d9617e177148704","74f4293f387b050c85e3a520eccfeb1a"]}},{"_id":"lineItemDetail_2_BAFBDD02-6953-5E5F-A7F6-59839997B2FC","_rev":"1-461b69d47c783b5fddc3e697d42d0764","data":{"department":null,"expenseAccount":null,"name":"Days","price":null,"quantity":11,"total":null,"lastModified":"2015-11-12T22:00:59.422Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-12T22:00:59.422Z","quantity":"2015-11-12T22:00:59.422Z"}}},{"_id":"lineItemDetail_2_EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","_rev":"5-b4ecd3a3ca2ec72abb2b265aa6a865a0","data":{"department":"O.R.","expenseAccount":null,"name":"Leg Casting","price":2,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.044Z","modifiedBy":"Admin User","pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"name":"2015-11-13T16:38:20.044Z","expenseAccount":"2015-11-13T16:38:20.044Z","quantity":"2015-11-13T16:38:20.044Z","price":"2015-11-13T16:38:20.044Z","department":"2015-11-13T16:38:20.044Z"}},"_revisions":{"start":5,"ids":["b4ecd3a3ca2ec72abb2b265aa6a865a0","88e87af8cff7a93b0d14ad1152dc40bf","d9d966a397398a53cf66ad2452e904e2","48400862e9be71150140585017cf0b3e","a2a39c01032abf83c945fc5dcbfa1fdc"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-13d3772f546b5c7a9dfcbb9ad8c27a63","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Leg casting"]}},{"_id":"lookup_2_imaging_pricing_types","_rev":"1-508f1018b1af1f65de250cd110e8ae4a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Imaging Procedure"]}},{"_id":"lookup_2_lab_pricing_types","_rev":"1-f64bac71fc698147e7b5802e38d326ec","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Lab Procedure"]}},{"_id":"lookup_2_physician_list","_rev":"1-fe60344a75c70341b869b5211a85d89c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Watson"]}},{"_id":"lookup_2_procedure_list","_rev":"2-5818e879a750999f9f317d262b70cabd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fix broken leg","Leg casting"]},"_revisions":{"start":2,"ids":["5818e879a750999f9f317d262b70cabd","13d3772f546b5c7a9dfcbb9ad8c27a63"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-e4823048fbfcefa1b230c38548dd6465","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-4f316909ed8500d0f80cf20a684ce343","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy"]}},{"_id":"medication_2_7F51BB93-6086-49D0-A284-FEB6C6690C95","_rev":"2-c438baf544b44547413edf90837cab1a","data":{"notes":null,"prescription":"Take two once a day for 5 days","prescriptionDate":"2015-11-13T05:00:00.000Z","quantity":10,"refills":null,"requestedDate":"2015-11-13T16:23:27.163Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-11-13T16:23:27.176Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","medicationTitle":"Acetaminophen 500 MG","priceOfMedication":null,"modifiedFields":{"prescriptionDate":"2015-11-13T16:23:27.176Z","prescription":"2015-11-13T16:23:27.176Z","quantity":"2015-11-13T16:23:27.176Z","status":"2015-11-13T16:23:27.176Z","requestedBy":"2015-11-13T16:23:27.176Z","requestedDate":"2015-11-13T16:23:27.176Z"}},"_revisions":{"start":2,"ids":["c438baf544b44547413edf90837cab1a","f441e894d0aaaab3c3c394186e0cad67"]}},{"_id":"overridePrice_2_9C4DC6CF-EC9B-B303-A483-6B80930CC658","_rev":"1-73b042aa49125ce4f3961ed9316756f7","data":{"price":4,"lastModified":"2015-11-11T21:52:55.514Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:52:55.514Z"}}},{"_id":"overridePrice_2_FBF5B1A6-BBEE-6D17-99C8-EB4A91358183","_rev":"1-87dc3dc101c2d1b1a122e74de183281a","data":{"price":2,"lastModified":"2015-11-11T21:06:20.663Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:06:20.663Z"}}},{"_id":"patient_2_8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","_rev":"4-c630f25455e20c41f394ac77f0f7a73c","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"TCH 00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:51:59.117Z","modifiedBy":"Admin User","payments":[],"modifiedFields":{"friendlyId":"2015-11-12T21:13:52.796Z","firstName":"2015-11-12T21:13:52.796Z","middleName":"2015-11-12T21:13:52.796Z","lastName":"2015-11-12T21:13:52.796Z","admitted":"2015-11-12T21:15:12.204Z","sex":"2016-02-22T21:51:59.117Z"}},"_revisions":{"start":4,"ids":["c630f25455e20c41f394ac77f0f7a73c","63565b6c7b01bbb4af8dbd37a6cd7ca2","7ab83617d991bfa730e55757d90c35ad","d5bb9506d7ebd07a2fd7e2bd8a9afc03"]}},{"_id":"priceProfile_2_5331626A-EF59-E723-AC44-A063049201DC","_rev":"1-c9ede1cd1775d2ccc9e0bcc5d099d614","data":{"name":"Half off","discountAmount":null,"discountPercentage":50,"lastModified":"2015-11-11T21:05:25.047Z","modifiedBy":"Admin User","modifiedFields":{"name":"2015-11-11T21:05:25.047Z","discountPercentage":"2015-11-11T21:05:25.047Z"}}},{"_id":"pricing_2_1D198B41-338B-6E49-8BB1-4696D5DAD715","_rev":"1-5fd5619f2cc1dcf4e7c051add2deaf5d","data":{"category":"Procedure","expenseAccount":null,"name":"Leg Casting","price":2,"pricingType":null,"lastModified":"2015-11-11T21:53:29.953Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:29.953Z","name":"2015-11-11T21:53:29.953Z","price":"2015-11-11T21:53:29.953Z"}}},{"_id":"pricing_2_5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","_rev":"1-7f85b8fb293360badee861fb4a685721","data":{"category":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"pricingType":null,"lastModified":"2015-11-11T21:53:52.661Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:52.661Z","name":"2015-11-11T21:53:52.661Z","price":"2015-11-11T21:53:52.661Z"}}},{"_id":"pricing_2_5931700E-7965-23B1-9835-2D1615E7E755","_rev":"2-300f644f420f7f76581093329a9aa519","data":{"category":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"pricingType":"Imaging Procedure","lastModified":"2015-11-11T21:52:55.549Z","modifiedBy":"Admin User","pricingOverrides":["9C4DC6CF-EC9B-B303-A483-6B80930CC658"],"modifiedFields":{"category":"2015-11-11T21:52:55.549Z","name":"2015-11-11T21:52:55.549Z","price":"2015-11-11T21:52:55.549Z","pricingType":"2015-11-11T21:52:55.549Z"}},"_revisions":{"start":2,"ids":["300f644f420f7f76581093329a9aa519","9f00f9d6a35374e7d7fcbeffd8d4697b"]}},{"_id":"pricing_2_F71A1788-3407-515B-8006-F9CC788CA8EA","_rev":"2-9762d8a2d76d242671a3bea610a0904f","data":{"category":"Lab","expenseAccount":null,"name":"Blood test","price":123,"pricingType":"Lab Procedure","lastModified":"2015-11-11T21:06:20.719Z","modifiedBy":"Admin User","pricingOverrides":["FBF5B1A6-BBEE-6D17-99C8-EB4A91358183"],"modifiedFields":{"category":"2015-11-11T21:06:20.719Z","name":"2015-11-11T21:06:20.719Z","price":"2015-11-11T21:06:20.719Z","pricingType":"2015-11-11T21:06:20.719Z"}},"_revisions":{"start":2,"ids":["9762d8a2d76d242671a3bea610a0904f","e6eada16de79ddba78e890c01837a3f5"]}},{"_id":"procCharge_2_0834BF27-A2E0-5ADD-9509-B97CA547E532","_rev":"1-0bb58d85915b11cbcb1547ba44b86f5f","data":{"quantity":1,"dateCharged":"2015-11-13T05:00:00.000Z","lastModified":"2015-11-13T16:11:54.012Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-13T16:11:54.012Z","quantity":"2015-11-13T16:11:54.012Z"}}},{"_id":"procCharge_2_17BC9913-E49F-FB8A-AA42-4F617D839510","_rev":"1-2917bd58af0d9cbb9e3835013c857d2f","data":{"quantity":1,"dateCharged":"2015-11-12T05:00:00.000Z","lastModified":"2015-11-12T21:53:52.879Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-12T21:53:52.879Z","quantity":"2015-11-12T21:53:52.879Z"}}},{"_id":"procCharge_2_2648E500-C287-2EE4-B569-99D6291FB46C","_rev":"2-1875764ed6d4a41e96277d678bcda2b3","_deleted":true,"_revisions":{"start":2,"ids":["1875764ed6d4a41e96277d678bcda2b3","f0554786c3ad14c941dced65e1df8649"]}},{"_id":"procCharge_2_412AD48B-EDD4-E5E2-8134-BB3B5E459972","_rev":"1-2cdee6e8d8fd1207c073b5e6f33b4c6e","data":{"quantity":12,"dateCharged":"2015-11-03T05:00:00.000Z","lastModified":"2015-11-12T21:18:30.366Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-12T21:18:30.366Z","quantity":"2015-11-12T21:18:30.366Z"}}},{"_id":"procCharge_2_561AD584-144B-D21F-840A-8600B8D900CF","_rev":"1-8f30246e0bba661deeb2c08617ec1128","data":{"quantity":12,"dateCharged":"2015-11-11T05:00:00.000Z","lastModified":"2015-11-13T16:24:24.528Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-13T16:24:24.528Z","quantity":"2015-11-13T16:24:24.528Z"}}},{"_id":"procCharge_2_704FA289-CA15-A178-B571-D0ECCE8229F3","_rev":"2-6d00bf1656e7ef89bc6ba38c3711982b","_deleted":true,"_revisions":{"start":2,"ids":["6d00bf1656e7ef89bc6ba38c3711982b","2103b76190a412ab081bae469ef27dee"]}},{"_id":"procCharge_2_A28911F7-FC62-9F3D-A82E-8EB0D43B9B68","_rev":"2-3959e9c3eb93a0fd7bc1d36ece0dbcd9","_deleted":true,"_revisions":{"start":2,"ids":["3959e9c3eb93a0fd7bc1d36ece0dbcd9","b5b4fd9fa56d91b689be62a9fc0506ae"]}},{"_id":"procCharge_2_A2F0320B-AFD0-BB29-AFFE-6470FD537D05","_rev":"1-d29a0c613aa6282b87a3e3eb37278453","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"quantity":12,"dateCharged":"2016-02-09T20:18:54.966Z","lastModified":"2016-02-09T20:18:59.012Z","modifiedBy":"Admin User","medication":"igxvfw26_lh","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T20:18:59.012Z","quantity":"2016-02-09T20:18:59.012Z","medicationTitle":"2016-02-09T20:18:59.012Z","priceOfMedication":"2016-02-09T20:18:59.012Z"}}},{"_id":"procCharge_2_BDAC9E94-96A0-1994-9196-BD3F56F891CA","_rev":"1-090a8baf0cf5219ab842f6a5f85c98b2","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:20:16.119Z","lastModified":"2016-02-09T19:20:22.089Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:20:22.089Z","quantity":"2016-02-09T19:20:22.089Z","medication":"2016-02-09T19:20:22.089Z","medicationTitle":"2016-02-09T19:20:22.089Z","priceOfMedication":"2016-02-09T19:20:22.089Z"}}},{"_id":"procCharge_2_F632124D-557D-0B35-8213-F7054DE6AFB0","_rev":"1-f88672a41bab0bf53f3d744944b623e5","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:16:13.269Z","lastModified":"2016-02-09T19:16:22.209Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:16:22.209Z","quantity":"2016-02-09T19:16:22.209Z","medication":"2016-02-09T19:16:22.209Z","medicationTitle":"2016-02-09T19:16:22.209Z","priceOfMedication":"2016-02-09T19:16:22.209Z"}}},{"_id":"procedure_2_539C4B9B-B275-EF14-8BA2-9CAC6403424A","_rev":"1-e4a243fe73d67885206ff1d406beba1a","data":{"anesthesiaType":null,"anesthesiologist":null,"assistant":null,"description":"Leg casting","cptCode":"Leg casting","location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-12T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-12T21:54:00.381Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["17BC9913-E49F-FB8A-AA42-4F617D839510"],"modifiedFields":{"procedureDate":"2015-11-12T21:54:00.381Z","description":"2015-11-12T21:54:00.381Z","cptCode":"2015-11-12T21:54:00.381Z","timeStarted":"2015-11-12T21:54:00.381Z","timeEnded":"2015-11-12T21:54:00.381Z","physician":"2015-11-12T21:54:00.381Z"}}},{"_id":"procedure_2_653A07CE-66E2-1DC8-A83C-4A25934559F0","_rev":"11-9852c642c6108359ec3d1a1915be7d77","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"Fix broken leg","cptCode":null,"location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-13T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-13T16:11:57.940Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["0834BF27-A2E0-5ADD-9509-B97CA547E532","A2F0320B-AFD0-BB29-AFFE-6470FD537D05"],"modifiedFields":{"procedureDate":"2015-11-13T16:11:57.940Z","description":"2015-11-13T16:11:57.940Z","timeStarted":"2015-11-13T16:11:57.940Z","timeEnded":"2015-11-13T16:11:57.940Z","physician":"2015-11-13T16:11:57.940Z","anesthesiaType":"2015-11-13T16:11:57.940Z"}},"_revisions":{"start":11,"ids":["9852c642c6108359ec3d1a1915be7d77","32f7b134f4a1489bad30b20b41a402b7","79317aa8224c831799a41588c9c00572","25edbe7f3e8f872997aec5b8e57959c0","53e45632484af05ac967f6af430bced9","8700b634cefddb7c2ef0b810e4d8241a","e0abfee94018abcefb7b541c6bb7b242","715ed4e72deba043868bfbe500f964a0","483b770e04706f935dc6275abf496a3a","0f22a93f70def208660a024b0fa6a6c6","b078e6e7004154529f8fd0901b60ed19"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_invoice","_rev":"3-f0ef6923c78e739d9228517a4813b646","data":{"prefix":null,"value":3},"_revisions":{"start":3,"ids":["f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"sequence_2_patient","_rev":"1-5bc31ffefa482f2e66299cf0704623c8","data":{"prefix":null,"value":1}},{"_id":"visit_2_666DFC61-3230-A865-A145-C7D9139DA1CA","_rev":"12-9f26178fcda83e39cc9df1950035a7fc","data":{"dischargeInfo":null,"endDate":"2015-11-12T05:00:00.000Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-01T04:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-12T21:47:53.994Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","vitals":[],"procedures":["653A07CE-66E2-1DC8-A83C-4A25934559F0"],"medication":["7F51BB93-6086-49D0-A284-FEB6C6690C95"],"labs":["0762040A-CAC7-130F-8D0C-E3DE9245EE38"],"imaging":["9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9"],"charges":["561AD584-144B-D21F-840A-8600B8D900CF"],"modifiedFields":{"visitType":"2015-11-12T21:15:12.160Z","startDate":"2015-11-12T21:15:12.160Z","status":"2015-11-12T21:47:53.994Z","outPatient":"2015-11-12T21:15:12.160Z","endDate":"2015-11-12T21:47:53.994Z"}},"_revisions":{"start":12,"ids":["9f26178fcda83e39cc9df1950035a7fc","64ef0abb729090bd64b948f9ca2318de","19a1560274f7e5dc07c3b6b0543278a1","793cb2bc5919ef9ced471818f5e7c3b5","8201fa77027c3929455f4c9368ce1c32","4f345e06fefbc87fa23fa1a0d194d1ee","e82f9737c00c8b9004653355ed0cb743","03b09430dde4f6d3c5b62f1c5c6b1378","1db70a4f91b8ed3da25df05dcc91713d","5745b4455c849281c543b2c447feb480","37ad5eae5583240c5143012937658d48","c35ad6c0332fc471d3a8fa485a48d1de"]}}]} -{"seq":112} +{"docs":[{"_id":"invoice_2_8929C38C-B621-B2FB-ABB7-DE15C61DFCC8","_rev":"5-7a7d93b820b6085c5beea49fc3efb520","data":{"externalInvoiceNumber":"inv00001","patientInfo":"Joe Bagadonuts - TCH 00001","status":"Billed","remarks":null,"billDate":"2015-11-13T05:00:00.000Z","paidTotal":0,"lastModified":"2015-11-13T16:50:24.904Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","paymentProfile":null,"lineItems":["D33B74D7-87A0-96F8-AAA1-8455635581A9","5A0DDD6C-6A8B-D336-B0AC-2568B648DBA2","D6886EFD-5FD8-0048-8F18-70D1C2AF6B7B","C193854D-A0D6-5E6B-A900-870904FE92DD","CCC87C0C-DD95-53E6-B645-C3DEAA1C266F","9F1F38EA-168E-9F84-9F1D-C544D64DCD3D"],"payments":[],"modifiedFields":{"billDate":"2015-11-13T16:38:21.206Z","status":"2015-11-13T16:50:24.904Z","patientInfo":"2015-11-13T16:38:21.206Z","externalInvoiceNumber":"2015-11-13T16:44:21.692Z","paidTotal":"2015-11-13T16:50:24.904Z"}},"_revisions":{"start":5,"ids":["7a7d93b820b6085c5beea49fc3efb520","dd0fbb2e7a00eb9ee9be70696621571a","831c42f1a919ec0ad0592bc301c3f48f","db6828f498d4ec6147ef996cfb4b809a","3aeae1614fd7caa7178cf470bc62c366"]}},{"_id":"lab_2_0762040A-CAC7-130F-8D0C-E3DE9245EE38","_rev":"1-f7d92c5e72cc67fc22c1e7634ca08881","data":{"labDate":"2015-11-12T21:46:23.129Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-11-12T21:46:24.462Z","result":"Good","status":"Completed","lastModified":"2015-11-12T21:46:50.177Z","modifiedBy":"Admin User","labType":"F71A1788-3407-515B-8006-F9CC788CA8EA","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":[],"modifiedFields":{"result":"2015-11-12T21:46:50.177Z","status":"2015-11-12T21:46:50.177Z","labDate":"2015-11-12T21:46:50.177Z","requestedBy":"2015-11-12T21:46:50.177Z","requestedDate":"2015-11-12T21:46:50.177Z"}}},{"_id":"lineItemDetail_2_0195CE1B-EA11-CB34-8970-BD6378C11C0B","_rev":"5-50e91d40fbef6f01247cdc2c797df755","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.046Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-13T16:38:20.046Z","expenseAccount":"2015-11-13T16:38:20.046Z","quantity":"2015-11-13T16:38:20.046Z","price":"2015-11-13T16:38:20.046Z","department":"2015-11-13T16:38:20.046Z"}},"_revisions":{"start":5,"ids":["50e91d40fbef6f01247cdc2c797df755","b784cb137af68027834c22b372b7abab","0694194f05c3b79c026ff540d9736043","5cbe22057ba23a8ee0f81d8526d8fc8b","91688cbe5d5da849ea8d4cc2516bd0e6"]}},{"_id":"lineItemDetail_2_04A406D0-EB6B-7BD6-A328-4505150D5A70","_rev":"5-3c5cfebc1004ba1adc877f79101943b9","data":{"department":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"quantity":12,"total":null,"lastModified":"2015-11-13T16:38:20.047Z","modifiedBy":"Admin User","pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"name":"2015-11-13T16:38:20.047Z","expenseAccount":"2015-11-13T16:38:20.047Z","quantity":"2015-11-13T16:38:20.047Z","price":"2015-11-13T16:38:20.047Z","department":"2015-11-13T16:38:20.047Z"}},"_revisions":{"start":5,"ids":["3c5cfebc1004ba1adc877f79101943b9","aa24b7d5f6f4be91b9f148bb3c090e5e","442c20d22e8ee94f549dbcd12f86f5db","4ee7bf808212cbaefddbcb1e6cd4bd16","46a4da005639ebeefc736b3cc305354c"]}},{"_id":"lineItemDetail_2_41A8F093-D8F1-30AD-A070-E9881F072F4C","_rev":"5-bb70abfec5de06d15fdc8bddb0153c50","data":{"department":"Pharmacy","expenseAccount":null,"name":"Acetaminophen 500 MG","price":12,"quantity":10,"total":null,"lastModified":"2015-11-13T16:38:20.042Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.042Z","quantity":"2015-11-13T16:38:20.042Z","price":"2015-11-13T16:38:20.042Z","department":"2015-11-13T16:38:20.042Z"}},"_revisions":{"start":5,"ids":["bb70abfec5de06d15fdc8bddb0153c50","4da37ad0ef6925a3838db19d86c306e7","d7d4a2a5502c92b6225a354639f503d2","882434ab090177ffc5da7f5a20ec1663","f189693c2c4fac5b634b703dc3e253d7"]}},{"_id":"lineItemDetail_2_6006AE5D-5B16-4665-BF2A-0549CFA18B05","_rev":"1-b16638cf08bbd83f98e84c1b682249f9","data":{"department":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"quantity":1,"total":null,"lastModified":"2015-11-12T22:00:59.427Z","modifiedBy":"Admin User","pricingItem":"5931700E-7965-23B1-9835-2D1615E7E755","modifiedFields":{"name":"2015-11-12T22:00:59.427Z","expenseAccount":"2015-11-12T22:00:59.427Z","quantity":"2015-11-12T22:00:59.427Z","price":"2015-11-12T22:00:59.427Z","department":"2015-11-12T22:00:59.427Z"}}},{"_id":"lineItemDetail_2_89E9DCF0-E5FD-F0FA-A34F-8A80A2892934","_rev":"5-4008862e1efdded3cc2c5e77e445f214","data":{"department":null,"expenseAccount":null,"name":"Days","price":45,"quantity":11,"total":null,"lastModified":"2015-11-13T16:38:51.843Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-13T16:38:20.039Z","quantity":"2015-11-13T16:38:20.039Z","price":"2015-11-13T16:38:51.843Z"}},"_revisions":{"start":5,"ids":["4008862e1efdded3cc2c5e77e445f214","03d46eaecd46f6336d0ccc07f6881cfd","376b97227567079e8dfd82bad223e1de","d18636e346ef69fa1d9617e177148704","74f4293f387b050c85e3a520eccfeb1a"]}},{"_id":"lineItemDetail_2_BAFBDD02-6953-5E5F-A7F6-59839997B2FC","_rev":"1-461b69d47c783b5fddc3e697d42d0764","data":{"department":null,"expenseAccount":null,"name":"Days","price":null,"quantity":11,"total":null,"lastModified":"2015-11-12T22:00:59.422Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"name":"2015-11-12T22:00:59.422Z","quantity":"2015-11-12T22:00:59.422Z"}}},{"_id":"lineItemDetail_2_EEA8B1B7-42DB-A4E1-BBB1-BDEDED85B17F","_rev":"5-b4ecd3a3ca2ec72abb2b265aa6a865a0","data":{"department":"O.R.","expenseAccount":null,"name":"Leg Casting","price":2,"quantity":1,"total":null,"lastModified":"2015-11-13T16:38:20.044Z","modifiedBy":"Admin User","pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"name":"2015-11-13T16:38:20.044Z","expenseAccount":"2015-11-13T16:38:20.044Z","quantity":"2015-11-13T16:38:20.044Z","price":"2015-11-13T16:38:20.044Z","department":"2015-11-13T16:38:20.044Z"}},"_revisions":{"start":5,"ids":["b4ecd3a3ca2ec72abb2b265aa6a865a0","88e87af8cff7a93b0d14ad1152dc40bf","d9d966a397398a53cf66ad2452e904e2","48400862e9be71150140585017cf0b3e","a2a39c01032abf83c945fc5dcbfa1fdc"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-13d3772f546b5c7a9dfcbb9ad8c27a63","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Leg casting"]}},{"_id":"lookup_2_imaging_pricing_types","_rev":"1-508f1018b1af1f65de250cd110e8ae4a","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Imaging Procedure"]}},{"_id":"lookup_2_lab_pricing_types","_rev":"1-f64bac71fc698147e7b5802e38d326ec","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Lab Procedure"]}},{"_id":"lookup_2_physician_list","_rev":"1-fe60344a75c70341b869b5211a85d89c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Watson"]}},{"_id":"lookup_2_procedure_list","_rev":"2-5818e879a750999f9f317d262b70cabd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fix broken leg","Leg casting"]},"_revisions":{"start":2,"ids":["5818e879a750999f9f317d262b70cabd","13d3772f546b5c7a9dfcbb9ad8c27a63"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-e4823048fbfcefa1b230c38548dd6465","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-4f316909ed8500d0f80cf20a684ce343","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy"]}},{"_id":"medication_2_7F51BB93-6086-49D0-A284-FEB6C6690C95","_rev":"2-c438baf544b44547413edf90837cab1a","data":{"notes":null,"prescription":"Take two once a day for 5 days","prescriptionDate":"2015-11-13T05:00:00.000Z","quantity":10,"refills":null,"requestedDate":"2015-11-13T16:23:27.163Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-11-13T16:23:27.176Z","modifiedBy":"Admin User","inventoryItem":"igxvfw26_lh","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","medicationTitle":"Acetaminophen 500 MG","priceOfMedication":null,"modifiedFields":{"prescriptionDate":"2015-11-13T16:23:27.176Z","prescription":"2015-11-13T16:23:27.176Z","quantity":"2015-11-13T16:23:27.176Z","status":"2015-11-13T16:23:27.176Z","requestedBy":"2015-11-13T16:23:27.176Z","requestedDate":"2015-11-13T16:23:27.176Z"}},"_revisions":{"start":2,"ids":["c438baf544b44547413edf90837cab1a","f441e894d0aaaab3c3c394186e0cad67"]}},{"_id":"overridePrice_2_9C4DC6CF-EC9B-B303-A483-6B80930CC658","_rev":"1-73b042aa49125ce4f3961ed9316756f7","data":{"price":4,"lastModified":"2015-11-11T21:52:55.514Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:52:55.514Z"}}},{"_id":"overridePrice_2_FBF5B1A6-BBEE-6D17-99C8-EB4A91358183","_rev":"1-87dc3dc101c2d1b1a122e74de183281a","data":{"price":2,"lastModified":"2015-11-11T21:06:20.663Z","modifiedBy":"Admin User","profile":"5331626A-EF59-E723-AC44-A063049201DC","modifiedFields":{"price":"2015-11-11T21:06:20.663Z"}}},{"_id":"patient_2_8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","_rev":"4-c630f25455e20c41f394ac77f0f7a73c","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"TCH 00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T21:51:59.117Z","modifiedBy":"Admin User","payments":[],"modifiedFields":{"friendlyId":"2015-11-12T21:13:52.796Z","firstName":"2015-11-12T21:13:52.796Z","middleName":"2015-11-12T21:13:52.796Z","lastName":"2015-11-12T21:13:52.796Z","admitted":"2015-11-12T21:15:12.204Z","sex":"2016-02-22T21:51:59.117Z"}},"_revisions":{"start":4,"ids":["c630f25455e20c41f394ac77f0f7a73c","63565b6c7b01bbb4af8dbd37a6cd7ca2","7ab83617d991bfa730e55757d90c35ad","d5bb9506d7ebd07a2fd7e2bd8a9afc03"]}},{"_id":"priceProfile_2_5331626A-EF59-E723-AC44-A063049201DC","_rev":"1-c9ede1cd1775d2ccc9e0bcc5d099d614","data":{"name":"Half off","discountAmount":null,"discountPercentage":50,"lastModified":"2015-11-11T21:05:25.047Z","modifiedBy":"Admin User","modifiedFields":{"name":"2015-11-11T21:05:25.047Z","discountPercentage":"2015-11-11T21:05:25.047Z"}}},{"_id":"pricing_2_1D198B41-338B-6E49-8BB1-4696D5DAD715","_rev":"1-5fd5619f2cc1dcf4e7c051add2deaf5d","data":{"category":"Procedure","expenseAccount":null,"name":"Leg Casting","price":2,"pricingType":null,"lastModified":"2015-11-11T21:53:29.953Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:29.953Z","name":"2015-11-11T21:53:29.953Z","price":"2015-11-11T21:53:29.953Z"}}},{"_id":"pricing_2_5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","_rev":"1-7f85b8fb293360badee861fb4a685721","data":{"category":"Ward","expenseAccount":null,"name":"Gauze pad","price":3,"pricingType":null,"lastModified":"2015-11-11T21:53:52.661Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"category":"2015-11-11T21:53:52.661Z","name":"2015-11-11T21:53:52.661Z","price":"2015-11-11T21:53:52.661Z"}}},{"_id":"pricing_2_5931700E-7965-23B1-9835-2D1615E7E755","_rev":"2-300f644f420f7f76581093329a9aa519","data":{"category":"Imaging","expenseAccount":null,"name":"Xray Hand","price":12,"pricingType":"Imaging Procedure","lastModified":"2015-11-11T21:52:55.549Z","modifiedBy":"Admin User","pricingOverrides":["9C4DC6CF-EC9B-B303-A483-6B80930CC658"],"modifiedFields":{"category":"2015-11-11T21:52:55.549Z","name":"2015-11-11T21:52:55.549Z","price":"2015-11-11T21:52:55.549Z","pricingType":"2015-11-11T21:52:55.549Z"}},"_revisions":{"start":2,"ids":["300f644f420f7f76581093329a9aa519","9f00f9d6a35374e7d7fcbeffd8d4697b"]}},{"_id":"pricing_2_F71A1788-3407-515B-8006-F9CC788CA8EA","_rev":"2-9762d8a2d76d242671a3bea610a0904f","data":{"category":"Lab","expenseAccount":null,"name":"Blood test","price":123,"pricingType":"Lab Procedure","lastModified":"2015-11-11T21:06:20.719Z","modifiedBy":"Admin User","pricingOverrides":["FBF5B1A6-BBEE-6D17-99C8-EB4A91358183"],"modifiedFields":{"category":"2015-11-11T21:06:20.719Z","name":"2015-11-11T21:06:20.719Z","price":"2015-11-11T21:06:20.719Z","pricingType":"2015-11-11T21:06:20.719Z"}},"_revisions":{"start":2,"ids":["9762d8a2d76d242671a3bea610a0904f","e6eada16de79ddba78e890c01837a3f5"]}},{"_id":"procCharge_2_0834BF27-A2E0-5ADD-9509-B97CA547E532","_rev":"1-0bb58d85915b11cbcb1547ba44b86f5f","data":{"quantity":1,"dateCharged":"2015-11-13T05:00:00.000Z","lastModified":"2015-11-13T16:11:54.012Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-13T16:11:54.012Z","quantity":"2015-11-13T16:11:54.012Z"}}},{"_id":"procCharge_2_17BC9913-E49F-FB8A-AA42-4F617D839510","_rev":"1-2917bd58af0d9cbb9e3835013c857d2f","data":{"quantity":1,"dateCharged":"2015-11-12T05:00:00.000Z","lastModified":"2015-11-12T21:53:52.879Z","modifiedBy":"Admin User","medication":null,"pricingItem":"1D198B41-338B-6E49-8BB1-4696D5DAD715","modifiedFields":{"dateCharged":"2015-11-12T21:53:52.879Z","quantity":"2015-11-12T21:53:52.879Z"}}},{"_id":"procCharge_2_2648E500-C287-2EE4-B569-99D6291FB46C","_rev":"2-1875764ed6d4a41e96277d678bcda2b3","_deleted":true,"_revisions":{"start":2,"ids":["1875764ed6d4a41e96277d678bcda2b3","f0554786c3ad14c941dced65e1df8649"]}},{"_id":"procCharge_2_412AD48B-EDD4-E5E2-8134-BB3B5E459972","_rev":"1-2cdee6e8d8fd1207c073b5e6f33b4c6e","data":{"quantity":12,"dateCharged":"2015-11-03T05:00:00.000Z","lastModified":"2015-11-12T21:18:30.366Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-12T21:18:30.366Z","quantity":"2015-11-12T21:18:30.366Z"}}},{"_id":"procCharge_2_561AD584-144B-D21F-840A-8600B8D900CF","_rev":"1-8f30246e0bba661deeb2c08617ec1128","data":{"quantity":12,"dateCharged":"2015-11-11T05:00:00.000Z","lastModified":"2015-11-13T16:24:24.528Z","modifiedBy":"Admin User","medication":null,"pricingItem":"5029F0F9-BBCF-62F5-BA2B-E8990AC7D151","modifiedFields":{"dateCharged":"2015-11-13T16:24:24.528Z","quantity":"2015-11-13T16:24:24.528Z"}}},{"_id":"procCharge_2_704FA289-CA15-A178-B571-D0ECCE8229F3","_rev":"2-6d00bf1656e7ef89bc6ba38c3711982b","_deleted":true,"_revisions":{"start":2,"ids":["6d00bf1656e7ef89bc6ba38c3711982b","2103b76190a412ab081bae469ef27dee"]}},{"_id":"procCharge_2_A28911F7-FC62-9F3D-A82E-8EB0D43B9B68","_rev":"2-3959e9c3eb93a0fd7bc1d36ece0dbcd9","_deleted":true,"_revisions":{"start":2,"ids":["3959e9c3eb93a0fd7bc1d36ece0dbcd9","b5b4fd9fa56d91b689be62a9fc0506ae"]}},{"_id":"procCharge_2_A2F0320B-AFD0-BB29-AFFE-6470FD537D05","_rev":"1-d29a0c613aa6282b87a3e3eb37278453","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"quantity":12,"dateCharged":"2016-02-09T20:18:54.966Z","lastModified":"2016-02-09T20:18:59.012Z","modifiedBy":"Admin User","medication":"igxvfw26_lh","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T20:18:59.012Z","quantity":"2016-02-09T20:18:59.012Z","medicationTitle":"2016-02-09T20:18:59.012Z","priceOfMedication":"2016-02-09T20:18:59.012Z"}}},{"_id":"procCharge_2_BDAC9E94-96A0-1994-9196-BD3F56F891CA","_rev":"1-090a8baf0cf5219ab842f6a5f85c98b2","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:20:16.119Z","lastModified":"2016-02-09T19:20:22.089Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:20:22.089Z","quantity":"2016-02-09T19:20:22.089Z","medication":"2016-02-09T19:20:22.089Z","medicationTitle":"2016-02-09T19:20:22.089Z","priceOfMedication":"2016-02-09T19:20:22.089Z"}}},{"_id":"procCharge_2_F632124D-557D-0B35-8213-F7054DE6AFB0","_rev":"1-f88672a41bab0bf53f3d744944b623e5","data":{"medicationTitle":"Acetaminophen 500 MG","priceOfMedication":12,"medication":"","quantity":12,"dateCharged":"2016-02-09T19:16:13.269Z","lastModified":"2016-02-09T19:16:22.209Z","modifiedBy":"Admin User","pricingItem":null,"modifiedFields":{"dateCharged":"2016-02-09T19:16:22.209Z","quantity":"2016-02-09T19:16:22.209Z","medication":"2016-02-09T19:16:22.209Z","medicationTitle":"2016-02-09T19:16:22.209Z","priceOfMedication":"2016-02-09T19:16:22.209Z"}}},{"_id":"procedure_2_539C4B9B-B275-EF14-8BA2-9CAC6403424A","_rev":"1-e4a243fe73d67885206ff1d406beba1a","data":{"anesthesiaType":null,"anesthesiologist":null,"assistant":null,"description":"Leg casting","cptCode":"Leg casting","location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-12T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-12T21:54:00.381Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["17BC9913-E49F-FB8A-AA42-4F617D839510"],"modifiedFields":{"procedureDate":"2015-11-12T21:54:00.381Z","description":"2015-11-12T21:54:00.381Z","cptCode":"2015-11-12T21:54:00.381Z","timeStarted":"2015-11-12T21:54:00.381Z","timeEnded":"2015-11-12T21:54:00.381Z","physician":"2015-11-12T21:54:00.381Z"}}},{"_id":"procedure_2_653A07CE-66E2-1DC8-A83C-4A25934559F0","_rev":"11-9852c642c6108359ec3d1a1915be7d77","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"Fix broken leg","cptCode":null,"location":null,"notes":null,"physician":"Dr Watson","procedureDate":"2015-11-13T05:00:00.000Z","timeStarted":"","timeEnded":"","lastModified":"2015-11-13T16:11:57.940Z","modifiedBy":"Admin User","visit":"666DFC61-3230-A865-A145-C7D9139DA1CA","charges":["0834BF27-A2E0-5ADD-9509-B97CA547E532","A2F0320B-AFD0-BB29-AFFE-6470FD537D05"],"modifiedFields":{"procedureDate":"2015-11-13T16:11:57.940Z","description":"2015-11-13T16:11:57.940Z","timeStarted":"2015-11-13T16:11:57.940Z","timeEnded":"2015-11-13T16:11:57.940Z","physician":"2015-11-13T16:11:57.940Z","anesthesiaType":"2015-11-13T16:11:57.940Z"}},"_revisions":{"start":11,"ids":["9852c642c6108359ec3d1a1915be7d77","32f7b134f4a1489bad30b20b41a402b7","79317aa8224c831799a41588c9c00572","25edbe7f3e8f872997aec5b8e57959c0","53e45632484af05ac967f6af430bced9","8700b634cefddb7c2ef0b810e4d8241a","e0abfee94018abcefb7b541c6bb7b242","715ed4e72deba043868bfbe500f964a0","483b770e04706f935dc6275abf496a3a","0f22a93f70def208660a024b0fa6a6c6","b078e6e7004154529f8fd0901b60ed19"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_invoice","_rev":"3-f0ef6923c78e739d9228517a4813b646","data":{"prefix":null,"value":3},"_revisions":{"start":3,"ids":["f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"sequence_2_patient","_rev":"1-5bc31ffefa482f2e66299cf0704623c8","data":{"prefix":null,"value":1}},{"_id":"visit_2_666DFC61-3230-A865-A145-C7D9139DA1CA","_rev":"12-9f26178fcda83e39cc9df1950035a7fc","data":{"dischargeInfo":null,"endDate":"2015-11-12T05:00:00.000Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-01T04:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-12T21:47:53.994Z","modifiedBy":"Admin User","patient":"8F7CEF9B-D9C6-E4C4-8BE2-E4DC1E87FCDA","vitals":[],"procedures":["653A07CE-66E2-1DC8-A83C-4A25934559F0"],"medication":["7F51BB93-6086-49D0-A284-FEB6C6690C95"],"labs":["0762040A-CAC7-130F-8D0C-E3DE9245EE38"],"imaging":["9DF8A9FF-D32D-371C-8F04-7D26B9EF5CB9"],"charges":["561AD584-144B-D21F-840A-8600B8D900CF"],"modifiedFields":{"visitType":"2015-11-12T21:15:12.160Z","startDate":"2015-11-12T21:15:12.160Z","status":"2015-11-12T21:47:53.994Z","outPatient":"2015-11-12T21:15:12.160Z","endDate":"2015-11-12T21:47:53.994Z"}},"_revisions":{"start":12,"ids":["9f26178fcda83e39cc9df1950035a7fc","64ef0abb729090bd64b948f9ca2318de","19a1560274f7e5dc07c3b6b0543278a1","793cb2bc5919ef9ced471818f5e7c3b5","8201fa77027c3929455f4c9368ce1c32","4f345e06fefbc87fa23fa1a0d194d1ee","e82f9737c00c8b9004653355ed0cb743","03b09430dde4f6d3c5b62f1c5c6b1378","1db70a4f91b8ed3da25df05dcc91713d","5745b4455c849281c543b2c447feb480","37ad5eae5583240c5143012937658d48","c35ad6c0332fc471d3a8fa485a48d1de"]}}]} +{"seq":116} diff --git a/tests/fixtures/default.txt b/tests/fixtures/default.txt index 1b8e433c73..5512a47ef5 100644 --- a/tests/fixtures/default.txt +++ b/tests/fixtures/default.txt @@ -1,7 +1,7 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:23:08.224Z","db_info":{"db_name":"main","doc_count":25,"doc_del_count":0,"update_seq":50,"purge_seq":0,"compact_running":false,"disk_size":102507,"data_size":45094,"instance_start_time":"1486135329738579","disk_format_version":6,"committed_update_seq":50,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:49:54.252Z","db_info":{"db_name":"main","doc_count":30,"doc_del_count":0,"update_seq":54,"purge_seq":0,"compact_running":false,"disk_size":102507,"data_size":48145,"instance_start_time":"1488836930038548","disk_format_version":6,"committed_update_seq":54,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} {"seq":3} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":22} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-4bdc8957d4338cde0bdce05a2ecfe7b5","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["4bdc8957d4338cde0bdce05a2ecfe7b5"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-a1cd6b8922ed0f24a090ba9fd96f5c05","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["a1cd6b8922ed0f24a090ba9fd96f5c05"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}}]} -{"seq":50} +{"docs":[{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":5} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-4bdc8957d4338cde0bdce05a2ecfe7b5","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["4bdc8957d4338cde0bdce05a2ecfe7b5"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-a1cd6b8922ed0f24a090ba9fd96f5c05","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["a1cd6b8922ed0f24a090ba9fd96f5c05"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}}]} +{"seq":54} diff --git a/tests/fixtures/imaging.txt b/tests/fixtures/imaging.txt index 53a22f008a..f0b396e5bb 100644 --- a/tests/fixtures/imaging.txt +++ b/tests/fixtures/imaging.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:25:06.834Z","db_info":{"db_name":"main","doc_count":70,"doc_del_count":0,"update_seq":95,"purge_seq":0,"compact_running":false,"disk_size":118888,"data_size":70333,"instance_start_time":"1486135418197026","disk_format_version":6,"committed_update_seq":95,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:51:08.878Z","db_info":{"db_name":"main","doc_count":75,"doc_del_count":0,"update_seq":99,"purge_seq":0,"compact_running":false,"disk_size":131176,"data_size":73446,"instance_start_time":"1488837006689004","disk_format_version":6,"committed_update_seq":99,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} {"seq":5} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":21} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-6f596cec9eb82609308fd9d25a9f9df2","version":4,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'gender':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_C47BE127-E509-6322-BB33-2E6ABE03D0F0","_rev":"2-44597ea8b1cdd20dc8d2c0ad9b2edbb6","data":{"allDay":true,"provider":"Dr Nick","location":"Hospital","appointmentType":"Followup","startDate":"2015-12-30T06:00:00.000Z","endDate":"2015-12-30T06:00:00.000Z","notes":null,"status":"Scheduled","lastModified":"2015-12-29T04:14:36.585Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","modifiedFields":{"appointmentType":"2015-12-29T04:14:21.124Z","allDay":"2015-12-29T04:14:21.124Z","startDate":"2015-12-29T04:14:36.585Z","endDate":"2015-12-29T04:14:36.585Z","location":"2015-12-29T04:14:21.124Z","provider":"2015-12-29T04:14:21.124Z"}},"_revisions":{"start":2,"ids":["44597ea8b1cdd20dc8d2c0ad9b2edbb6","953a11c67a694ef2daa469bd8c0f40ec"]}},{"_id":"imaging_2_12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7","_rev":"1-3237f1a60f7ef9869553893a25e91e87","data":{"imagingDate":null,"notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-12-29T04:15:41.380Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:15:41.382Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:15:41.382Z","status":"2015-12-29T04:15:41.382Z","requestedBy":"2015-12-29T04:15:41.382Z","requestedDate":"2015-12-29T04:15:41.382Z"}}},{"_id":"imaging_2_51AFF85A-69C0-97C1-B22C-716A1BA7B80B","_rev":"1-3e1a5d957291144f7ba1e9c0c7c2cb12","data":{"imagingDate":"2015-12-29T04:07:03.693Z","notes":null,"radiologist":"Dr Xray","requestedBy":"Admin User","requestedDate":"2015-12-29T04:07:03.694Z","result":null,"status":"Completed","lastModified":"2015-12-29T04:07:03.744Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:07:03.744Z","status":"2015-12-29T04:07:03.744Z","imagingDate":"2015-12-29T04:07:03.744Z","requestedBy":"2015-12-29T04:07:03.744Z","requestedDate":"2015-12-29T04:07:03.744Z"}}},{"_id":"invLocation_2_0323721B-EDD0-6C91-BB34-52FBEACBA7DE","_rev":"3-f43e02982eff2b35453b4dcf537fec3f","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:13:47.396Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:13:47.396Z"}},"_revisions":{"start":3,"ids":["f43e02982eff2b35453b4dcf537fec3f","e8c15241efd7bb6c8bf891c28558d83b","c2e397e9ebd1266da5de2e1a3033fcc6"]}},{"_id":"invLocation_2_24BB235E-B271-AF61-9A3D-9ACD77CE25AF","_rev":"3-b8964e3b548efa84d5602224e88a1126","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:08:57.289Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:08:57.289Z"}},"_revisions":{"start":3,"ids":["b8964e3b548efa84d5602224e88a1126","dff7e3f8434279a562a3d4ffc0106c6e","2d8c410350e7ecfffd6e496f6f05ca30"]}},{"_id":"invLocation_2_32BCC947-E272-1564-90E1-C6E2ECE14881","_rev":"2-74b9d0e13f10a766c8e02a411b21bc9e","data":{"quantity":12,"location":"Warehouse","aisleLocation":"A1","lastModified":"2015-12-29T03:47:25.988Z","modifiedBy":"Admin User","modifiedFields":{"aisleLocation":"2015-12-29T03:47:25.919Z","location":"2015-12-29T03:47:25.919Z","quantity":"2015-12-29T03:47:25.988Z"}},"_revisions":{"start":2,"ids":["74b9d0e13f10a766c8e02a411b21bc9e","8adc0c9f4543aebccdfce691b8c1199d"]}},{"_id":"invLocation_2_7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","_rev":"3-85e5ea976718b1331eade5d9f567654b","data":{"quantity":0,"location":"Warehouse","aisleLocation":null,"lastModified":"2015-12-29T03:46:41.557Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:13:47.288Z","quantity":"2015-12-29T03:46:41.557Z"}},"_revisions":{"start":3,"ids":["85e5ea976718b1331eade5d9f567654b","eb663365f6944558113da9820789b8fd","ac3af5754777c65209c3d9c7cc03dfb2"]}},{"_id":"invLocation_2_DBCF3E06-B812-B6C7-930E-74F9372D384A","_rev":"3-a15f0e36baae0abfa52ae68b42e3ad0e","data":{"quantity":999998,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-12-29T04:01:16.092Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:08:57.191Z","quantity":"2015-12-29T04:01:16.092Z"}},"_revisions":{"start":3,"ids":["a15f0e36baae0abfa52ae68b42e3ad0e","d365a641356ccd999cf5f91ec842f5a9","e8dfec40fbf6418583392d73b24a9b32"]}},{"_id":"invPurchase_2_05760051-8BD1-ACC0-8013-0C59A545FB8D","_rev":"2-d7477df9559ec794be0e3084f09c310b","data":{"purchaseCost":12,"lotNumber":"","dateReceived":"2015-11-01T05:00:00.000Z","originalQuantity":25,"currentQuantity":0,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T03:46:41.558Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:12:56.853Z","purchaseCost":"2015-12-29T03:12:56.853Z","lotNumber":"2015-12-29T03:12:56.853Z","vendor":"2015-12-29T03:12:56.853Z","vendorItemNo":"2015-12-29T03:12:56.853Z","originalQuantity":"2015-12-29T03:12:56.853Z","currentQuantity":"2015-12-29T03:46:41.558Z","inventoryItem":"2015-12-29T03:12:56.853Z"}},"_revisions":{"start":2,"ids":["d7477df9559ec794be0e3084f09c310b","2b41a3edbfe25818058eca69712b2033"]}},{"_id":"invPurchase_2_155B2B94-6C47-E6B5-BD1E-11F375CB2C29","_rev":"1-8308be24f6677a3a6aefc7cdde9b1c13","data":{"purchaseCost":6,"lotNumber":null,"dateReceived":"2015-12-03T06:00:00.000Z","originalQuantity":12,"currentQuantity":12,"expirationDate":null,"expired":false,"location":"Warehouse","aisleLocation":"A1","giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":"pcs","invoiceNo":"","lastModified":"2015-12-29T03:47:25.866Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:47:25.866Z","distributionUnit":"2015-12-29T03:47:25.866Z","inventoryItem":"2015-12-29T03:47:25.866Z","invoiceNo":"2015-12-29T03:47:25.866Z","originalQuantity":"2015-12-29T03:47:25.866Z","quantityGroups":"2015-12-29T03:47:25.866Z","purchaseCost":"2015-12-29T03:47:25.866Z","vendor":"2015-12-29T03:47:25.866Z","vendorItemNo":"2015-12-29T03:47:25.866Z","location":"2015-12-29T03:47:25.866Z","aisleLocation":"2015-12-29T03:47:25.866Z","currentQuantity":"2015-12-29T03:47:25.866Z"},"quantityGroups":[{"index":0,"unit":"pcs","firstQuantity":true,"quantity":"12"}]}},{"_id":"invPurchase_2_E3B2184F-4ECA-3B76-92C8-437846C2E3DC","_rev":"2-846e30db369e739e0603938b12776d45","data":{"purchaseCost":12345,"lotNumber":null,"dateReceived":"2015-12-01T06:00:00.000Z","originalQuantity":1000000,"currentQuantity":999998,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtc6w3_31","vendor":"ACME INC","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T04:01:16.093Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:08:23.921Z","purchaseCost":"2015-12-29T03:08:23.921Z","vendor":"2015-12-29T03:08:23.921Z","originalQuantity":"2015-12-29T03:08:23.921Z","currentQuantity":"2015-12-29T04:01:16.093Z","inventoryItem":"2015-12-29T03:08:23.921Z"}},"_revisions":{"start":2,"ids":["846e30db369e739e0603938b12776d45","03ddad7882d9ed7041637de509902109"]}},{"_id":"invRequest_2_2A5251B5-1919-CB55-8757-A53DC057A77E","_rev":"1-222c0c115dc924e7d90cbde2b6023ebd","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":null,"markAsConsumed":true,"quantity":1000000,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:08:57.351Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:08:57.351Z","dateCompleted":"2015-12-29T03:08:57.351Z","quantity":"2015-12-29T03:08:57.351Z","deliveryLocation":"2015-12-29T03:08:57.351Z","transactionType":"2015-12-29T03:08:57.351Z","locationsAffected":"2015-12-29T03:08:57.351Z","status":"2015-12-29T03:08:57.351Z","completedBy":"2015-12-29T03:08:57.351Z"},"locationsAffected":[{"name":"No Location","quantity":"1000000"}]}},{"_id":"invRequest_2_6F095231-0D58-E48D-B59F-8D4CB3965802","_rev":"1-f709e83b929a4ac8e25c39de04bb36d9","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.01,"dateCompleted":"2015-12-29T04:01:16.080Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":2,"quantityAtCompletion":1000000,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T04:01:16.251Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":null,"modifiedFields":{"dateCompleted":"2015-12-29T04:01:16.251Z","quantity":"2015-12-29T04:01:16.251Z","transactionType":"2015-12-29T04:01:16.251Z","markAsConsumed":"2015-12-29T04:01:16.251Z","adjustPurchases":"2015-12-29T04:01:16.251Z","costPerUnit":"2015-12-29T04:01:16.251Z","quantityAtCompletion":"2015-12-29T04:01:16.251Z","purchasesAffected":"2015-12-29T04:01:16.251Z","locationsAffected":"2015-12-29T04:01:16.251Z","status":"2015-12-29T04:01:16.251Z","completedBy":"2015-12-29T04:01:16.251Z"},"purchasesAffected":[{"id":"E3B2184F-4ECA-3B76-92C8-437846C2E3DC","quantity":2}],"locationsAffected":[{"name":"Pharmacy","quantity":2}]}},{"_id":"invRequest_2_91481B28-0A00-9C72-9094-E34D6B70442D","_rev":"1-c1b1d2ef55725427ea6f31fafd43a776","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-12-29T03:47:47.911Z","deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":"Pharmacy","markAsConsumed":true,"quantity":2,"quantityAtCompletion":null,"reason":null,"requestedBy":"Admin User","status":"Requested","transactionType":"Request","lastModified":"2015-12-29T03:47:47.912Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:47:47.912Z","quantity":"2015-12-29T03:47:47.912Z","deliveryLocation":"2015-12-29T03:47:47.912Z","expenseAccount":"2015-12-29T03:47:47.912Z","dateRequested":"2015-12-29T03:47:47.912Z","requestedBy":"2015-12-29T03:47:47.912Z","status":"2015-12-29T03:47:47.912Z"}}},{"_id":"invRequest_2_B419E42C-87A8-1AFC-BDEF-3145ED774BE7","_rev":"1-a61eb2eac18550ed06ae528db3de51f0","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Warehouse","expenseAccount":null,"markAsConsumed":true,"quantity":25,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:13:47.447Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:13:47.447Z","dateCompleted":"2015-12-29T03:13:47.447Z","quantity":"2015-12-29T03:13:47.447Z","deliveryLocation":"2015-12-29T03:13:47.447Z","transactionType":"2015-12-29T03:13:47.447Z","locationsAffected":"2015-12-29T03:13:47.447Z","status":"2015-12-29T03:13:47.447Z","completedBy":"2015-12-29T03:13:47.447Z"},"locationsAffected":[{"name":"No Location","quantity":"25"}]}},{"_id":"invRequest_2_CA5F4301-1600-1230-B276-0B3C98402C13","_rev":"1-9c9872e5caf5f80fe4cf434e014fcfe3","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.48,"dateCompleted":"2015-12-28T06:00:00.000Z","dateRequested":"2015-12-29T03:46:41.543Z","deliveryAisle":null,"deliveryLocation":"Ward 1","expenseAccount":"Ward","markAsConsumed":true,"quantity":25,"quantityAtCompletion":25,"reason":null,"requestedBy":"Admin User","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T03:46:41.732Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:46:41.732Z","quantity":"2015-12-29T03:46:41.732Z","dateCompleted":"2015-12-29T03:46:41.732Z","deliveryLocation":"2015-12-29T03:46:41.732Z","expenseAccount":"2015-12-29T03:46:41.732Z","dateRequested":"2015-12-29T03:46:41.732Z","requestedBy":"2015-12-29T03:46:41.732Z","adjustPurchases":"2015-12-29T03:46:41.732Z","costPerUnit":"2015-12-29T03:46:41.732Z","quantityAtCompletion":"2015-12-29T03:46:41.732Z","purchasesAffected":"2015-12-29T03:46:41.732Z","locationsAffected":"2015-12-29T03:46:41.732Z","status":"2015-12-29T03:46:41.732Z","completedBy":"2015-12-29T03:46:41.732Z"},"purchasesAffected":[{"id":"05760051-8BD1-ACC0-8013-0C59A545FB8D","quantity":25}],"locationsAffected":[{"name":"Warehouse","quantity":25}]}},{"_id":"inventory_2_iiqtc6w3_31","_rev":"3-0c0a71f273bf0633cafce271b0f35007","data":{"description":null,"friendlyId":"m00001","name":"Cefazolin 500mg vial (Hazolin)","quantity":999998,"crossReference":null,"inventoryType":"Medication","price":null,"reorderPoint":null,"distributionUnit":"vial","rank":null,"lastModified":"2015-12-29T04:01:16.249Z","modifiedBy":"Admin User","locations":["24BB235E-B271-AF61-9A3D-9ACD77CE25AF","DBCF3E06-B812-B6C7-930E-74F9372D384A"],"purchases":["E3B2184F-4ECA-3B76-92C8-437846C2E3DC"],"modifiedFields":{"name":"2015-12-29T03:08:24.053Z","inventoryType":"2015-12-29T03:08:24.053Z","distributionUnit":"2015-12-29T03:08:24.053Z","quantity":"2015-12-29T04:01:16.249Z","friendlyId":"2015-12-29T03:08:24.053Z"}},"_revisions":{"start":3,"ids":["0c0a71f273bf0633cafce271b0f35007","42bc38c66d9a87103c7871aa9aadb6b5","295e3c0d1de3d7a7d384ae5090d82125"]}},{"_id":"inventory_2_iiqtim0c_ex","_rev":"4-6900f25cb0aa33334fb6c69e4a828718","data":{"description":null,"friendlyId":"s00001","name":"Pumpset Kangaroo 1000ml","quantity":12,"crossReference":null,"inventoryType":"Supply","price":null,"reorderPoint":null,"distributionUnit":"pcs","rank":null,"lastModified":"2015-12-29T03:47:26.017Z","modifiedBy":"Admin User","locations":["0323721B-EDD0-6C91-BB34-52FBEACBA7DE","7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","32BCC947-E272-1564-90E1-C6E2ECE14881"],"purchases":["05760051-8BD1-ACC0-8013-0C59A545FB8D","155B2B94-6C47-E6B5-BD1E-11F375CB2C29"],"modifiedFields":{"name":"2015-12-29T03:12:56.959Z","inventoryType":"2015-12-29T03:12:56.959Z","distributionUnit":"2015-12-29T03:12:56.959Z","quantity":"2015-12-29T03:47:26.017Z","friendlyId":"2015-12-29T03:12:56.959Z"}},"_revisions":{"start":4,"ids":["6900f25cb0aa33334fb6c69e4a828718","03eb3fc36799eb0e78c1d4f5b45e50a0","064996d833372bc743ccd60baa1174b9","1622cc9c6428d24950f02c88112840f4"]}},{"_id":"lab_2_C9274C34-248C-FF7C-9E8B-F3110467C941","_rev":"2-78aaf934410f626a7dc64c8ce640ad17","data":{"labDate":"2015-12-29T04:07:25.725Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:03:22.879Z","result":"Normal","status":"Completed","lastModified":"2015-12-29T04:07:25.725Z","modifiedBy":"Admin User","labType":"A33BFA09-AFBB-CA35-A01C-702B568FFAE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:07:25.725Z","requestedBy":"2015-12-29T04:03:22.927Z","requestedDate":"2015-12-29T04:03:22.927Z","result":"2015-12-29T04:07:25.725Z","labDate":"2015-12-29T04:07:25.725Z"}},"_revisions":{"start":2,"ids":["78aaf934410f626a7dc64c8ce640ad17","0e55563ae178ae5b340c29a50f168925"]}},{"_id":"lab_2_EE3063E6-832D-930D-AD4E-D27341709886","_rev":"1-b0364bd6b060df4a2084ca292de1ad71","data":{"labDate":null,"notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:18:34.699Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:18:34.731Z","modifiedBy":"Admin User","labType":"4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:18:34.731Z","requestedBy":"2015-12-29T04:18:34.731Z","requestedDate":"2015-12-29T04:18:34.731Z"}}},{"_id":"lookup_2_aisle_location_list","_rev":"1-255c62c74fb06e5c13664e9e70aebef5","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["A1"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-499cca90fccff759c62b2fc781010226","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["27001"]}},{"_id":"lookup_2_diagnosis_list","_rev":"1-889e0d198f50d28df33bf522106b9438","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fall from in-line roller-skates, initial encounter"]}},{"_id":"lookup_2_expense_account_list","_rev":"2-3404736b154767f3fe30e297704480be","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward"]},"_revisions":{"start":2,"ids":["3404736b154767f3fe30e297704480be","36426f839aa10324a85e92d34fcf2c26"]}},{"_id":"lookup_2_patient_status_list","_rev":"1-01d7dfb8ec77de492bf913c5c763578c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Scheduled for surgery"]}},{"_id":"lookup_2_physician_list","_rev":"1-99c8212cef905d552ab95fc88b8c3d5b","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Nick"]}}]} -{"seq":75} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"lookup_2_procedure_list","_rev":"1-d48989bf01a1ae70a26e397c43266278","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["hip adductor release"]}},{"_id":"lookup_2_radiologists","_rev":"1-f029e944b51dcc7fd6f980d72c7027c7","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Xray"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-a2760a7c86532da3f92ac75899b37e06","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME INC"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-d373d65b719c266173d92d3bb8f14e9f","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Hospital"]}},{"_id":"lookup_2_warehouse_list","_rev":"3-86923622f95bb3f49a906cb7cbacdc85","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward 1","Warehouse"]},"_revisions":{"start":3,"ids":["86923622f95bb3f49a906cb7cbacdc85","64a1b3813d337c7000044dbc2de21892","4f316909ed8500d0f80cf20a684ce343"]}},{"_id":"medication_2_7B63E873-D056-CCC5-A69C-60064472A16E","_rev":"1-1ebd1e9a0f4dd4d90b52eb37db7fb493","data":{"notes":null,"prescription":"Twice a day for two days","prescriptionDate":"2015-12-28T06:00:00.000Z","quantity":4,"refills":null,"requestedDate":"2015-12-29T04:16:44.877Z","requestedBy":"Admin User","status":"Requested","lastModified":"2015-12-29T04:16:44.879Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:16:44.879Z","prescription":"2015-12-29T04:16:44.879Z","quantity":"2015-12-29T04:16:44.879Z","status":"2015-12-29T04:16:44.879Z","requestedBy":"2015-12-29T04:16:44.879Z","requestedDate":"2015-12-29T04:16:44.879Z"}}},{"_id":"medication_2_9187CEE0-13EC-1816-A2A4-95E9797999BF","_rev":"1-271cd0960f61b322d66b57a994141733","data":{"notes":null,"prescription":"Once a day for 2 days","prescriptionDate":"2015-12-01T06:00:00.000Z","quantity":2,"refills":null,"requestedDate":"2015-12-29T04:01:16.079Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-12-29T04:01:16.096Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:01:16.096Z","prescription":"2015-12-29T04:01:16.096Z","quantity":"2015-12-29T04:01:16.096Z","status":"2015-12-29T04:01:16.096Z","requestedBy":"2015-12-29T04:01:16.096Z","requestedDate":"2015-12-29T04:01:16.096Z"}}},{"_id":"patient_2_C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","_rev":"4-dfabed4aec7088c46df7dac9bce8bc3f","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":"2013-08-06T04:00:00.000Z","economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":"Scheduled for surgery","lastModified":"2016-02-22T21:57:21.549Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-12-29T03:51:02.781Z","firstName":"2015-12-29T03:51:02.781Z","middleName":"2015-12-29T03:51:02.781Z","lastName":"2015-12-29T03:51:02.781Z","gender":"2015-12-29T03:51:02.781Z","dateOfBirth":"2016-02-22T21:57:21.549Z","status":"2015-12-29T03:53:17.032Z","admitted":"2015-12-29T03:53:58.574Z","sex":"2016-02-22T21:57:21.549Z"}},"_revisions":{"start":4,"ids":["dfabed4aec7088c46df7dac9bce8bc3f","1351af326b99acc03278830f30192916","105429e78d710023d6d490e880a3132a","fa6de36be0214f08f09477729bdfb339"]}},{"_id":"pricing_2_4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","_rev":"1-410ff865070244eac14c5cad5db0ad80","data":{"category":"Lab","expenseAccount":null,"name":"Fasting Blood Sugar (FBS)","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:18:34.703Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:18:34.703Z","category":"2015-12-29T04:18:34.703Z","pricingType":"2015-12-29T04:18:34.703Z"}}},{"_id":"pricing_2_A33BFA09-AFBB-CA35-A01C-702B568FFAE8","_rev":"1-70ff211de7621293ffbd91df901f6d0f","data":{"category":"Lab","expenseAccount":null,"name":"Bleeding Time","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:03:22.884Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:03:22.884Z","category":"2015-12-29T04:03:22.884Z","pricingType":"2015-12-29T04:03:22.884Z"}}},{"_id":"pricing_2_B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","_rev":"1-30c9df5437c85bb21539024c7222d307","data":{"category":"Imaging","expenseAccount":null,"name":"Ankle (Any Single View)","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-12-29T04:07:03.700Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:07:03.700Z","category":"2015-12-29T04:07:03.700Z","pricingType":"2015-12-29T04:07:03.700Z"}}},{"_id":"procCharge_2_0AD46995-188B-EFB9-8A33-E47B3980476C","_rev":"1-3f577e28daa86e12c2ad71799e383c3b","data":{"quantity":1,"dateCharged":"2015-12-29T04:00:00.093Z","lastModified":"2015-12-29T04:00:08.611Z","modifiedBy":"Admin User","medication":"iiqtc6w3_31","pricingItem":null,"modifiedFields":{"dateCharged":"2015-12-29T04:00:08.611Z","quantity":"2015-12-29T04:00:08.611Z"}}},{"_id":"procedure_2_398B4F58-152F-1476-8ED1-329C4D85E25F","_rev":"5-979bd8081e0ae3ccebf595c28bafd145","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"hip adductor release","cptCode":"27001","location":null,"notes":null,"physician":"Dr Nick","procedureDate":"2015-12-01T06:00:00.000Z","timeStarted":null,"timeEnded":null,"lastModified":"2015-12-29T04:00:33.229Z","modifiedBy":"Admin User","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":["0AD46995-188B-EFB9-8A33-E47B3980476C"],"modifiedFields":{"procedureDate":"2015-12-29T03:59:55.401Z","description":"2015-12-29T03:59:37.244Z","physician":"2015-12-29T03:59:37.244Z","anesthesiaType":"2015-12-29T03:59:37.244Z","cptCode":"2015-12-29T04:00:33.229Z"}},"_revisions":{"start":5,"ids":["979bd8081e0ae3ccebf595c28bafd145","561ab91abdd5e0f240a3ec30c9a3e09c","0a938774f0f0e600f15dd29d08b98b50","5570e1e8726f29f430a5de6e81a36e60","6c0abd3cf72cb182b05caa21150fb113"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_inventory_Supply","_rev":"1-538fc2bf7cd4745eea01fcf24ced6164","data":{"prefix":"s","value":1}},{"_id":"sequence_2_patient","_rev":"5-f6fd8c9cb7b07567399a04a72f02822a","data":{"prefix":null,"value":1},"_revisions":{"start":5,"ids":["f6fd8c9cb7b07567399a04a72f02822a","79dabe4ed5c7897e103171a7bf8bf1b6","945c072575a32fca103968a3cd425c31","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_03C7BF8B-04E0-DD9E-9469-96A5604F5340","_rev":"12-48973daa88a2567931f70586aa5f4b6e","data":{"dischargeInfo":null,"endDate":"2015-12-29T04:11:00.724Z","examiner":"Dr Nick","history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":"Fall from in-line roller-skates, initial encounter","primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-12-01T15:53:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-12-29T04:11:47.272Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","vitals":["B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC"],"procedures":["398B4F58-152F-1476-8ED1-329C4D85E25F"],"medication":["9187CEE0-13EC-1816-A2A4-95E9797999BF","7B63E873-D056-CCC5-A69C-60064472A16E"],"labs":["C9274C34-248C-FF7C-9E8B-F3110467C941","EE3063E6-832D-930D-AD4E-D27341709886"],"imaging":["51AFF85A-69C0-97C1-B22C-716A1BA7B80B","12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7"],"charges":[],"modifiedFields":{"visitType":"2015-12-29T03:53:58.543Z","startDate":"2015-12-29T04:11:47.272Z","status":"2015-12-29T04:11:47.272Z","outPatient":"2015-12-29T03:53:58.543Z","primaryDiagnosis":"2015-12-29T03:59:37.312Z","examiner":"2015-12-29T04:06:19.274Z","endDate":"2015-12-29T04:11:47.272Z"}},"_revisions":{"start":12,"ids":["48973daa88a2567931f70586aa5f4b6e","0baeb91a16dad77c0d8e55e6b38e6c8e","e26c621939e57cdf40fe92362f5dac3a","7315d0ff5e6eac570c2b47fd6e9d9406","d1be40a55f4329d18cc6c8f8b8b2d55a","e8567f5b5576aa5d4141f2776b24ab58","d54e63df97dd964288c6dd66d049dae9","210c948fb309be4793ca14cec7f3a335","29e6bb7a6732517b79f8c90fbcebdedd","a83b26f6b056f7c54d917160b366a75b","ebed6471bdd978af39c5acfc3f1f34b7","284cb8e69ca4b392156fe1d22866fcfb"]}},{"_id":"vital_2_B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC","_rev":"1-62233a35020adba2b7d65fd09e5e3cba","data":{"dateRecorded":"2015-12-04T04:08:00.000Z","temperature":36.67,"weight":"57lb","height":"3'6\"","sbp":117,"dbp":76,"heartRate":60,"respiratoryRate":12,"lastModified":"2015-12-29T04:11:11.942Z","modifiedBy":"Admin User","modifiedFields":{"dateRecorded":"2015-12-29T04:11:11.942Z","temperature":"2015-12-29T04:11:11.942Z","weight":"2015-12-29T04:11:11.942Z","height":"2015-12-29T04:11:11.942Z","sbp":"2015-12-29T04:11:11.942Z","dbp":"2015-12-29T04:11:11.942Z","heartRate":"2015-12-29T04:11:11.942Z","respiratoryRate":"2015-12-29T04:11:11.942Z"}}}]} -{"seq":95} +{"docs":[{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":7} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-6f596cec9eb82609308fd9d25a9f9df2","version":4,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'gender':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_C47BE127-E509-6322-BB33-2E6ABE03D0F0","_rev":"2-44597ea8b1cdd20dc8d2c0ad9b2edbb6","data":{"allDay":true,"provider":"Dr Nick","location":"Hospital","appointmentType":"Followup","startDate":"2015-12-30T06:00:00.000Z","endDate":"2015-12-30T06:00:00.000Z","notes":null,"status":"Scheduled","lastModified":"2015-12-29T04:14:36.585Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","modifiedFields":{"appointmentType":"2015-12-29T04:14:21.124Z","allDay":"2015-12-29T04:14:21.124Z","startDate":"2015-12-29T04:14:36.585Z","endDate":"2015-12-29T04:14:36.585Z","location":"2015-12-29T04:14:21.124Z","provider":"2015-12-29T04:14:21.124Z"}},"_revisions":{"start":2,"ids":["44597ea8b1cdd20dc8d2c0ad9b2edbb6","953a11c67a694ef2daa469bd8c0f40ec"]}},{"_id":"imaging_2_12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7","_rev":"1-3237f1a60f7ef9869553893a25e91e87","data":{"imagingDate":null,"notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-12-29T04:15:41.380Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:15:41.382Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:15:41.382Z","status":"2015-12-29T04:15:41.382Z","requestedBy":"2015-12-29T04:15:41.382Z","requestedDate":"2015-12-29T04:15:41.382Z"}}},{"_id":"imaging_2_51AFF85A-69C0-97C1-B22C-716A1BA7B80B","_rev":"1-3e1a5d957291144f7ba1e9c0c7c2cb12","data":{"imagingDate":"2015-12-29T04:07:03.693Z","notes":null,"radiologist":"Dr Xray","requestedBy":"Admin User","requestedDate":"2015-12-29T04:07:03.694Z","result":null,"status":"Completed","lastModified":"2015-12-29T04:07:03.744Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:07:03.744Z","status":"2015-12-29T04:07:03.744Z","imagingDate":"2015-12-29T04:07:03.744Z","requestedBy":"2015-12-29T04:07:03.744Z","requestedDate":"2015-12-29T04:07:03.744Z"}}},{"_id":"invLocation_2_0323721B-EDD0-6C91-BB34-52FBEACBA7DE","_rev":"3-f43e02982eff2b35453b4dcf537fec3f","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:13:47.396Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:13:47.396Z"}},"_revisions":{"start":3,"ids":["f43e02982eff2b35453b4dcf537fec3f","e8c15241efd7bb6c8bf891c28558d83b","c2e397e9ebd1266da5de2e1a3033fcc6"]}},{"_id":"invLocation_2_24BB235E-B271-AF61-9A3D-9ACD77CE25AF","_rev":"3-b8964e3b548efa84d5602224e88a1126","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:08:57.289Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:08:57.289Z"}},"_revisions":{"start":3,"ids":["b8964e3b548efa84d5602224e88a1126","dff7e3f8434279a562a3d4ffc0106c6e","2d8c410350e7ecfffd6e496f6f05ca30"]}},{"_id":"invLocation_2_32BCC947-E272-1564-90E1-C6E2ECE14881","_rev":"2-74b9d0e13f10a766c8e02a411b21bc9e","data":{"quantity":12,"location":"Warehouse","aisleLocation":"A1","lastModified":"2015-12-29T03:47:25.988Z","modifiedBy":"Admin User","modifiedFields":{"aisleLocation":"2015-12-29T03:47:25.919Z","location":"2015-12-29T03:47:25.919Z","quantity":"2015-12-29T03:47:25.988Z"}},"_revisions":{"start":2,"ids":["74b9d0e13f10a766c8e02a411b21bc9e","8adc0c9f4543aebccdfce691b8c1199d"]}},{"_id":"invLocation_2_7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","_rev":"3-85e5ea976718b1331eade5d9f567654b","data":{"quantity":0,"location":"Warehouse","aisleLocation":null,"lastModified":"2015-12-29T03:46:41.557Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:13:47.288Z","quantity":"2015-12-29T03:46:41.557Z"}},"_revisions":{"start":3,"ids":["85e5ea976718b1331eade5d9f567654b","eb663365f6944558113da9820789b8fd","ac3af5754777c65209c3d9c7cc03dfb2"]}},{"_id":"invLocation_2_DBCF3E06-B812-B6C7-930E-74F9372D384A","_rev":"3-a15f0e36baae0abfa52ae68b42e3ad0e","data":{"quantity":999998,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-12-29T04:01:16.092Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:08:57.191Z","quantity":"2015-12-29T04:01:16.092Z"}},"_revisions":{"start":3,"ids":["a15f0e36baae0abfa52ae68b42e3ad0e","d365a641356ccd999cf5f91ec842f5a9","e8dfec40fbf6418583392d73b24a9b32"]}},{"_id":"invPurchase_2_05760051-8BD1-ACC0-8013-0C59A545FB8D","_rev":"2-d7477df9559ec794be0e3084f09c310b","data":{"purchaseCost":12,"lotNumber":"","dateReceived":"2015-11-01T05:00:00.000Z","originalQuantity":25,"currentQuantity":0,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T03:46:41.558Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:12:56.853Z","purchaseCost":"2015-12-29T03:12:56.853Z","lotNumber":"2015-12-29T03:12:56.853Z","vendor":"2015-12-29T03:12:56.853Z","vendorItemNo":"2015-12-29T03:12:56.853Z","originalQuantity":"2015-12-29T03:12:56.853Z","currentQuantity":"2015-12-29T03:46:41.558Z","inventoryItem":"2015-12-29T03:12:56.853Z"}},"_revisions":{"start":2,"ids":["d7477df9559ec794be0e3084f09c310b","2b41a3edbfe25818058eca69712b2033"]}},{"_id":"invPurchase_2_155B2B94-6C47-E6B5-BD1E-11F375CB2C29","_rev":"1-8308be24f6677a3a6aefc7cdde9b1c13","data":{"purchaseCost":6,"lotNumber":null,"dateReceived":"2015-12-03T06:00:00.000Z","originalQuantity":12,"currentQuantity":12,"expirationDate":null,"expired":false,"location":"Warehouse","aisleLocation":"A1","giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":"pcs","invoiceNo":"","lastModified":"2015-12-29T03:47:25.866Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:47:25.866Z","distributionUnit":"2015-12-29T03:47:25.866Z","inventoryItem":"2015-12-29T03:47:25.866Z","invoiceNo":"2015-12-29T03:47:25.866Z","originalQuantity":"2015-12-29T03:47:25.866Z","quantityGroups":"2015-12-29T03:47:25.866Z","purchaseCost":"2015-12-29T03:47:25.866Z","vendor":"2015-12-29T03:47:25.866Z","vendorItemNo":"2015-12-29T03:47:25.866Z","location":"2015-12-29T03:47:25.866Z","aisleLocation":"2015-12-29T03:47:25.866Z","currentQuantity":"2015-12-29T03:47:25.866Z"},"quantityGroups":[{"index":0,"unit":"pcs","firstQuantity":true,"quantity":"12"}]}},{"_id":"invPurchase_2_E3B2184F-4ECA-3B76-92C8-437846C2E3DC","_rev":"2-846e30db369e739e0603938b12776d45","data":{"purchaseCost":12345,"lotNumber":null,"dateReceived":"2015-12-01T06:00:00.000Z","originalQuantity":1000000,"currentQuantity":999998,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtc6w3_31","vendor":"ACME INC","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T04:01:16.093Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:08:23.921Z","purchaseCost":"2015-12-29T03:08:23.921Z","vendor":"2015-12-29T03:08:23.921Z","originalQuantity":"2015-12-29T03:08:23.921Z","currentQuantity":"2015-12-29T04:01:16.093Z","inventoryItem":"2015-12-29T03:08:23.921Z"}},"_revisions":{"start":2,"ids":["846e30db369e739e0603938b12776d45","03ddad7882d9ed7041637de509902109"]}},{"_id":"invRequest_2_2A5251B5-1919-CB55-8757-A53DC057A77E","_rev":"1-222c0c115dc924e7d90cbde2b6023ebd","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":null,"markAsConsumed":true,"quantity":1000000,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:08:57.351Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:08:57.351Z","dateCompleted":"2015-12-29T03:08:57.351Z","quantity":"2015-12-29T03:08:57.351Z","deliveryLocation":"2015-12-29T03:08:57.351Z","transactionType":"2015-12-29T03:08:57.351Z","locationsAffected":"2015-12-29T03:08:57.351Z","status":"2015-12-29T03:08:57.351Z","completedBy":"2015-12-29T03:08:57.351Z"},"locationsAffected":[{"name":"No Location","quantity":"1000000"}]}},{"_id":"invRequest_2_6F095231-0D58-E48D-B59F-8D4CB3965802","_rev":"1-f709e83b929a4ac8e25c39de04bb36d9","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.01,"dateCompleted":"2015-12-29T04:01:16.080Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":2,"quantityAtCompletion":1000000,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T04:01:16.251Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":null,"modifiedFields":{"dateCompleted":"2015-12-29T04:01:16.251Z","quantity":"2015-12-29T04:01:16.251Z","transactionType":"2015-12-29T04:01:16.251Z","markAsConsumed":"2015-12-29T04:01:16.251Z","adjustPurchases":"2015-12-29T04:01:16.251Z","costPerUnit":"2015-12-29T04:01:16.251Z","quantityAtCompletion":"2015-12-29T04:01:16.251Z","purchasesAffected":"2015-12-29T04:01:16.251Z","locationsAffected":"2015-12-29T04:01:16.251Z","status":"2015-12-29T04:01:16.251Z","completedBy":"2015-12-29T04:01:16.251Z"},"purchasesAffected":[{"id":"E3B2184F-4ECA-3B76-92C8-437846C2E3DC","quantity":2}],"locationsAffected":[{"name":"Pharmacy","quantity":2}]}},{"_id":"invRequest_2_91481B28-0A00-9C72-9094-E34D6B70442D","_rev":"1-c1b1d2ef55725427ea6f31fafd43a776","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-12-29T03:47:47.911Z","deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":"Pharmacy","markAsConsumed":true,"quantity":2,"quantityAtCompletion":null,"reason":null,"requestedBy":"Admin User","status":"Requested","transactionType":"Request","lastModified":"2015-12-29T03:47:47.912Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:47:47.912Z","quantity":"2015-12-29T03:47:47.912Z","deliveryLocation":"2015-12-29T03:47:47.912Z","expenseAccount":"2015-12-29T03:47:47.912Z","dateRequested":"2015-12-29T03:47:47.912Z","requestedBy":"2015-12-29T03:47:47.912Z","status":"2015-12-29T03:47:47.912Z"}}},{"_id":"invRequest_2_B419E42C-87A8-1AFC-BDEF-3145ED774BE7","_rev":"1-a61eb2eac18550ed06ae528db3de51f0","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Warehouse","expenseAccount":null,"markAsConsumed":true,"quantity":25,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:13:47.447Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:13:47.447Z","dateCompleted":"2015-12-29T03:13:47.447Z","quantity":"2015-12-29T03:13:47.447Z","deliveryLocation":"2015-12-29T03:13:47.447Z","transactionType":"2015-12-29T03:13:47.447Z","locationsAffected":"2015-12-29T03:13:47.447Z","status":"2015-12-29T03:13:47.447Z","completedBy":"2015-12-29T03:13:47.447Z"},"locationsAffected":[{"name":"No Location","quantity":"25"}]}},{"_id":"invRequest_2_CA5F4301-1600-1230-B276-0B3C98402C13","_rev":"1-9c9872e5caf5f80fe4cf434e014fcfe3","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.48,"dateCompleted":"2015-12-28T06:00:00.000Z","dateRequested":"2015-12-29T03:46:41.543Z","deliveryAisle":null,"deliveryLocation":"Ward 1","expenseAccount":"Ward","markAsConsumed":true,"quantity":25,"quantityAtCompletion":25,"reason":null,"requestedBy":"Admin User","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T03:46:41.732Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:46:41.732Z","quantity":"2015-12-29T03:46:41.732Z","dateCompleted":"2015-12-29T03:46:41.732Z","deliveryLocation":"2015-12-29T03:46:41.732Z","expenseAccount":"2015-12-29T03:46:41.732Z","dateRequested":"2015-12-29T03:46:41.732Z","requestedBy":"2015-12-29T03:46:41.732Z","adjustPurchases":"2015-12-29T03:46:41.732Z","costPerUnit":"2015-12-29T03:46:41.732Z","quantityAtCompletion":"2015-12-29T03:46:41.732Z","purchasesAffected":"2015-12-29T03:46:41.732Z","locationsAffected":"2015-12-29T03:46:41.732Z","status":"2015-12-29T03:46:41.732Z","completedBy":"2015-12-29T03:46:41.732Z"},"purchasesAffected":[{"id":"05760051-8BD1-ACC0-8013-0C59A545FB8D","quantity":25}],"locationsAffected":[{"name":"Warehouse","quantity":25}]}},{"_id":"inventory_2_iiqtc6w3_31","_rev":"3-0c0a71f273bf0633cafce271b0f35007","data":{"description":null,"friendlyId":"m00001","name":"Cefazolin 500mg vial (Hazolin)","quantity":999998,"crossReference":null,"inventoryType":"Medication","price":null,"reorderPoint":null,"distributionUnit":"vial","rank":null,"lastModified":"2015-12-29T04:01:16.249Z","modifiedBy":"Admin User","locations":["24BB235E-B271-AF61-9A3D-9ACD77CE25AF","DBCF3E06-B812-B6C7-930E-74F9372D384A"],"purchases":["E3B2184F-4ECA-3B76-92C8-437846C2E3DC"],"modifiedFields":{"name":"2015-12-29T03:08:24.053Z","inventoryType":"2015-12-29T03:08:24.053Z","distributionUnit":"2015-12-29T03:08:24.053Z","quantity":"2015-12-29T04:01:16.249Z","friendlyId":"2015-12-29T03:08:24.053Z"}},"_revisions":{"start":3,"ids":["0c0a71f273bf0633cafce271b0f35007","42bc38c66d9a87103c7871aa9aadb6b5","295e3c0d1de3d7a7d384ae5090d82125"]}},{"_id":"inventory_2_iiqtim0c_ex","_rev":"4-6900f25cb0aa33334fb6c69e4a828718","data":{"description":null,"friendlyId":"s00001","name":"Pumpset Kangaroo 1000ml","quantity":12,"crossReference":null,"inventoryType":"Supply","price":null,"reorderPoint":null,"distributionUnit":"pcs","rank":null,"lastModified":"2015-12-29T03:47:26.017Z","modifiedBy":"Admin User","locations":["0323721B-EDD0-6C91-BB34-52FBEACBA7DE","7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","32BCC947-E272-1564-90E1-C6E2ECE14881"],"purchases":["05760051-8BD1-ACC0-8013-0C59A545FB8D","155B2B94-6C47-E6B5-BD1E-11F375CB2C29"],"modifiedFields":{"name":"2015-12-29T03:12:56.959Z","inventoryType":"2015-12-29T03:12:56.959Z","distributionUnit":"2015-12-29T03:12:56.959Z","quantity":"2015-12-29T03:47:26.017Z","friendlyId":"2015-12-29T03:12:56.959Z"}},"_revisions":{"start":4,"ids":["6900f25cb0aa33334fb6c69e4a828718","03eb3fc36799eb0e78c1d4f5b45e50a0","064996d833372bc743ccd60baa1174b9","1622cc9c6428d24950f02c88112840f4"]}},{"_id":"lab_2_C9274C34-248C-FF7C-9E8B-F3110467C941","_rev":"2-78aaf934410f626a7dc64c8ce640ad17","data":{"labDate":"2015-12-29T04:07:25.725Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:03:22.879Z","result":"Normal","status":"Completed","lastModified":"2015-12-29T04:07:25.725Z","modifiedBy":"Admin User","labType":"A33BFA09-AFBB-CA35-A01C-702B568FFAE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:07:25.725Z","requestedBy":"2015-12-29T04:03:22.927Z","requestedDate":"2015-12-29T04:03:22.927Z","result":"2015-12-29T04:07:25.725Z","labDate":"2015-12-29T04:07:25.725Z"}},"_revisions":{"start":2,"ids":["78aaf934410f626a7dc64c8ce640ad17","0e55563ae178ae5b340c29a50f168925"]}},{"_id":"lab_2_EE3063E6-832D-930D-AD4E-D27341709886","_rev":"1-b0364bd6b060df4a2084ca292de1ad71","data":{"labDate":null,"notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:18:34.699Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:18:34.731Z","modifiedBy":"Admin User","labType":"4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:18:34.731Z","requestedBy":"2015-12-29T04:18:34.731Z","requestedDate":"2015-12-29T04:18:34.731Z"}}}]} +{"seq":74} +{"docs":[{"_id":"lookup_2_aisle_location_list","_rev":"1-255c62c74fb06e5c13664e9e70aebef5","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["A1"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-499cca90fccff759c62b2fc781010226","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["27001"]}},{"_id":"lookup_2_diagnosis_list","_rev":"1-889e0d198f50d28df33bf522106b9438","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fall from in-line roller-skates, initial encounter"]}},{"_id":"lookup_2_expense_account_list","_rev":"2-3404736b154767f3fe30e297704480be","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward"]},"_revisions":{"start":2,"ids":["3404736b154767f3fe30e297704480be","36426f839aa10324a85e92d34fcf2c26"]}},{"_id":"lookup_2_patient_status_list","_rev":"1-01d7dfb8ec77de492bf913c5c763578c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Scheduled for surgery"]}},{"_id":"lookup_2_physician_list","_rev":"1-99c8212cef905d552ab95fc88b8c3d5b","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Nick"]}},{"_id":"lookup_2_procedure_list","_rev":"1-d48989bf01a1ae70a26e397c43266278","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["hip adductor release"]}},{"_id":"lookup_2_radiologists","_rev":"1-f029e944b51dcc7fd6f980d72c7027c7","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Xray"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-a2760a7c86532da3f92ac75899b37e06","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME INC"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-d373d65b719c266173d92d3bb8f14e9f","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Hospital"]}},{"_id":"lookup_2_warehouse_list","_rev":"3-86923622f95bb3f49a906cb7cbacdc85","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward 1","Warehouse"]},"_revisions":{"start":3,"ids":["86923622f95bb3f49a906cb7cbacdc85","64a1b3813d337c7000044dbc2de21892","4f316909ed8500d0f80cf20a684ce343"]}},{"_id":"medication_2_7B63E873-D056-CCC5-A69C-60064472A16E","_rev":"1-1ebd1e9a0f4dd4d90b52eb37db7fb493","data":{"notes":null,"prescription":"Twice a day for two days","prescriptionDate":"2015-12-28T06:00:00.000Z","quantity":4,"refills":null,"requestedDate":"2015-12-29T04:16:44.877Z","requestedBy":"Admin User","status":"Requested","lastModified":"2015-12-29T04:16:44.879Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:16:44.879Z","prescription":"2015-12-29T04:16:44.879Z","quantity":"2015-12-29T04:16:44.879Z","status":"2015-12-29T04:16:44.879Z","requestedBy":"2015-12-29T04:16:44.879Z","requestedDate":"2015-12-29T04:16:44.879Z"}}},{"_id":"medication_2_9187CEE0-13EC-1816-A2A4-95E9797999BF","_rev":"1-271cd0960f61b322d66b57a994141733","data":{"notes":null,"prescription":"Once a day for 2 days","prescriptionDate":"2015-12-01T06:00:00.000Z","quantity":2,"refills":null,"requestedDate":"2015-12-29T04:01:16.079Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-12-29T04:01:16.096Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:01:16.096Z","prescription":"2015-12-29T04:01:16.096Z","quantity":"2015-12-29T04:01:16.096Z","status":"2015-12-29T04:01:16.096Z","requestedBy":"2015-12-29T04:01:16.096Z","requestedDate":"2015-12-29T04:01:16.096Z"}}},{"_id":"patient_2_C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","_rev":"4-dfabed4aec7088c46df7dac9bce8bc3f","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":"2013-08-06T04:00:00.000Z","economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":"Scheduled for surgery","lastModified":"2016-02-22T21:57:21.549Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-12-29T03:51:02.781Z","firstName":"2015-12-29T03:51:02.781Z","middleName":"2015-12-29T03:51:02.781Z","lastName":"2015-12-29T03:51:02.781Z","gender":"2015-12-29T03:51:02.781Z","dateOfBirth":"2016-02-22T21:57:21.549Z","status":"2015-12-29T03:53:17.032Z","admitted":"2015-12-29T03:53:58.574Z","sex":"2016-02-22T21:57:21.549Z"}},"_revisions":{"start":4,"ids":["dfabed4aec7088c46df7dac9bce8bc3f","1351af326b99acc03278830f30192916","105429e78d710023d6d490e880a3132a","fa6de36be0214f08f09477729bdfb339"]}},{"_id":"pricing_2_4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","_rev":"1-410ff865070244eac14c5cad5db0ad80","data":{"category":"Lab","expenseAccount":null,"name":"Fasting Blood Sugar (FBS)","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:18:34.703Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:18:34.703Z","category":"2015-12-29T04:18:34.703Z","pricingType":"2015-12-29T04:18:34.703Z"}}},{"_id":"pricing_2_A33BFA09-AFBB-CA35-A01C-702B568FFAE8","_rev":"1-70ff211de7621293ffbd91df901f6d0f","data":{"category":"Lab","expenseAccount":null,"name":"Bleeding Time","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:03:22.884Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:03:22.884Z","category":"2015-12-29T04:03:22.884Z","pricingType":"2015-12-29T04:03:22.884Z"}}},{"_id":"pricing_2_B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","_rev":"1-30c9df5437c85bb21539024c7222d307","data":{"category":"Imaging","expenseAccount":null,"name":"Ankle (Any Single View)","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-12-29T04:07:03.700Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:07:03.700Z","category":"2015-12-29T04:07:03.700Z","pricingType":"2015-12-29T04:07:03.700Z"}}},{"_id":"procCharge_2_0AD46995-188B-EFB9-8A33-E47B3980476C","_rev":"1-3f577e28daa86e12c2ad71799e383c3b","data":{"quantity":1,"dateCharged":"2015-12-29T04:00:00.093Z","lastModified":"2015-12-29T04:00:08.611Z","modifiedBy":"Admin User","medication":"iiqtc6w3_31","pricingItem":null,"modifiedFields":{"dateCharged":"2015-12-29T04:00:08.611Z","quantity":"2015-12-29T04:00:08.611Z"}}},{"_id":"procedure_2_398B4F58-152F-1476-8ED1-329C4D85E25F","_rev":"5-979bd8081e0ae3ccebf595c28bafd145","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"hip adductor release","cptCode":"27001","location":null,"notes":null,"physician":"Dr Nick","procedureDate":"2015-12-01T06:00:00.000Z","timeStarted":null,"timeEnded":null,"lastModified":"2015-12-29T04:00:33.229Z","modifiedBy":"Admin User","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":["0AD46995-188B-EFB9-8A33-E47B3980476C"],"modifiedFields":{"procedureDate":"2015-12-29T03:59:55.401Z","description":"2015-12-29T03:59:37.244Z","physician":"2015-12-29T03:59:37.244Z","anesthesiaType":"2015-12-29T03:59:37.244Z","cptCode":"2015-12-29T04:00:33.229Z"}},"_revisions":{"start":5,"ids":["979bd8081e0ae3ccebf595c28bafd145","561ab91abdd5e0f240a3ec30c9a3e09c","0a938774f0f0e600f15dd29d08b98b50","5570e1e8726f29f430a5de6e81a36e60","6c0abd3cf72cb182b05caa21150fb113"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_inventory_Supply","_rev":"1-538fc2bf7cd4745eea01fcf24ced6164","data":{"prefix":"s","value":1}},{"_id":"sequence_2_patient","_rev":"5-f6fd8c9cb7b07567399a04a72f02822a","data":{"prefix":null,"value":1},"_revisions":{"start":5,"ids":["f6fd8c9cb7b07567399a04a72f02822a","79dabe4ed5c7897e103171a7bf8bf1b6","945c072575a32fca103968a3cd425c31","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_03C7BF8B-04E0-DD9E-9469-96A5604F5340","_rev":"12-48973daa88a2567931f70586aa5f4b6e","data":{"dischargeInfo":null,"endDate":"2015-12-29T04:11:00.724Z","examiner":"Dr Nick","history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"primaryDiagnosis":"Fall from in-line roller-skates, initial encounter","primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-12-01T15:53:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-12-29T04:11:47.272Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","vitals":["B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC"],"procedures":["398B4F58-152F-1476-8ED1-329C4D85E25F"],"medication":["9187CEE0-13EC-1816-A2A4-95E9797999BF","7B63E873-D056-CCC5-A69C-60064472A16E"],"labs":["C9274C34-248C-FF7C-9E8B-F3110467C941","EE3063E6-832D-930D-AD4E-D27341709886"],"imaging":["51AFF85A-69C0-97C1-B22C-716A1BA7B80B","12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7"],"charges":[],"modifiedFields":{"visitType":"2015-12-29T03:53:58.543Z","startDate":"2015-12-29T04:11:47.272Z","status":"2015-12-29T04:11:47.272Z","outPatient":"2015-12-29T03:53:58.543Z","primaryDiagnosis":"2015-12-29T03:59:37.312Z","examiner":"2015-12-29T04:06:19.274Z","endDate":"2015-12-29T04:11:47.272Z"}},"_revisions":{"start":12,"ids":["48973daa88a2567931f70586aa5f4b6e","0baeb91a16dad77c0d8e55e6b38e6c8e","e26c621939e57cdf40fe92362f5dac3a","7315d0ff5e6eac570c2b47fd6e9d9406","d1be40a55f4329d18cc6c8f8b8b2d55a","e8567f5b5576aa5d4141f2776b24ab58","d54e63df97dd964288c6dd66d049dae9","210c948fb309be4793ca14cec7f3a335","29e6bb7a6732517b79f8c90fbcebdedd","a83b26f6b056f7c54d917160b366a75b","ebed6471bdd978af39c5acfc3f1f34b7","284cb8e69ca4b392156fe1d22866fcfb"]}},{"_id":"vital_2_B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC","_rev":"1-62233a35020adba2b7d65fd09e5e3cba","data":{"dateRecorded":"2015-12-04T04:08:00.000Z","temperature":36.67,"weight":"57lb","height":"3'6\"","sbp":117,"dbp":76,"heartRate":60,"respiratoryRate":12,"lastModified":"2015-12-29T04:11:11.942Z","modifiedBy":"Admin User","modifiedFields":{"dateRecorded":"2015-12-29T04:11:11.942Z","temperature":"2015-12-29T04:11:11.942Z","weight":"2015-12-29T04:11:11.942Z","height":"2015-12-29T04:11:11.942Z","sbp":"2015-12-29T04:11:11.942Z","dbp":"2015-12-29T04:11:11.942Z","heartRate":"2015-12-29T04:11:11.942Z","respiratoryRate":"2015-12-29T04:11:11.942Z"}}}]} +{"seq":99} diff --git a/tests/fixtures/incident.txt b/tests/fixtures/incident.txt new file mode 100644 index 0000000000..5cc1259ac0 --- /dev/null +++ b/tests/fixtures/incident.txt @@ -0,0 +1,7 @@ +{"version":"1.2.5","db_type":"http","start_time":"2017-03-10T17:57:44.198Z","db_info":{"db_name":"main","doc_count":39,"doc_del_count":0,"update_seq":49,"purge_seq":0,"compact_running":false,"disk_size":159851,"data_size":36296,"instance_start_time":"1489163172063223","disk_format_version":6,"committed_update_seq":49,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} +{"seq":2} +{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}}}]} +{"seq":3} +{"docs":[{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}}},{"_id":"attachment_2_58847f56-83af-4c15-a2e3-a57321d7ec99","_rev":"2-9a52175abfc01e988687f068cc0ecbb0","data":{"addedBy":"hradmin","addedByDisplayName":"Admin User","dateAdded":"2017-03-10T16:27:19.394Z","title":"Test attachment","caption":null,"coverImage":false,"fileName":"/incidents/56c64d71-ba30-4271-b899-f6f6b031f589/incident.txt","isImage":false,"localFile":true,"url":"filesystem:http://localhost:4200/persistent/incidents/56c64d71-ba30-4271-b899-f6f6b031f589/incident.txt","archived":false,"lastModified":"2017-03-10T16:27:55.024Z","modifiedBy":"Admin User","patient":null,"modifiedFields":{"dateAdded":"2017-03-10T16:27:54.840Z","addedBy":"2017-03-10T16:27:54.840Z","addedByDisplayName":"2017-03-10T16:27:54.840Z","fileName":"2017-03-10T16:27:55.024Z","title":"2017-03-10T16:27:54.840Z","files":"2017-03-10T16:27:54.840Z","isImage":"2017-03-10T16:27:54.840Z","localFile":"2017-03-10T16:27:55.024Z","url":"2017-03-10T16:27:55.024Z"},"files":{"file":{}}},"_revisions":{"start":2,"ids":["9a52175abfc01e988687f068cc0ecbb0","acc7631f57a6a19a20a3fd1cbd53719a"]},"_attachments":{"file":{"data":"eyJ2ZXJzaW9uIjoiMS4yLjUiLCJkYl90eXBlIjoiaHR0cCIsInN0YXJ0X3RpbWUiOiIyMDE3LTAzLTA4VDIwOjIzOjE2Ljg0MVoiLCJkYl9pbmZvIjp7ImRiX25hbWUiOiJtYWluIiwiZG9jX2NvdW50IjozOCwiZG9jX2RlbF9jb3VudCI6MCwidXBkYXRlX3NlcSI6NzYsInB1cmdlX3NlcSI6MCwiY29tcGFjdF9ydW5uaW5nIjpmYWxzZSwiZGlza19zaXplIjoyNDk5NTYsImRhdGFfc2l6ZSI6MjgxMDUsImluc3RhbmNlX3N0YXJ0X3RpbWUiOiIxNDg5MDAxMTI0OTM5NjEwIiwiZGlza19mb3JtYXRfdmVyc2lvbiI6NiwiY29tbWl0dGVkX3VwZGF0ZV9zZXEiOjc2LCJob3N0IjoiaHR0cDovL2xvY2FsaG9zdDo1OTg0L21haW4vIiwiYXV0b19jb21wYWN0aW9uIjpmYWxzZSwiYWRhcHRlciI6Imh0dHAifX0KeyJkb2NzIjpbeyJfaWQiOiJfZGVzaWduL2ludmVudG9yeV9ieV9mcmllbmRseV9pZCIsIl9yZXYiOiIxLTgyZTI0Mzc4ZjA3NGEyODRjYWUxNGRhNGRiNTQzMWVkIiwidmVyc2lvbiI6MSwidmlld3MiOnsiaW52ZW50b3J5X2J5X2ZyaWVuZGx5X2lkIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW52ZW50b3J5Jykge1xuICAgICAgICBlbWl0KFtkb2MuZGF0YS5mcmllbmRseUlkLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fV19Cnsic2VxIjoyfQp7ImRvY3MiOlt7Il9pZCI6Il9kZXNpZ24vaW52ZW50b3J5X2J5X25hbWUiLCJfcmV2IjoiMS05MWY1NWFlNmJkMzBmNzY2ZDlkYTk1YmZmZTA1NGJjYiIsInZlcnNpb24iOjUsInZpZXdzIjp7ImludmVudG9yeV9ieV9uYW1lIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW52ZW50b3J5Jykge1xuICAgICAgICBlbWl0KFtkb2MuZGF0YS5uYW1lLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19LCJsaXN0cyI6eyJzb3J0IjoiZnVuY3Rpb24oaGVhZCwgcmVxKSB7ZnVuY3Rpb24ga2V5c0VxdWFsKGtleUEsIGtleUIpIHtmb3IgKHZhciBpPSAwOyBpIDwga2V5QS5sZW5ndGg7IGkrKykge2lmIChrZXlBW2ldICE9PSBrZXlCW2ldKSB7cmV0dXJuIGZhbHNlO319cmV0dXJuIHRydWU7fWZ1bmN0aW9uIGNvbXBhcmVTdHJpbmdzKGFTdHJpbmcsIGJTdHJpbmcpIHtpZiAoIWFTdHJpbmcpIHthU3RyaW5nID0gXCJcIjt9aWYgKCFiU3RyaW5nKSB7YlN0cmluZyA9IFwiXCI7fWlmIChhU3RyaW5nIDwgYlN0cmluZykge3JldHVybiAtMTt9IGVsc2UgaWYgKGFTdHJpbmcgPiBiU3RyaW5nKSB7cmV0dXJuIDE7fSBlbHNlIHtyZXR1cm4gMDt9fXZhciByb3cscm93cz1bXSxzdGFydGluZ1Bvc2l0aW9uID0gMDt3aGlsZShyb3cgPSBnZXRSb3coKSkge3Jvd3MucHVzaChyb3cpO31yb3dzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHtcbiAgICAgIHZhciBzb3J0QnkgPSAnJztcbiAgICAgIGlmIChyZXEucXVlcnkgJiYgcmVxLnF1ZXJ5LnNvcnRLZXkpIHtcbiAgICAgICAgc29ydEJ5ID0gcmVxLnF1ZXJ5LnNvcnRLZXk7XG4gICAgICB9XG4gICAgICBzd2l0Y2ggKHNvcnRCeSkge1xuICAgICAgICBjYXNlICdjcm9zc1JlZmVyZW5jZSc6XG4gICAgICAgIGNhc2UgJ2Rlc2NyaXB0aW9uJzpcbiAgICAgICAgY2FzZSAnZnJpZW5kbHlJZCc6XG4gICAgICAgIGNhc2UgJ25hbWUnOlxuICAgICAgICBjYXNlICdwcmljZSc6XG4gICAgICAgIGNhc2UgJ3F1YW50aXR5JzpcbiAgICAgICAgY2FzZSAnaW52ZW50b3J5VHlwZSc6XG4gICAgICAgICAge1xuICAgICAgICAgICAgcmV0dXJuIGNvbXBhcmVTdHJpbmdzKGEuZG9jLmRhdGFbc29ydEJ5XSwgYi5kb2MuZGF0YVtzb3J0QnldKTtcbiAgICAgICAgICB9XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAge1xuICAgICAgICAgICAgcmV0dXJuIDA7IC8vIERvbid0IHNvcnRcbiAgICAgICAgICB9XG4gICAgICB9XG4gICAgfSk7aWYgKHJlcS5xdWVyeS5zb3J0RGVzYykge3Jvd3MgPSByb3dzLnJldmVyc2UoKTt9aWYgKHJlcS5xdWVyeS5zb3J0U3RhcnRLZXkpIHt2YXIgc3RhcnRLZXkgPSBKU09OLnBhcnNlKHJlcS5xdWVyeS5zb3J0U3RhcnRLZXkpO2ZvciAodmFyIGk9MDsgaTxyb3dzLmxlbmd0aDsgaSsrKSB7aWYgKGtleXNFcXVhbChzdGFydEtleSwgcm93c1tpXS5rZXkpKSB7c3RhcnRpbmdQb3NpdGlvbiA9IGk7YnJlYWs7fX19aWYgKHJlcS5xdWVyeS5zb3J0TGltaXQpIHtyb3dzID0gcm93cy5zbGljZShzdGFydGluZ1Bvc2l0aW9uLCBwYXJzZUludChyZXEucXVlcnkuc29ydExpbWl0KStzdGFydGluZ1Bvc2l0aW9uKTt9IGVsc2UgaWYgKHN0YXJ0aW5nUG9zaXRpb24gPiAwKSB7cm93cyA9IHJvd3Muc2xpY2Uoc3RhcnRpbmdQb3NpdGlvbik7fXNlbmQoSlNPTi5zdHJpbmdpZnkoe1wicm93c1wiIDogcm93c30pKTt9In19XX0KeyJzZXEiOjN9CnsiZG9jcyI6W3siX2lkIjoiX2Rlc2lnbi9hcHBvaW50bWVudHNfYnlfZGF0ZSIsIl9yZXYiOiIxLTVkZjI5ZjFkN2RiZDM5ZDZiM2EyMTQ1OTIzYWI3M2NmIiwidmVyc2lvbiI6Nywidmlld3MiOnsiYXBwb2ludG1lbnRzX2J5X2RhdGUiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdhcHBvaW50bWVudCcpIHtcbiAgICAgICAgdmFyIGVuZERhdGUgPSBkb2MuZGF0YS5lbmREYXRlO1xuICAgIGlmIChlbmREYXRlICYmIGVuZERhdGUgIT09IFwiXCIpIHtcbiAgICAgIGVuZERhdGUgPSBuZXcgRGF0ZShlbmREYXRlKTtcbiAgICAgIGlmIChlbmREYXRlLmdldFRpbWUpIHtcbiAgICAgICAgZW5kRGF0ZSA9IGVuZERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICB2YXIgc3RhcnREYXRlID0gZG9jLmRhdGEuc3RhcnREYXRlO1xuICAgIGlmIChzdGFydERhdGUgJiYgc3RhcnREYXRlICE9PSBcIlwiKSB7XG4gICAgICBzdGFydERhdGUgPSBuZXcgRGF0ZShzdGFydERhdGUpO1xuICAgICAgaWYgKHN0YXJ0RGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIHN0YXJ0RGF0ZSA9IHN0YXJ0RGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGlmIChkb2MuZGF0YS5hcHBvaW50bWVudFR5cGUgIT09ICdTdXJnZXJ5Jykge1xuICAgICAgZW1pdChbc3RhcnREYXRlLCBlbmREYXRlLCBkb2MuX2lkXSk7XG4gICAgfVxuICAgICAgfVxuICAgIH1cbiAgfSJ9fSwibGlzdHMiOnsic29ydCI6ImZ1bmN0aW9uKGhlYWQsIHJlcSkge2Z1bmN0aW9uIGtleXNFcXVhbChrZXlBLCBrZXlCKSB7Zm9yICh2YXIgaT0gMDsgaSA8IGtleUEubGVuZ3RoOyBpKyspIHtpZiAoa2V5QVtpXSAhPT0ga2V5QltpXSkge3JldHVybiBmYWxzZTt9fXJldHVybiB0cnVlO31mdW5jdGlvbiBnZXRDb21wYXJlRGF0ZShkYXRlU3RyaW5nKSB7aWYgKCFkYXRlU3RyaW5nIHx8IGRhdGVTdHJpbmcgPT09IFwiXCIpIHtyZXR1cm4gMDt9cmV0dXJuIG5ldyBEYXRlKGRhdGVTdHJpbmcpLmdldFRpbWUoKTt9ZnVuY3Rpb24gY29tcGFyZVN0cmluZ3MoYVN0cmluZywgYlN0cmluZykge2lmICghYVN0cmluZykge2FTdHJpbmcgPSBcIlwiO31pZiAoIWJTdHJpbmcpIHtiU3RyaW5nID0gXCJcIjt9aWYgKGFTdHJpbmcgPCBiU3RyaW5nKSB7cmV0dXJuIC0xO30gZWxzZSBpZiAoYVN0cmluZyA+IGJTdHJpbmcpIHtyZXR1cm4gMTt9IGVsc2Uge3JldHVybiAwO319dmFyIHJvdyxyb3dzPVtdLHN0YXJ0aW5nUG9zaXRpb24gPSAwO3doaWxlKHJvdyA9IGdldFJvdygpKSB7cm93cy5wdXNoKHJvdyk7fXJvd3MgPSByb3dzLmZpbHRlcihmdW5jdGlvbiAocm93KSB7XG4gICAgdmFyIGZpbHRlckJ5ID0gbnVsbDtcbiAgICB2YXIgaW5jbHVkZVJvdyA9IHRydWU7XG4gICAgaWYgKHJlcS5xdWVyeSAmJiByZXEucXVlcnkuZmlsdGVyQnkpIHtcbiAgICAgIGZpbHRlckJ5ID0gSlNPTi5wYXJzZShyZXEucXVlcnkuZmlsdGVyQnkpO1xuICAgIH1cbiAgICBpZiAoIWZpbHRlckJ5KSB7XG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCBmaWx0ZXJCeS5sZW5ndGg7IGkrKykge1xuICAgICAgdmFyIGN1cnJlbnRWYWx1ZSA9IHJvdy5kb2MuZGF0YVtmaWx0ZXJCeVtpXS5uYW1lXTtcbiAgICAgIGlmIChmaWx0ZXJCeVtpXS5uYW1lID09PSAnc3RhdHVzJyAmJiAoIWN1cnJlbnRWYWx1ZSB8fCBjdXJyZW50VmFsdWUgPT09ICcnKSkge1xuICAgICAgICBjdXJyZW50VmFsdWUgPSAnU2NoZWR1bGVkJztcbiAgICAgIH1cbiAgICAgIGlmIChjdXJyZW50VmFsdWUgIT09IGZpbHRlckJ5W2ldLnZhbHVlKSB7XG4gICAgICAgIGluY2x1ZGVSb3cgPSBmYWxzZTtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBpbmNsdWRlUm93O1xuICB9KTtyb3dzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHtcbiAgICBmdW5jdGlvbiBkZWZhdWx0U3RhdHVzKHZhbHVlKSB7XG4gICAgICBpZiAoIXZhbHVlIHx8IHZhbHVlID09PSAnJykge1xuICAgICAgICByZXR1cm4gJ1NjaGVkdWxlZCc7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICB9XG4gICAgfVxuICAgIHZhciBzb3J0QnkgPSAnJztcbiAgICBpZiAocmVxLnF1ZXJ5ICYmIHJlcS5xdWVyeS5zb3J0S2V5KSB7XG4gICAgICBzb3J0QnkgPSByZXEucXVlcnkuc29ydEtleTtcbiAgICB9XG4gICAgc3dpdGNoIChzb3J0QnkpIHtcbiAgICAgIGNhc2UgJ2FwcG9pbnRtZW50VHlwZSc6XG4gICAgICBjYXNlICdsb2NhdGlvbic6XG4gICAgICBjYXNlICdwcm92aWRlcic6XG4gICAgICAgIHJldHVybiBjb21wYXJlU3RyaW5ncyhhLmRvYy5kYXRhW3NvcnRCeV0sIGIuZG9jLmRhdGFbc29ydEJ5XSk7XG4gICAgICBjYXNlICdkYXRlJzpcbiAgICAgICAge1xuICAgICAgICAgIHZhciBzdGFydERpZmYgPSBnZXRDb21wYXJlRGF0ZShhLmRvYy5kYXRhLnN0YXJ0RGF0ZSkgLSBnZXRDb21wYXJlRGF0ZShiLmRvYy5kYXRhLnN0YXJ0RGF0ZSk7XG4gICAgICAgICAgaWYgKHN0YXJ0RGlmZiA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuIGdldENvbXBhcmVEYXRlKGEuZG9jLmRhdGEuZW5kRGF0ZSkgLSBnZXRDb21wYXJlRGF0ZShiLmRvYy5kYXRhLmVuZERhdGUpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gc3RhcnREaWZmO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgY2FzZSAnc3RhdHVzJzpcbiAgICAgICAge1xuICAgICAgICAgIHZhciBhU3RhdHVzID0gZGVmYXVsdFN0YXR1cyhhLmRvYy5kYXRhW3NvcnRCeV0pO1xuICAgICAgICAgIHZhciBiU3RhdHVzID0gZGVmYXVsdFN0YXR1cyhiLmRvYy5kYXRhW3NvcnRCeV0pO1xuICAgICAgICAgIHJldHVybiBjb21wYXJlU3RyaW5ncyhhU3RhdHVzLCBiU3RhdHVzKTtcbiAgICAgICAgfVxuICAgICAgZGVmYXVsdDpcbiAgICAgICAge1xuICAgICAgICAgIHJldHVybiAwOyAvLyBEb24ndCBzb3J0XG4gICAgICAgIH1cbiAgICB9XG4gIH0pO2lmIChyZXEucXVlcnkuc29ydERlc2MpIHtyb3dzID0gcm93cy5yZXZlcnNlKCk7fWlmIChyZXEucXVlcnkuc29ydFN0YXJ0S2V5KSB7dmFyIHN0YXJ0S2V5ID0gSlNPTi5wYXJzZShyZXEucXVlcnkuc29ydFN0YXJ0S2V5KTtmb3IgKHZhciBpPTA7IGk8cm93cy5sZW5ndGg7IGkrKykge2lmIChrZXlzRXF1YWwoc3RhcnRLZXksIHJvd3NbaV0ua2V5KSkge3N0YXJ0aW5nUG9zaXRpb24gPSBpO2JyZWFrO319fWlmIChyZXEucXVlcnkuc29ydExpbWl0KSB7cm93cyA9IHJvd3Muc2xpY2Uoc3RhcnRpbmdQb3NpdGlvbiwgcGFyc2VJbnQocmVxLnF1ZXJ5LnNvcnRMaW1pdCkrc3RhcnRpbmdQb3NpdGlvbik7fSBlbHNlIGlmIChzdGFydGluZ1Bvc2l0aW9uID4gMCkge3Jvd3MgPSByb3dzLnNsaWNlKHN0YXJ0aW5nUG9zaXRpb24pO31zZW5kKEpTT04uc3RyaW5naWZ5KHtcInJvd3NcIiA6IHJvd3N9KSk7fSJ9fSx7Il9pZCI6Il9kZXNpZ24vYXBwb2ludG1lbnRzX2J5X3BhdGllbnQiLCJfcmV2IjoiMS05YTk3YWNkNWI4ZmQwNzFhZDgxYWZjOWU3MzA3MjFjNSIsInZlcnNpb24iOjQsInZpZXdzIjp7ImFwcG9pbnRtZW50c19ieV9wYXRpZW50Ijp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnYXBwb2ludG1lbnQnKSB7XG4gICAgICAgIHZhciBlbmREYXRlID0gZG9jLmRhdGEuZW5kRGF0ZTtcbiAgICBpZiAoZW5kRGF0ZSAmJiBlbmREYXRlICE9PSBcIlwiKSB7XG4gICAgICBlbmREYXRlID0gbmV3IERhdGUoZW5kRGF0ZSk7XG4gICAgICBpZiAoZW5kRGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIGVuZERhdGUgPSBlbmREYXRlLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgdmFyIHN0YXJ0RGF0ZSA9IGRvYy5kYXRhLnN0YXJ0RGF0ZTtcbiAgICBpZiAoc3RhcnREYXRlICYmIHN0YXJ0RGF0ZSAhPT0gXCJcIikge1xuICAgICAgc3RhcnREYXRlID0gbmV3IERhdGUoc3RhcnREYXRlKTtcbiAgICAgIGlmIChzdGFydERhdGUuZ2V0VGltZSkge1xuICAgICAgICBzdGFydERhdGUgPSBzdGFydERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBlbWl0KFtkb2MuZGF0YS5wYXRpZW50LCBzdGFydERhdGUsIGVuZERhdGUsZG9jLl9pZF0pO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL2Nsb3NlZF9pbmNpZGVudHNfYnlfdXNlciIsIl9yZXYiOiIxLWJmMTYxNzZjMTNiZTU3YWY5YTRmMWEwOTgwNzEwMTkwIiwidmVyc2lvbiI6MSwidmlld3MiOnsiY2xvc2VkX2luY2lkZW50c19ieV91c2VyIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW5jaWRlbnQnKSB7XG4gICAgICAgIGlmIChkb2MuZGF0YS5zdGF0dXMgPT09IFwiQ2xvc2VkXCIpIHtcbiAgICAgIGVtaXQoW2RvYy5kYXRhLnJlcG9ydGVkQnksIGRvYy5faWRdKTtcbiAgICB9XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vY3VzdG9tX2Zvcm1fYnlfdHlwZSIsIl9yZXYiOiIxLWRkZjBlZTc1YzFlOGU4NTlkODIxYTlmNWMxZWM0M2I2IiwidmVyc2lvbiI6MSwidmlld3MiOnsiY3VzdG9tX2Zvcm1fYnlfdHlwZSI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ2N1c3RvbUZvcm0nKSB7XG4gICAgICAgIGVtaXQoZG9jLmRhdGEuZm9ybVR5cGUpO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL2ltYWdpbmdfYnlfc3RhdHVzIiwiX3JldiI6IjEtMWEzYmFiM2QyZDE0MDMyOTlhOWU0YWQ4ZGZmZTVmYTEiLCJ2ZXJzaW9uIjo0LCJ2aWV3cyI6eyJpbWFnaW5nX2J5X3N0YXR1cyI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ2ltYWdpbmcnKSB7XG4gICAgICAgIHZhciBpbWFnaW5nRGF0ZSA9IGRvYy5kYXRhLmltYWdpbmdEYXRlO1xuICAgIGlmIChpbWFnaW5nRGF0ZSAmJiBpbWFnaW5nRGF0ZSAhPT0gXCJcIikge1xuICAgICAgaW1hZ2luZ0RhdGUgPSBuZXcgRGF0ZShpbWFnaW5nRGF0ZSk7XG4gICAgICBpZiAoaW1hZ2luZ0RhdGUuZ2V0VGltZSkge1xuICAgICAgICBpbWFnaW5nRGF0ZSA9IGltYWdpbmdEYXRlLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgdmFyIHJlcXVlc3RlZERhdGUgPSBkb2MuZGF0YS5yZXF1ZXN0ZWREYXRlO1xuICAgIGlmIChyZXF1ZXN0ZWREYXRlICYmIHJlcXVlc3RlZERhdGUgIT09IFwiXCIpIHtcbiAgICAgIHJlcXVlc3RlZERhdGUgPSBuZXcgRGF0ZShyZXF1ZXN0ZWREYXRlKTtcbiAgICAgIGlmIChyZXF1ZXN0ZWREYXRlLmdldFRpbWUpIHtcbiAgICAgICAgcmVxdWVzdGVkRGF0ZSA9IHJlcXVlc3RlZERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBlbWl0KFtkb2MuZGF0YS5zdGF0dXMsIHJlcXVlc3RlZERhdGUsIGltYWdpbmdEYXRlLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW5jaWRlbnRfYnlfZGF0ZSIsIl9yZXYiOiIxLTU5ZmE1OTczNGVlMTI5Y2ZmMDU2MGIyMGE5NWQyZDRlIiwidmVyc2lvbiI6MSwidmlld3MiOnsiaW5jaWRlbnRfYnlfZGF0ZSI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ2luY2lkZW50Jykge1xuICAgICAgICB2YXIgZGF0ZU9mSW5jaWRlbnQgPSBkb2MuZGF0YS5kYXRlT2ZJbmNpZGVudDtcbiAgICBpZiAoZGF0ZU9mSW5jaWRlbnQgJiYgZGF0ZU9mSW5jaWRlbnQgIT09IFwiXCIpIHtcbiAgICAgIGRhdGVPZkluY2lkZW50ID0gbmV3IERhdGUoZGF0ZU9mSW5jaWRlbnQpO1xuICAgICAgaWYgKGRhdGVPZkluY2lkZW50LmdldFRpbWUpIHtcbiAgICAgICAgZGF0ZU9mSW5jaWRlbnQgPSBkYXRlT2ZJbmNpZGVudC5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2RhdGVPZkluY2lkZW50LCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW5jaWRlbnRfYnlfZnJpZW5kbHlfaWQiLCJfcmV2IjoiMS04ODVhMTJiNjdkYTQ3ZTk1NmJjMTkwZmUxZmUwZDRlNiIsInZlcnNpb24iOjEsInZpZXdzIjp7ImluY2lkZW50X2J5X2ZyaWVuZGx5X2lkIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW5jaWRlbnQnKSB7XG4gICAgICAgIGVtaXQoW2RvYy5kYXRhLmZyaWVuZGx5SWQsIGRvYy5faWRdKTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi9pbnZlbnRvcnlfYnlfdHlwZSIsIl9yZXYiOiIxLTE4NDU1NTAwZTFlODY1NDRlZGNlYWFiMDFiYjUxMWJjIiwidmVyc2lvbiI6NSwidmlld3MiOnsiaW52ZW50b3J5X2J5X3R5cGUiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdpbnZlbnRvcnknKSB7XG4gICAgICAgIGVtaXQoZG9jLmRhdGEuaW52ZW50b3J5VHlwZSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW52ZW50b3J5X3B1cmNoYXNlX2J5X2RhdGVfcmVjZWl2ZWQiLCJfcmV2IjoiMS0wZDdiNTk3YWVhZTc0NjU4OTk4MGIxMjkwMzc2ODI1MiIsInZlcnNpb24iOjUsInZpZXdzIjp7ImludmVudG9yeV9wdXJjaGFzZV9ieV9kYXRlX3JlY2VpdmVkIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW52UHVyY2hhc2UnKSB7XG4gICAgICAgIHZhciBkYXRlUmVjZWl2ZWQgPSBkb2MuZGF0YS5kYXRlUmVjZWl2ZWQ7XG4gICAgaWYgKGRhdGVSZWNlaXZlZCAmJiBkYXRlUmVjZWl2ZWQgIT09IFwiXCIpIHtcbiAgICAgIGRhdGVSZWNlaXZlZCA9IG5ldyBEYXRlKGRhdGVSZWNlaXZlZCk7XG4gICAgICBpZiAoZGF0ZVJlY2VpdmVkLmdldFRpbWUpIHtcbiAgICAgICAgZGF0ZVJlY2VpdmVkID0gZGF0ZVJlY2VpdmVkLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZW1pdChbZGF0ZVJlY2VpdmVkLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW52ZW50b3J5X3B1cmNoYXNlX2J5X2V4cGlyYXRpb25fZGF0ZSIsIl9yZXYiOiIxLTFmNDFkZDZkMDMwYzU4ODg0ZDcwMTNlZjk0MzZkZWNiIiwidmVyc2lvbiI6NSwidmlld3MiOnsiaW52ZW50b3J5X3B1cmNoYXNlX2J5X2V4cGlyYXRpb25fZGF0ZSI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ2ludlB1cmNoYXNlJykge1xuICAgICAgICB2YXIgZXhwaXJhdGlvbkRhdGUgPSBkb2MuZGF0YS5leHBpcmF0aW9uRGF0ZTtcbiAgICBpZiAoZXhwaXJhdGlvbkRhdGUgJiYgZXhwaXJhdGlvbkRhdGUgIT09IFwiXCIpIHtcbiAgICAgIGV4cGlyYXRpb25EYXRlID0gbmV3IERhdGUoZXhwaXJhdGlvbkRhdGUpO1xuICAgICAgaWYgKGV4cGlyYXRpb25EYXRlLmdldFRpbWUpIHtcbiAgICAgICAgZXhwaXJhdGlvbkRhdGUgPSBleHBpcmF0aW9uRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2V4cGlyYXRpb25EYXRlLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW52ZW50b3J5X3JlcXVlc3RfYnlfaXRlbSIsIl9yZXYiOiIxLTAyMWY0YzI0YjViNjIwMjU5NGY2MTBjZjVkNGM2M2E0IiwidmVyc2lvbiI6NSwidmlld3MiOnsiaW52ZW50b3J5X3JlcXVlc3RfYnlfaXRlbSI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ2ludlJlcXVlc3QnKSB7XG4gICAgICAgIHZhciBkYXRlQ29tcGxldGVkID0gZG9jLmRhdGEuZGF0ZUNvbXBsZXRlZDtcbiAgICBpZiAoZGF0ZUNvbXBsZXRlZCAmJiBkYXRlQ29tcGxldGVkICE9PSBcIlwiKSB7XG4gICAgICBkYXRlQ29tcGxldGVkID0gbmV3IERhdGUoZGF0ZUNvbXBsZXRlZCk7XG4gICAgICBpZiAoZGF0ZUNvbXBsZXRlZC5nZXRUaW1lKSB7XG4gICAgICAgIGRhdGVDb21wbGV0ZWQgPSBkYXRlQ29tcGxldGVkLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZW1pdChbZG9jLmRhdGEuaW52ZW50b3J5SXRlbSwgZG9jLmRhdGEuc3RhdHVzLCBkYXRlQ29tcGxldGVkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vaW52ZW50b3J5X3JlcXVlc3RfYnlfc3RhdHVzIiwiX3JldiI6IjEtY2MwYzFlMGUwMTA2MGFhNjI0NTZkNmVhNzY4ZDhlYzciLCJ2ZXJzaW9uIjo1LCJ2aWV3cyI6eyJpbnZlbnRvcnlfcmVxdWVzdF9ieV9zdGF0dXMiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdpbnZSZXF1ZXN0Jykge1xuICAgICAgICB2YXIgZGF0ZUNvbXBsZXRlZCA9IGRvYy5kYXRhLmRhdGVDb21wbGV0ZWQ7XG4gICAgaWYgKGRhdGVDb21wbGV0ZWQgJiYgZGF0ZUNvbXBsZXRlZCAhPT0gXCJcIikge1xuICAgICAgZGF0ZUNvbXBsZXRlZCA9IG5ldyBEYXRlKGRhdGVDb21wbGV0ZWQpO1xuICAgICAgaWYgKGRhdGVDb21wbGV0ZWQuZ2V0VGltZSkge1xuICAgICAgICBkYXRlQ29tcGxldGVkID0gZGF0ZUNvbXBsZXRlZC5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2RvYy5kYXRhLnN0YXR1cywgZGF0ZUNvbXBsZXRlZCwgZG9jLl9pZF0pO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL2ludm9pY2VfYnlfcGF0aWVudCIsIl9yZXYiOiIxLTlmNjdhNThkNGU0Mjg2MTQ4NDRhYzgyY2IyNTQ4MjY4IiwidmVyc2lvbiI6MSwidmlld3MiOnsiaW52b2ljZV9ieV9wYXRpZW50Ijp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnaW52b2ljZScpIHtcbiAgICAgICAgZW1pdChkb2MuZGF0YS5wYXRpZW50KTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi9pbnZvaWNlX2J5X3N0YXR1cyIsIl9yZXYiOiIxLWQ0MTFlNmY2NmY4OTdmMGI5Yjk4NWRjNmU1MTg4ZDg1IiwidmVyc2lvbiI6NCwidmlld3MiOnsiaW52b2ljZV9ieV9zdGF0dXMiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdpbnZvaWNlJykge1xuICAgICAgICB2YXIgYmlsbERhdGUgPSBkb2MuZGF0YS5iaWxsRGF0ZTtcbiAgICBpZiAoYmlsbERhdGUgJiYgYmlsbERhdGUgIT09IFwiXCIpIHtcbiAgICAgIGJpbGxEYXRlID0gbmV3IERhdGUoYmlsbERhdGUpO1xuICAgICAgaWYgKGJpbGxEYXRlLmdldFRpbWUpIHtcbiAgICAgICAgYmlsbERhdGUgPSBiaWxsRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2RvYy5kYXRhLnN0YXR1cywgYmlsbERhdGUsIGRvYy5faWRdKTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi9sYWJfYnlfc3RhdHVzIiwiX3JldiI6IjEtN2Q0ZGU2ZTIxOWI0ODIxNzFiN2VjZDQ4NWVmNzIyMzgiLCJ2ZXJzaW9uIjo0LCJ2aWV3cyI6eyJsYWJfYnlfc3RhdHVzIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnbGFiJykge1xuICAgICAgICB2YXIgbGFiRGF0ZSA9IGRvYy5kYXRhLmxhYkRhdGU7XG4gICAgaWYgKGxhYkRhdGUgJiYgbGFiRGF0ZSAhPT0gXCJcIikge1xuICAgICAgbGFiRGF0ZSA9IG5ldyBEYXRlKGxhYkRhdGUpO1xuICAgICAgaWYgKGxhYkRhdGUuZ2V0VGltZSkge1xuICAgICAgICBsYWJEYXRlID0gbGFiRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIHZhciByZXF1ZXN0ZWREYXRlID0gZG9jLmRhdGEucmVxdWVzdGVkRGF0ZTtcbiAgICBpZiAocmVxdWVzdGVkRGF0ZSAmJiByZXF1ZXN0ZWREYXRlICE9PSBcIlwiKSB7XG4gICAgICByZXF1ZXN0ZWREYXRlID0gbmV3IERhdGUocmVxdWVzdGVkRGF0ZSk7XG4gICAgICBpZiAocmVxdWVzdGVkRGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIHJlcXVlc3RlZERhdGUgPSByZXF1ZXN0ZWREYXRlLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZW1pdChbZG9jLmRhdGEuc3RhdHVzLCByZXF1ZXN0ZWREYXRlLCBsYWJEYXRlLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vbWVkaWNhdGlvbl9ieV9zdGF0dXMiLCJfcmV2IjoiMS1hNjQwM2M1M2IyZGI0NjkwNWIzYjE4NjExMjBjNjYwMSIsInZlcnNpb24iOjQsInZpZXdzIjp7Im1lZGljYXRpb25fYnlfc3RhdHVzIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnbWVkaWNhdGlvbicpIHtcbiAgICAgICAgdmFyIHByZXNjcmlwdGlvbkRhdGUgPSBkb2MuZGF0YS5wcmVzY3JpcHRpb25EYXRlO1xuICAgIGlmIChwcmVzY3JpcHRpb25EYXRlICYmIHByZXNjcmlwdGlvbkRhdGUgIT09IFwiXCIpIHtcbiAgICAgIHByZXNjcmlwdGlvbkRhdGUgPSBuZXcgRGF0ZShwcmVzY3JpcHRpb25EYXRlKTtcbiAgICAgIGlmIChwcmVzY3JpcHRpb25EYXRlLmdldFRpbWUpIHtcbiAgICAgICAgcHJlc2NyaXB0aW9uRGF0ZSA9IHByZXNjcmlwdGlvbkRhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICB2YXIgcmVxdWVzdGVkRGF0ZSA9IGRvYy5kYXRhLnJlcXVlc3RlZERhdGU7XG4gICAgaWYgKHJlcXVlc3RlZERhdGUgJiYgcmVxdWVzdGVkRGF0ZSAhPT0gXCJcIikge1xuICAgICAgcmVxdWVzdGVkRGF0ZSA9IG5ldyBEYXRlKHJlcXVlc3RlZERhdGUpO1xuICAgICAgaWYgKHJlcXVlc3RlZERhdGUuZ2V0VGltZSkge1xuICAgICAgICByZXF1ZXN0ZWREYXRlID0gcmVxdWVzdGVkRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2RvYy5kYXRhLnN0YXR1cywgcmVxdWVzdGVkRGF0ZSwgcHJlc2NyaXB0aW9uRGF0ZSwgZG9jLl9pZF0pO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL29wZW5faW5jaWRlbnRzX2J5X3VzZXIiLCJfcmV2IjoiMS0zNDc3MGVmZDIxMDkyMGEzMGM5NmQzNzg3NTIxZThhNSIsInZlcnNpb24iOjEsInZpZXdzIjp7Im9wZW5faW5jaWRlbnRzX2J5X3VzZXIiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdpbmNpZGVudCcpIHtcbiAgICAgICAgaWYgKGRvYy5kYXRhLnN0YXR1cyAhPT0gXCJDbG9zZWRcIikge1xuICAgICAgZW1pdChbZG9jLmRhdGEucmVwb3J0ZWRCeSwgZG9jLl9pZF0pO1xuICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH0ifX0sImxpc3RzIjp7InNvcnQiOiJmdW5jdGlvbihoZWFkLCByZXEpIHtmdW5jdGlvbiBrZXlzRXF1YWwoa2V5QSwga2V5Qikge2ZvciAodmFyIGk9IDA7IGkgPCBrZXlBLmxlbmd0aDsgaSsrKSB7aWYgKGtleUFbaV0gIT09IGtleUJbaV0pIHtyZXR1cm4gZmFsc2U7fX1yZXR1cm4gdHJ1ZTt9ZnVuY3Rpb24gY29tcGFyZVN0cmluZ3MoYVN0cmluZywgYlN0cmluZykge2lmICghYVN0cmluZykge2FTdHJpbmcgPSBcIlwiO31pZiAoIWJTdHJpbmcpIHtiU3RyaW5nID0gXCJcIjt9aWYgKGFTdHJpbmcgPCBiU3RyaW5nKSB7cmV0dXJuIC0xO30gZWxzZSBpZiAoYVN0cmluZyA+IGJTdHJpbmcpIHtyZXR1cm4gMTt9IGVsc2Uge3JldHVybiAwO319dmFyIHJvdyxyb3dzPVtdLHN0YXJ0aW5nUG9zaXRpb24gPSAwO3doaWxlKHJvdyA9IGdldFJvdygpKSB7cm93cy5wdXNoKHJvdyk7fXJvd3Muc29ydChmdW5jdGlvbiAoYSwgYikge1xuICAgICAgdmFyIHNvcnRCeSA9ICcnO1xuICAgICAgaWYgKHJlcS5xdWVyeSAmJiByZXEucXVlcnkuc29ydEtleSkge1xuICAgICAgICBzb3J0QnkgPSByZXEucXVlcnkuc29ydEtleTtcbiAgICAgICAgcmV0dXJuIGNvbXBhcmVTdHJpbmdzKGEuZG9jLmRhdGFbc29ydEJ5XSwgYi5kb2MuZGF0YVtzb3J0QnldKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiAwOyAvLyBEb24ndCBzb3J0XG4gICAgfSk7aWYgKHJlcS5xdWVyeS5zb3J0RGVzYykge3Jvd3MgPSByb3dzLnJldmVyc2UoKTt9aWYgKHJlcS5xdWVyeS5zb3J0U3RhcnRLZXkpIHt2YXIgc3RhcnRLZXkgPSBKU09OLnBhcnNlKHJlcS5xdWVyeS5zb3J0U3RhcnRLZXkpO2ZvciAodmFyIGk9MDsgaTxyb3dzLmxlbmd0aDsgaSsrKSB7aWYgKGtleXNFcXVhbChzdGFydEtleSwgcm93c1tpXS5rZXkpKSB7c3RhcnRpbmdQb3NpdGlvbiA9IGk7YnJlYWs7fX19aWYgKHJlcS5xdWVyeS5zb3J0TGltaXQpIHtyb3dzID0gcm93cy5zbGljZShzdGFydGluZ1Bvc2l0aW9uLCBwYXJzZUludChyZXEucXVlcnkuc29ydExpbWl0KStzdGFydGluZ1Bvc2l0aW9uKTt9IGVsc2UgaWYgKHN0YXJ0aW5nUG9zaXRpb24gPiAwKSB7cm93cyA9IHJvd3Muc2xpY2Uoc3RhcnRpbmdQb3NpdGlvbik7fXNlbmQoSlNPTi5zdHJpbmdpZnkoe1wicm93c1wiIDogcm93c30pKTt9In19LHsiX2lkIjoiX2Rlc2lnbi9wYXRpZW50X2J5X2FkbWlzc2lvbiIsIl9yZXYiOiIxLTNjMmRhNDM4MGQyNTdjOTVlYmY0NDMwYWZhNDhkZTNiIiwidmVyc2lvbiI6NCwidmlld3MiOnsicGF0aWVudF9ieV9hZG1pc3Npb24iOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdwYXRpZW50Jykge1xuICAgICAgICBpZiAoZG9jLmRhdGEuYWRtaXR0ZWQgPT09IHRydWUpIHtcbiAgICAgIGlmIChkb2MuZGF0YS5mcmllbmRseUlkKSB7XG4gICAgZW1pdChbZG9jLmRhdGEuZnJpZW5kbHlJZCwgZG9jLl9pZF0pO1xuICB9IGVsc2UgaWYgKGRvYy5kYXRhLmV4dGVybmFsUGF0aWVudElkKSB7XG4gICAgZW1pdChbZG9jLmRhdGEuZXh0ZXJuYWxQYXRpZW50SWQsIGRvYy5faWRdKTtcbiAgfSBlbHNlIHtcbiAgICBlbWl0KFtkb2MuX2lkLCBkb2MuX2lkXSk7XG4gfVxuICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH0ifX0sImxpc3RzIjp7InNvcnQiOiJmdW5jdGlvbihoZWFkLCByZXEpIHtmdW5jdGlvbiBrZXlzRXF1YWwoa2V5QSwga2V5Qikge2ZvciAodmFyIGk9IDA7IGkgPCBrZXlBLmxlbmd0aDsgaSsrKSB7aWYgKGtleUFbaV0gIT09IGtleUJbaV0pIHtyZXR1cm4gZmFsc2U7fX1yZXR1cm4gdHJ1ZTt9ZnVuY3Rpb24gZ2V0Q29tcGFyZURhdGUoZGF0ZVN0cmluZykge2lmICghZGF0ZVN0cmluZyB8fCBkYXRlU3RyaW5nID09PSBcIlwiKSB7cmV0dXJuIDA7fXJldHVybiBuZXcgRGF0ZShkYXRlU3RyaW5nKS5nZXRUaW1lKCk7fWZ1bmN0aW9uIGNvbXBhcmVTdHJpbmdzKGFTdHJpbmcsIGJTdHJpbmcpIHtpZiAoIWFTdHJpbmcpIHthU3RyaW5nID0gXCJcIjt9aWYgKCFiU3RyaW5nKSB7YlN0cmluZyA9IFwiXCI7fWlmIChhU3RyaW5nIDwgYlN0cmluZykge3JldHVybiAtMTt9IGVsc2UgaWYgKGFTdHJpbmcgPiBiU3RyaW5nKSB7cmV0dXJuIDE7fSBlbHNlIHtyZXR1cm4gMDt9fXZhciByb3cscm93cz1bXSxzdGFydGluZ1Bvc2l0aW9uID0gMDt3aGlsZShyb3cgPSBnZXRSb3coKSkge3Jvd3MucHVzaChyb3cpO31yb3dzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHtcbiAgICB2YXIgc29ydEJ5ID0gJyc7XG4gICAgaWYgKHJlcS5xdWVyeSAmJiByZXEucXVlcnkuc29ydEtleSkge1xuICAgICAgc29ydEJ5ID0gcmVxLnF1ZXJ5LnNvcnRLZXk7XG4gICAgfVxuICAgIHN3aXRjaCAoc29ydEJ5KSB7XG4gICAgICBjYXNlICdmaXJzdE5hbWUnOlxuICAgICAgY2FzZSAnc2V4JzpcbiAgICAgIGNhc2UgJ2xhc3ROYW1lJzpcbiAgICAgIGNhc2UgJ3N0YXR1cyc6XG4gICAgICAgIHtcbiAgICAgICAgICByZXR1cm4gY29tcGFyZVN0cmluZ3MoYS5kb2MuZGF0YVtzb3J0QnldLCBiLmRvYy5kYXRhW3NvcnRCeV0pO1xuICAgICAgICB9XG4gICAgICBjYXNlICdkYXRlT2ZCaXJ0aCc6XG4gICAgICAgIHtcbiAgICAgICAgICByZXR1cm4gZ2V0Q29tcGFyZURhdGUoYS5kb2MuZGF0YS5kYXRlT2ZCaXJ0aCkgLSBnZXRDb21wYXJlRGF0ZShiLmRvYy5kYXRhLmRhdGVPZkJpcnRoKTtcbiAgICAgICAgfVxuICAgICAgZGVmYXVsdDpcbiAgICAgICAge1xuICAgICAgICAgIHJldHVybiAwOyAvLyBEb24ndCBzb3J0XG4gICAgICAgIH1cbiAgICB9XG4gIH0pO2lmIChyZXEucXVlcnkuc29ydERlc2MpIHtyb3dzID0gcm93cy5yZXZlcnNlKCk7fWlmIChyZXEucXVlcnkuc29ydFN0YXJ0S2V5KSB7dmFyIHN0YXJ0S2V5ID0gSlNPTi5wYXJzZShyZXEucXVlcnkuc29ydFN0YXJ0S2V5KTtmb3IgKHZhciBpPTA7IGk8cm93cy5sZW5ndGg7IGkrKykge2lmIChrZXlzRXF1YWwoc3RhcnRLZXksIHJvd3NbaV0ua2V5KSkge3N0YXJ0aW5nUG9zaXRpb24gPSBpO2JyZWFrO319fWlmIChyZXEucXVlcnkuc29ydExpbWl0KSB7cm93cyA9IHJvd3Muc2xpY2Uoc3RhcnRpbmdQb3NpdGlvbiwgcGFyc2VJbnQocmVxLnF1ZXJ5LnNvcnRMaW1pdCkrc3RhcnRpbmdQb3NpdGlvbik7fSBlbHNlIGlmIChzdGFydGluZ1Bvc2l0aW9uID4gMCkge3Jvd3MgPSByb3dzLnNsaWNlKHN0YXJ0aW5nUG9zaXRpb24pO31zZW5kKEpTT04uc3RyaW5naWZ5KHtcInJvd3NcIiA6IHJvd3N9KSk7fSJ9fSx7Il9pZCI6Il9kZXNpZ24vcGF0aWVudF9ieV9kaXNwbGF5X2lkIiwiX3JldiI6IjEtOGE2OTMwMDAyYWY2ZDU4OGVjZGVkZDVmMDdkYTAyMzAiLCJ2ZXJzaW9uIjo3LCJ2aWV3cyI6eyJwYXRpZW50X2J5X2Rpc3BsYXlfaWQiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdwYXRpZW50Jykge1xuICAgICAgICBpZiAoZG9jLmRhdGEuZnJpZW5kbHlJZCkge1xuICAgIGVtaXQoW2RvYy5kYXRhLmZyaWVuZGx5SWQsIGRvYy5faWRdKTtcbiAgfSBlbHNlIGlmIChkb2MuZGF0YS5leHRlcm5hbFBhdGllbnRJZCkge1xuICAgIGVtaXQoW2RvYy5kYXRhLmV4dGVybmFsUGF0aWVudElkLCBkb2MuX2lkXSk7XG4gIH0gZWxzZSB7XG4gICAgZW1pdChbZG9jLl9pZCwgZG9jLl9pZF0pO1xuIH1cbiAgICAgIH1cbiAgICB9XG4gIH0ifX0sImxpc3RzIjp7InNvcnQiOiJmdW5jdGlvbihoZWFkLCByZXEpIHtmdW5jdGlvbiBrZXlzRXF1YWwoa2V5QSwga2V5Qikge2ZvciAodmFyIGk9IDA7IGkgPCBrZXlBLmxlbmd0aDsgaSsrKSB7aWYgKGtleUFbaV0gIT09IGtleUJbaV0pIHtyZXR1cm4gZmFsc2U7fX1yZXR1cm4gdHJ1ZTt9ZnVuY3Rpb24gZ2V0Q29tcGFyZURhdGUoZGF0ZVN0cmluZykge2lmICghZGF0ZVN0cmluZyB8fCBkYXRlU3RyaW5nID09PSBcIlwiKSB7cmV0dXJuIDA7fXJldHVybiBuZXcgRGF0ZShkYXRlU3RyaW5nKS5nZXRUaW1lKCk7fWZ1bmN0aW9uIGNvbXBhcmVTdHJpbmdzKGFTdHJpbmcsIGJTdHJpbmcpIHtpZiAoIWFTdHJpbmcpIHthU3RyaW5nID0gXCJcIjt9aWYgKCFiU3RyaW5nKSB7YlN0cmluZyA9IFwiXCI7fWlmIChhU3RyaW5nIDwgYlN0cmluZykge3JldHVybiAtMTt9IGVsc2UgaWYgKGFTdHJpbmcgPiBiU3RyaW5nKSB7cmV0dXJuIDE7fSBlbHNlIHtyZXR1cm4gMDt9fXZhciByb3cscm93cz1bXSxzdGFydGluZ1Bvc2l0aW9uID0gMDt3aGlsZShyb3cgPSBnZXRSb3coKSkge3Jvd3MucHVzaChyb3cpO31yb3dzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHtcbiAgICB2YXIgc29ydEJ5ID0gJyc7XG4gICAgaWYgKHJlcS5xdWVyeSAmJiByZXEucXVlcnkuc29ydEtleSkge1xuICAgICAgc29ydEJ5ID0gcmVxLnF1ZXJ5LnNvcnRLZXk7XG4gICAgfVxuICAgIHN3aXRjaCAoc29ydEJ5KSB7XG4gICAgICBjYXNlICdmaXJzdE5hbWUnOlxuICAgICAgY2FzZSAnc2V4JzpcbiAgICAgIGNhc2UgJ2xhc3ROYW1lJzpcbiAgICAgIGNhc2UgJ3N0YXR1cyc6XG4gICAgICAgIHtcbiAgICAgICAgICByZXR1cm4gY29tcGFyZVN0cmluZ3MoYS5kb2MuZGF0YVtzb3J0QnldLCBiLmRvYy5kYXRhW3NvcnRCeV0pO1xuICAgICAgICB9XG4gICAgICBjYXNlICdkYXRlT2ZCaXJ0aCc6XG4gICAgICAgIHtcbiAgICAgICAgICByZXR1cm4gZ2V0Q29tcGFyZURhdGUoYS5kb2MuZGF0YS5kYXRlT2ZCaXJ0aCkgLSBnZXRDb21wYXJlRGF0ZShiLmRvYy5kYXRhLmRhdGVPZkJpcnRoKTtcbiAgICAgICAgfVxuICAgICAgZGVmYXVsdDpcbiAgICAgICAge1xuICAgICAgICAgIHJldHVybiAwOyAvLyBEb24ndCBzb3J0XG4gICAgICAgIH1cbiAgICB9XG4gIH0pO2lmIChyZXEucXVlcnkuc29ydERlc2MpIHtyb3dzID0gcm93cy5yZXZlcnNlKCk7fWlmIChyZXEucXVlcnkuc29ydFN0YXJ0S2V5KSB7dmFyIHN0YXJ0S2V5ID0gSlNPTi5wYXJzZShyZXEucXVlcnkuc29ydFN0YXJ0S2V5KTtmb3IgKHZhciBpPTA7IGk8cm93cy5sZW5ndGg7IGkrKykge2lmIChrZXlzRXF1YWwoc3RhcnRLZXksIHJvd3NbaV0ua2V5KSkge3N0YXJ0aW5nUG9zaXRpb24gPSBpO2JyZWFrO319fWlmIChyZXEucXVlcnkuc29ydExpbWl0KSB7cm93cyA9IHJvd3Muc2xpY2Uoc3RhcnRpbmdQb3NpdGlvbiwgcGFyc2VJbnQocmVxLnF1ZXJ5LnNvcnRMaW1pdCkrc3RhcnRpbmdQb3NpdGlvbik7fSBlbHNlIGlmIChzdGFydGluZ1Bvc2l0aW9uID4gMCkge3Jvd3MgPSByb3dzLnNsaWNlKHN0YXJ0aW5nUG9zaXRpb24pO31zZW5kKEpTT04uc3RyaW5naWZ5KHtcInJvd3NcIiA6IHJvd3N9KSk7fSJ9fSx7Il9pZCI6Il9kZXNpZ24vcGF0aWVudF9ieV9zdGF0dXMiLCJfcmV2IjoiMS01NGJjNzRmZjkzZGI0YWVkZmY4M2JjNjQ5Zjc2NjU5NiIsInZlcnNpb24iOjMsInZpZXdzIjp7InBhdGllbnRfYnlfc3RhdHVzIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAncGF0aWVudCcpIHtcbiAgICAgICAgZW1pdChkb2MuZGF0YS5zdGF0dXMpO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL3Bob3RvX2J5X3BhdGllbnQiLCJfcmV2IjoiMS02YTRmYWQ0ZmE2ODJlZmJiZDA1OGU4NThjMzI4NTc0ZiIsInZlcnNpb24iOjQsInZpZXdzIjp7InBob3RvX2J5X3BhdGllbnQiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICdwaG90bycpIHtcbiAgICAgICAgZW1pdChkb2MuZGF0YS5wYXRpZW50KTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi9wcmljaW5nX2J5X2NhdGVnb3J5IiwiX3JldiI6IjEtM2Q3MDNiNWYyNDBhZTU4MzhkMWYyMGE4YWQwNDcxZGUiLCJ2ZXJzaW9uIjo1LCJ2aWV3cyI6eyJwcmljaW5nX2J5X2NhdGVnb3J5Ijp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAncHJpY2luZycpIHtcbiAgICAgICAgZW1pdChbZG9jLmRhdGEuY2F0ZWdvcnksIGRvYy5kYXRhLm5hbWUsIGRvYy5kYXRhLnByaWNpbmdUeXBlLCBkb2MuX2lkXSk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vcHJvY2VkdXJlX2J5X2RhdGUiLCJfcmV2IjoiMS1hNDRkZWNkOGYxNGQwMWM2MTVjZjNmNWI4ZTcwZjEwYiIsInZlcnNpb24iOjQsInZpZXdzIjp7InByb2NlZHVyZV9ieV9kYXRlIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAncHJvY2VkdXJlJykge1xuICAgICAgICB2YXIgcHJvY2VkdXJlRGF0ZSA9IGRvYy5kYXRhLnByb2NlZHVyZURhdGU7XG4gICAgaWYgKHByb2NlZHVyZURhdGUgJiYgcHJvY2VkdXJlRGF0ZSAhPT0gXCJcIikge1xuICAgICAgcHJvY2VkdXJlRGF0ZSA9IG5ldyBEYXRlKHByb2NlZHVyZURhdGUpO1xuICAgICAgaWYgKHByb2NlZHVyZURhdGUuZ2V0VGltZSkge1xuICAgICAgICBwcm9jZWR1cmVEYXRlID0gcHJvY2VkdXJlRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW3Byb2NlZHVyZURhdGUsIGRvYy5faWRdKTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi9zZXF1ZW5jZV9ieV9wcmVmaXgiLCJfcmV2IjoiMS0xMGY4MWM5Mjg3ZjJkYjc4MmI4ZTI5M2U3ZDliMWNkZSIsInZlcnNpb24iOjQsInZpZXdzIjp7InNlcXVlbmNlX2J5X3ByZWZpeCI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ3NlcXVlbmNlJykge1xuICAgICAgICBlbWl0KGRvYy5kYXRhLnByZWZpeCk7XG4gICAgICB9XG4gICAgfVxuICB9In19fSx7Il9pZCI6Il9kZXNpZ24vc3VyZ2ljYWxfYXBwb2ludG1lbnRzX2J5X2RhdGUiLCJfcmV2IjoiMS05MGQ4ZGU4MzRkZTFmZTBlMTU0ZDFjZGFiODg4OTk4NCIsInZlcnNpb24iOjEsInZpZXdzIjp7InN1cmdpY2FsX2FwcG9pbnRtZW50c19ieV9kYXRlIjp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAnYXBwb2ludG1lbnQnKSB7XG4gICAgICAgIHZhciBlbmREYXRlID0gZG9jLmRhdGEuZW5kRGF0ZTtcbiAgICBpZiAoZW5kRGF0ZSAmJiBlbmREYXRlICE9PSBcIlwiKSB7XG4gICAgICBlbmREYXRlID0gbmV3IERhdGUoZW5kRGF0ZSk7XG4gICAgICBpZiAoZW5kRGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIGVuZERhdGUgPSBlbmREYXRlLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgdmFyIHN0YXJ0RGF0ZSA9IGRvYy5kYXRhLnN0YXJ0RGF0ZTtcbiAgICBpZiAoc3RhcnREYXRlICYmIHN0YXJ0RGF0ZSAhPT0gXCJcIikge1xuICAgICAgc3RhcnREYXRlID0gbmV3IERhdGUoc3RhcnREYXRlKTtcbiAgICAgIGlmIChzdGFydERhdGUuZ2V0VGltZSkge1xuICAgICAgICBzdGFydERhdGUgPSBzdGFydERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBpZiAoZG9jLmRhdGEuYXBwb2ludG1lbnRUeXBlID09PSAnU3VyZ2VyeScpIHtcbiAgICAgIGVtaXQoW3N0YXJ0RGF0ZSwgZW5kRGF0ZSwgZG9jLl9pZF0pO1xuICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH0ifX0sImxpc3RzIjp7InNvcnQiOiJmdW5jdGlvbihoZWFkLCByZXEpIHtmdW5jdGlvbiBrZXlzRXF1YWwoa2V5QSwga2V5Qikge2ZvciAodmFyIGk9IDA7IGkgPCBrZXlBLmxlbmd0aDsgaSsrKSB7aWYgKGtleUFbaV0gIT09IGtleUJbaV0pIHtyZXR1cm4gZmFsc2U7fX1yZXR1cm4gdHJ1ZTt9ZnVuY3Rpb24gZ2V0Q29tcGFyZURhdGUoZGF0ZVN0cmluZykge2lmICghZGF0ZVN0cmluZyB8fCBkYXRlU3RyaW5nID09PSBcIlwiKSB7cmV0dXJuIDA7fXJldHVybiBuZXcgRGF0ZShkYXRlU3RyaW5nKS5nZXRUaW1lKCk7fWZ1bmN0aW9uIGNvbXBhcmVTdHJpbmdzKGFTdHJpbmcsIGJTdHJpbmcpIHtpZiAoIWFTdHJpbmcpIHthU3RyaW5nID0gXCJcIjt9aWYgKCFiU3RyaW5nKSB7YlN0cmluZyA9IFwiXCI7fWlmIChhU3RyaW5nIDwgYlN0cmluZykge3JldHVybiAtMTt9IGVsc2UgaWYgKGFTdHJpbmcgPiBiU3RyaW5nKSB7cmV0dXJuIDE7fSBlbHNlIHtyZXR1cm4gMDt9fXZhciByb3cscm93cz1bXSxzdGFydGluZ1Bvc2l0aW9uID0gMDt3aGlsZShyb3cgPSBnZXRSb3coKSkge3Jvd3MucHVzaChyb3cpO31yb3dzID0gcm93cy5maWx0ZXIoZnVuY3Rpb24gKHJvdykge1xuICAgIHZhciBmaWx0ZXJCeSA9IG51bGw7XG4gICAgdmFyIGluY2x1ZGVSb3cgPSB0cnVlO1xuICAgIGlmIChyZXEucXVlcnkgJiYgcmVxLnF1ZXJ5LmZpbHRlckJ5KSB7XG4gICAgICBmaWx0ZXJCeSA9IEpTT04ucGFyc2UocmVxLnF1ZXJ5LmZpbHRlckJ5KTtcbiAgICB9XG4gICAgaWYgKCFmaWx0ZXJCeSkge1xuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgZmlsdGVyQnkubGVuZ3RoOyBpKyspIHtcbiAgICAgIHZhciBjdXJyZW50VmFsdWUgPSByb3cuZG9jLmRhdGFbZmlsdGVyQnlbaV0ubmFtZV07XG4gICAgICBpZiAoZmlsdGVyQnlbaV0ubmFtZSA9PT0gJ3N0YXR1cycgJiYgKCFjdXJyZW50VmFsdWUgfHwgY3VycmVudFZhbHVlID09PSAnJykpIHtcbiAgICAgICAgY3VycmVudFZhbHVlID0gJ1NjaGVkdWxlZCc7XG4gICAgICB9XG4gICAgICBpZiAoY3VycmVudFZhbHVlICE9PSBmaWx0ZXJCeVtpXS52YWx1ZSkge1xuICAgICAgICBpbmNsdWRlUm93ID0gZmFsc2U7XG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gaW5jbHVkZVJvdztcbiAgfSk7cm93cy5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7XG4gICAgZnVuY3Rpb24gZGVmYXVsdFN0YXR1cyh2YWx1ZSkge1xuICAgICAgaWYgKCF2YWx1ZSB8fCB2YWx1ZSA9PT0gJycpIHtcbiAgICAgICAgcmV0dXJuICdTY2hlZHVsZWQnO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgfVxuICAgIH1cbiAgICB2YXIgc29ydEJ5ID0gJyc7XG4gICAgaWYgKHJlcS5xdWVyeSAmJiByZXEucXVlcnkuc29ydEtleSkge1xuICAgICAgc29ydEJ5ID0gcmVxLnF1ZXJ5LnNvcnRLZXk7XG4gICAgfVxuICAgIHN3aXRjaCAoc29ydEJ5KSB7XG4gICAgICBjYXNlICdhcHBvaW50bWVudFR5cGUnOlxuICAgICAgY2FzZSAnbG9jYXRpb24nOlxuICAgICAgY2FzZSAncHJvdmlkZXInOlxuICAgICAgICByZXR1cm4gY29tcGFyZVN0cmluZ3MoYS5kb2MuZGF0YVtzb3J0QnldLCBiLmRvYy5kYXRhW3NvcnRCeV0pO1xuICAgICAgY2FzZSAnZGF0ZSc6XG4gICAgICAgIHtcbiAgICAgICAgICB2YXIgc3RhcnREaWZmID0gZ2V0Q29tcGFyZURhdGUoYS5kb2MuZGF0YS5zdGFydERhdGUpIC0gZ2V0Q29tcGFyZURhdGUoYi5kb2MuZGF0YS5zdGFydERhdGUpO1xuICAgICAgICAgIGlmIChzdGFydERpZmYgPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRDb21wYXJlRGF0ZShhLmRvYy5kYXRhLmVuZERhdGUpIC0gZ2V0Q29tcGFyZURhdGUoYi5kb2MuZGF0YS5lbmREYXRlKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHN0YXJ0RGlmZjtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIGNhc2UgJ3N0YXR1cyc6XG4gICAgICAgIHtcbiAgICAgICAgICB2YXIgYVN0YXR1cyA9IGRlZmF1bHRTdGF0dXMoYS5kb2MuZGF0YVtzb3J0QnldKTtcbiAgICAgICAgICB2YXIgYlN0YXR1cyA9IGRlZmF1bHRTdGF0dXMoYi5kb2MuZGF0YVtzb3J0QnldKTtcbiAgICAgICAgICByZXR1cm4gY29tcGFyZVN0cmluZ3MoYVN0YXR1cywgYlN0YXR1cyk7XG4gICAgICAgIH1cbiAgICAgIGRlZmF1bHQ6XG4gICAgICAgIHtcbiAgICAgICAgICByZXR1cm4gMDsgLy8gRG9uJ3Qgc29ydFxuICAgICAgICB9XG4gICAgfVxuICB9KTtpZiAocmVxLnF1ZXJ5LnNvcnREZXNjKSB7cm93cyA9IHJvd3MucmV2ZXJzZSgpO31pZiAocmVxLnF1ZXJ5LnNvcnRTdGFydEtleSkge3ZhciBzdGFydEtleSA9IEpTT04ucGFyc2UocmVxLnF1ZXJ5LnNvcnRTdGFydEtleSk7Zm9yICh2YXIgaT0wOyBpPHJvd3MubGVuZ3RoOyBpKyspIHtpZiAoa2V5c0VxdWFsKHN0YXJ0S2V5LCByb3dzW2ldLmtleSkpIHtzdGFydGluZ1Bvc2l0aW9uID0gaTticmVhazt9fX1pZiAocmVxLnF1ZXJ5LnNvcnRMaW1pdCkge3Jvd3MgPSByb3dzLnNsaWNlKHN0YXJ0aW5nUG9zaXRpb24sIHBhcnNlSW50KHJlcS5xdWVyeS5zb3J0TGltaXQpK3N0YXJ0aW5nUG9zaXRpb24pO30gZWxzZSBpZiAoc3RhcnRpbmdQb3NpdGlvbiA+IDApIHtyb3dzID0gcm93cy5zbGljZShzdGFydGluZ1Bvc2l0aW9uKTt9c2VuZChKU09OLnN0cmluZ2lmeSh7XCJyb3dzXCIgOiByb3dzfSkpO30ifX0seyJfaWQiOiJfZGVzaWduL3Zpc2l0X2J5X2RhdGUiLCJfcmV2IjoiMS1kYjYxZjk5M2ExZTE2OTljODIwNWZlZTM0MzRmYzRjOCIsInZlcnNpb24iOjQsInZpZXdzIjp7InZpc2l0X2J5X2RhdGUiOnsibWFwIjoiZnVuY3Rpb24oZG9jKSB7XG4gICAgdmFyIGRvY3R5cGUsIHVpZHg7XG4gICAgaWYgKGRvYy5faWQgJiYgKHVpZHggPSBkb2MuX2lkLmluZGV4T2YoJ18nKSkgPiAwICYmICFkb2MuZGF0YS5hcmNoaXZlZCkge1xuICAgICAgZG9jdHlwZSA9IGRvYy5faWQuc3Vic3RyaW5nKDAsIHVpZHgpO1xuICAgICAgaWYgKGRvY3R5cGUgPT09ICd2aXNpdCcpIHtcbiAgICAgICAgdmFyIGVuZERhdGUgPSBkb2MuZGF0YS5lbmREYXRlO1xuICAgIGlmIChlbmREYXRlICYmIGVuZERhdGUgIT09IFwiXCIpIHtcbiAgICAgIGVuZERhdGUgPSBuZXcgRGF0ZShlbmREYXRlKTtcbiAgICAgIGlmIChlbmREYXRlLmdldFRpbWUpIHtcbiAgICAgICAgZW5kRGF0ZSA9IGVuZERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICB2YXIgc3RhcnREYXRlID0gZG9jLmRhdGEuc3RhcnREYXRlO1xuICAgIGlmIChzdGFydERhdGUgJiYgc3RhcnREYXRlICE9PSBcIlwiKSB7XG4gICAgICBzdGFydERhdGUgPSBuZXcgRGF0ZShzdGFydERhdGUpO1xuICAgICAgaWYgKHN0YXJ0RGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIHN0YXJ0RGF0ZSA9IHN0YXJ0RGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW3N0YXJ0RGF0ZSwgZW5kRGF0ZSwgZG9jLl9pZF0pO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJfZGVzaWduL3Zpc2l0X2J5X2Rpc2NoYXJnZV9kYXRlIiwiX3JldiI6IjEtYjRiYWNhODVkNTRlNzI3OTY2YWViMmU4YWQxNzIxMzYiLCJ2ZXJzaW9uIjoyLCJ2aWV3cyI6eyJ2aXNpdF9ieV9kaXNjaGFyZ2VfZGF0ZSI6eyJtYXAiOiJmdW5jdGlvbihkb2MpIHtcbiAgICB2YXIgZG9jdHlwZSwgdWlkeDtcbiAgICBpZiAoZG9jLl9pZCAmJiAodWlkeCA9IGRvYy5faWQuaW5kZXhPZignXycpKSA+IDAgJiYgIWRvYy5kYXRhLmFyY2hpdmVkKSB7XG4gICAgICBkb2N0eXBlID0gZG9jLl9pZC5zdWJzdHJpbmcoMCwgdWlkeCk7XG4gICAgICBpZiAoZG9jdHlwZSA9PT0gJ3Zpc2l0Jykge1xuICAgICAgICB2YXIgZW5kRGF0ZSA9IGRvYy5kYXRhLmVuZERhdGU7XG4gICAgaWYgKGVuZERhdGUgJiYgZW5kRGF0ZSAhPT0gXCJcIikge1xuICAgICAgZW5kRGF0ZSA9IG5ldyBEYXRlKGVuZERhdGUpO1xuICAgICAgaWYgKGVuZERhdGUuZ2V0VGltZSkge1xuICAgICAgICBlbmREYXRlID0gZW5kRGF0ZS5nZXRUaW1lKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGVtaXQoW2VuZERhdGUsIGRvYy5faWRdKTtcbiAgICAgIH1cbiAgICB9XG4gIH0ifX19LHsiX2lkIjoiX2Rlc2lnbi92aXNpdF9ieV9wYXRpZW50IiwiX3JldiI6IjEtZjI4NjVjNzRlZWZlZTcxNjkzNzQ5MmRiOTE0ZjJjY2QiLCJ2ZXJzaW9uIjo0LCJ2aWV3cyI6eyJ2aXNpdF9ieV9wYXRpZW50Ijp7Im1hcCI6ImZ1bmN0aW9uKGRvYykge1xuICAgIHZhciBkb2N0eXBlLCB1aWR4O1xuICAgIGlmIChkb2MuX2lkICYmICh1aWR4ID0gZG9jLl9pZC5pbmRleE9mKCdfJykpID4gMCAmJiAhZG9jLmRhdGEuYXJjaGl2ZWQpIHtcbiAgICAgIGRvY3R5cGUgPSBkb2MuX2lkLnN1YnN0cmluZygwLCB1aWR4KTtcbiAgICAgIGlmIChkb2N0eXBlID09PSAndmlzaXQnKSB7XG4gICAgICAgIHZhciBlbmREYXRlID0gZG9jLmRhdGEuZW5kRGF0ZTtcbiAgICBpZiAoZW5kRGF0ZSAmJiBlbmREYXRlICE9PSBcIlwiKSB7XG4gICAgICBlbmREYXRlID0gbmV3IERhdGUoZW5kRGF0ZSk7XG4gICAgICBpZiAoZW5kRGF0ZS5nZXRUaW1lKSB7XG4gICAgICAgIGVuZERhdGUgPSBlbmREYXRlLmdldFRpbWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgdmFyIHN0YXJ0RGF0ZSA9IGRvYy5kYXRhLnN0YXJ0RGF0ZTtcbiAgICBpZiAoc3RhcnREYXRlICYmIHN0YXJ0RGF0ZSAhPT0gXCJcIikge1xuICAgICAgc3RhcnREYXRlID0gbmV3IERhdGUoc3RhcnREYXRlKTtcbiAgICAgIGlmIChzdGFydERhdGUuZ2V0VGltZSkge1xuICAgICAgICBzdGFydERhdGUgPSBzdGFydERhdGUuZ2V0VGltZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBlbWl0KFtkb2MuZGF0YS5wYXRpZW50LCBzdGFydERhdGUsIGVuZERhdGUsIGRvYy5kYXRhLnZpc2l0VHlwZSwgZG9jLl9pZF0pO1xuICAgICAgfVxuICAgIH1cbiAgfSJ9fX0seyJfaWQiOiJjdXN0b21Gb3JtXzJfYWQxY2IxZjItNGZjMC00YzlkLWIzNWEtYTBmOTg4Y2U3YzVlIiwiX3JldiI6IjctNGQ4ZDUyYmVkYjMzMGFiMTQyZmQ1M2FiZjY3YTYzNDciLCJkYXRhIjp7ImFsd2F5c0luY2x1ZGUiOmZhbHNlLCJjb2x1bW5zIjoyLCJmb3JtVHlwZSI6ImluY2lkZW50IiwibmFtZSI6IlByZS1JbmNpZGVudCBSaXNrIEFzc2Vzc21lbnQiLCJhcmNoaXZlZCI6ZmFsc2UsImxhc3RNb2RpZmllZCI6IjIwMTctMDMtMDhUMjA6MTE6MjAuMDE3WiIsIm1vZGlmaWVkQnkiOiJBZG1pbiBVc2VyIiwibW9kaWZpZWRGaWVsZHMiOnsibmFtZSI6IjIwMTctMDMtMDhUMjA6MTE6MjAuMDE3WiIsImZvcm1UeXBlIjoiMjAxNy0wMy0wOFQyMDoxMToyMC4wMTdaIiwiY29sdW1ucyI6IjIwMTctMDMtMDhUMjA6MTE6MjAuMDE3WiJ9LCJmaWVsZHMiOlt7ImNsYXNzTmFtZXMiOm51bGwsImNvbFNwYW4iOjEsImluY2x1ZGVPdGhlck9wdGlvbiI6ZmFsc2UsImxhYmVsIjoiU2V2ZXJpdHkiLCJvdGhlck9wdGlvbkxhYmVsIjpudWxsLCJwcm9tcHQiOm51bGwsInByb3BlcnR5Ijoic2V2ZXJpdHkiLCJ0eXBlIjoicmFkaW8iLCJ2YWx1ZXMiOlt7ImxhYmVsIjoiNSBFeHRyZW1lIERlYXRoLCB0b3hpYyByZWxlYXNlIG9mZi1zaXRlIHdpdGggZGV0cmltZW50YWwgZWZmZWN0LCBodWdlIGZpbmFuY2lhbCBsb3NzIn0seyJsYWJlbCI6IjQgSGlnaCBFeHRlbnNpdmUgaW5qdXJpZXMsIGxvc3Mgb2YgcHJvZHVjdGlvbiBjYXBhYmlsaXR5LCBvZmYtc2l0ZSByZWxlYXNlIHdpdGggbm8gZGV0cmltZW50YWwgZWZmZWN0cywgbWFqb3IgZmluYW5jaWFsIGxvc3MifSx7ImxhYmVsIjoiMyBNb2RlcmF0ZSBNZWRpY2FsIHRyZWF0bWVudCByZXF1aXJlZCwgb24tc2l0ZSByZWxlYXNlIGNvbnRhaW5lZCB3aXRoIG91dHNpZGUgYXNzaXN0YW5jZSwgaGlnaCBmaW5hbmNpYWwgbG9zcyJ9LHsibGFiZWwiOiIyIExvdyBGaXJzdCBhaWQgdHJlYXRtZW50LCBvbi1zaXRlIHJlbGVhc2UgY29udGFpbmVkLCBtZWRpdW0gZmluYW5jaWFsIGxvc3MifSx7ImxhYmVsIjoiMSBNaW5pbXVtIE5vIGluanVyaWVzLCBsb3cgZmluYW5jaWFsIGxvc3MifV19LHsiY2xhc3NOYW1lcyI6bnVsbCwiY29sU3BhbiI6MSwiaW5jbHVkZU90aGVyT3B0aW9uIjpmYWxzZSwibGFiZWwiOiJPY2N1cnJlbmNlIiwib3RoZXJPcHRpb25MYWJlbCI6bnVsbCwicHJvbXB0IjpudWxsLCJwcm9wZXJ0eSI6Im9jY3VycmVuY2UiLCJ0eXBlIjoicmFkaW8iLCJ2YWx1ZXMiOlt7ImxhYmVsIjoiNSAgQWxtb3N0IENlcnRhaW4gIElzIGV4cGVjdGVkIHRvIG9jY3VyIGluIG1vc3QgY2lyY3Vtc3RhbmNlcyAoZS5nLiBtb3N0IHdlZWtzIG9yIG1vbnRocykifSx7ImxhYmVsIjoiNCAgTGlrZWx5IFdpbGwgcHJvYmFibHkgb2NjdXIgaW4gbW9zdCBjaXJjdW1zdGFuY2VzIChzZXZlcmFsIHRpbWVzIGEgeWVhcikifSx7ImxhYmVsIjoiMyAgUG9zc2libGUgTWlnaHQgb2NjdXIgYXQgc29tZSB0aW1lIChldmVyeSAxIHRvIDIgeWVhcnMpIn0seyJsYWJlbCI6IjIgIFVubGlrZWx5IENvdWxkIG9jY3VyIGF0IHNvbWUgdGltZSAocG9zc2libHkgaW4gdGhlIG5leHQgMiB0byA1IHllYXJzKSJ9LHsibGFiZWwiOiIxICBSYXJlIE1heSBvY2N1ciBvbmx5IGluIGV4Y2VwdGlvbmFsIGNpcmN1bXN0YW5jZXMgKHBlcmhhcHMgZXZlcnkgNSB0byAzMCB5ZWFycykifV19XX0sIl9yZXZpc2lvbnMiOnsic3RhcnQiOjcsImlkcyI6WyI0ZDhkNTJiZWRiMzMwYWIxNDJmZDUzYWJmNjdhNjM0NyIsIjE0NGNlODk5ZTlkYjVmYzIzMDA5OTZkYTlmZTZjMGFiIiwiOGYzNjhmZGM5ZDlkYmNlNWI0ZDJiOTAyMTBmMmJjYjkiLCI4MDczODE1ZmE3M2Y2OTkwZTdiYjJkZWI3N2ZiMTJhNyIsIjQxNGQ3M2ZlZGRjZjQwZjVhMWZkMTY3OTY5YzNhNjAyIiwiYzhiN2E0NDEwOTE2MTJjNDQ4OWY5OWM5YmQ1N2NkOTIiLCJmOGE0Nzk5YTIxZWNlM2YwMzU3OGZiNTE2NjlhMDcyOCJdfX0seyJfaWQiOiJjdXN0b21Gb3JtXzJfYjVlNzA4NDEtYjc4Yi00MTU1LTlhYjUtYmFiYzZlMGY0NWQxIiwiX3JldiI6IjItMGE5ZGMzN2EyOGFiY2U2MzEwMWJlMGZlNDljYzY1YzkiLCJkYXRhIjp7ImFsd2F5c0luY2x1ZGUiOnRydWUsImNvbHVtbnMiOjEsImZvcm1UeXBlIjoiaW5jaWRlbnQiLCJuYW1lIjoiSGFybSBTY29yZSIsImFyY2hpdmVkIjpmYWxzZSwibGFzdE1vZGlmaWVkIjoiMjAxNy0wMy0wOFQyMDowMzoxOS4yNjZaIiwibW9kaWZpZWRCeSI6IkFkbWluIFVzZXIiLCJtb2RpZmllZEZpZWxkcyI6eyJuYW1lIjoiMjAxNy0wMy0wOFQyMDowMzoxOS4yNjZaIiwiZm9ybVR5cGUiOiIyMDE3LTAzLTA4VDIwOjAzOjE5LjI2NloiLCJjb2x1bW5zIjoiMjAxNy0wMy0wOFQyMDowMzoxOS4yNjZaIiwiYWx3YXlzSW5jbHVkZSI6IjIwMTctMDMtMDhUMjA6MDM6MTkuMjY2WiJ9LCJmaWVsZHMiOlt7ImNsYXNzTmFtZXMiOm51bGwsImNvbFNwYW4iOm51bGwsImluY2x1ZGVPdGhlck9wdGlvbiI6ZmFsc2UsImxhYmVsIjoiSGFybSBTY29yZSIsIm90aGVyT3B0aW9uTGFiZWwiOm51bGwsInByb21wdCI6bnVsbCwicHJvcGVydHkiOiJoYXJtU2NvcmUiLCJ0eXBlIjoicmFkaW8iLCJ2YWx1ZXMiOlt7ImxhYmVsIjoiQSAgIE5vIEFjdHVhbCBFdmVudCAoVW5zYWZlIENvbmRpdGlvbikifSx7ImxhYmVsIjoiQjEgIE5lYXIgTWlzcyAtIFRoZSBldmVudCBkaWQgbm90IHJlYWNoIHRoZSBpbmRpdmlkdWFsIGJlY2F1c2Ugb2YgY2hhbmNlIGFsb25lLiJ9LHsibGFiZWwiOiJCMiAgTmVhciBNaXNzIC0gVGhlIGV2ZW50IGRpZCBub3QgcmVhY2ggdGhlIGluZGl2aWR1YWwgYmVjYXVzZSBvZiBhY3RpdmUgcmVjb3ZlcnkgZWZmb3J0cyBieSBjYXJlZ2l2ZXJzLiJ9LHsibGFiZWwiOiJDICAgVGhlIGV2ZW50IHJlYWNoZWQgdGhlIGluZGl2aWR1YWwgYnV0IGRpZCBub3QgY2F1c2UgaGFybS4ifSx7ImxhYmVsIjoiRCAgIFRoZSBldmVudCByZWFjaGVkIHRoZSBpbmRpdmlkdWFsIGFuZCByZXF1aXJlZCBhZGRpdGlvbmFsIG1vbml0b3Jpbmcgb3IgdHJlYXRtZW50IHRvIHByZXZlbnQgaGFybS4ifSx7ImxhYmVsIjoiRSAgIFRoZSBpbmRpdmlkdWFsIGV4cGVyaWVuY2VkIHRlbXBvcmFyeSBoYXJtIGFuZCByZXF1aXJlZCB0cmVhdG1lbnQgb3IgaW50ZXJ2ZW50aW9uLiJ9LHsibGFiZWwiOiJGICAgVGhlIGluZGl2aWR1YWwgZXhwZXJpZW5jZWQgdGVtcG9yYXJ5IGhhcm0gYW5kIHJlcXVpcmVkIGluaXRpYWwgb3IgcHJvbG9uZ2VkIGhvc3BpdGFsaXphdGlvbiJ9LHsibGFiZWwiOiJHICAgVGhlIGluZGl2aWR1YWwgZXhwZXJpZW5jZWQgcGVybWFuZW50IGhhcm0uIn0seyJsYWJlbCI6IkggICBUaGUgaW5kaXZpZHVhbCBleHBlcmllbmNlZCBwZXJtYW5lbnQgaGFybSBhbmQgcmVxdWlyZWQgaW50ZXJ2ZW50aW9uIG5lY2Vzc2FyeSB0byBzdXN0YWluIGxpZmUgKGUuZy4gdHJhbnNmZXIgdG8gSUNVKSJ9LHsibGFiZWwiOiJJICAgVGhlIGluZGl2aWR1YWwgZGllZC4ifV19XX0sIl9yZXZpc2lvbnMiOnsic3RhcnQiOjIsImlkcyI6WyIwYTlkYzM3YTI4YWJjZTYzMTAxYmUwZmU0OWNjNjVjOSIsIjAyMmQzNzgyNTA5YTJlMzkyMzEwOThmOTFjNGZmNmUzIl19fSx7Il9pZCI6ImluY0NhdGVnb3J5XzJfOTI2MDE0YWUtMDllOC00YTg0LWI1Y2EtYmY1Yjc0ZTZhNjZlIiwiX3JldiI6IjE5LTk1MmZhNDM5YmU1NWI1ZDA1ZGFhYzliMjIwMzZmY2Q4IiwiZGF0YSI6eyJpbmNpZGVudENhdGVnb3J5TmFtZSI6IkFjY2lkZW50IG9yIEluanVyeSIsImFyY2hpdmVkIjpmYWxzZSwibGFzdE1vZGlmaWVkIjoiMjAxNy0wMy0wOFQxOToyNzoyMy4yNTJaIiwibW9kaWZpZWRCeSI6IkFkbWluIFVzZXIiLCJtb2RpZmllZEZpZWxkcyI6eyJpbmNpZGVudENhdGVnb3J5TmFtZSI6IjIwMTctMDMtMDhUMTk6Mjc6MjMuMjUyWiIsImluY2lkZW50Q2F0ZWdvcnlJdGVtcyI6IjIwMTctMDMtMDhUMTk6Mjc6MjMuMjUyWiJ9LCJpbmNpZGVudENhdGVnb3J5SXRlbXMiOlt7Iml0ZW0iOiJQYXRpZW50In0seyJpdGVtIjoiU3RhZmYifSx7Iml0ZW0iOiJWaXNpdG9yIn0seyJpdGVtIjoiT3RoZXIifV19LCJfcmV2aXNpb25zIjp7InN0YXJ0IjoxOSwiaWRzIjpbIjk1MmZhNDM5YmU1NWI1ZDA1ZGFhYzliMjIwMzZmY2Q4IiwiZmY5MjkyNWY1ZGU3NzQ2NDJiMzE3NDFkMWU3MTljNzIiLCI2MjM2MzM1MTMwMGIzNWE4ZWEwOGE3NmViZGU3MGM3OCIsIjBmYWNkMzdjNzM1M2QyNjg3YjdlMDAxNjY3MWUxM2VhIiwiZjQ4OGJlZjg1ZTYzYTJjZDM3YTRjOGY4N2IxMjRhZDciLCI4NDNkNjcwZjE1MDUyODZjNDc3NmEyZDMxZGQyNGE2ZCIsIjRjNjQwZDYyYmYwZGVmODczZDc1YzYxY2JiZDFkMDI4IiwiNGE2MGEzNmZhMWE4OTc0NWM5YjQ2M2JjNmE4MmNlNjMiLCI2MjEzM2I5YzdiMjM2YjAwYzVhZmNlYjllYzIzN2UzNSIsIjFhNjY4OTU2Y2U5YTEzMmZkMDFiNDg5YWY3MmVlMmRhIiwiMTAwNzNiMTY0ZGMzYjNkMDMyN2Q1NGJmYTEwMjk4OTMiLCJkZWI1MzJkZjYyZjdlNDM3MzJmMTJhNGU5MDQ4MzQzZiIsIjVlMDJiMmY5MDY4YmIwMWZhMjAxNzRjNDVhMTkxZWRkIiwiYWRmYWQ5MjcxNWExMjVhZmYzN2IzNmE0MTQ2ZDE3MTgiLCJlNmE4ODNlZTQ5MzgzN2U0ZGI4NzFkYWVjOTUwMmMzOCIsIjZlOWQxYmRhZGVjYzIzYmM5YTU3ODRmOTMzZDc1N2QxIiwiMjU2MGM1NzUzYTY3MjY3YWM3ZmI4MzEyNDJiNjZkMzYiLCJhOTFkYTM5NjEyNGQ2ZjAyNjQwOTY2NTIzMjY3ZWZmOSIsIjIxNGRkNjNkNjhiMWVlOWM3NDI4MTRiYWQ2YTc0MWMwIl19fSx7Il9pZCI6ImluY0NhdGVnb3J5XzJfYmU1NDAxMDktMmU3YS00MjEwLTk5ZjgtOGVjYzgyMjliMTIxIiwiX3JldiI6IjUtNWFlZTVmODFjMjExYzM3YWQyMTBlN2JmZDQ5YjQ2ZjMiLCJkYXRhIjp7ImluY2lkZW50Q2F0ZWdvcnlOYW1lIjoiUGF0aWVudCBGYWxscyIsImFyY2hpdmVkIjpmYWxzZSwibGFzdE1vZGlmaWVkIjoiMjAxNy0wMy0wOFQxOTo0MTo1Ni4xNjdaIiwibW9kaWZpZWRCeSI6IkFkbWluIFVzZXIiLCJtb2RpZmllZEZpZWxkcyI6eyJpbmNpZGVudENhdGVnb3J5TmFtZSI6IjIwMTctMDMtMDhUMTk6NDE6NTYuMTY3WiIsImluY2lkZW50Q2F0ZWdvcnlJdGVtcyI6IjIwMTctMDMtMDhUMTk6NDE6NTYuMTY3WiJ9LCJpbmNpZGVudENhdGVnb3J5SXRlbXMiOlt7Iml0ZW0iOiJGcm9tIGJlZCJ9LHsiaXRlbSI6IlNpdHRpbmcgaW4gY2hhaXIifSx7Iml0ZW0iOiJBbWJ1bGF0aW5nIn0seyJpdGVtIjoiR3JvdW5kcyBvZiBGYWNpbGl0eSJ9LHsiaXRlbSI6Ik90aGVyIn1dfSwiX3JldmlzaW9ucyI6eyJzdGFydCI6NSwiaWRzIjpbIjVhZWU1ZjgxYzIxMWMzN2FkMjEwZTdiZmQ0OWI0NmYzIiwiMzJhODA2N2Q4Zjg0ODc4YWJmMWNjNTRjM2IyYjc1NjIiLCI5ZWE2MjA3OGE3NDY5OWJmMTU2YmNlMjE4N2JjYTdjNyIsIjdlYzBiYTMxN2U1MDI0YTliNmY3Yzk1MTVkNTQzYThmIiwiYTMyOTI5NGU1Y2Q1YWI3YmU4YjZlNzhmMTI4NGZjNDYiXX19LHsiX2lkIjoiaW5jaWRlbnROb3RlXzJfNmNlMWI5ZTgtMjA1OS00NDEyLThmZWYtYWM1MWVlNjY1NjFlIiwiX3JldiI6IjEtMWVkNjcxZmE5NTRhNmY0ZmJmMDA3NmU1NDdiNmI0YmUiLCJkYXRhIjp7ImdpdmVuQnkiOiJocmFkbWluIiwiZ2l2ZW5CeURpc3BsYXlOYW1lIjoiQWRtaW4gVXNlciIsImRlc2NyaXB0aW9uIjoiVGhlIHdldCBmbG9vciBzaWduIGhhZCBmYWxsZW4gZG93bi4iLCJkYXRlUmVjb3JkZWQiOiIyMDE3LTAzLTA4VDIwOjIyOjAwLjMzOVoiLCJhcmNoaXZlZCI6ZmFsc2UsImxhc3RNb2RpZmllZCI6IjIwMTctMDMtMDhUMjA6MjI6MzAuODk0WiIsIm1vZGlmaWVkQnkiOiJBZG1pbiBVc2VyIiwibW9kaWZpZWRGaWVsZHMiOnsiZGF0ZVJlY29yZGVkIjoiMjAxNy0wMy0wOFQyMDoyMjozMC44OTRaIiwiZ2l2ZW5CeSI6IjIwMTctMDMtMDhUMjA6MjI6MzAuODk0WiIsImdpdmVuQnlEaXNwbGF5TmFtZSI6IjIwMTctMDMtMDhUMjA6MjI6MzAuODk0WiIsImRlc2NyaXB0aW9uIjoiMjAxNy0wMy0wOFQyMDoyMjozMC44OTRaIn19fSx7Il9pZCI6ImluY2lkZW50XzJfNTZjNjRkNzEtYmEzMC00MjcxLWI4OTktZjZmNmIwMzFmNTg5IiwiX3JldiI6IjItZmJkNjQ4OWUxMTJiY2U5ODA3MzcyMjFjZTRjYThlMTQiLCJkYXRhIjp7ImNhdGVnb3J5SXRlbSI6IlBhdGllbnQiLCJjYXRlZ29yeU5hbWUiOiJBY2NpZGVudCBvciBJbmp1cnkiLCJkYXRlT2ZJbmNpZGVudCI6IjIwMTctMDMtMDhUMjA6MjA6MDAuODYzWiIsImRlcGFydG1lbnQiOiJSZWNlcHRpb24iLCJkZXNjcmlwdGlvbiI6IlBhdGllbnQgZmVsbCBvbiB3ZXQgZmxvb3IuIiwiZnJpZW5kbHlJZCI6ImkwMDAwMSIsIm1vZGlmaWVkQnlEaXNwbGF5TmFtZSI6IkFkbWluIFVzZXIiLCJub3RpZmljYXRpb25TZW5kIjpmYWxzZSwicmVwb3J0ZWRCeSI6ImhyYWRtaW4iLCJyZXBvcnRlZEJ5RGlzcGxheU5hbWUiOiJBZG1pbiBVc2VyIiwicmVwb3J0ZWREYXRlIjoiMjAxNy0wMy0wOFQyMDoyMDozMS44NjNaIiwicmVwb3J0ZWRUbyI6IkphbmUgQmFnYWRvbnV0cyIsInNlbnRpbmVsRXZlbnQiOmZhbHNlLCJzdGF0dXMiOiJSZXBvcnRlZCIsImFyY2hpdmVkIjpmYWxzZSwibGFzdE1vZGlmaWVkIjoiMjAxNy0wMy0wOFQyMDoyMTozMC40OTlaIiwibW9kaWZpZWRCeSI6IkFkbWluIFVzZXIiLCJwYXRpZW50SW1wYWN0ZWQiOm51bGwsIm5vdGVzIjpbIjZjZTFiOWU4LTIwNTktNDQxMi04ZmVmLWFjNTFlZTY2NTYxZSJdLCJpbmNpZGVudEF0dGFjaG1lbnRzIjpbXSwibW9kaWZpZWRGaWVsZHMiOnsiZGF0ZU9mSW5jaWRlbnQiOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoiLCJyZXBvcnRlZERhdGUiOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoiLCJyZXBvcnRlZEJ5IjoiMjAxNy0wMy0wOFQyMDoyMTozMC40OTlaIiwicmVwb3J0ZWRCeURpc3BsYXlOYW1lIjoiMjAxNy0wMy0wOFQyMDoyMTozMC40OTlaIiwiZGVwYXJ0bWVudCI6IjIwMTctMDMtMDhUMjA6MjE6MzAuNDk5WiIsInJlcG9ydGVkVG8iOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoiLCJjYXRlZ29yeU5hbWUiOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoiLCJjYXRlZ29yeUl0ZW0iOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoiLCJkZXNjcmlwdGlvbiI6IjIwMTctMDMtMDhUMjA6MjE6MzAuNDk5WiIsIm1vZGlmaWVkQnlEaXNwbGF5TmFtZSI6IjIwMTctMDMtMDhUMjA6MjE6MzAuNDk5WiIsImZyaWVuZGx5SWQiOiIyMDE3LTAzLTA4VDIwOjIxOjMwLjQ5OVoifX0sIl9yZXZpc2lvbnMiOnsic3RhcnQiOjIsImlkcyI6WyJmYmQ2NDg5ZTExMmJjZTk4MDczNzIyMWNlNGNhOGUxNCIsIjM2YTE3Y2MxNjUxOTlkNjhmOTA4ZDc5ODQxNjIxZWRkIl19fSx7Il9pZCI6Imxvb2t1cF8yX2luY2lkZW50X2RlcGFydG1lbnRzIiwiX3JldiI6IjctMzQ2YjJmMmQ5ZGI5Mzk2NTAyZWIyNGM3MDIzNzM4MTYiLCJkYXRhIjp7Im9yZ2FuaXplQnlUeXBlIjpmYWxzZSwidXNlckNhbkFkZCI6dHJ1ZSwidmFsdWUiOlsiQWRtaW5pc3RyYXRpdmUgU2VydmljZXMiLCJMYWJvcmF0b3J5IiwiT3BlcmF0aW5nIFJvb20iLCJQZWRpYXRyaWNzIENsaW5pYyIsIlBoYXJtYWN5IiwiUmFkaW9sb2d5IiwiUmVjZXB0aW9uIl19LCJfcmV2aXNpb25zIjp7InN0YXJ0Ijo3LCJpZHMiOlsiMzQ2YjJmMmQ5ZGI5Mzk2NTAyZWIyNGM3MDIzNzM4MTYiLCI3MDVlMzUwZGMwOWZiMWM4OTA4YzRiNjEwNmRmYzgyZSIsImZiYmJiMDE3NDkzMmI4Mzc3MzdkYjdkZGZjODI2MWUyIiwiYWIyZGYyYWY3YjRjNGQ2NTU1MzU0NDdjYTdkNjcxOTciLCIwMjY4Mjc4ZmNmYjk3OTY4MzQ3Y2Y3ZDViMDMyYzFjMCIsIjU1NWUzZGJkMDFhMWUzYTlmNmI4OGM5YjVjNDkyZDBkIiwiYzIwMmQwNjI0NTBlMWE4ZGUxM2Y2NWJlOWFmODU0N2MiXX19LHsiX2lkIjoicGF0aWVudF8yXzk2NWE4YzM5LTgxYTMtNDJiNS05ODgxLWI3YWQ3ZGExMjdkNiIsIl9yZXYiOiIyLWIxZTg4YWJkNTZiM2NhZDQ2M2E1NzkwNWUwNmE3Yzc2IiwiZGF0YSI6eyJhZG1pdHRlZCI6ZmFsc2UsImFkZHJlc3MiOm51bGwsImFkZHJlc3MyIjpudWxsLCJhZGRyZXNzMyI6bnVsbCwiYWRkcmVzczQiOm51bGwsImJsb29kVHlwZSI6bnVsbCwiY2xpbmljIjpudWxsLCJjb3VudHJ5IjpudWxsLCJjaGVja2VkSW4iOmZhbHNlLCJjdXN0b21Gb3JtcyI6e30sImRhdGVPZkJpcnRoIjoiMjAxNi0wNi0wN1QwNDowMDowMC4wMDBaIiwiZWNvbm9taWNDbGFzc2lmaWNhdGlvbiI6bnVsbCwiZW1haWwiOm51bGwsImV4dGVybmFsUGF0aWVudElkIjpudWxsLCJmYW1pbHlTdXBwb3J0MSI6bnVsbCwiZmFtaWx5U3VwcG9ydDIiOm51bGwsImZhbWlseVN1cHBvcnQzIjpudWxsLCJmYW1pbHlTdXBwb3J0NCI6bnVsbCwiZmFtaWx5U3VwcG9ydDUiOm51bGwsImZyaWVuZGx5SWQiOiJQMDAwMDEiLCJmaXJzdE5hbWUiOiJKb2UiLCJzZXgiOiJNYWxlIiwib2NjdXBhdGlvbiI6bnVsbCwiaGlzdG9yeSI6bnVsbCwiaW5zdXJhbmNlIjpudWxsLCJsYXN0TmFtZSI6IkJhZ2Fkb251dHMiLCJsaXZpbmdBcnJhbmdlbWVudCI6bnVsbCwibWlkZGxlTmFtZSI6IiIsIm5vdGVzIjpudWxsLCJvdGhlckluY29tZSI6bnVsbCwicGF0aWVudFR5cGUiOm51bGwsInBhcmVudCI6bnVsbCwicGhvbmUiOm51bGwsInBsYWNlT2ZCaXJ0aCI6bnVsbCwicmVmZXJyZWREYXRlIjpudWxsLCJyZWZlcnJlZEJ5IjpudWxsLCJyZWxpZ2lvbiI6bnVsbCwic29jaWFsQWN0aW9uVGFrZW4iOm51bGwsInNvY2lhbFJlY29tbWVuZGF0aW9uIjpudWxsLCJzdGF0dXMiOm51bGwsImFyY2hpdmVkIjpmYWxzZSwibGFzdE1vZGlmaWVkIjoiMjAxNy0wMy0wOFQyMDoxNjowMC44MjZaIiwibW9kaWZpZWRCeSI6IkFkbWluIFVzZXIiLCJwYXltZW50UHJvZmlsZSI6bnVsbCwicGF5bWVudHMiOltdLCJvcGVyYXRpdmVQbGFucyI6W10sIm9wZXJhdGlvblJlcG9ydHMiOltdLCJkaWFnbm9zZXMiOltdLCJhbGxlcmdpZXMiOltdLCJtb2RpZmllZEZpZWxkcyI6eyJjdXN0b21Gb3JtcyI6IjIwMTctMDMtMDhUMjA6MTU6MzUuMTk4WiIsImZpcnN0TmFtZSI6IjIwMTctMDMtMDhUMjA6MTU6MzUuMTk4WiIsIm1pZGRsZU5hbWUiOiIyMDE3LTAzLTA4VDIwOjE1OjM1LjE5OFoiLCJsYXN0TmFtZSI6IjIwMTctMDMtMDhUMjA6MTU6MzUuMTk4WiIsImZyaWVuZGx5SWQiOiIyMDE3LTAzLTA4VDIwOjE1OjM1LjE5OFoiLCJzZXgiOiIyMDE3LTAzLTA4VDIwOjE2OjAwLjgyNloiLCJkYXRlT2ZCaXJ0aCI6IjIwMTctMDMtMDhUMjA6MTY6MDAuODI2WiJ9fSwiX3JldmlzaW9ucyI6eyJzdGFydCI6MiwiaWRzIjpbImIxZTg4YWJkNTZiM2NhZDQ2M2E1NzkwNWUwNmE3Yzc2IiwiMDQ5MmQ5MTQyZGIwM2FhNmQzNDM0ZjJhM2E2NDA1M2UiXX19XX0KeyJzZXEiOjc2fQo=","digest":"md5-O8Ghp6RjqroMJxbCD4MFOg==","content_type":"text/plain","revpos":2}}},{"_id":"customForm_2_ad1cb1f2-4fc0-4c9d-b35a-a0f988ce7c5e","_rev":"7-4d8d52bedb330ab142fd53abf67a6347","data":{"alwaysInclude":false,"columns":2,"formType":"incident","name":"Pre-Incident Risk Assessment","archived":false,"lastModified":"2017-03-08T20:11:20.017Z","modifiedBy":"Admin User","modifiedFields":{"name":"2017-03-08T20:11:20.017Z","formType":"2017-03-08T20:11:20.017Z","columns":"2017-03-08T20:11:20.017Z"},"fields":[{"classNames":null,"colSpan":1,"includeOtherOption":false,"label":"Severity","otherOptionLabel":null,"prompt":null,"property":"severity","type":"radio","values":[{"label":"5 Extreme Death, toxic release off-site with detrimental effect, huge financial loss"},{"label":"4 High Extensive injuries, loss of production capability, off-site release with no detrimental effects, major financial loss"},{"label":"3 Moderate Medical treatment required, on-site release contained with outside assistance, high financial loss"},{"label":"2 Low First aid treatment, on-site release contained, medium financial loss"},{"label":"1 Minimum No injuries, low financial loss"}]},{"classNames":null,"colSpan":1,"includeOtherOption":false,"label":"Occurrence","otherOptionLabel":null,"prompt":null,"property":"occurrence","type":"radio","values":[{"label":"5 Almost Certain Is expected to occur in most circumstances (e.g. most weeks or months)"},{"label":"4 Likely Will probably occur in most circumstances (several times a year)"},{"label":"3 Possible Might occur at some time (every 1 to 2 years)"},{"label":"2 Unlikely Could occur at some time (possibly in the next 2 to 5 years)"},{"label":"1 Rare May occur only in exceptional circumstances (perhaps every 5 to 30 years)"}]}]},"_revisions":{"start":7,"ids":["4d8d52bedb330ab142fd53abf67a6347","144ce899e9db5fc2300996da9fe6c0ab","8f368fdc9d9dbce5b4d2b90210f2bcb9","8073815fa73f6990e7bb2deb77fb12a7","414d73feddcf40f5a1fd167969c3a602","c8b7a441091612c4489f99c9bd57cd92","f8a4799a21ece3f03578fb51669a0728"]}},{"_id":"customForm_2_b5e70841-b78b-4155-9ab5-babc6e0f45d1","_rev":"2-0a9dc37a28abce63101be0fe49cc65c9","data":{"alwaysInclude":true,"columns":1,"formType":"incident","name":"Harm Score","archived":false,"lastModified":"2017-03-08T20:03:19.266Z","modifiedBy":"Admin User","modifiedFields":{"name":"2017-03-08T20:03:19.266Z","formType":"2017-03-08T20:03:19.266Z","columns":"2017-03-08T20:03:19.266Z","alwaysInclude":"2017-03-08T20:03:19.266Z"},"fields":[{"classNames":null,"colSpan":null,"includeOtherOption":false,"label":"Harm Score","otherOptionLabel":null,"prompt":null,"property":"harmScore","type":"radio","values":[{"label":"A No Actual Event (Unsafe Condition)"},{"label":"B1 Near Miss - The event did not reach the individual because of chance alone."},{"label":"B2 Near Miss - The event did not reach the individual because of active recovery efforts by caregivers."},{"label":"C The event reached the individual but did not cause harm."},{"label":"D The event reached the individual and required additional monitoring or treatment to prevent harm."},{"label":"E The individual experienced temporary harm and required treatment or intervention."},{"label":"F The individual experienced temporary harm and required initial or prolonged hospitalization"},{"label":"G The individual experienced permanent harm."},{"label":"H The individual experienced permanent harm and required intervention necessary to sustain life (e.g. transfer to ICU)"},{"label":"I The individual died."}]}]},"_revisions":{"start":2,"ids":["0a9dc37a28abce63101be0fe49cc65c9","022d3782509a2e39231098f91c4ff6e3"]}},{"_id":"incCategory_2_926014ae-09e8-4a84-b5ca-bf5b74e6a66e","_rev":"19-952fa439be55b5d05daac9b22036fcd8","data":{"incidentCategoryName":"Accident or Injury","archived":false,"lastModified":"2017-03-08T19:27:23.252Z","modifiedBy":"Admin User","modifiedFields":{"incidentCategoryName":"2017-03-08T19:27:23.252Z","incidentCategoryItems":"2017-03-08T19:27:23.252Z"},"incidentCategoryItems":[{"item":"Patient"},{"item":"Staff"},{"item":"Visitor"},{"item":"Other"}]},"_revisions":{"start":19,"ids":["952fa439be55b5d05daac9b22036fcd8","ff92925f5de774642b31741d1e719c72","62363351300b35a8ea08a76ebde70c78","0facd37c7353d2687b7e0016671e13ea","f488bef85e63a2cd37a4c8f87b124ad7","843d670f1505286c4776a2d31dd24a6d","4c640d62bf0def873d75c61cbbd1d028","4a60a36fa1a89745c9b463bc6a82ce63","62133b9c7b236b00c5afceb9ec237e35","1a668956ce9a132fd01b489af72ee2da","10073b164dc3b3d0327d54bfa1029893","deb532df62f7e43732f12a4e9048343f","5e02b2f9068bb01fa20174c45a191edd","adfad92715a125aff37b36a4146d1718","e6a883ee493837e4db871daec9502c38","6e9d1bdadecc23bc9a5784f933d757d1","2560c5753a67267ac7fb831242b66d36","a91da396124d6f02640966523267eff9","214dd63d68b1ee9c742814bad6a741c0"]}},{"_id":"incCategory_2_be540109-2e7a-4210-99f8-8ecc8229b121","_rev":"5-5aee5f81c211c37ad210e7bfd49b46f3","data":{"incidentCategoryName":"Patient Falls","archived":false,"lastModified":"2017-03-08T19:41:56.167Z","modifiedBy":"Admin User","modifiedFields":{"incidentCategoryName":"2017-03-08T19:41:56.167Z","incidentCategoryItems":"2017-03-08T19:41:56.167Z"},"incidentCategoryItems":[{"item":"From bed"},{"item":"Sitting in chair"},{"item":"Ambulating"},{"item":"Grounds of Facility"},{"item":"Other"}]},"_revisions":{"start":5,"ids":["5aee5f81c211c37ad210e7bfd49b46f3","32a8067d8f84878abf1cc54c3b2b7562","9ea62078a74699bf156bce2187bca7c7","7ec0ba317e5024a9b6f7c9515d543a8f","a329294e5cd5ab7be8b6e78f1284fc46"]}},{"_id":"incidentNote_2_6ce1b9e8-2059-4412-8fef-ac51ee66561e","_rev":"1-1ed671fa954a6f4fbf0076e547b6b4be","data":{"givenBy":"hradmin","givenByDisplayName":"Admin User","description":"The wet floor sign had fallen down.","dateRecorded":"2017-03-08T20:22:00.339Z","archived":false,"lastModified":"2017-03-08T20:22:30.894Z","modifiedBy":"Admin User","modifiedFields":{"dateRecorded":"2017-03-08T20:22:30.894Z","givenBy":"2017-03-08T20:22:30.894Z","givenByDisplayName":"2017-03-08T20:22:30.894Z","description":"2017-03-08T20:22:30.894Z"}}},{"_id":"incident_2_56c64d71-ba30-4271-b899-f6f6b031f589","_rev":"10-54985aff97faf8502d2c1bc7cac2e51c","data":{"categoryItem":"Patient","categoryName":"Accident or Injury","customForms":{"b5e70841-b78b-4155-9ab5-babc6e0f45d1":{}},"dateOfIncident":"2017-03-08T20:20:00.863Z","department":"Reception","description":"Patient fell on wet floor.","friendlyId":"i00001","modifiedByDisplayName":"Admin User","notificationSend":false,"reportedBy":"hradmin","reportedByDisplayName":"Admin User","reportedDate":"2017-03-08T20:20:31.863Z","reportedTo":"Jane Bagadonuts","sentinelEvent":true,"status":"Reported","archived":false,"lastModified":"2017-03-10T16:29:39.946Z","modifiedBy":"Admin User","patient":"965a8c39-81a3-42b5-9881-b7ad7da127d6","notes":["6ce1b9e8-2059-4412-8fef-ac51ee66561e"],"incidentAttachments":["58847f56-83af-4c15-a2e3-a57321d7ec99"],"modifiedFields":{"dateOfIncident":"2017-03-08T20:21:30.499Z","reportedDate":"2017-03-08T20:21:30.499Z","reportedBy":"2017-03-08T20:21:30.499Z","reportedByDisplayName":"2017-03-08T20:21:30.499Z","department":"2017-03-08T20:21:30.499Z","reportedTo":"2017-03-08T20:21:30.499Z","categoryName":"2017-03-08T20:21:30.499Z","categoryItem":"2017-03-08T20:21:30.499Z","description":"2017-03-08T20:21:30.499Z","modifiedByDisplayName":"2017-03-08T20:21:30.499Z","friendlyId":"2017-03-08T20:21:30.499Z","customForms":"2017-03-10T16:29:00.039Z","sentinelEvent":"2017-03-10T16:29:39.946Z"}},"_revisions":{"start":10,"ids":["54985aff97faf8502d2c1bc7cac2e51c","21d1afe4f6b7a583797fd227f4a62428","566a77dbbf92a5a46236e40f4d866034","acd64eadb33939525d3fb6df118be3c7","226742d6cca305a7b755555b4bd89758","4355d5493f1f3bcb32a73956bd7c4bbf","f5a1ac0398c14f65369ea37c7b8edd63","483618654c57d42fb9702be81277192e","fbd6489e112bce980737221ce4ca8e14","36a17cc165199d68f908d79841621edd"]}},{"_id":"lookup_2_incident_departments","_rev":"7-346b2f2d9db9396502eb24c702373816","data":{"organizeByType":false,"userCanAdd":true,"value":["Administrative Services","Laboratory","Operating Room","Pediatrics Clinic","Pharmacy","Radiology","Reception"]},"_revisions":{"start":7,"ids":["346b2f2d9db9396502eb24c702373816","705e350dc09fb1c8908c4b6106dfc82e","fbbbb0174932b837737db7ddfc8261e2","ab2df2af7b4c4d655535447ca7d67197","0268278fcfb97968347cf7d5b032c1c0","555e3dbd01a1e3a9f6b88c9b5c492d0d","c202d062450e1a8de13f65be9af8547c"]}},{"_id":"patient_2_965a8c39-81a3-42b5-9881-b7ad7da127d6","_rev":"2-b1e88abd56b3cad463a57905e06a7c76","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"checkedIn":false,"customForms":{},"dateOfBirth":"2016-06-07T04:00:00.000Z","economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","occupation":null,"history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"archived":false,"lastModified":"2017-03-08T20:16:00.826Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"operativePlans":[],"operationReports":[],"diagnoses":[],"allergies":[],"modifiedFields":{"customForms":"2017-03-08T20:15:35.198Z","firstName":"2017-03-08T20:15:35.198Z","middleName":"2017-03-08T20:15:35.198Z","lastName":"2017-03-08T20:15:35.198Z","friendlyId":"2017-03-08T20:15:35.198Z","sex":"2017-03-08T20:16:00.826Z","dateOfBirth":"2017-03-08T20:16:00.826Z"}},"_revisions":{"start":2,"ids":["b1e88abd56b3cad463a57905e06a7c76","0492d9142db03aa6d3434f2a3a64053e"]}}]} +{"seq":49} diff --git a/tests/fixtures/inventory.txt b/tests/fixtures/inventory.txt index de4749f7ce..0e8a1a0272 100644 --- a/tests/fixtures/inventory.txt +++ b/tests/fixtures/inventory.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:27:02.784Z","db_info":{"db_name":"main","doc_count":61,"doc_del_count":21,"update_seq":107,"purge_seq":0,"compact_running":false,"disk_size":135272,"data_size":76504,"instance_start_time":"1486135544363520","disk_format_version":6,"committed_update_seq":107,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:52:41.836Z","db_info":{"db_name":"main","doc_count":66,"doc_del_count":21,"update_seq":111,"purge_seq":0,"compact_running":false,"disk_size":131176,"data_size":79359,"instance_start_time":"1488837086913029","disk_format_version":6,"committed_update_seq":111,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} {"seq":4} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":24} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"2-6b49176eeeafb82a88a10aa5d954d965","data":{"quantity":1000,"location":null,"aisleLocation":null,"lastModified":"2015-10-29T02:44:10.582Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-29T02:44:10.582Z"}},"_revisions":{"start":2,"ids":["6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"1-d0a2104fa76a4161da3f527b23a6d61a","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":1000,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-29T02:44:10.493Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-29T02:44:10.493Z","inventoryItem":"2015-10-29T02:44:10.493Z"}}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"1-0e093fbeafc9c59eaeaaf0739ad56e13","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":null,"reason":null,"requestedBy":"hradmin","status":"Requested","transactionType":"Request","lastModified":"2015-10-29T08:35:51.497Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-10-29T08:35:51.497Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-29T08:35:51.497Z"}}},{"_id":"inventory_2_igbmk5zf_is","_rev":"1-26fffdb13350d70c54f01078f7ea7058","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":1000,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-29T02:44:10.610Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-29T02:44:10.610Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}}]} -{"seq":75} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"2-abadab1984c60d7e4e1a67576335a2bc","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:00:07.816Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","sex":"2016-02-22T22:00:07.816Z"}},"_revisions":{"start":2,"ids":["abadab1984c60d7e4e1a67576335a2bc","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}}]} -{"seq":107} +{"docs":[{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":6} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"2-6b49176eeeafb82a88a10aa5d954d965","data":{"quantity":1000,"location":null,"aisleLocation":null,"lastModified":"2015-10-29T02:44:10.582Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-29T02:44:10.582Z"}},"_revisions":{"start":2,"ids":["6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"1-d0a2104fa76a4161da3f527b23a6d61a","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":1000,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-29T02:44:10.493Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-29T02:44:10.493Z","inventoryItem":"2015-10-29T02:44:10.493Z"}}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"1-0e093fbeafc9c59eaeaaf0739ad56e13","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":null,"reason":null,"requestedBy":"hradmin","status":"Requested","transactionType":"Request","lastModified":"2015-10-29T08:35:51.497Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-10-29T08:35:51.497Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-29T08:35:51.497Z"}}},{"_id":"inventory_2_igbmk5zf_is","_rev":"1-26fffdb13350d70c54f01078f7ea7058","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":1000,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-29T02:44:10.610Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-29T02:44:10.610Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}}]} +{"seq":74} +{"docs":[{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"2-abadab1984c60d7e4e1a67576335a2bc","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:00:07.816Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","sex":"2016-02-22T22:00:07.816Z"}},"_revisions":{"start":2,"ids":["abadab1984c60d7e4e1a67576335a2bc","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}}]} +{"seq":111} diff --git a/tests/fixtures/labs.txt b/tests/fixtures/labs.txt index 4cc079872f..5ec78ab45e 100644 --- a/tests/fixtures/labs.txt +++ b/tests/fixtures/labs.txt @@ -1,11 +1,11 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:28:37.203Z","db_info":{"db_name":"main","doc_count":100,"doc_del_count":21,"update_seq":146,"purge_seq":0,"compact_running":false,"disk_size":172139,"data_size":101595,"instance_start_time":"1486135637366757","disk_format_version":6,"committed_update_seq":146,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:54:41.556Z","db_info":{"db_name":"main","doc_count":105,"doc_del_count":21,"update_seq":150,"purge_seq":0,"compact_running":false,"disk_size":172139,"data_size":104550,"instance_start_time":"1488837173937326","disk_format_version":6,"committed_update_seq":150,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} -{"seq":4} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":22} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"4-cc029ce23e24c88924abe875e644c20e","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":4,"ids":["cc029ce23e24c88924abe875e644c20e","2c3d0116f9462d0945bba5d8092f1f13","b07bbda1569b8575e3fb3f118584c0c2","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"4-27780ee78d428c60962e7add42fbe696","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["27780ee78d428c60962e7add42fbe696","ed2e6ee8dd0c31542cd651be11c27d30","26b4791796949ad78268d383e39a1ee5","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-c12e4467c9c3ecc8021b660934257f25","version":4,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-48c47b3b2eb831a69fd6c3d0b9ad1713","_deleted":true,"_revisions":{"start":2,"ids":["48c47b3b2eb831a69fd6c3d0b9ad1713","3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"5-c925a4a9709410de9d08a3a93a44fa10","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":5,"ids":["c925a4a9709410de9d08a3a93a44fa10","9e1ce570a02dce9309203bfc01903252","7f9be41d3ceb65d74450e57d51152c10","6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"4-c1906643bf01c3824d2578f9bd3a1a80","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":4,"ids":["c1906643bf01c3824d2578f9bd3a1a80","5e78c81a3f3acc2cd577f4743233b5f6","2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"4-ac6802792a6a84310f6116a36af282fa","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["ac6802792a6a84310f6116a36af282fa","0d58604e8df561f2a7e1f74df37aa699","65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"4-ed94d431336c675269f8d885cf6286f9","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["ed94d431336c675269f8d885cf6286f9","018a00a593301ef97818b36d89501387","d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"4-677826d6dc14137e854f01eed77dbf02","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":4,"ids":["677826d6dc14137e854f01eed77dbf02","0040cb66e900e1886780881cdbb5ec39","c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"4-c94aa7c5f3ed5ace3f9804b6c5c7a8a5","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["c94aa7c5f3ed5ace3f9804b6c5c7a8a5","0d7f2c75a57d13685e096bdbe9b42c20","0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"4-33a509053df2aeb2a3fa9c6f47862122","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["33a509053df2aeb2a3fa9c6f47862122","cf3a304d6172c15cc8ecfe3f6b4857ff","cda5e78ae504f4aaf101cc43d434d5ab","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"4-f931b82ee70f0d2996497c97bd76e57c","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["f931b82ee70f0d2996497c97bd76e57c","2ccbba6e4057a9b83d103aedefc00188","9fdf54dfbf4c6b9136d6addf5e624fcc","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"4-63806ca3d30ae3bf789087e22f0f8a4b","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["63806ca3d30ae3bf789087e22f0f8a4b","3284bca2c5c65c2518fddfb7f7868d16","7949d287e31bd3487aa205ae3b23a352","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-3f200c7d54cda6b4fea8699bc1a3e6d0","_deleted":true,"_revisions":{"start":2,"ids":["3f200c7d54cda6b4fea8699bc1a3e6d0","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_display_id","_rev":"5-1edbb6a3bad437e344e909f5a7c134cd","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":5,"ids":["1edbb6a3bad437e344e909f5a7c134cd","97cd67d85a6bfb0896c657f69014036a","02ebb613cc059e0541a8bc9e0c999df4","eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"4-0ccbfd3ab95d03df289893210b0827bb","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":4,"ids":["0ccbfd3ab95d03df289893210b0827bb","56954022c675ccc9a4cd9f7807717559","9409c5c4fa24c2247009585f9d4a6833","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"4-45b3ca4efb82f8d7a9fceb24b329989a","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":4,"ids":["45b3ca4efb82f8d7a9fceb24b329989a","fa45a9cbe22c09f221ff666d54413588","8f2b02b810676cb5af00f6e34aff987e","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"4-fe08fdf8bc669956b37ed0796869eeef","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["fe08fdf8bc669956b37ed0796869eeef","5462fbacd302cd763c692fb70c0eb521","68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"4-66384eddfc1ed1cc7dd604fa121b4a43","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["66384eddfc1ed1cc7dd604fa121b4a43","3ad96e6c81fdac90bc4a3a1ccbe93047","5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"4-aa39124a28526c2347e4b54094cf6917","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":4,"ids":["aa39124a28526c2347e4b54094cf6917","3909b0733e3185594d978e8a1cbe96bc","7c153bf61fed5e6742224f9df92cf676","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"4-1af42c6d4d4ffc72aa0528198bdcf893","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["1af42c6d4d4ffc72aa0528198bdcf893","92b1278be8c3eecc884da20ef05ce626","add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"4-8350d43fffd50295bccd534888e236f9","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["8350d43fffd50295bccd534888e236f9","ddcfa99c875a0579775dfa3a0c98aa3f","6670d76cab3888a8c2c2a399beb1764f","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"4-a265b65d70028f0be38677aa538d86e1","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["a265b65d70028f0be38677aa538d86e1","91f492ce3aab5449a7fb4ad4bbffea95","048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"appointment_2_EE5D1ABE-2625-645B-9F84-5B0DD4B4D5EC","_rev":"1-1bb336da899bbd4807cde6620d630bd1","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-11-02T22:00:00.000Z","endDate":"2015-11-02T22:00:00.000Z","notes":"Basic Checkup","status":"Scheduled","lastModified":"2015-11-03T06:50:48.404Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-11-03T06:50:48.404Z","startDate":"2015-11-03T06:50:48.404Z","endDate":"2015-11-03T06:50:48.404Z","appointmentType":"2015-11-03T06:50:48.404Z","provider":"2015-11-03T06:50:48.404Z","location":"2015-11-03T06:50:48.404Z","notes":"2015-11-03T06:50:48.404Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lab_2_8F1C615D-8E59-5090-BC4A-BFA41C57FABE","_rev":"1-5cc96eeacaa8118793770bd5a80f0b4f","data":{"labDate":null,"notes":"Dr ordered another test","requestedBy":"hradmin","requestedDate":"2015-11-03T14:39:16.608Z","result":"Everything is clear","status":"Requested","lastModified":"2015-11-03T14:39:16.920Z","modifiedBy":"hradmin","labType":"5AB262C7-719D-19A6-ADC8-06CBA3088FA8","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"EC9C09F9-676F-AD32-AB61-DDAD615F2632","modifiedFields":{"result":"2015-11-03T14:39:16.920Z","notes":"2015-11-03T14:39:16.920Z","status":"2015-11-03T14:39:16.920Z","requestedBy":"2015-11-03T14:39:16.920Z","requestedDate":"2015-11-03T14:39:16.920Z"},"charges":[]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}}]} -{"seq":75} -{"docs":[{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"4-8c8179f150da9a8bb43bfd246f16f33b","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:02:54.249Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","admitted":"2015-11-03T07:08:13.749Z","sex":"2016-02-22T22:02:54.249Z"}},"_revisions":{"start":4,"ids":["8c8179f150da9a8bb43bfd246f16f33b","020fe2a48d4cbfcb78ce17b8dca2808a","09ad83b2ef8b869ecc41360ccee87e05","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_5AB262C7-719D-19A6-ADC8-06CBA3088FA8","_rev":"1-428c4aeffee433314c955d75e831332b","data":{"category":"Lab","expenseAccount":null,"name":"Chest","price":null,"pricingType":"Lab Procedure","lastModified":"2015-11-03T14:39:16.623Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-11-03T14:39:16.623Z","category":"2015-11-03T14:39:16.623Z","pricingType":"2015-11-03T14:39:16.623Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0312A352-EF8B-C1A2-B9DF-3EC932C96AD8","_rev":"2-8eb7818cb7b808ea467b2e60f0a6a5e2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-03T07:43:21.662Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:15.853Z","startDate":"2015-11-03T07:31:15.853Z","status":"2015-11-03T07:43:21.662Z","outPatient":"2015-11-03T07:31:15.853Z","endDate":"2015-11-03T07:43:21.662Z","location":"2015-11-03T07:31:15.853Z","examiner":"2015-11-03T07:31:15.853Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8eb7818cb7b808ea467b2e60f0a6a5e2","3036466a87ec0a9967be1433386b0bdc"]}},{"_id":"visit_2_07AF1E0E-3CB2-3837-990C-968158E25235","_rev":"1-ce894ba889d506531e4cb2a36394cab4","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:16.594Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:16.594Z","startDate":"2015-11-03T07:46:16.594Z","status":"2015-11-03T07:46:16.594Z","outPatient":"2015-11-03T07:46:16.594Z","endDate":"2015-11-03T07:46:16.594Z","location":"2015-11-03T07:46:16.594Z","examiner":"2015-11-03T07:46:16.594Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0B84AF59-A182-5840-9E7A-CEF7633D4071","_rev":"1-ce3b40be34d77ec1d9c29ccb99a7e905","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:37:46.164Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:37:46.164Z","startDate":"2015-11-03T07:37:46.164Z","status":"2015-11-03T07:37:46.164Z","outPatient":"2015-11-03T07:37:46.164Z","endDate":"2015-11-03T07:37:46.164Z","location":"2015-11-03T07:37:46.164Z","examiner":"2015-11-03T07:37:46.164Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_13340816-9F02-846D-85C3-C3278561BA23","_rev":"1-6ce02a99e4868c5a5bdb88a23f9ff400","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:24:20.451Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:24:20.451Z","startDate":"2015-11-03T07:24:20.451Z","status":"2015-11-03T07:24:20.451Z","outPatient":"2015-11-03T07:24:20.451Z","endDate":"2015-11-03T07:24:20.451Z","location":"2015-11-03T07:24:20.451Z","examiner":"2015-11-03T07:24:20.451Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_15759FA2-6691-6EF3-9636-21570F400F04","_rev":"1-d28274492b5b3cd306c3d38e535388a7","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:38:17.049Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:38:17.049Z","startDate":"2015-11-03T07:38:17.049Z","status":"2015-11-03T07:38:17.049Z","outPatient":"2015-11-03T07:38:17.049Z","endDate":"2015-11-03T07:38:17.049Z","location":"2015-11-03T07:38:17.049Z","examiner":"2015-11-03T07:38:17.049Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_17AB2BCF-5F9F-30FB-8B80-9FB82E51D0B3","_rev":"1-bc13c64ebb47144840cc91ce3087ebd6","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:03.461Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:03.461Z","startDate":"2015-11-03T07:23:03.461Z","status":"2015-11-03T07:23:03.461Z","outPatient":"2015-11-03T07:23:03.461Z","endDate":"2015-11-03T07:23:03.461Z","location":"2015-11-03T07:23:03.461Z","examiner":"2015-11-03T07:23:03.461Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1800A65C-861C-CCA5-85C5-16950322C7E0","_rev":"1-a67e8d8a018844ef176184947055b683","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:40:08.177Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:40:08.177Z","startDate":"2015-11-03T07:40:08.177Z","status":"2015-11-03T07:40:08.177Z","outPatient":"2015-11-03T07:40:08.177Z","endDate":"2015-11-03T07:40:08.177Z","location":"2015-11-03T07:40:08.177Z","examiner":"2015-11-03T07:40:08.177Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1EBA7E42-F96D-C5E2-923C-2F842FDFE714","_rev":"1-8fd6cfa23288f7394ce94970c4b3a8c2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:45.676Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:45.676Z","startDate":"2015-11-03T07:19:45.676Z","status":"2015-11-03T07:19:45.676Z","outPatient":"2015-11-03T07:19:45.676Z","endDate":"2015-11-03T07:19:45.676Z","location":"2015-11-03T07:19:45.676Z","examiner":"2015-11-03T07:19:45.676Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_2D795EA3-DAEF-AA15-8846-607A873AD1AF","_rev":"1-4c665c9221069fe72f9d66ac458e92df","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:28:51.490Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:28:51.490Z","startDate":"2015-11-03T07:28:51.490Z","status":"2015-11-03T07:28:51.490Z","outPatient":"2015-11-03T07:28:51.490Z","endDate":"2015-11-03T07:28:51.490Z","location":"2015-11-03T07:28:51.490Z","examiner":"2015-11-03T07:28:51.490Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_3A8FE46D-2CE6-C74E-98BB-ECFECB8F4AB9","_rev":"1-4c2559b35790501b6fae26a031a59cad","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:11.759Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:11.759Z","startDate":"2015-11-03T07:42:11.759Z","status":"2015-11-03T07:42:11.759Z","outPatient":"2015-11-03T07:42:11.759Z","endDate":"2015-11-03T07:42:11.759Z","location":"2015-11-03T07:42:11.759Z","examiner":"2015-11-03T07:42:11.759Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_50FD1C68-0889-0867-99D1-CFFDB3223154","_rev":"1-85d776e0088793e80073525cf6b7a501","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:47:59.399Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:47:59.399Z","startDate":"2015-11-03T07:47:59.399Z","status":"2015-11-03T07:47:59.399Z","outPatient":"2015-11-03T07:47:59.399Z","endDate":"2015-11-03T07:47:59.399Z","location":"2015-11-03T07:47:59.399Z","examiner":"2015-11-03T07:47:59.399Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_53E986EB-4C23-9B3B-B8D7-2C7A7ECDBC33","_rev":"1-fb5ce8d11793c3da21e06d1f88e48d00","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:24.134Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:24.134Z","startDate":"2015-11-03T07:23:24.134Z","status":"2015-11-03T07:23:24.134Z","outPatient":"2015-11-03T07:23:24.134Z","endDate":"2015-11-03T07:23:24.134Z","location":"2015-11-03T07:23:24.134Z","examiner":"2015-11-03T07:23:24.134Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_542BB0F0-27BB-7C5C-99BC-28B013DDB837","_rev":"1-6e3af7515e9b2d7fbcec6264b9194a17","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:32:40.937Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:32:40.937Z","startDate":"2015-11-03T07:32:40.937Z","status":"2015-11-03T07:32:40.937Z","outPatient":"2015-11-03T07:32:40.937Z","endDate":"2015-11-03T07:32:40.937Z","location":"2015-11-03T07:32:40.937Z","examiner":"2015-11-03T07:32:40.937Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_560E25D9-9736-BA05-B2A6-4555A93B2628","_rev":"2-04c2d6343f6d2a10ad1f891718cecab5","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:08:13.698Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:08:13.698Z","startDate":"2015-11-03T07:08:13.698Z","status":"2015-11-03T07:08:13.698Z","outPatient":"2015-11-03T07:08:13.698Z","endDate":"2015-11-03T07:08:13.698Z","location":"2015-11-03T07:08:13.698Z","examiner":"2015-11-03T07:08:13.698Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["04c2d6343f6d2a10ad1f891718cecab5","6bbe45974af0b60410ea29026a38e2ec"]}},{"_id":"visit_2_59F8FB60-9956-E93F-826D-11618BC95E13","_rev":"1-8489694a221cd2c43e7c39fdcaa89700","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:41:35.597Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:41:35.597Z","startDate":"2015-11-03T07:41:35.597Z","status":"2015-11-03T07:41:35.597Z","outPatient":"2015-11-03T07:41:35.597Z","endDate":"2015-11-03T07:41:35.597Z","location":"2015-11-03T07:41:35.597Z","examiner":"2015-11-03T07:41:35.597Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5F404B11-D8B6-CE18-9557-2B563BCFD2F8","_rev":"1-2637dc1d6c95364743de0c97c7fb443d","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:34:38.929Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:34:38.929Z","startDate":"2015-11-03T07:34:38.929Z","status":"2015-11-03T07:34:38.929Z","outPatient":"2015-11-03T07:34:38.929Z","endDate":"2015-11-03T07:34:38.929Z","location":"2015-11-03T07:34:38.929Z","examiner":"2015-11-03T07:34:38.929Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_6D126583-2852-25C2-A352-E5BA4CBBD106","_rev":"1-222d722266f5d407204eb411f68ab4f0","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:20:56.778Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:20:56.778Z","startDate":"2015-11-03T07:20:56.778Z","status":"2015-11-03T07:20:56.778Z","outPatient":"2015-11-03T07:20:56.778Z","endDate":"2015-11-03T07:20:56.778Z","location":"2015-11-03T07:20:56.778Z","examiner":"2015-11-03T07:20:56.778Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}}]} -{"seq":125} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-4c8dd95ad6d36b9b4d86136d5e417f5c","version":5,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"6-d33b75c96b6747a173db1e2056cef3ad","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":6,"ids":["d33b75c96b6747a173db1e2056cef3ad","813b4e941fde42179a8c0bf84cbb0149","596eb2a7b7c8a9e5509d106fee8cb9a3","384efd51245c64e75b8307add874ff31","32e2a3c0bdbdef4511fd301ea83e0b6e","3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"visit_2_7916D533-54AE-55EB-8DE7-E4B83A4BBAB2","_rev":"1-269d23778ac6f89244ff93d17c73352c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:45.358Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:45.358Z","startDate":"2015-11-03T07:46:45.358Z","status":"2015-11-03T07:46:45.358Z","outPatient":"2015-11-03T07:46:45.358Z","endDate":"2015-11-03T07:46:45.358Z","location":"2015-11-03T07:46:45.358Z","examiner":"2015-11-03T07:46:45.358Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_817CE5FB-FF79-B05D-8296-2FCE91B125CD","_rev":"1-410079742e88e59e0598107fd9ef40c1","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:33:16.393Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:33:16.393Z","startDate":"2015-11-03T07:33:16.393Z","status":"2015-11-03T07:33:16.393Z","outPatient":"2015-11-03T07:33:16.393Z","endDate":"2015-11-03T07:33:16.393Z","location":"2015-11-03T07:33:16.393Z","examiner":"2015-11-03T07:33:16.393Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_90FCADB8-7109-3906-94A3-269F29CFAB69","_rev":"1-7a8189c07dde6b9bf498545cdaa3e621","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:31:49.176Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:49.176Z","startDate":"2015-11-03T07:31:49.176Z","status":"2015-11-03T07:31:49.176Z","outPatient":"2015-11-03T07:31:49.176Z","endDate":"2015-11-03T07:31:49.176Z","location":"2015-11-03T07:31:49.176Z","examiner":"2015-11-03T07:31:49.176Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9C962DF7-E239-966B-A47B-15F405899B62","_rev":"1-d5bc412bfa629333e6cd79c978ea8218","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:25:27.802Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:25:27.802Z","startDate":"2015-11-03T07:25:27.802Z","status":"2015-11-03T07:25:27.802Z","outPatient":"2015-11-03T07:25:27.802Z","endDate":"2015-11-03T07:25:27.802Z","location":"2015-11-03T07:25:27.802Z","examiner":"2015-11-03T07:25:27.802Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9E627361-BA73-210A-8E76-2FA13B559DB9","_rev":"1-30a87dbc678b99d42b1a90bebff97834","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:21:48.053Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:21:48.053Z","startDate":"2015-11-03T07:21:48.053Z","status":"2015-11-03T07:21:48.053Z","outPatient":"2015-11-03T07:21:48.053Z","endDate":"2015-11-03T07:21:48.053Z","location":"2015-11-03T07:21:48.053Z","examiner":"2015-11-03T07:21:48.053Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_A6E37F8D-F740-8B01-93C9-D476A886E030","_rev":"1-d094eb56a680b4a8a6a354bd48d6bfe2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:53.782Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:53.782Z","startDate":"2015-11-03T07:42:53.782Z","status":"2015-11-03T07:42:53.782Z","outPatient":"2015-11-03T07:42:53.782Z","endDate":"2015-11-03T07:42:53.782Z","location":"2015-11-03T07:42:53.782Z","examiner":"2015-11-03T07:42:53.782Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_AAB85ADA-7058-DF7A-9244-C6B60A2EF743","_rev":"1-1bd78b61646023aacce18b1efaa27646","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:39:09.272Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:39:09.272Z","startDate":"2015-11-03T07:39:09.272Z","status":"2015-11-03T07:39:09.272Z","outPatient":"2015-11-03T07:39:09.272Z","endDate":"2015-11-03T07:39:09.272Z","location":"2015-11-03T07:39:09.272Z","examiner":"2015-11-03T07:39:09.272Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C15054D2-D062-DB01-A96D-80ED1B8F8CBD","_rev":"1-5a9a0e7eafe911586556666ad1a2bd27","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:09.735Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:09.735Z","startDate":"2015-11-03T07:46:09.735Z","status":"2015-11-03T07:46:09.735Z","outPatient":"2015-11-03T07:46:09.735Z","endDate":"2015-11-03T07:46:09.735Z","location":"2015-11-03T07:46:09.735Z","examiner":"2015-11-03T07:46:09.735Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}},{"_id":"visit_2_D845EA6E-C4CD-3657-A6F6-3E40FE02B069","_rev":"1-16657f6b4014bf268d63323ed8832a56","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:50:55.344Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:50:55.344Z","startDate":"2015-11-03T07:50:55.344Z","status":"2015-11-03T07:50:55.344Z","outPatient":"2015-11-03T07:50:55.344Z","endDate":"2015-11-03T07:50:55.344Z","location":"2015-11-03T07:50:55.344Z","examiner":"2015-11-03T07:50:55.344Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_DA661CAB-1BB5-3119-B9DD-0A92D7C3913B","_rev":"1-ecb23bc4c60a32dd627969637f85d1fb","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:15.689Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:15.689Z","startDate":"2015-11-03T07:19:15.689Z","status":"2015-11-03T07:19:15.689Z","outPatient":"2015-11-03T07:19:15.689Z","endDate":"2015-11-03T07:19:15.689Z","location":"2015-11-03T07:19:15.689Z","examiner":"2015-11-03T07:19:15.689Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E66983BC-BFB9-E361-A59F-AAC966A0FD3B","_rev":"1-8d0f4af9593120f2dfd0371303239e2b","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:15:24.456Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:15:24.456Z","startDate":"2015-11-03T07:15:24.456Z","status":"2015-11-03T07:15:24.456Z","outPatient":"2015-11-03T07:15:24.456Z","endDate":"2015-11-03T07:15:24.456Z","location":"2015-11-03T07:15:24.456Z","examiner":"2015-11-03T07:15:24.456Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E8E7BD06-13EB-AA68-BBE2-51B9EEE85257","_rev":"1-c54a6aea31c6c3805edc706b4ed64d40","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:30:31.501Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:30:31.501Z","startDate":"2015-11-03T07:30:31.501Z","status":"2015-11-03T07:30:31.501Z","outPatient":"2015-11-03T07:30:31.501Z","endDate":"2015-11-03T07:30:31.501Z","location":"2015-11-03T07:30:31.501Z","examiner":"2015-11-03T07:30:31.501Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E90C9A07-74D2-0589-8DDC-C94B09E0F238","_rev":"1-7a3d4f0d4056960dabad849d1da9bd7c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:22:15.702Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:22:15.702Z","startDate":"2015-11-03T07:22:15.702Z","status":"2015-11-03T07:22:15.702Z","outPatient":"2015-11-03T07:22:15.702Z","endDate":"2015-11-03T07:22:15.702Z","location":"2015-11-03T07:22:15.702Z","examiner":"2015-11-03T07:22:15.702Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_EC9C09F9-676F-AD32-AB61-DDAD615F2632","_rev":"2-8ce10f08748bebcd2df0267258ec2433","data":{"dischargeInfo":null,"endDate":"2015-11-03T14:39:16.671Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-03T14:39:16.671Z","status":null,"visitType":"Lab","lastModified":"2015-11-03T14:39:16.679Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-03T14:39:16.679Z","endDate":"2015-11-03T14:39:16.679Z","outPatient":"2015-11-03T14:39:16.679Z","visitType":"2015-11-03T14:39:16.679Z"},"charges":[],"imaging":[],"labs":["8F1C615D-8E59-5090-BC4A-BFA41C57FABE"],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8ce10f08748bebcd2df0267258ec2433","4a113155a529e6200ba18813cd922ad0"]}},{"_id":"visit_2_EF0D793D-346D-242A-8F4D-589448DA49A6","_rev":"1-413ff66d683c532d2be4cfa04632343c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:26:35.010Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:26:35.010Z","startDate":"2015-11-03T07:26:35.010Z","status":"2015-11-03T07:26:35.010Z","outPatient":"2015-11-03T07:26:35.010Z","endDate":"2015-11-03T07:26:35.010Z","location":"2015-11-03T07:26:35.010Z","examiner":"2015-11-03T07:26:35.010Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_F9D51E3F-E938-1F24-9B19-D76F03E56892","_rev":"1-9e4fb077c716ccd6b149953e4c005aae","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:17:22.667Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:17:22.667Z","startDate":"2015-11-03T07:17:22.667Z","status":"2015-11-03T07:17:22.667Z","outPatient":"2015-11-03T07:17:22.667Z","endDate":"2015-11-03T07:17:22.667Z","location":"2015-11-03T07:17:22.667Z","examiner":"2015-11-03T07:17:22.667Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}}]} -{"seq":146} +{"seq":2} +{"docs":[{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":3} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-4c8dd95ad6d36b9b4d86136d5e417f5c","version":5,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"2-1fc384eae57485ff9100c0614780ab62","_deleted":true,"_revisions":{"start":2,"ids":["1fc384eae57485ff9100c0614780ab62","03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"6-d33b75c96b6747a173db1e2056cef3ad","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":6,"ids":["d33b75c96b6747a173db1e2056cef3ad","813b4e941fde42179a8c0bf84cbb0149","596eb2a7b7c8a9e5509d106fee8cb9a3","384efd51245c64e75b8307add874ff31","32e2a3c0bdbdef4511fd301ea83e0b6e","3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"4-cc029ce23e24c88924abe875e644c20e","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":4,"ids":["cc029ce23e24c88924abe875e644c20e","2c3d0116f9462d0945bba5d8092f1f13","b07bbda1569b8575e3fb3f118584c0c2","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"4-27780ee78d428c60962e7add42fbe696","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["27780ee78d428c60962e7add42fbe696","ed2e6ee8dd0c31542cd651be11c27d30","26b4791796949ad78268d383e39a1ee5","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"1-c12e4467c9c3ecc8021b660934257f25","version":4,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_name","_rev":"2-48c47b3b2eb831a69fd6c3d0b9ad1713","_deleted":true,"_revisions":{"start":2,"ids":["48c47b3b2eb831a69fd6c3d0b9ad1713","3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"5-c925a4a9709410de9d08a3a93a44fa10","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":5,"ids":["c925a4a9709410de9d08a3a93a44fa10","9e1ce570a02dce9309203bfc01903252","7f9be41d3ceb65d74450e57d51152c10","6970ab89b44af8c2703a89d6dea9b20b","304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"4-c1906643bf01c3824d2578f9bd3a1a80","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":4,"ids":["c1906643bf01c3824d2578f9bd3a1a80","5e78c81a3f3acc2cd577f4743233b5f6","2f0df4e3dc8ba6d384f896efd4a272cf","003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"4-ac6802792a6a84310f6116a36af282fa","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["ac6802792a6a84310f6116a36af282fa","0d58604e8df561f2a7e1f74df37aa699","65f020065c11403193b02742a05b91ae","78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"4-ed94d431336c675269f8d885cf6286f9","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["ed94d431336c675269f8d885cf6286f9","018a00a593301ef97818b36d89501387","d900cddd5fcc673d77fbd2f6d783475d","17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"4-677826d6dc14137e854f01eed77dbf02","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":4,"ids":["677826d6dc14137e854f01eed77dbf02","0040cb66e900e1886780881cdbb5ec39","c2f0efb7a0a9b3ece1cf9b7b0e88d37f","7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"4-c94aa7c5f3ed5ace3f9804b6c5c7a8a5","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["c94aa7c5f3ed5ace3f9804b6c5c7a8a5","0d7f2c75a57d13685e096bdbe9b42c20","0338b756f9c3471052577cadc4ed9505","187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"4-33a509053df2aeb2a3fa9c6f47862122","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["33a509053df2aeb2a3fa9c6f47862122","cf3a304d6172c15cc8ecfe3f6b4857ff","cda5e78ae504f4aaf101cc43d434d5ab","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"4-f931b82ee70f0d2996497c97bd76e57c","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["f931b82ee70f0d2996497c97bd76e57c","2ccbba6e4057a9b83d103aedefc00188","9fdf54dfbf4c6b9136d6addf5e624fcc","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"4-63806ca3d30ae3bf789087e22f0f8a4b","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["63806ca3d30ae3bf789087e22f0f8a4b","3284bca2c5c65c2518fddfb7f7868d16","7949d287e31bd3487aa205ae3b23a352","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"2-3f200c7d54cda6b4fea8699bc1a3e6d0","_deleted":true,"_revisions":{"start":2,"ids":["3f200c7d54cda6b4fea8699bc1a3e6d0","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_display_id","_rev":"5-1edbb6a3bad437e344e909f5a7c134cd","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":5,"ids":["1edbb6a3bad437e344e909f5a7c134cd","97cd67d85a6bfb0896c657f69014036a","02ebb613cc059e0541a8bc9e0c999df4","eae82996b36349ac1fce13b33546eaec","0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"4-0ccbfd3ab95d03df289893210b0827bb","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":4,"ids":["0ccbfd3ab95d03df289893210b0827bb","56954022c675ccc9a4cd9f7807717559","9409c5c4fa24c2247009585f9d4a6833","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"4-45b3ca4efb82f8d7a9fceb24b329989a","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":4,"ids":["45b3ca4efb82f8d7a9fceb24b329989a","fa45a9cbe22c09f221ff666d54413588","8f2b02b810676cb5af00f6e34aff987e","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"4-fe08fdf8bc669956b37ed0796869eeef","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["fe08fdf8bc669956b37ed0796869eeef","5462fbacd302cd763c692fb70c0eb521","68d447e856a6194de82dcd9e506569ae","23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"4-66384eddfc1ed1cc7dd604fa121b4a43","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["66384eddfc1ed1cc7dd604fa121b4a43","3ad96e6c81fdac90bc4a3a1ccbe93047","5b5eb6c8ca33d0d3ff9c1f6ee70eb04c","25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"4-aa39124a28526c2347e4b54094cf6917","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":4,"ids":["aa39124a28526c2347e4b54094cf6917","3909b0733e3185594d978e8a1cbe96bc","7c153bf61fed5e6742224f9df92cf676","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"4-1af42c6d4d4ffc72aa0528198bdcf893","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["1af42c6d4d4ffc72aa0528198bdcf893","92b1278be8c3eecc884da20ef05ce626","add6c18db9db449d2af501f6f3fc9a68","367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"4-8350d43fffd50295bccd534888e236f9","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["8350d43fffd50295bccd534888e236f9","ddcfa99c875a0579775dfa3a0c98aa3f","6670d76cab3888a8c2c2a399beb1764f","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"4-a265b65d70028f0be38677aa538d86e1","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":4,"ids":["a265b65d70028f0be38677aa538d86e1","91f492ce3aab5449a7fb4ad4bbffea95","048bd179b127054d3279071160a6f314","412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"appointment_2_EE5D1ABE-2625-645B-9F84-5B0DD4B4D5EC","_rev":"1-1bb336da899bbd4807cde6620d630bd1","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-11-02T22:00:00.000Z","endDate":"2015-11-02T22:00:00.000Z","notes":"Basic Checkup","status":"Scheduled","lastModified":"2015-11-03T06:50:48.404Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-11-03T06:50:48.404Z","startDate":"2015-11-03T06:50:48.404Z","endDate":"2015-11-03T06:50:48.404Z","appointmentType":"2015-11-03T06:50:48.404Z","provider":"2015-11-03T06:50:48.404Z","location":"2015-11-03T06:50:48.404Z","notes":"2015-11-03T06:50:48.404Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lab_2_8F1C615D-8E59-5090-BC4A-BFA41C57FABE","_rev":"1-5cc96eeacaa8118793770bd5a80f0b4f","data":{"labDate":null,"notes":"Dr ordered another test","requestedBy":"hradmin","requestedDate":"2015-11-03T14:39:16.608Z","result":"Everything is clear","status":"Requested","lastModified":"2015-11-03T14:39:16.920Z","modifiedBy":"hradmin","labType":"5AB262C7-719D-19A6-ADC8-06CBA3088FA8","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"EC9C09F9-676F-AD32-AB61-DDAD615F2632","modifiedFields":{"result":"2015-11-03T14:39:16.920Z","notes":"2015-11-03T14:39:16.920Z","status":"2015-11-03T14:39:16.920Z","requestedBy":"2015-11-03T14:39:16.920Z","requestedDate":"2015-11-03T14:39:16.920Z"},"charges":[]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}}]} +{"seq":74} +{"docs":[{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"4-8c8179f150da9a8bb43bfd246f16f33b","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:02:54.249Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","admitted":"2015-11-03T07:08:13.749Z","sex":"2016-02-22T22:02:54.249Z"}},"_revisions":{"start":4,"ids":["8c8179f150da9a8bb43bfd246f16f33b","020fe2a48d4cbfcb78ce17b8dca2808a","09ad83b2ef8b869ecc41360ccee87e05","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_5AB262C7-719D-19A6-ADC8-06CBA3088FA8","_rev":"1-428c4aeffee433314c955d75e831332b","data":{"category":"Lab","expenseAccount":null,"name":"Chest","price":null,"pricingType":"Lab Procedure","lastModified":"2015-11-03T14:39:16.623Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-11-03T14:39:16.623Z","category":"2015-11-03T14:39:16.623Z","pricingType":"2015-11-03T14:39:16.623Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0312A352-EF8B-C1A2-B9DF-3EC932C96AD8","_rev":"2-8eb7818cb7b808ea467b2e60f0a6a5e2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-03T07:43:21.662Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:15.853Z","startDate":"2015-11-03T07:31:15.853Z","status":"2015-11-03T07:43:21.662Z","outPatient":"2015-11-03T07:31:15.853Z","endDate":"2015-11-03T07:43:21.662Z","location":"2015-11-03T07:31:15.853Z","examiner":"2015-11-03T07:31:15.853Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8eb7818cb7b808ea467b2e60f0a6a5e2","3036466a87ec0a9967be1433386b0bdc"]}},{"_id":"visit_2_07AF1E0E-3CB2-3837-990C-968158E25235","_rev":"1-ce894ba889d506531e4cb2a36394cab4","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:16.594Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:16.594Z","startDate":"2015-11-03T07:46:16.594Z","status":"2015-11-03T07:46:16.594Z","outPatient":"2015-11-03T07:46:16.594Z","endDate":"2015-11-03T07:46:16.594Z","location":"2015-11-03T07:46:16.594Z","examiner":"2015-11-03T07:46:16.594Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0B84AF59-A182-5840-9E7A-CEF7633D4071","_rev":"1-ce3b40be34d77ec1d9c29ccb99a7e905","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:37:46.164Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:37:46.164Z","startDate":"2015-11-03T07:37:46.164Z","status":"2015-11-03T07:37:46.164Z","outPatient":"2015-11-03T07:37:46.164Z","endDate":"2015-11-03T07:37:46.164Z","location":"2015-11-03T07:37:46.164Z","examiner":"2015-11-03T07:37:46.164Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_13340816-9F02-846D-85C3-C3278561BA23","_rev":"1-6ce02a99e4868c5a5bdb88a23f9ff400","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:24:20.451Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:24:20.451Z","startDate":"2015-11-03T07:24:20.451Z","status":"2015-11-03T07:24:20.451Z","outPatient":"2015-11-03T07:24:20.451Z","endDate":"2015-11-03T07:24:20.451Z","location":"2015-11-03T07:24:20.451Z","examiner":"2015-11-03T07:24:20.451Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_15759FA2-6691-6EF3-9636-21570F400F04","_rev":"1-d28274492b5b3cd306c3d38e535388a7","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:38:17.049Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:38:17.049Z","startDate":"2015-11-03T07:38:17.049Z","status":"2015-11-03T07:38:17.049Z","outPatient":"2015-11-03T07:38:17.049Z","endDate":"2015-11-03T07:38:17.049Z","location":"2015-11-03T07:38:17.049Z","examiner":"2015-11-03T07:38:17.049Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_17AB2BCF-5F9F-30FB-8B80-9FB82E51D0B3","_rev":"1-bc13c64ebb47144840cc91ce3087ebd6","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:03.461Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:03.461Z","startDate":"2015-11-03T07:23:03.461Z","status":"2015-11-03T07:23:03.461Z","outPatient":"2015-11-03T07:23:03.461Z","endDate":"2015-11-03T07:23:03.461Z","location":"2015-11-03T07:23:03.461Z","examiner":"2015-11-03T07:23:03.461Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1800A65C-861C-CCA5-85C5-16950322C7E0","_rev":"1-a67e8d8a018844ef176184947055b683","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:40:08.177Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:40:08.177Z","startDate":"2015-11-03T07:40:08.177Z","status":"2015-11-03T07:40:08.177Z","outPatient":"2015-11-03T07:40:08.177Z","endDate":"2015-11-03T07:40:08.177Z","location":"2015-11-03T07:40:08.177Z","examiner":"2015-11-03T07:40:08.177Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1EBA7E42-F96D-C5E2-923C-2F842FDFE714","_rev":"1-8fd6cfa23288f7394ce94970c4b3a8c2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:45.676Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:45.676Z","startDate":"2015-11-03T07:19:45.676Z","status":"2015-11-03T07:19:45.676Z","outPatient":"2015-11-03T07:19:45.676Z","endDate":"2015-11-03T07:19:45.676Z","location":"2015-11-03T07:19:45.676Z","examiner":"2015-11-03T07:19:45.676Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_2D795EA3-DAEF-AA15-8846-607A873AD1AF","_rev":"1-4c665c9221069fe72f9d66ac458e92df","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:28:51.490Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:28:51.490Z","startDate":"2015-11-03T07:28:51.490Z","status":"2015-11-03T07:28:51.490Z","outPatient":"2015-11-03T07:28:51.490Z","endDate":"2015-11-03T07:28:51.490Z","location":"2015-11-03T07:28:51.490Z","examiner":"2015-11-03T07:28:51.490Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_3A8FE46D-2CE6-C74E-98BB-ECFECB8F4AB9","_rev":"1-4c2559b35790501b6fae26a031a59cad","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:11.759Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:11.759Z","startDate":"2015-11-03T07:42:11.759Z","status":"2015-11-03T07:42:11.759Z","outPatient":"2015-11-03T07:42:11.759Z","endDate":"2015-11-03T07:42:11.759Z","location":"2015-11-03T07:42:11.759Z","examiner":"2015-11-03T07:42:11.759Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_50FD1C68-0889-0867-99D1-CFFDB3223154","_rev":"1-85d776e0088793e80073525cf6b7a501","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:47:59.399Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:47:59.399Z","startDate":"2015-11-03T07:47:59.399Z","status":"2015-11-03T07:47:59.399Z","outPatient":"2015-11-03T07:47:59.399Z","endDate":"2015-11-03T07:47:59.399Z","location":"2015-11-03T07:47:59.399Z","examiner":"2015-11-03T07:47:59.399Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_53E986EB-4C23-9B3B-B8D7-2C7A7ECDBC33","_rev":"1-fb5ce8d11793c3da21e06d1f88e48d00","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:24.134Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:24.134Z","startDate":"2015-11-03T07:23:24.134Z","status":"2015-11-03T07:23:24.134Z","outPatient":"2015-11-03T07:23:24.134Z","endDate":"2015-11-03T07:23:24.134Z","location":"2015-11-03T07:23:24.134Z","examiner":"2015-11-03T07:23:24.134Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_542BB0F0-27BB-7C5C-99BC-28B013DDB837","_rev":"1-6e3af7515e9b2d7fbcec6264b9194a17","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:32:40.937Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:32:40.937Z","startDate":"2015-11-03T07:32:40.937Z","status":"2015-11-03T07:32:40.937Z","outPatient":"2015-11-03T07:32:40.937Z","endDate":"2015-11-03T07:32:40.937Z","location":"2015-11-03T07:32:40.937Z","examiner":"2015-11-03T07:32:40.937Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}}]} +{"seq":124} +{"docs":[{"_id":"visit_2_560E25D9-9736-BA05-B2A6-4555A93B2628","_rev":"2-04c2d6343f6d2a10ad1f891718cecab5","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:08:13.698Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:08:13.698Z","startDate":"2015-11-03T07:08:13.698Z","status":"2015-11-03T07:08:13.698Z","outPatient":"2015-11-03T07:08:13.698Z","endDate":"2015-11-03T07:08:13.698Z","location":"2015-11-03T07:08:13.698Z","examiner":"2015-11-03T07:08:13.698Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["04c2d6343f6d2a10ad1f891718cecab5","6bbe45974af0b60410ea29026a38e2ec"]}},{"_id":"visit_2_59F8FB60-9956-E93F-826D-11618BC95E13","_rev":"1-8489694a221cd2c43e7c39fdcaa89700","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:41:35.597Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:41:35.597Z","startDate":"2015-11-03T07:41:35.597Z","status":"2015-11-03T07:41:35.597Z","outPatient":"2015-11-03T07:41:35.597Z","endDate":"2015-11-03T07:41:35.597Z","location":"2015-11-03T07:41:35.597Z","examiner":"2015-11-03T07:41:35.597Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5F404B11-D8B6-CE18-9557-2B563BCFD2F8","_rev":"1-2637dc1d6c95364743de0c97c7fb443d","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:34:38.929Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:34:38.929Z","startDate":"2015-11-03T07:34:38.929Z","status":"2015-11-03T07:34:38.929Z","outPatient":"2015-11-03T07:34:38.929Z","endDate":"2015-11-03T07:34:38.929Z","location":"2015-11-03T07:34:38.929Z","examiner":"2015-11-03T07:34:38.929Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_6D126583-2852-25C2-A352-E5BA4CBBD106","_rev":"1-222d722266f5d407204eb411f68ab4f0","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:20:56.778Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:20:56.778Z","startDate":"2015-11-03T07:20:56.778Z","status":"2015-11-03T07:20:56.778Z","outPatient":"2015-11-03T07:20:56.778Z","endDate":"2015-11-03T07:20:56.778Z","location":"2015-11-03T07:20:56.778Z","examiner":"2015-11-03T07:20:56.778Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_7916D533-54AE-55EB-8DE7-E4B83A4BBAB2","_rev":"1-269d23778ac6f89244ff93d17c73352c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:45.358Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:45.358Z","startDate":"2015-11-03T07:46:45.358Z","status":"2015-11-03T07:46:45.358Z","outPatient":"2015-11-03T07:46:45.358Z","endDate":"2015-11-03T07:46:45.358Z","location":"2015-11-03T07:46:45.358Z","examiner":"2015-11-03T07:46:45.358Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_817CE5FB-FF79-B05D-8296-2FCE91B125CD","_rev":"1-410079742e88e59e0598107fd9ef40c1","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:33:16.393Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:33:16.393Z","startDate":"2015-11-03T07:33:16.393Z","status":"2015-11-03T07:33:16.393Z","outPatient":"2015-11-03T07:33:16.393Z","endDate":"2015-11-03T07:33:16.393Z","location":"2015-11-03T07:33:16.393Z","examiner":"2015-11-03T07:33:16.393Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_90FCADB8-7109-3906-94A3-269F29CFAB69","_rev":"1-7a8189c07dde6b9bf498545cdaa3e621","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:31:49.176Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:49.176Z","startDate":"2015-11-03T07:31:49.176Z","status":"2015-11-03T07:31:49.176Z","outPatient":"2015-11-03T07:31:49.176Z","endDate":"2015-11-03T07:31:49.176Z","location":"2015-11-03T07:31:49.176Z","examiner":"2015-11-03T07:31:49.176Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9C962DF7-E239-966B-A47B-15F405899B62","_rev":"1-d5bc412bfa629333e6cd79c978ea8218","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:25:27.802Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:25:27.802Z","startDate":"2015-11-03T07:25:27.802Z","status":"2015-11-03T07:25:27.802Z","outPatient":"2015-11-03T07:25:27.802Z","endDate":"2015-11-03T07:25:27.802Z","location":"2015-11-03T07:25:27.802Z","examiner":"2015-11-03T07:25:27.802Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9E627361-BA73-210A-8E76-2FA13B559DB9","_rev":"1-30a87dbc678b99d42b1a90bebff97834","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:21:48.053Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:21:48.053Z","startDate":"2015-11-03T07:21:48.053Z","status":"2015-11-03T07:21:48.053Z","outPatient":"2015-11-03T07:21:48.053Z","endDate":"2015-11-03T07:21:48.053Z","location":"2015-11-03T07:21:48.053Z","examiner":"2015-11-03T07:21:48.053Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_A6E37F8D-F740-8B01-93C9-D476A886E030","_rev":"1-d094eb56a680b4a8a6a354bd48d6bfe2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:53.782Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:53.782Z","startDate":"2015-11-03T07:42:53.782Z","status":"2015-11-03T07:42:53.782Z","outPatient":"2015-11-03T07:42:53.782Z","endDate":"2015-11-03T07:42:53.782Z","location":"2015-11-03T07:42:53.782Z","examiner":"2015-11-03T07:42:53.782Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_AAB85ADA-7058-DF7A-9244-C6B60A2EF743","_rev":"1-1bd78b61646023aacce18b1efaa27646","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:39:09.272Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:39:09.272Z","startDate":"2015-11-03T07:39:09.272Z","status":"2015-11-03T07:39:09.272Z","outPatient":"2015-11-03T07:39:09.272Z","endDate":"2015-11-03T07:39:09.272Z","location":"2015-11-03T07:39:09.272Z","examiner":"2015-11-03T07:39:09.272Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C15054D2-D062-DB01-A96D-80ED1B8F8CBD","_rev":"1-5a9a0e7eafe911586556666ad1a2bd27","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:09.735Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:09.735Z","startDate":"2015-11-03T07:46:09.735Z","status":"2015-11-03T07:46:09.735Z","outPatient":"2015-11-03T07:46:09.735Z","endDate":"2015-11-03T07:46:09.735Z","location":"2015-11-03T07:46:09.735Z","examiner":"2015-11-03T07:46:09.735Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}},{"_id":"visit_2_D845EA6E-C4CD-3657-A6F6-3E40FE02B069","_rev":"1-16657f6b4014bf268d63323ed8832a56","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:50:55.344Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:50:55.344Z","startDate":"2015-11-03T07:50:55.344Z","status":"2015-11-03T07:50:55.344Z","outPatient":"2015-11-03T07:50:55.344Z","endDate":"2015-11-03T07:50:55.344Z","location":"2015-11-03T07:50:55.344Z","examiner":"2015-11-03T07:50:55.344Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_DA661CAB-1BB5-3119-B9DD-0A92D7C3913B","_rev":"1-ecb23bc4c60a32dd627969637f85d1fb","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:15.689Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:15.689Z","startDate":"2015-11-03T07:19:15.689Z","status":"2015-11-03T07:19:15.689Z","outPatient":"2015-11-03T07:19:15.689Z","endDate":"2015-11-03T07:19:15.689Z","location":"2015-11-03T07:19:15.689Z","examiner":"2015-11-03T07:19:15.689Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E66983BC-BFB9-E361-A59F-AAC966A0FD3B","_rev":"1-8d0f4af9593120f2dfd0371303239e2b","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:15:24.456Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:15:24.456Z","startDate":"2015-11-03T07:15:24.456Z","status":"2015-11-03T07:15:24.456Z","outPatient":"2015-11-03T07:15:24.456Z","endDate":"2015-11-03T07:15:24.456Z","location":"2015-11-03T07:15:24.456Z","examiner":"2015-11-03T07:15:24.456Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E8E7BD06-13EB-AA68-BBE2-51B9EEE85257","_rev":"1-c54a6aea31c6c3805edc706b4ed64d40","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:30:31.501Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:30:31.501Z","startDate":"2015-11-03T07:30:31.501Z","status":"2015-11-03T07:30:31.501Z","outPatient":"2015-11-03T07:30:31.501Z","endDate":"2015-11-03T07:30:31.501Z","location":"2015-11-03T07:30:31.501Z","examiner":"2015-11-03T07:30:31.501Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E90C9A07-74D2-0589-8DDC-C94B09E0F238","_rev":"1-7a3d4f0d4056960dabad849d1da9bd7c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:22:15.702Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:22:15.702Z","startDate":"2015-11-03T07:22:15.702Z","status":"2015-11-03T07:22:15.702Z","outPatient":"2015-11-03T07:22:15.702Z","endDate":"2015-11-03T07:22:15.702Z","location":"2015-11-03T07:22:15.702Z","examiner":"2015-11-03T07:22:15.702Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_EC9C09F9-676F-AD32-AB61-DDAD615F2632","_rev":"2-8ce10f08748bebcd2df0267258ec2433","data":{"dischargeInfo":null,"endDate":"2015-11-03T14:39:16.671Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-03T14:39:16.671Z","status":null,"visitType":"Lab","lastModified":"2015-11-03T14:39:16.679Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-03T14:39:16.679Z","endDate":"2015-11-03T14:39:16.679Z","outPatient":"2015-11-03T14:39:16.679Z","visitType":"2015-11-03T14:39:16.679Z"},"charges":[],"imaging":[],"labs":["8F1C615D-8E59-5090-BC4A-BFA41C57FABE"],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8ce10f08748bebcd2df0267258ec2433","4a113155a529e6200ba18813cd922ad0"]}},{"_id":"visit_2_EF0D793D-346D-242A-8F4D-589448DA49A6","_rev":"1-413ff66d683c532d2be4cfa04632343c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:26:35.010Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:26:35.010Z","startDate":"2015-11-03T07:26:35.010Z","status":"2015-11-03T07:26:35.010Z","outPatient":"2015-11-03T07:26:35.010Z","endDate":"2015-11-03T07:26:35.010Z","location":"2015-11-03T07:26:35.010Z","examiner":"2015-11-03T07:26:35.010Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_F9D51E3F-E938-1F24-9B19-D76F03E56892","_rev":"1-9e4fb077c716ccd6b149953e4c005aae","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:17:22.667Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:17:22.667Z","startDate":"2015-11-03T07:17:22.667Z","status":"2015-11-03T07:17:22.667Z","outPatient":"2015-11-03T07:17:22.667Z","endDate":"2015-11-03T07:17:22.667Z","location":"2015-11-03T07:17:22.667Z","examiner":"2015-11-03T07:17:22.667Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}}]} +{"seq":150} diff --git a/tests/fixtures/medication.txt b/tests/fixtures/medication.txt index e2cef1a7f5..0de4f1b5ff 100644 --- a/tests/fixtures/medication.txt +++ b/tests/fixtures/medication.txt @@ -1,11 +1,11 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:29:57.485Z","db_info":{"db_name":"main","doc_count":102,"doc_del_count":21,"update_seq":148,"purge_seq":0,"compact_running":false,"disk_size":176232,"data_size":105044,"instance_start_time":"1486135731624745","disk_format_version":6,"committed_update_seq":148,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:56:27.953Z","db_info":{"db_name":"main","doc_count":107,"doc_del_count":21,"update_seq":152,"purge_seq":0,"compact_running":false,"disk_size":168040,"data_size":108359,"instance_start_time":"1488837327494900","disk_format_version":6,"committed_update_seq":152,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"docs":[{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":4} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} {"seq":5} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":23} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"appointment_2_EE5D1ABE-2625-645B-9F84-5B0DD4B4D5EC","_rev":"1-1bb336da899bbd4807cde6620d630bd1","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-11-02T22:00:00.000Z","endDate":"2015-11-02T22:00:00.000Z","notes":"Basic Checkup","status":"Scheduled","lastModified":"2015-11-03T06:50:48.404Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-11-03T06:50:48.404Z","startDate":"2015-11-03T06:50:48.404Z","endDate":"2015-11-03T06:50:48.404Z","appointmentType":"2015-11-03T06:50:48.404Z","provider":"2015-11-03T06:50:48.404Z","location":"2015-11-03T06:50:48.404Z","notes":"2015-11-03T06:50:48.404Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lab_2_8F1C615D-8E59-5090-BC4A-BFA41C57FABE","_rev":"1-5cc96eeacaa8118793770bd5a80f0b4f","data":{"labDate":null,"notes":"Dr ordered another test","requestedBy":"hradmin","requestedDate":"2015-11-03T14:39:16.608Z","result":"Everything is clear","status":"Requested","lastModified":"2015-11-03T14:39:16.920Z","modifiedBy":"hradmin","labType":"5AB262C7-719D-19A6-ADC8-06CBA3088FA8","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"EC9C09F9-676F-AD32-AB61-DDAD615F2632","modifiedFields":{"result":"2015-11-03T14:39:16.920Z","notes":"2015-11-03T14:39:16.920Z","status":"2015-11-03T14:39:16.920Z","requestedBy":"2015-11-03T14:39:16.920Z","requestedDate":"2015-11-03T14:39:16.920Z"},"charges":[]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}},{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"medication_2_35DC84B9-C25B-4C83-A287-D1DEC2FC6028","_rev":"1-03630e954041324546dba2254b04afd2","data":{"notes":null,"prescription":"60 Biogesic Pills","prescriptionDate":"2015-11-08T22:00:00.000Z","quantity":60,"refills":null,"requestedDate":"2015-11-09T10:09:25.619Z","requestedBy":"hradmin","status":"Requested","lastModified":"2015-11-09T10:09:25.950Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"5108DC53-4E2D-53C8-A506-E55E554A3643","modifiedFields":{"prescriptionDate":"2015-11-09T10:09:25.950Z","prescription":"2015-11-09T10:09:25.950Z","quantity":"2015-11-09T10:09:25.950Z","status":"2015-11-09T10:09:25.950Z","requestedBy":"2015-11-09T10:09:25.950Z","requestedDate":"2015-11-09T10:09:25.950Z"}}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}}]} -{"seq":75} -{"docs":[{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"4-67b555cc65659782ad7e91606805b769","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:14:52.397Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","admitted":"2015-11-03T07:08:13.749Z","sex":"2016-02-22T22:14:52.397Z"}},"_revisions":{"start":4,"ids":["67b555cc65659782ad7e91606805b769","020fe2a48d4cbfcb78ce17b8dca2808a","09ad83b2ef8b869ecc41360ccee87e05","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_5AB262C7-719D-19A6-ADC8-06CBA3088FA8","_rev":"1-428c4aeffee433314c955d75e831332b","data":{"category":"Lab","expenseAccount":null,"name":"Chest","price":null,"pricingType":"Lab Procedure","lastModified":"2015-11-03T14:39:16.623Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-11-03T14:39:16.623Z","category":"2015-11-03T14:39:16.623Z","pricingType":"2015-11-03T14:39:16.623Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0312A352-EF8B-C1A2-B9DF-3EC932C96AD8","_rev":"2-8eb7818cb7b808ea467b2e60f0a6a5e2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-03T07:43:21.662Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:15.853Z","startDate":"2015-11-03T07:31:15.853Z","status":"2015-11-03T07:43:21.662Z","outPatient":"2015-11-03T07:31:15.853Z","endDate":"2015-11-03T07:43:21.662Z","location":"2015-11-03T07:31:15.853Z","examiner":"2015-11-03T07:31:15.853Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8eb7818cb7b808ea467b2e60f0a6a5e2","3036466a87ec0a9967be1433386b0bdc"]}},{"_id":"visit_2_07AF1E0E-3CB2-3837-990C-968158E25235","_rev":"1-ce894ba889d506531e4cb2a36394cab4","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:16.594Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:16.594Z","startDate":"2015-11-03T07:46:16.594Z","status":"2015-11-03T07:46:16.594Z","outPatient":"2015-11-03T07:46:16.594Z","endDate":"2015-11-03T07:46:16.594Z","location":"2015-11-03T07:46:16.594Z","examiner":"2015-11-03T07:46:16.594Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0B84AF59-A182-5840-9E7A-CEF7633D4071","_rev":"1-ce3b40be34d77ec1d9c29ccb99a7e905","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:37:46.164Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:37:46.164Z","startDate":"2015-11-03T07:37:46.164Z","status":"2015-11-03T07:37:46.164Z","outPatient":"2015-11-03T07:37:46.164Z","endDate":"2015-11-03T07:37:46.164Z","location":"2015-11-03T07:37:46.164Z","examiner":"2015-11-03T07:37:46.164Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_13340816-9F02-846D-85C3-C3278561BA23","_rev":"1-6ce02a99e4868c5a5bdb88a23f9ff400","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:24:20.451Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:24:20.451Z","startDate":"2015-11-03T07:24:20.451Z","status":"2015-11-03T07:24:20.451Z","outPatient":"2015-11-03T07:24:20.451Z","endDate":"2015-11-03T07:24:20.451Z","location":"2015-11-03T07:24:20.451Z","examiner":"2015-11-03T07:24:20.451Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_15759FA2-6691-6EF3-9636-21570F400F04","_rev":"1-d28274492b5b3cd306c3d38e535388a7","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:38:17.049Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:38:17.049Z","startDate":"2015-11-03T07:38:17.049Z","status":"2015-11-03T07:38:17.049Z","outPatient":"2015-11-03T07:38:17.049Z","endDate":"2015-11-03T07:38:17.049Z","location":"2015-11-03T07:38:17.049Z","examiner":"2015-11-03T07:38:17.049Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_17AB2BCF-5F9F-30FB-8B80-9FB82E51D0B3","_rev":"1-bc13c64ebb47144840cc91ce3087ebd6","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:03.461Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:03.461Z","startDate":"2015-11-03T07:23:03.461Z","status":"2015-11-03T07:23:03.461Z","outPatient":"2015-11-03T07:23:03.461Z","endDate":"2015-11-03T07:23:03.461Z","location":"2015-11-03T07:23:03.461Z","examiner":"2015-11-03T07:23:03.461Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1800A65C-861C-CCA5-85C5-16950322C7E0","_rev":"1-a67e8d8a018844ef176184947055b683","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:40:08.177Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:40:08.177Z","startDate":"2015-11-03T07:40:08.177Z","status":"2015-11-03T07:40:08.177Z","outPatient":"2015-11-03T07:40:08.177Z","endDate":"2015-11-03T07:40:08.177Z","location":"2015-11-03T07:40:08.177Z","examiner":"2015-11-03T07:40:08.177Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1EBA7E42-F96D-C5E2-923C-2F842FDFE714","_rev":"1-8fd6cfa23288f7394ce94970c4b3a8c2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:45.676Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:45.676Z","startDate":"2015-11-03T07:19:45.676Z","status":"2015-11-03T07:19:45.676Z","outPatient":"2015-11-03T07:19:45.676Z","endDate":"2015-11-03T07:19:45.676Z","location":"2015-11-03T07:19:45.676Z","examiner":"2015-11-03T07:19:45.676Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_2D795EA3-DAEF-AA15-8846-607A873AD1AF","_rev":"1-4c665c9221069fe72f9d66ac458e92df","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:28:51.490Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:28:51.490Z","startDate":"2015-11-03T07:28:51.490Z","status":"2015-11-03T07:28:51.490Z","outPatient":"2015-11-03T07:28:51.490Z","endDate":"2015-11-03T07:28:51.490Z","location":"2015-11-03T07:28:51.490Z","examiner":"2015-11-03T07:28:51.490Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_3A8FE46D-2CE6-C74E-98BB-ECFECB8F4AB9","_rev":"1-4c2559b35790501b6fae26a031a59cad","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:11.759Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:11.759Z","startDate":"2015-11-03T07:42:11.759Z","status":"2015-11-03T07:42:11.759Z","outPatient":"2015-11-03T07:42:11.759Z","endDate":"2015-11-03T07:42:11.759Z","location":"2015-11-03T07:42:11.759Z","examiner":"2015-11-03T07:42:11.759Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_50FD1C68-0889-0867-99D1-CFFDB3223154","_rev":"1-85d776e0088793e80073525cf6b7a501","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:47:59.399Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:47:59.399Z","startDate":"2015-11-03T07:47:59.399Z","status":"2015-11-03T07:47:59.399Z","outPatient":"2015-11-03T07:47:59.399Z","endDate":"2015-11-03T07:47:59.399Z","location":"2015-11-03T07:47:59.399Z","examiner":"2015-11-03T07:47:59.399Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5108DC53-4E2D-53C8-A506-E55E554A3643","_rev":"2-884c940bde0d28898a94bb3d118fe89f","data":{"dischargeInfo":null,"endDate":"2015-11-09T10:09:25.619Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-09T10:09:25.619Z","status":null,"visitType":"Pharmacy","lastModified":"2015-11-09T10:09:25.628Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-09T10:09:25.628Z","endDate":"2015-11-09T10:09:25.628Z","outPatient":"2015-11-09T10:09:25.628Z","visitType":"2015-11-09T10:09:25.628Z"},"charges":[],"imaging":[],"labs":[],"medication":["35DC84B9-C25B-4C83-A287-D1DEC2FC6028"],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["884c940bde0d28898a94bb3d118fe89f","d84c4b4dda04554d6e41ca7e6368cc3d"]}},{"_id":"visit_2_53E986EB-4C23-9B3B-B8D7-2C7A7ECDBC33","_rev":"1-fb5ce8d11793c3da21e06d1f88e48d00","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:24.134Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:24.134Z","startDate":"2015-11-03T07:23:24.134Z","status":"2015-11-03T07:23:24.134Z","outPatient":"2015-11-03T07:23:24.134Z","endDate":"2015-11-03T07:23:24.134Z","location":"2015-11-03T07:23:24.134Z","examiner":"2015-11-03T07:23:24.134Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_542BB0F0-27BB-7C5C-99BC-28B013DDB837","_rev":"1-6e3af7515e9b2d7fbcec6264b9194a17","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:32:40.937Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:32:40.937Z","startDate":"2015-11-03T07:32:40.937Z","status":"2015-11-03T07:32:40.937Z","outPatient":"2015-11-03T07:32:40.937Z","endDate":"2015-11-03T07:32:40.937Z","location":"2015-11-03T07:32:40.937Z","examiner":"2015-11-03T07:32:40.937Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_560E25D9-9736-BA05-B2A6-4555A93B2628","_rev":"2-04c2d6343f6d2a10ad1f891718cecab5","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:08:13.698Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:08:13.698Z","startDate":"2015-11-03T07:08:13.698Z","status":"2015-11-03T07:08:13.698Z","outPatient":"2015-11-03T07:08:13.698Z","endDate":"2015-11-03T07:08:13.698Z","location":"2015-11-03T07:08:13.698Z","examiner":"2015-11-03T07:08:13.698Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["04c2d6343f6d2a10ad1f891718cecab5","6bbe45974af0b60410ea29026a38e2ec"]}},{"_id":"visit_2_59F8FB60-9956-E93F-826D-11618BC95E13","_rev":"1-8489694a221cd2c43e7c39fdcaa89700","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:41:35.597Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:41:35.597Z","startDate":"2015-11-03T07:41:35.597Z","status":"2015-11-03T07:41:35.597Z","outPatient":"2015-11-03T07:41:35.597Z","endDate":"2015-11-03T07:41:35.597Z","location":"2015-11-03T07:41:35.597Z","examiner":"2015-11-03T07:41:35.597Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5F404B11-D8B6-CE18-9557-2B563BCFD2F8","_rev":"1-2637dc1d6c95364743de0c97c7fb443d","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:34:38.929Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:34:38.929Z","startDate":"2015-11-03T07:34:38.929Z","status":"2015-11-03T07:34:38.929Z","outPatient":"2015-11-03T07:34:38.929Z","endDate":"2015-11-03T07:34:38.929Z","location":"2015-11-03T07:34:38.929Z","examiner":"2015-11-03T07:34:38.929Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}}]} -{"seq":125} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"visit_2_6D126583-2852-25C2-A352-E5BA4CBBD106","_rev":"1-222d722266f5d407204eb411f68ab4f0","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:20:56.778Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:20:56.778Z","startDate":"2015-11-03T07:20:56.778Z","status":"2015-11-03T07:20:56.778Z","outPatient":"2015-11-03T07:20:56.778Z","endDate":"2015-11-03T07:20:56.778Z","location":"2015-11-03T07:20:56.778Z","examiner":"2015-11-03T07:20:56.778Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_7916D533-54AE-55EB-8DE7-E4B83A4BBAB2","_rev":"1-269d23778ac6f89244ff93d17c73352c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:45.358Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:45.358Z","startDate":"2015-11-03T07:46:45.358Z","status":"2015-11-03T07:46:45.358Z","outPatient":"2015-11-03T07:46:45.358Z","endDate":"2015-11-03T07:46:45.358Z","location":"2015-11-03T07:46:45.358Z","examiner":"2015-11-03T07:46:45.358Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_817CE5FB-FF79-B05D-8296-2FCE91B125CD","_rev":"1-410079742e88e59e0598107fd9ef40c1","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:33:16.393Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:33:16.393Z","startDate":"2015-11-03T07:33:16.393Z","status":"2015-11-03T07:33:16.393Z","outPatient":"2015-11-03T07:33:16.393Z","endDate":"2015-11-03T07:33:16.393Z","location":"2015-11-03T07:33:16.393Z","examiner":"2015-11-03T07:33:16.393Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_90FCADB8-7109-3906-94A3-269F29CFAB69","_rev":"1-7a8189c07dde6b9bf498545cdaa3e621","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:31:49.176Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:49.176Z","startDate":"2015-11-03T07:31:49.176Z","status":"2015-11-03T07:31:49.176Z","outPatient":"2015-11-03T07:31:49.176Z","endDate":"2015-11-03T07:31:49.176Z","location":"2015-11-03T07:31:49.176Z","examiner":"2015-11-03T07:31:49.176Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9C962DF7-E239-966B-A47B-15F405899B62","_rev":"1-d5bc412bfa629333e6cd79c978ea8218","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:25:27.802Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:25:27.802Z","startDate":"2015-11-03T07:25:27.802Z","status":"2015-11-03T07:25:27.802Z","outPatient":"2015-11-03T07:25:27.802Z","endDate":"2015-11-03T07:25:27.802Z","location":"2015-11-03T07:25:27.802Z","examiner":"2015-11-03T07:25:27.802Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9E627361-BA73-210A-8E76-2FA13B559DB9","_rev":"1-30a87dbc678b99d42b1a90bebff97834","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:21:48.053Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:21:48.053Z","startDate":"2015-11-03T07:21:48.053Z","status":"2015-11-03T07:21:48.053Z","outPatient":"2015-11-03T07:21:48.053Z","endDate":"2015-11-03T07:21:48.053Z","location":"2015-11-03T07:21:48.053Z","examiner":"2015-11-03T07:21:48.053Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_A6E37F8D-F740-8B01-93C9-D476A886E030","_rev":"1-d094eb56a680b4a8a6a354bd48d6bfe2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:53.782Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:53.782Z","startDate":"2015-11-03T07:42:53.782Z","status":"2015-11-03T07:42:53.782Z","outPatient":"2015-11-03T07:42:53.782Z","endDate":"2015-11-03T07:42:53.782Z","location":"2015-11-03T07:42:53.782Z","examiner":"2015-11-03T07:42:53.782Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_AAB85ADA-7058-DF7A-9244-C6B60A2EF743","_rev":"1-1bd78b61646023aacce18b1efaa27646","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:39:09.272Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:39:09.272Z","startDate":"2015-11-03T07:39:09.272Z","status":"2015-11-03T07:39:09.272Z","outPatient":"2015-11-03T07:39:09.272Z","endDate":"2015-11-03T07:39:09.272Z","location":"2015-11-03T07:39:09.272Z","examiner":"2015-11-03T07:39:09.272Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C15054D2-D062-DB01-A96D-80ED1B8F8CBD","_rev":"1-5a9a0e7eafe911586556666ad1a2bd27","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:09.735Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:09.735Z","startDate":"2015-11-03T07:46:09.735Z","status":"2015-11-03T07:46:09.735Z","outPatient":"2015-11-03T07:46:09.735Z","endDate":"2015-11-03T07:46:09.735Z","location":"2015-11-03T07:46:09.735Z","examiner":"2015-11-03T07:46:09.735Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}},{"_id":"visit_2_D845EA6E-C4CD-3657-A6F6-3E40FE02B069","_rev":"1-16657f6b4014bf268d63323ed8832a56","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:50:55.344Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:50:55.344Z","startDate":"2015-11-03T07:50:55.344Z","status":"2015-11-03T07:50:55.344Z","outPatient":"2015-11-03T07:50:55.344Z","endDate":"2015-11-03T07:50:55.344Z","location":"2015-11-03T07:50:55.344Z","examiner":"2015-11-03T07:50:55.344Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_DA661CAB-1BB5-3119-B9DD-0A92D7C3913B","_rev":"1-ecb23bc4c60a32dd627969637f85d1fb","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:15.689Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:15.689Z","startDate":"2015-11-03T07:19:15.689Z","status":"2015-11-03T07:19:15.689Z","outPatient":"2015-11-03T07:19:15.689Z","endDate":"2015-11-03T07:19:15.689Z","location":"2015-11-03T07:19:15.689Z","examiner":"2015-11-03T07:19:15.689Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E66983BC-BFB9-E361-A59F-AAC966A0FD3B","_rev":"1-8d0f4af9593120f2dfd0371303239e2b","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:15:24.456Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:15:24.456Z","startDate":"2015-11-03T07:15:24.456Z","status":"2015-11-03T07:15:24.456Z","outPatient":"2015-11-03T07:15:24.456Z","endDate":"2015-11-03T07:15:24.456Z","location":"2015-11-03T07:15:24.456Z","examiner":"2015-11-03T07:15:24.456Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E8E7BD06-13EB-AA68-BBE2-51B9EEE85257","_rev":"1-c54a6aea31c6c3805edc706b4ed64d40","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:30:31.501Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:30:31.501Z","startDate":"2015-11-03T07:30:31.501Z","status":"2015-11-03T07:30:31.501Z","outPatient":"2015-11-03T07:30:31.501Z","endDate":"2015-11-03T07:30:31.501Z","location":"2015-11-03T07:30:31.501Z","examiner":"2015-11-03T07:30:31.501Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E90C9A07-74D2-0589-8DDC-C94B09E0F238","_rev":"1-7a3d4f0d4056960dabad849d1da9bd7c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:22:15.702Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:22:15.702Z","startDate":"2015-11-03T07:22:15.702Z","status":"2015-11-03T07:22:15.702Z","outPatient":"2015-11-03T07:22:15.702Z","endDate":"2015-11-03T07:22:15.702Z","location":"2015-11-03T07:22:15.702Z","examiner":"2015-11-03T07:22:15.702Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_EC9C09F9-676F-AD32-AB61-DDAD615F2632","_rev":"2-8ce10f08748bebcd2df0267258ec2433","data":{"dischargeInfo":null,"endDate":"2015-11-03T14:39:16.671Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-03T14:39:16.671Z","status":null,"visitType":"Lab","lastModified":"2015-11-03T14:39:16.679Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-03T14:39:16.679Z","endDate":"2015-11-03T14:39:16.679Z","outPatient":"2015-11-03T14:39:16.679Z","visitType":"2015-11-03T14:39:16.679Z"},"charges":[],"imaging":[],"labs":["8F1C615D-8E59-5090-BC4A-BFA41C57FABE"],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8ce10f08748bebcd2df0267258ec2433","4a113155a529e6200ba18813cd922ad0"]}},{"_id":"visit_2_EF0D793D-346D-242A-8F4D-589448DA49A6","_rev":"1-413ff66d683c532d2be4cfa04632343c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:26:35.010Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:26:35.010Z","startDate":"2015-11-03T07:26:35.010Z","status":"2015-11-03T07:26:35.010Z","outPatient":"2015-11-03T07:26:35.010Z","endDate":"2015-11-03T07:26:35.010Z","location":"2015-11-03T07:26:35.010Z","examiner":"2015-11-03T07:26:35.010Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_F9D51E3F-E938-1F24-9B19-D76F03E56892","_rev":"1-9e4fb077c716ccd6b149953e4c005aae","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:17:22.667Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:17:22.667Z","startDate":"2015-11-03T07:17:22.667Z","status":"2015-11-03T07:17:22.667Z","outPatient":"2015-11-03T07:17:22.667Z","endDate":"2015-11-03T07:17:22.667Z","location":"2015-11-03T07:17:22.667Z","examiner":"2015-11-03T07:17:22.667Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}}]} -{"seq":148} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-3c37df4fed5a034aedc1a295f4a672fd","version":4,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3c37df4fed5a034aedc1a295f4a672fd"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"1-3eb498726e0d057818618808c0db46bf","version":3,"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc[sortBy], b.doc[sortBy]);\n }\n default:\n {\n return 0; //Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["3eb498726e0d057818618808c0db46bf"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"1-c619a041bccecc7e83b05015cc92706e","version":6,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"3-76930b682e13aef4b2a31fcc57c0ba17","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["76930b682e13aef4b2a31fcc57c0ba17","f2bcbc75b5c6af36a93ff450e1764247","e6d44a1448953362319c910bf33a8668"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"appointment_2_D0C3934D-E023-66E4-97D4-FC58F3595409","_rev":"1-5775c0c9cdf58099fa3ae4197634505f","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-10-29T22:00:00.000Z","endDate":"2015-10-29T22:00:00.000Z","notes":"Admission","status":"Scheduled","lastModified":"2015-10-30T15:08:29.970Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-10-30T15:08:29.970Z","startDate":"2015-10-30T15:08:29.970Z","endDate":"2015-10-30T15:08:29.970Z","provider":"2015-10-30T15:08:29.970Z","location":"2015-10-30T15:08:29.970Z","appointmentType":"2015-10-30T15:08:29.970Z","notes":"2015-10-30T15:08:29.970Z"}}},{"_id":"appointment_2_EE5D1ABE-2625-645B-9F84-5B0DD4B4D5EC","_rev":"1-1bb336da899bbd4807cde6620d630bd1","data":{"allDay":true,"provider":"Dr Test","location":"Harare","appointmentType":"Admission","startDate":"2015-11-02T22:00:00.000Z","endDate":"2015-11-02T22:00:00.000Z","notes":"Basic Checkup","status":"Scheduled","lastModified":"2015-11-03T06:50:48.404Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"allDay":"2015-11-03T06:50:48.404Z","startDate":"2015-11-03T06:50:48.404Z","endDate":"2015-11-03T06:50:48.404Z","appointmentType":"2015-11-03T06:50:48.404Z","provider":"2015-11-03T06:50:48.404Z","location":"2015-11-03T06:50:48.404Z","notes":"2015-11-03T06:50:48.404Z"}}},{"_id":"imaging_2_07CC6746-C7D9-A410-9B8C-C4B4E095A96D","_rev":"2-ffa7adb60618346cba98a559d81df36a","data":{"imagingDate":"2015-10-15T09:39:44.603Z","notes":"random notes","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T09:39:37.866Z","result":"to collect","status":"Completed","lastModified":"2015-10-15T09:39:44.603Z","modifiedBy":"hradmin","imagingType":"22208FBE-9C6E-079D-A1E6-A562F9310FE5","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","modifiedFields":{"radiologist":"2015-10-15T09:39:38.088Z","result":"2015-10-15T09:39:38.088Z","notes":"2015-10-15T09:39:38.088Z","status":"2015-10-15T09:39:44.603Z","requestedBy":"2015-10-15T09:39:38.088Z","requestedDate":"2015-10-15T09:39:38.088Z","imagingDate":"2015-10-15T09:39:44.603Z"},"charges":[]},"_revisions":{"start":2,"ids":["ffa7adb60618346cba98a559d81df36a","be0a6780ba1f2b7e3e8d49ebf20ed8d6"]}},{"_id":"imaging_2_1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB","_rev":"1-83a3398c448faf2ea1962004c5652a52","data":{"imagingDate":null,"notes":"jkmn","radiologist":"zinyando","requestedBy":"hradmin","requestedDate":"2015-10-15T10:37:57.852Z","result":"hu","status":"Requested","lastModified":"2015-10-15T10:37:58.038Z","modifiedBy":"hradmin","imagingType":"4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","modifiedFields":{"radiologist":"2015-10-15T10:37:58.038Z","result":"2015-10-15T10:37:58.038Z","notes":"2015-10-15T10:37:58.038Z","status":"2015-10-15T10:37:58.038Z","requestedBy":"2015-10-15T10:37:58.038Z","requestedDate":"2015-10-15T10:37:58.038Z"},"charges":[]}},{"_id":"imaging_2_4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99","_rev":"2-0ddb54b6d0376b87fdf409eb6d205f82","data":{"imagingDate":"2015-10-28T07:32:45.311Z","notes":null,"radiologist":null,"requestedBy":"hradmin","requestedDate":"2015-10-26T11:49:08.227Z","result":null,"status":"Completed","lastModified":"2015-10-28T07:32:45.314Z","modifiedBy":"hradmin","imagingType":"CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"C5C296AC-E238-CBA5-8DD8-99942843BC5A","modifiedFields":{"status":"2015-10-28T07:32:45.314Z","requestedBy":"2015-10-26T11:49:08.483Z","requestedDate":"2015-10-26T11:49:08.483Z","imagingDate":"2015-10-28T07:32:45.314Z"},"charges":[]},"_revisions":{"start":2,"ids":["0ddb54b6d0376b87fdf409eb6d205f82","0cefb2d2a3e8ba76052c1a08c27df1eb"]}},{"_id":"imaging_2_51D8DC28-78EB-62B1-942A-1158F5862F34","_rev":"2-40eac78a67beecaa77b17ea5e7481866","data":{"imagingDate":"2015-10-28T07:32:55.293Z","notes":"Chest is ok","radiologist":"Mr Test","requestedBy":"hradmin","requestedDate":"2015-10-28T07:23:34.834Z","result":"Ok","status":"Completed","lastModified":"2015-10-28T07:32:55.294Z","modifiedBy":"hradmin","imagingType":"E53305F3-BA40-B305-B2DC-0732C7AB0042","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","modifiedFields":{"radiologist":"2015-10-28T07:23:35.055Z","result":"2015-10-28T07:23:35.055Z","notes":"2015-10-28T07:23:35.055Z","status":"2015-10-28T07:32:55.294Z","requestedBy":"2015-10-28T07:23:35.055Z","requestedDate":"2015-10-28T07:23:35.055Z","imagingDate":"2015-10-28T07:32:55.294Z"},"charges":[]},"_revisions":{"start":2,"ids":["40eac78a67beecaa77b17ea5e7481866","fb212193dfed510d7935aed17e5f0456"]}},{"_id":"imaging_2_91B061E9-2986-D539-90C8-CD14EC2010B0","_rev":"1-2abe559a8f8075862b282ed4f9d54da5","data":{"imagingDate":null,"notes":"jbkj","radiologist":"b","requestedBy":"hradmin","requestedDate":"2015-10-28T07:39:18.255Z","result":"jjjk","status":"Requested","lastModified":"2015-10-28T07:39:18.406Z","modifiedBy":"hradmin","imagingType":null,"patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"6AD00ED1-670A-2C3F-BC10-0742B1F99264","modifiedFields":{"radiologist":"2015-10-28T07:39:18.406Z","result":"2015-10-28T07:39:18.406Z","notes":"2015-10-28T07:39:18.406Z","status":"2015-10-28T07:39:18.406Z","requestedBy":"2015-10-28T07:39:18.406Z","requestedDate":"2015-10-28T07:39:18.406Z"},"charges":[]}},{"_id":"imaging_2_D0F299E4-CD8D-557D-8C23-216FD23EF844","_rev":"3-8b87996abf9161e5d7908be6676a64d7","data":{"imagingDate":"2015-10-22T07:09:04.249Z","notes":"vbj nkm","radiologist":"fcgvb","requestedBy":"hradmin","requestedDate":"2015-10-22T07:08:38.080Z","result":"cgvhbj n","status":"Completed","lastModified":"2015-10-22T07:09:04.251Z","modifiedBy":"hradmin","imagingType":"B492AA26-22F2-52A9-93C7-17106A57A62E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"9F1A65ED-683F-056E-8D50-A8AF63201CE2","modifiedFields":{"radiologist":"2015-10-22T07:08:38.523Z","result":"2015-10-22T07:08:38.523Z","notes":"2015-10-22T07:08:38.523Z","status":"2015-10-22T07:08:59.403Z","requestedBy":"2015-10-22T07:08:38.523Z","requestedDate":"2015-10-22T07:08:38.523Z","imagingDate":"2015-10-22T07:09:04.251Z"},"charges":[]},"_revisions":{"start":3,"ids":["8b87996abf9161e5d7908be6676a64d7","9f159b24551a1fa5acd7b84cd8d51994","c676b60d0d69556786f283da75b51c77"]}},{"_id":"imaging_2_DBE152F6-9508-2E12-81AC-39BC2CAFE08C","_rev":"2-69b11e7856d8b0fc3bd62debbfca3e55","data":{"imagingDate":"2015-10-28T07:33:17.867Z","notes":"ss","radiologist":"ss","requestedBy":"hradmin","requestedDate":"2015-10-28T07:31:20.891Z","result":"sss","status":"Completed","lastModified":"2015-10-28T07:33:17.868Z","modifiedBy":"hradmin","imagingType":"F51616AE-EB96-2778-824F-386DEAFFD2F9","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"D6938BD3-6346-F62B-8B19-5207B2E5A6AF","modifiedFields":{"radiologist":"2015-10-28T07:31:21.091Z","result":"2015-10-28T07:31:21.091Z","notes":"2015-10-28T07:31:21.091Z","status":"2015-10-28T07:33:17.868Z","requestedBy":"2015-10-28T07:31:21.091Z","requestedDate":"2015-10-28T07:31:21.091Z","imagingDate":"2015-10-28T07:33:17.868Z"},"charges":[]},"_revisions":{"start":2,"ids":["69b11e7856d8b0fc3bd62debbfca3e55","222ad15ae5eed89c6d8abe1c9e07c145"]}},{"_id":"imaging_2_EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B","_rev":"2-63da6e42fb59a811a5468e32bda0eb76","data":{"imagingDate":"2015-10-28T07:33:05.759Z","notes":"hbjn","radiologist":"cgvhbn","requestedBy":"hradmin","requestedDate":"2015-10-28T07:27:44.346Z","result":"fcghvj","status":"Completed","lastModified":"2015-10-28T07:33:05.759Z","modifiedBy":"hradmin","imagingType":"C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","modifiedFields":{"radiologist":"2015-10-28T07:27:44.514Z","result":"2015-10-28T07:27:44.514Z","notes":"2015-10-28T07:27:44.514Z","status":"2015-10-28T07:33:05.759Z","requestedBy":"2015-10-28T07:27:44.514Z","requestedDate":"2015-10-28T07:27:44.514Z","imagingDate":"2015-10-28T07:33:05.759Z"},"charges":[]},"_revisions":{"start":2,"ids":["63da6e42fb59a811a5468e32bda0eb76","51a7194f0c4b6b172b5d0b059285e118"]}},{"_id":"invLocation_2_B7B86EC1-6CCE-30B7-B4ED-FF2061879E03","_rev":"3-28a915c1093e6e8497c2742a4806f926","data":{"quantity":950,"location":null,"aisleLocation":null,"lastModified":"2015-10-30T12:44:28.530Z","modifiedBy":"hradmin","modifiedFields":{"quantity":"2015-10-30T12:44:28.530Z"}},"_revisions":{"start":3,"ids":["28a915c1093e6e8497c2742a4806f926","6b49176eeeafb82a88a10aa5d954d965","e7ffcb12925c148d50279cc2ee012d25"]}},{"_id":"invPurchase_2_CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","_rev":"2-4f1115c8c7b03b0bf06059d01e5ff7bd","data":{"purchaseCost":4000,"lotNumber":null,"dateReceived":"2015-10-28T22:00:00.000Z","originalQuantity":1000,"currentQuantity":950,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"igbmk5zf_is","vendor":"Alpha Pharmacy","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-10-30T12:44:28.533Z","modifiedBy":"hradmin","modifiedFields":{"dateReceived":"2015-10-29T02:44:10.493Z","purchaseCost":"2015-10-29T02:44:10.493Z","vendor":"2015-10-29T02:44:10.493Z","originalQuantity":"2015-10-29T02:44:10.493Z","currentQuantity":"2015-10-30T12:44:28.533Z","inventoryItem":"2015-10-29T02:44:10.493Z"}},"_revisions":{"start":2,"ids":["4f1115c8c7b03b0bf06059d01e5ff7bd","d0a2104fa76a4161da3f527b23a6d61a"]}},{"_id":"invRequest_2_4691AB2D-AEF3-1AA8-A11E-790BA5788239","_rev":"2-cf9eeeed6d9004aa0479660df622e08c","data":{"adjustPurchases":true,"completedBy":"hradmin","costPerUnit":4,"dateCompleted":"2015-10-29T22:00:00.000Z","dateRequested":"2015-10-29T08:35:51.495Z","deliveryAisle":"C100","deliveryLocation":"Harare","expenseAccount":"Accounts","markAsConsumed":true,"quantity":50,"quantityAtCompletion":1000,"reason":null,"requestedBy":"hradmin","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-10-30T12:44:28.623Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":null,"visit":null,"locationsAffected":[{"name":"No Location","quantity":50}],"purchasesAffected":[{"id":"CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC","quantity":50}],"modifiedFields":{"transactionType":"2015-10-30T12:44:28.623Z","quantity":"2015-10-29T08:35:51.497Z","deliveryLocation":"2015-10-29T08:35:51.497Z","deliveryAisle":"2015-10-29T08:35:51.497Z","expenseAccount":"2015-10-29T08:35:51.497Z","dateRequested":"2015-10-29T08:35:51.497Z","requestedBy":"2015-10-29T08:35:51.497Z","status":"2015-10-30T12:44:28.623Z","dateCompleted":"2015-10-30T12:44:28.623Z","adjustPurchases":"2015-10-30T12:44:28.623Z","costPerUnit":"2015-10-30T12:44:28.623Z","quantityAtCompletion":"2015-10-30T12:44:28.623Z","purchasesAffected":"2015-10-30T12:44:28.623Z","locationsAffected":"2015-10-30T12:44:28.623Z","completedBy":"2015-10-30T12:44:28.623Z"}},"_revisions":{"start":2,"ids":["cf9eeeed6d9004aa0479660df622e08c","0e093fbeafc9c59eaeaaf0739ad56e13"]}},{"_id":"inventory_2_igbmk5zf_is","_rev":"2-586df5949f0c9046947fae0fcf009b6f","data":{"description":"Biogesic nga medisina","friendlyId":"m00001","name":"Biogesic","quantity":950,"crossReference":"2600","inventoryType":"Medication","price":5,"reorderPoint":100,"distributionUnit":"tablet","lastModified":"2015-10-30T12:44:28.620Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-29T02:44:10.610Z","inventoryType":"2015-10-29T02:44:10.610Z","crossReference":"2015-10-29T02:44:10.610Z","description":"2015-10-29T02:44:10.610Z","reorderPoint":"2015-10-29T02:44:10.610Z","price":"2015-10-29T02:44:10.610Z","distributionUnit":"2015-10-29T02:44:10.610Z","quantity":"2015-10-30T12:44:28.620Z","friendlyId":"2015-10-29T02:44:10.610Z"},"purchases":["CDC3AB7D-A0AD-E146-87A4-FDB1096C2EEC"],"locations":["B7B86EC1-6CCE-30B7-B4ED-FF2061879E03"]},"_revisions":{"start":2,"ids":["586df5949f0c9046947fae0fcf009b6f","26fffdb13350d70c54f01078f7ea7058"]}},{"_id":"lab_2_8F1C615D-8E59-5090-BC4A-BFA41C57FABE","_rev":"1-5cc96eeacaa8118793770bd5a80f0b4f","data":{"labDate":null,"notes":"Dr ordered another test","requestedBy":"hradmin","requestedDate":"2015-11-03T14:39:16.608Z","result":"Everything is clear","status":"Requested","lastModified":"2015-11-03T14:39:16.920Z","modifiedBy":"hradmin","labType":"5AB262C7-719D-19A6-ADC8-06CBA3088FA8","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"EC9C09F9-676F-AD32-AB61-DDAD615F2632","modifiedFields":{"result":"2015-11-03T14:39:16.920Z","notes":"2015-11-03T14:39:16.920Z","status":"2015-11-03T14:39:16.920Z","requestedBy":"2015-11-03T14:39:16.920Z","requestedDate":"2015-11-03T14:39:16.920Z"},"charges":[]}},{"_id":"lookup_2_aisle_location_list","_rev":"1-7257ef0f361f763b2692f692dab6bb7c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["C100"]}},{"_id":"lookup_2_expense_account_list","_rev":"1-bb8267ec5987084be9890734e55df7e0","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Accounts"]}},{"_id":"lookup_2_physician_list","_rev":"1-539fb71896153ad54253f5eb86f508cd","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Test"]}},{"_id":"lookup_2_radiologists","_rev":"6-38c1cbc8559ef893d7ebd043e93ce427","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Mr Test","b","cgvhbn","fcgvb","ss","zinyando"]},"_revisions":{"start":6,"ids":["38c1cbc8559ef893d7ebd043e93ce427","515694dee3f8a35894f6287347485e40","10ef5b07a7d56f64ac26e84507484d41","33cff401403de9c1efd0a9edbec7e50b","cb3dd07e07a6fa2f9e9323b7e15c48fd","864e65b754e2ec13fe2eb8c452bce282"]}},{"_id":"lookup_2_sex","_rev":"1-c433c64d3ecf2a60e4539b1d1dc43d27","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Male"]}}]} +{"seq":74} +{"docs":[{"_id":"lookup_2_vendor_list","_rev":"1-3b1a6a2565242e3db9cbdb6c579de2af","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Alpha Pharmacy"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"lookup_2_warehouse_list","_rev":"1-578a5af6fd231a89f2fdeb1baae7036c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Harare"]}},{"_id":"medication_2_35DC84B9-C25B-4C83-A287-D1DEC2FC6028","_rev":"1-03630e954041324546dba2254b04afd2","data":{"notes":null,"prescription":"60 Biogesic Pills","prescriptionDate":"2015-11-08T22:00:00.000Z","quantity":60,"refills":null,"requestedDate":"2015-11-09T10:09:25.619Z","requestedBy":"hradmin","status":"Requested","lastModified":"2015-11-09T10:09:25.950Z","modifiedBy":"hradmin","inventoryItem":"igbmk5zf_is","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","visit":"5108DC53-4E2D-53C8-A506-E55E554A3643","modifiedFields":{"prescriptionDate":"2015-11-09T10:09:25.950Z","prescription":"2015-11-09T10:09:25.950Z","quantity":"2015-11-09T10:09:25.950Z","status":"2015-11-09T10:09:25.950Z","requestedBy":"2015-11-09T10:09:25.950Z","requestedDate":"2015-11-09T10:09:25.950Z"}}},{"_id":"patient_2_19A03BBC-71F3-9F39-8B18-15773F446731","_rev":"3-c021a07297d99585de08b3fd96719914","_deleted":true,"_revisions":{"start":3,"ids":["c021a07297d99585de08b3fd96719914","a7323c9135948b4689f52c01826affe2","6ed64fbe474b36dac7c8ac071e33786d"]}},{"_id":"patient_2_2D1BEC2C-EA03-E737-9EC9-D2AEAF2C9EE6","_rev":"2-a587941fb557366a6b87122548a9ba0c","_deleted":true,"_revisions":{"start":2,"ids":["a587941fb557366a6b87122548a9ba0c","0048675586c8e2fd24c8cc2edc545769"]}},{"_id":"patient_2_3C01C5E5-7E64-B147-88F9-D127903B31D7","_rev":"4-be8dd294f8df42bcf220e1a4372340fd","_deleted":true,"_revisions":{"start":4,"ids":["be8dd294f8df42bcf220e1a4372340fd","74d74986cffc330788b0fc5e47f40788","1ed40ad430dba87ec4c0773779fac6aa","34e84dc96007fc737d932ebf875ce340"]}},{"_id":"patient_2_423A476C-2012-6339-8FED-D2E404037268","_rev":"4-263b75936a4ead5058dc1e17535c536c","_deleted":true,"_revisions":{"start":4,"ids":["263b75936a4ead5058dc1e17535c536c","12c22dbd6548922b326bd28b2f05ddb0","a4a9b0e7ed53aea140c1d3259c9b1e94","15ebcd46a46d830899afc17450d4b229"]}},{"_id":"patient_2_519E056C-BF04-2A3F-84D2-8963EAD04261","_rev":"2-13e0330c4610ea3dc8a8dcb64a9b61ae","_deleted":true,"_revisions":{"start":2,"ids":["13e0330c4610ea3dc8a8dcb64a9b61ae","193c2c5d9fcb17698411febac4015547"]}},{"_id":"patient_2_5DD90350-3A67-F3B7-BB4A-A6837A667697","_rev":"2-812e681275f7181b96e1428d5b2eb555","_deleted":true,"_revisions":{"start":2,"ids":["812e681275f7181b96e1428d5b2eb555","a9b1e632e8d3f96d106873396f7f04de"]}},{"_id":"patient_2_63165A06-C866-A0C2-BB43-5DE9A0146737","_rev":"2-5989c5e25baace8df71d475ae164bf40","_deleted":true,"_revisions":{"start":2,"ids":["5989c5e25baace8df71d475ae164bf40","4178d1d23fb9d40a647d573026480dad"]}},{"_id":"patient_2_632DBDA3-5DBF-DDCC-A2C6-915E357319BA","_rev":"2-6ce428f8cdb8d1ea864f976c1ade08e4","_deleted":true,"_revisions":{"start":2,"ids":["6ce428f8cdb8d1ea864f976c1ade08e4","abe897a1411af9ce5df82d2ddbe726f2"]}},{"_id":"patient_2_688E30F1-E068-A2E3-8986-C224AF671CDD","_rev":"2-cb950343c60eb7116359fb50dc58fb87","_deleted":true,"_revisions":{"start":2,"ids":["cb950343c60eb7116359fb50dc58fb87","949f54bb01a90f17a91a7b392aecd58e"]}},{"_id":"patient_2_694DF805-F7CD-9513-9EF5-4CF8EE009BE9","_rev":"2-005d256252779d14fb83b9614a75d84f","_deleted":true,"_revisions":{"start":2,"ids":["005d256252779d14fb83b9614a75d84f","79cbdb6ba8075de8b19b61f4ebd194b2"]}},{"_id":"patient_2_9C269C48-EE3E-FBEC-9371-A235EEFDA40E","_rev":"2-6d94af1fdf669e3d012e3370c17c7d0f","_deleted":true,"_revisions":{"start":2,"ids":["6d94af1fdf669e3d012e3370c17c7d0f","ba40f943d16f3594cdf2a1c0e7ce36eb"]}},{"_id":"patient_2_9ED02049-6F10-E89D-9BAA-9C113B3AA6E4","_rev":"2-472c94a0e9c78fde3be4c15a71e0f336","_deleted":true,"_revisions":{"start":2,"ids":["472c94a0e9c78fde3be4c15a71e0f336","c61b0ba276e4c88cfda15ae4b5d0768b"]}},{"_id":"patient_2_B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","_rev":"4-67b555cc65659782ad7e91606805b769","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00017","firstName":"Lennex","sex":"Male","history":null,"insurance":null,"lastName":"Zinyando","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"lastModified":"2016-02-22T22:14:52.397Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-10-06T10:56:52.507Z","firstName":"2015-10-06T10:56:52.507Z","middleName":"2015-10-06T10:56:52.507Z","lastName":"2015-10-06T10:56:52.507Z","admitted":"2015-11-03T07:08:13.749Z","sex":"2016-02-22T22:14:52.397Z"}},"_revisions":{"start":4,"ids":["67b555cc65659782ad7e91606805b769","020fe2a48d4cbfcb78ce17b8dca2808a","09ad83b2ef8b869ecc41360ccee87e05","e5548781a44e741ceac358e5e3413d76"]}},{"_id":"patient_2_BB4E9598-BD8B-528B-9D9E-AD9C3980787B","_rev":"3-957a69aebfae063d61ee8aaa55006803","_deleted":true,"_revisions":{"start":3,"ids":["957a69aebfae063d61ee8aaa55006803","0345093ba84e9c117c7dbb94b45edb8f","3e24d132e3bcc29db9d41a4d9f4296bf"]}},{"_id":"patient_2_C0361670-8B10-F212-9F51-B889D5BF92DF","_rev":"2-7b2217e2c2cb01610c32e0de44910282","_deleted":true,"_revisions":{"start":2,"ids":["7b2217e2c2cb01610c32e0de44910282","13ecb169a07f0e5a78a11209c26ede78"]}},{"_id":"patient_2_C680710A-BFBB-2868-8E5E-F4DD648CA24E","_rev":"2-d9acde506f230ec53a1cff9c97fe58bf","_deleted":true,"_revisions":{"start":2,"ids":["d9acde506f230ec53a1cff9c97fe58bf","9d954090afc2085fb97060446f8e4da0"]}},{"_id":"patient_2_E011AC5D-6F55-A16E-AB47-148E418071EE","_rev":"2-c263c9e9cf93e6d7b98f445b0d800809","_deleted":true,"_revisions":{"start":2,"ids":["c263c9e9cf93e6d7b98f445b0d800809","66c46fd3db8b057d58a35aba6ca99a5a"]}},{"_id":"patient_2_E54A8685-A36F-D1D1-B938-080545EABD0E","_rev":"2-a53992302cf7a33bad522d2dc5835b6e","_deleted":true,"_revisions":{"start":2,"ids":["a53992302cf7a33bad522d2dc5835b6e","5cebaf4e3ffef745a70ef22a1be1f0e8"]}},{"_id":"patient_2_E5EF1B7A-51B7-1610-BFBA-B1B21365C574","_rev":"2-182384c7dc0a26973583a692bfecbce8","_deleted":true,"_revisions":{"start":2,"ids":["182384c7dc0a26973583a692bfecbce8","497eb6ebf5074eeb32e2c02aab754a18"]}},{"_id":"patient_2_F3AA5446-1DE5-AC50-B9CF-B0D491E1D45E","_rev":"2-036325f33884580d2785dadf44527e25","_deleted":true,"_revisions":{"start":2,"ids":["036325f33884580d2785dadf44527e25","9eb866d5ca50209aec98d96470acce98"]}},{"_id":"photo_2_CF5189F1-5BDA-6896-B350-6A1A9B6A217B","_rev":"3-82a9b8e6b9f827259083f9bc560d9ee6","_deleted":true,"_revisions":{"start":3,"ids":["82a9b8e6b9f827259083f9bc560d9ee6","ee9b1e0283b24f4a02b00f92ed70f0ab","5ee18d0589c4ac578fe4e8a5350f725b"]}},{"_id":"photo_2_D2B805B1-8F22-B5D2-956B-AFF6372D18FF","_rev":"3-734e1f5956d3d438f8ba6e187aa4d97f","_deleted":true,"_revisions":{"start":3,"ids":["734e1f5956d3d438f8ba6e187aa4d97f","f574559c84a634ca88d1d10d41c93953","112ad019aa78ef8e06584c9109a9a850"]}},{"_id":"pricing_2_22208FBE-9C6E-079D-A1E6-A562F9310FE5","_rev":"1-7f1b8398ae5dbed5782085efbfdf5ee8","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T09:39:37.879Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T09:39:37.879Z","category":"2015-10-15T09:39:37.879Z","pricingType":"2015-10-15T09:39:37.879Z"},"pricingOverrides":[]}},{"_id":"pricing_2_4CEB69E7-B54A-9D45-B0EF-7643F0D48FA0","_rev":"1-866a210b1d9063493c97d580845fc13d","data":{"category":"Imaging","expenseAccount":null,"name":"New","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-15T10:37:57.867Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-15T10:37:57.867Z","category":"2015-10-15T10:37:57.867Z","pricingType":"2015-10-15T10:37:57.867Z"},"pricingOverrides":[]}},{"_id":"pricing_2_5AB262C7-719D-19A6-ADC8-06CBA3088FA8","_rev":"1-428c4aeffee433314c955d75e831332b","data":{"category":"Lab","expenseAccount":null,"name":"Chest","price":null,"pricingType":"Lab Procedure","lastModified":"2015-11-03T14:39:16.623Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-11-03T14:39:16.623Z","category":"2015-11-03T14:39:16.623Z","pricingType":"2015-11-03T14:39:16.623Z"},"pricingOverrides":[]}},{"_id":"pricing_2_B492AA26-22F2-52A9-93C7-17106A57A62E","_rev":"1-a03187de833a34d46302b5a740244353","data":{"category":"Imaging","expenseAccount":null,"name":"fghj","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-22T07:08:38.099Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-22T07:08:38.099Z","category":"2015-10-22T07:08:38.099Z","pricingType":"2015-10-22T07:08:38.099Z"},"pricingOverrides":[]}},{"_id":"pricing_2_C8826ADA-C3AC-37CD-84AE-FA86A203AC6E","_rev":"1-fcefadf7300a60430090a0b91df95cce","data":{"category":"Imaging","expenseAccount":null,"name":"dfghn","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:27:44.358Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:27:44.358Z","category":"2015-10-28T07:27:44.358Z","pricingType":"2015-10-28T07:27:44.358Z"},"pricingOverrides":[]}},{"_id":"pricing_2_CBB4C9D5-CE8C-2BB5-86F4-3FC16AE2E85D","_rev":"1-a34a6a2d89ae9d5cd57f532f8db1b02f","data":{"category":"Imaging","expenseAccount":null,"name":"hg","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-26T11:49:08.235Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-26T11:49:08.235Z","category":"2015-10-26T11:49:08.235Z","pricingType":"2015-10-26T11:49:08.235Z"},"pricingOverrides":[]}},{"_id":"pricing_2_E53305F3-BA40-B305-B2DC-0732C7AB0042","_rev":"1-5b2724a6d2dce84919a16388a8983a49","data":{"category":"Imaging","expenseAccount":null,"name":"Scan","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:23:34.851Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:23:34.851Z","category":"2015-10-28T07:23:34.851Z","pricingType":"2015-10-28T07:23:34.851Z"},"pricingOverrides":[]}},{"_id":"pricing_2_F51616AE-EB96-2778-824F-386DEAFFD2F9","_rev":"1-13d626d1730a99b3da4dee1a25146ddd","data":{"category":"Imaging","expenseAccount":null,"name":"sss","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-10-28T07:31:20.903Z","modifiedBy":"hradmin","modifiedFields":{"name":"2015-10-28T07:31:20.903Z","category":"2015-10-28T07:31:20.903Z","pricingType":"2015-10-28T07:31:20.903Z"},"pricingOverrides":[]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_patient","_rev":"130-943328c138b701637a579574f516e90b","data":{"prefix":null,"value":130},"_revisions":{"start":130,"ids":["943328c138b701637a579574f516e90b","b527a87cb4f86205dcc62a9ea0fa7a63","973262d1b9be91e82f997cf103481c55","44582fef141bcd8b558595514d3ba0ff","4a8d8f8ca25aa960aef16e5c1e489b81","2a48a9bc803b0d60b5018c07017aedeb","fe6186b5bd38fce211c0dc76ef4a619b","4d41059d2cd8accf225fce92edbbc428","449ad29c390c73126670290e2a351dce","ef33fac6f75c92df977deadcefd2ea21","bde0d0a9a34c662a05458f1d379c6038","4e2b60d439b5001f0562aaa5e836de72","9b7cf30a3a428b0ffbc5c08469b60dc4","fdfa70107c954a955eddc00f1710a412","acb0081b558f7dfc06520ce59abdca9d","b611e8c2f6823f040262e4e983aa8b3e","803c06167d785dca413153687432b9da","e2c71646996df37f91cabb3881395db4","e07b6a9914e89ef9b68e6412801e47db","5c4e63e3ec27823d46d7048c34f1035c","85c90147d202a4eb1a047e2633fdc911","e7dae8e43e473a4b347f5c22161844b4","471182bdd694919456395e3b8ee81d85","c45ce9b872e266344359c0637f9dd5d0","962ad8bf64b30813c4fef6958e83e3f3","5b281c4ea003d026419d35d05dd0b87a","9ed77096845040620cd2354c1ed74001","409143da04d5575669e515f6214f6220","c35ff5c786890aa0005b360749cefdd2","48cba21a512868f2c8e3beb5646ff1c1","58fcaf249567f43db62a1c77a1440b8e","71c619fe66ac2a2246708c6733e7af9e","0e2a21c17d44457443a58dd2db6824fb","7449d0f1ba104902ca08b888dfdc546f","20f7d87b7b4a5326bb93f84c11ae627d","bef379849a35ec5a7408f26a83026e2b","5dd124839c582c23e9279eda6f821796","15a041f1e149ae2989eba580b93969b0","93e7694e1741666512f83bd1bd5064f3","002edd9949b2993af6ce18817d0bc666","a8795752b4a5c9e587d5bbbd05ef41d4","c6f60912813f86724b49110221b713fe","728c2adfea6754b048f7acae42edd25f","b1ddbe8c27e77a561d22fec546349409","923830cdb237b3ba2088779642bca716","85f7e7891658b988333439ee84dfcd39","a52f2c92c951c2c7266a9ad170d3ae9d","79cfca9fdd7b6cdae2396862f103599e","87221151cfb4cb5bbdf73eb694a7eb34","f1c5faf2bc8f82ec5a29071b6156e5e2","84612c5298273469c586955ee8427555","cc81c865b33cf6d967bde9ff60b9af6d","8b16de2d23b9c7e216215085a08caea8","8be1c3c951d7c2355f910f785cac2534","696488469a9aa721643875029f6de938","04ffb420af095d229c45a69d0e1c56c2","f8fc0538d0eacb22a767c9eb449f4c84","6adb4264d4dd3b13829ffc7e17ba58c2","f50856bf682db17eee3d3cafb366a6be","743e61dcfce262c16251ed396ee76eb7","4fcdf09a763ec5da89d41dab6dd9edc8","912874972749c40ea838145828c14173","fd8c5a0d7662b27c8cbdfbfdd45ee32d","173fe5c207973de53fd984078bbd73a2","4e9ef14c62f9312cd0fb1b47e7fabe1e","ce6f1f9584656970cfd92f1e361e2fed","cf8cf83cf02c266b75af0bc69467a07f","5816c2ba418d387facd7b6ed0a0e6054","b3839c763f128f2ccf99cfb874a2413e","68b05605500c0109d046a56680a5a7a1","a13d320fed2c85ed0b173d6645ec0274","ba1dad02a90e4ac18632c1a53a90b759","c5e7e81e97d0fc7d0797bd9822685176","b580fcf4f4291b408f4dda64a4bdec96","bb1a562af157e3c24d23c3e2f1171b29","e9f245d9566dd9e116caf7d074792d36","30b587f2b5204d237572c86a545756fb","7df53a1742b52647118fec21f331e94d","0a4c120f78fa5899d0cea5d87d92c9b0","e62f1b02721a75fd1ea290da9acdc199","3e39b429ea4cda00c9ac9d3f0b61029c","038d82911c8979c0cd58e807871a09ca","618d916a14cfa55aa8e65d42b3761ca5","8d24a6b355e64a680f0f03ab0f738b8c","999e1fa6e5175dad02e4f2db0cd41843","782e7a1c4097f1aa1d117a7fbd01c443","67b3c03ea8609652c494a22242ce5a1f","3b1fc1b83a352ef9c672110a69306064","8a0da1966531daede44592906bf8df99","279e844131c96ca7b647cacfa3508022","42733f5f658de7ee440c02286fd4e21c","e3a50044a3cb2ac901b5b65653d0fc7f","b7fb5627bee7f642f8e608be1bb1e859","2fdb16832a0ed61b7f9e780750b70898","e38f4adbab987a8c628599ea9052ca44","7ece3f9fcff7b57b28f1237ba1107a0f","8fb6c171e3c6a345d199a8884e42951a","c76709145ca58dfcf67c1f397b772689","76182e657f0b0aa6fa07bf5491d2b427","ab161b88c332f3df338f1f4aa2b2e307","e00a3184b07c0459cf4ebdeb825f991f","cee6a3aac677927abaf3ae61508954a2","86bed2b62e1e6b6f98790ecafefcc17f","ae44899fdbc41d69076ec6a8f7563181","61cce97f5cd6ff092f28fe9ec9da4f27","f9008b952322c32322ef0e7e42fdf383","8fdecd159563a90d7cbc9c9aedc3068f","9b1f0f8f0e4db1f8931d290966f3bc3c","a9b5402ea07343a1b6d5612312e07a34","25ef3d2573778c3ebda4ef7860fe310f","3e39e8d6ceabb2079042e81613858906","b4e15c555737aa9573724407ce84b667","b2538362e8afb57e3e11e5231ae60d5d","04add3d3926f54232b0e0ed7a9fc141a","e924dcf4bb51c7c552538273e08901bb","77b6f226033c656d3a9768085ff3e80a","676dd4835b46e8f62ec2ce5908d1c60a","762481b2c71611cce80a5a9ef03aa48d","b9b73bf1d2df1598cc164089375ed7bc","0a581f677e6d8f7a484fa0a80156d95b","6b51cfdb83336973df284e4d5c2f308b","4a27247e93fabb86b6a5a9676f47ec8e","8b542908965798dd683a68f507635a83","515d8987a1e11acb866ede87612b53b1","d19e3759adc65398cf6a42a61345cdae","ac63c129bee25dc4c59a639e2721fb81","17c1209032c06df436ad0a4fa76723cc","f0ef6923c78e739d9228517a4813b646","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_0312A352-EF8B-C1A2-B9DF-3EC932C96AD8","_rev":"2-8eb7818cb7b808ea467b2e60f0a6a5e2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Discharged","visitType":"Admission","lastModified":"2015-11-03T07:43:21.662Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:15.853Z","startDate":"2015-11-03T07:31:15.853Z","status":"2015-11-03T07:43:21.662Z","outPatient":"2015-11-03T07:31:15.853Z","endDate":"2015-11-03T07:43:21.662Z","location":"2015-11-03T07:31:15.853Z","examiner":"2015-11-03T07:31:15.853Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8eb7818cb7b808ea467b2e60f0a6a5e2","3036466a87ec0a9967be1433386b0bdc"]}},{"_id":"visit_2_07AF1E0E-3CB2-3837-990C-968158E25235","_rev":"1-ce894ba889d506531e4cb2a36394cab4","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:16.594Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:16.594Z","startDate":"2015-11-03T07:46:16.594Z","status":"2015-11-03T07:46:16.594Z","outPatient":"2015-11-03T07:46:16.594Z","endDate":"2015-11-03T07:46:16.594Z","location":"2015-11-03T07:46:16.594Z","examiner":"2015-11-03T07:46:16.594Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0B84AF59-A182-5840-9E7A-CEF7633D4071","_rev":"1-ce3b40be34d77ec1d9c29ccb99a7e905","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:37:46.164Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:37:46.164Z","startDate":"2015-11-03T07:37:46.164Z","status":"2015-11-03T07:37:46.164Z","outPatient":"2015-11-03T07:37:46.164Z","endDate":"2015-11-03T07:37:46.164Z","location":"2015-11-03T07:37:46.164Z","examiner":"2015-11-03T07:37:46.164Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_0BD42BD9-0E5D-0533-A8FA-1C0ADB0F0D65","_rev":"2-0ddd43cbcc57cc5d6ff082a283d881ac","data":{"dischargeInfo":null,"endDate":"2015-10-15T10:37:57.902Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T10:37:57.902Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T10:37:57.915Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T10:37:57.915Z","endDate":"2015-10-15T10:37:57.915Z","outPatient":"2015-10-15T10:37:57.915Z","visitType":"2015-10-15T10:37:57.915Z"},"charges":[],"imaging":["1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["0ddd43cbcc57cc5d6ff082a283d881ac","e4540f9cf2a236335662116d4e0a66da"]}},{"_id":"visit_2_13340816-9F02-846D-85C3-C3278561BA23","_rev":"1-6ce02a99e4868c5a5bdb88a23f9ff400","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:24:20.451Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:24:20.451Z","startDate":"2015-11-03T07:24:20.451Z","status":"2015-11-03T07:24:20.451Z","outPatient":"2015-11-03T07:24:20.451Z","endDate":"2015-11-03T07:24:20.451Z","location":"2015-11-03T07:24:20.451Z","examiner":"2015-11-03T07:24:20.451Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_15759FA2-6691-6EF3-9636-21570F400F04","_rev":"1-d28274492b5b3cd306c3d38e535388a7","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:38:17.049Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:38:17.049Z","startDate":"2015-11-03T07:38:17.049Z","status":"2015-11-03T07:38:17.049Z","outPatient":"2015-11-03T07:38:17.049Z","endDate":"2015-11-03T07:38:17.049Z","location":"2015-11-03T07:38:17.049Z","examiner":"2015-11-03T07:38:17.049Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_17AB2BCF-5F9F-30FB-8B80-9FB82E51D0B3","_rev":"1-bc13c64ebb47144840cc91ce3087ebd6","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:03.461Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:03.461Z","startDate":"2015-11-03T07:23:03.461Z","status":"2015-11-03T07:23:03.461Z","outPatient":"2015-11-03T07:23:03.461Z","endDate":"2015-11-03T07:23:03.461Z","location":"2015-11-03T07:23:03.461Z","examiner":"2015-11-03T07:23:03.461Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1800A65C-861C-CCA5-85C5-16950322C7E0","_rev":"1-a67e8d8a018844ef176184947055b683","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:40:08.177Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:40:08.177Z","startDate":"2015-11-03T07:40:08.177Z","status":"2015-11-03T07:40:08.177Z","outPatient":"2015-11-03T07:40:08.177Z","endDate":"2015-11-03T07:40:08.177Z","location":"2015-11-03T07:40:08.177Z","examiner":"2015-11-03T07:40:08.177Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_1EBA7E42-F96D-C5E2-923C-2F842FDFE714","_rev":"1-8fd6cfa23288f7394ce94970c4b3a8c2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:45.676Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:45.676Z","startDate":"2015-11-03T07:19:45.676Z","status":"2015-11-03T07:19:45.676Z","outPatient":"2015-11-03T07:19:45.676Z","endDate":"2015-11-03T07:19:45.676Z","location":"2015-11-03T07:19:45.676Z","examiner":"2015-11-03T07:19:45.676Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_2D795EA3-DAEF-AA15-8846-607A873AD1AF","_rev":"1-4c665c9221069fe72f9d66ac458e92df","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:28:51.490Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:28:51.490Z","startDate":"2015-11-03T07:28:51.490Z","status":"2015-11-03T07:28:51.490Z","outPatient":"2015-11-03T07:28:51.490Z","endDate":"2015-11-03T07:28:51.490Z","location":"2015-11-03T07:28:51.490Z","examiner":"2015-11-03T07:28:51.490Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_377AA288-AAD4-F60B-ABD1-B5A0B9C75D50","_rev":"2-ee5b0686e20e1011d11b3051b93e7a93","data":{"dischargeInfo":null,"endDate":"2015-10-15T09:39:37.940Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-15T09:39:37.940Z","status":null,"visitType":"Imaging","lastModified":"2015-10-15T09:39:37.948Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-15T09:39:37.948Z","endDate":"2015-10-15T09:39:37.948Z","outPatient":"2015-10-15T09:39:37.948Z","visitType":"2015-10-15T09:39:37.948Z"},"charges":[],"imaging":["07CC6746-C7D9-A410-9B8C-C4B4E095A96D"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["ee5b0686e20e1011d11b3051b93e7a93","5fee255cf57220ddf1c19977118a540e"]}},{"_id":"visit_2_3A8FE46D-2CE6-C74E-98BB-ECFECB8F4AB9","_rev":"1-4c2559b35790501b6fae26a031a59cad","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:11.759Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:11.759Z","startDate":"2015-11-03T07:42:11.759Z","status":"2015-11-03T07:42:11.759Z","outPatient":"2015-11-03T07:42:11.759Z","endDate":"2015-11-03T07:42:11.759Z","location":"2015-11-03T07:42:11.759Z","examiner":"2015-11-03T07:42:11.759Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_50FD1C68-0889-0867-99D1-CFFDB3223154","_rev":"1-85d776e0088793e80073525cf6b7a501","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:47:59.399Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:47:59.399Z","startDate":"2015-11-03T07:47:59.399Z","status":"2015-11-03T07:47:59.399Z","outPatient":"2015-11-03T07:47:59.399Z","endDate":"2015-11-03T07:47:59.399Z","location":"2015-11-03T07:47:59.399Z","examiner":"2015-11-03T07:47:59.399Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5108DC53-4E2D-53C8-A506-E55E554A3643","_rev":"2-884c940bde0d28898a94bb3d118fe89f","data":{"dischargeInfo":null,"endDate":"2015-11-09T10:09:25.619Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-09T10:09:25.619Z","status":null,"visitType":"Pharmacy","lastModified":"2015-11-09T10:09:25.628Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-09T10:09:25.628Z","endDate":"2015-11-09T10:09:25.628Z","outPatient":"2015-11-09T10:09:25.628Z","visitType":"2015-11-09T10:09:25.628Z"},"charges":[],"imaging":[],"labs":[],"medication":["35DC84B9-C25B-4C83-A287-D1DEC2FC6028"],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["884c940bde0d28898a94bb3d118fe89f","d84c4b4dda04554d6e41ca7e6368cc3d"]}}]} +{"seq":124} +{"docs":[{"_id":"visit_2_53E986EB-4C23-9B3B-B8D7-2C7A7ECDBC33","_rev":"1-fb5ce8d11793c3da21e06d1f88e48d00","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:23:24.134Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:23:24.134Z","startDate":"2015-11-03T07:23:24.134Z","status":"2015-11-03T07:23:24.134Z","outPatient":"2015-11-03T07:23:24.134Z","endDate":"2015-11-03T07:23:24.134Z","location":"2015-11-03T07:23:24.134Z","examiner":"2015-11-03T07:23:24.134Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_542BB0F0-27BB-7C5C-99BC-28B013DDB837","_rev":"1-6e3af7515e9b2d7fbcec6264b9194a17","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:32:40.937Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:32:40.937Z","startDate":"2015-11-03T07:32:40.937Z","status":"2015-11-03T07:32:40.937Z","outPatient":"2015-11-03T07:32:40.937Z","endDate":"2015-11-03T07:32:40.937Z","location":"2015-11-03T07:32:40.937Z","examiner":"2015-11-03T07:32:40.937Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_560E25D9-9736-BA05-B2A6-4555A93B2628","_rev":"2-04c2d6343f6d2a10ad1f891718cecab5","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:08:13.698Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:08:13.698Z","startDate":"2015-11-03T07:08:13.698Z","status":"2015-11-03T07:08:13.698Z","outPatient":"2015-11-03T07:08:13.698Z","endDate":"2015-11-03T07:08:13.698Z","location":"2015-11-03T07:08:13.698Z","examiner":"2015-11-03T07:08:13.698Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["04c2d6343f6d2a10ad1f891718cecab5","6bbe45974af0b60410ea29026a38e2ec"]}},{"_id":"visit_2_59F8FB60-9956-E93F-826D-11618BC95E13","_rev":"1-8489694a221cd2c43e7c39fdcaa89700","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:41:35.597Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:41:35.597Z","startDate":"2015-11-03T07:41:35.597Z","status":"2015-11-03T07:41:35.597Z","outPatient":"2015-11-03T07:41:35.597Z","endDate":"2015-11-03T07:41:35.597Z","location":"2015-11-03T07:41:35.597Z","examiner":"2015-11-03T07:41:35.597Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_5F404B11-D8B6-CE18-9557-2B563BCFD2F8","_rev":"1-2637dc1d6c95364743de0c97c7fb443d","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:34:38.929Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:34:38.929Z","startDate":"2015-11-03T07:34:38.929Z","status":"2015-11-03T07:34:38.929Z","outPatient":"2015-11-03T07:34:38.929Z","endDate":"2015-11-03T07:34:38.929Z","location":"2015-11-03T07:34:38.929Z","examiner":"2015-11-03T07:34:38.929Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_6AD00ED1-670A-2C3F-BC10-0742B1F99264","_rev":"2-9bf9856192b6c8ef34d2fcdb27296593","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:39:18.257Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:39:18.257Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:39:18.275Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:39:18.275Z","endDate":"2015-10-28T07:39:18.275Z","outPatient":"2015-10-28T07:39:18.275Z","visitType":"2015-10-28T07:39:18.275Z"},"charges":[],"imaging":["91B061E9-2986-D539-90C8-CD14EC2010B0"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["9bf9856192b6c8ef34d2fcdb27296593","e50477b58f5edd257b9ce20ea65b1bca"]}},{"_id":"visit_2_6D126583-2852-25C2-A352-E5BA4CBBD106","_rev":"1-222d722266f5d407204eb411f68ab4f0","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:20:56.778Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:20:56.778Z","startDate":"2015-11-03T07:20:56.778Z","status":"2015-11-03T07:20:56.778Z","outPatient":"2015-11-03T07:20:56.778Z","endDate":"2015-11-03T07:20:56.778Z","location":"2015-11-03T07:20:56.778Z","examiner":"2015-11-03T07:20:56.778Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_74A4EF68-5D8D-BDF6-940F-33E50E50DDEA","_rev":"2-c24a52b04610b293fff293b18dd0bb15","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:27:44.394Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:27:44.394Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:27:44.406Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:27:44.406Z","endDate":"2015-10-28T07:27:44.406Z","outPatient":"2015-10-28T07:27:44.406Z","visitType":"2015-10-28T07:27:44.406Z"},"charges":[],"imaging":["EA6B989C-90B7-2E08-9D8F-CE4339BB9B4B"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["c24a52b04610b293fff293b18dd0bb15","5a6ae8f033eb99448ad898f164d822e8"]}},{"_id":"visit_2_7916D533-54AE-55EB-8DE7-E4B83A4BBAB2","_rev":"1-269d23778ac6f89244ff93d17c73352c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:45.358Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:45.358Z","startDate":"2015-11-03T07:46:45.358Z","status":"2015-11-03T07:46:45.358Z","outPatient":"2015-11-03T07:46:45.358Z","endDate":"2015-11-03T07:46:45.358Z","location":"2015-11-03T07:46:45.358Z","examiner":"2015-11-03T07:46:45.358Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_817CE5FB-FF79-B05D-8296-2FCE91B125CD","_rev":"1-410079742e88e59e0598107fd9ef40c1","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:33:16.393Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:33:16.393Z","startDate":"2015-11-03T07:33:16.393Z","status":"2015-11-03T07:33:16.393Z","outPatient":"2015-11-03T07:33:16.393Z","endDate":"2015-11-03T07:33:16.393Z","location":"2015-11-03T07:33:16.393Z","examiner":"2015-11-03T07:33:16.393Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_90FCADB8-7109-3906-94A3-269F29CFAB69","_rev":"1-7a8189c07dde6b9bf498545cdaa3e621","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:31:49.176Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:31:49.176Z","startDate":"2015-11-03T07:31:49.176Z","status":"2015-11-03T07:31:49.176Z","outPatient":"2015-11-03T07:31:49.176Z","endDate":"2015-11-03T07:31:49.176Z","location":"2015-11-03T07:31:49.176Z","examiner":"2015-11-03T07:31:49.176Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9C962DF7-E239-966B-A47B-15F405899B62","_rev":"1-d5bc412bfa629333e6cd79c978ea8218","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:25:27.802Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:25:27.802Z","startDate":"2015-11-03T07:25:27.802Z","status":"2015-11-03T07:25:27.802Z","outPatient":"2015-11-03T07:25:27.802Z","endDate":"2015-11-03T07:25:27.802Z","location":"2015-11-03T07:25:27.802Z","examiner":"2015-11-03T07:25:27.802Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9E627361-BA73-210A-8E76-2FA13B559DB9","_rev":"1-30a87dbc678b99d42b1a90bebff97834","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:21:48.053Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:21:48.053Z","startDate":"2015-11-03T07:21:48.053Z","status":"2015-11-03T07:21:48.053Z","outPatient":"2015-11-03T07:21:48.053Z","endDate":"2015-11-03T07:21:48.053Z","location":"2015-11-03T07:21:48.053Z","examiner":"2015-11-03T07:21:48.053Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_9F1A65ED-683F-056E-8D50-A8AF63201CE2","_rev":"2-e19734a8deff62722e6e023af4b8e130","data":{"dischargeInfo":null,"endDate":"2015-10-22T07:08:38.175Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-22T07:08:38.175Z","status":null,"visitType":"Imaging","lastModified":"2015-10-22T07:08:38.189Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-22T07:08:38.189Z","endDate":"2015-10-22T07:08:38.189Z","outPatient":"2015-10-22T07:08:38.189Z","visitType":"2015-10-22T07:08:38.189Z"},"charges":[],"imaging":["D0F299E4-CD8D-557D-8C23-216FD23EF844"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["e19734a8deff62722e6e023af4b8e130","bd81a41820526c8c0450ee544867c6fa"]}},{"_id":"visit_2_A6E37F8D-F740-8B01-93C9-D476A886E030","_rev":"1-d094eb56a680b4a8a6a354bd48d6bfe2","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:42:53.782Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:42:53.782Z","startDate":"2015-11-03T07:42:53.782Z","status":"2015-11-03T07:42:53.782Z","outPatient":"2015-11-03T07:42:53.782Z","endDate":"2015-11-03T07:42:53.782Z","location":"2015-11-03T07:42:53.782Z","examiner":"2015-11-03T07:42:53.782Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_AAB85ADA-7058-DF7A-9244-C6B60A2EF743","_rev":"1-1bd78b61646023aacce18b1efaa27646","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:39:09.272Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:39:09.272Z","startDate":"2015-11-03T07:39:09.272Z","status":"2015-11-03T07:39:09.272Z","outPatient":"2015-11-03T07:39:09.272Z","endDate":"2015-11-03T07:39:09.272Z","location":"2015-11-03T07:39:09.272Z","examiner":"2015-11-03T07:39:09.272Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C15054D2-D062-DB01-A96D-80ED1B8F8CBD","_rev":"1-5a9a0e7eafe911586556666ad1a2bd27","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:46:09.735Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:46:09.735Z","startDate":"2015-11-03T07:46:09.735Z","status":"2015-11-03T07:46:09.735Z","outPatient":"2015-11-03T07:46:09.735Z","endDate":"2015-11-03T07:46:09.735Z","location":"2015-11-03T07:46:09.735Z","examiner":"2015-11-03T07:46:09.735Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_C5C296AC-E238-CBA5-8DD8-99942843BC5A","_rev":"2-57e6740d8dac593d790cd7f76c4ad0c3","data":{"dischargeInfo":null,"endDate":"2015-10-26T11:49:08.277Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-26T11:49:08.277Z","status":null,"visitType":"Imaging","lastModified":"2015-10-26T11:49:08.282Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-26T11:49:08.282Z","endDate":"2015-10-26T11:49:08.282Z","outPatient":"2015-10-26T11:49:08.282Z","visitType":"2015-10-26T11:49:08.282Z"},"charges":[],"imaging":["4A7FC838-0B37-E151-AFD8-8DBAC9DE9D99"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["57e6740d8dac593d790cd7f76c4ad0c3","253e8d9f8c0865cb3e9ffd1f6849bcde"]}},{"_id":"visit_2_CBFA5C2C-191D-FC9C-AD19-14D26D5A3003","_rev":"2-f781f118fd87b036d8cbfbf7771cda99","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:23:34.906Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:23:34.906Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:23:34.914Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:23:34.914Z","endDate":"2015-10-28T07:23:34.914Z","outPatient":"2015-10-28T07:23:34.914Z","visitType":"2015-10-28T07:23:34.914Z"},"charges":[],"imaging":["51D8DC28-78EB-62B1-942A-1158F5862F34"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["f781f118fd87b036d8cbfbf7771cda99","e2b8bf1f76ea01c32b414c184905511e"]}},{"_id":"visit_2_D6938BD3-6346-F62B-8B19-5207B2E5A6AF","_rev":"2-631f62b5121ccfcd1a8de2bc9d3d252f","data":{"dischargeInfo":null,"endDate":"2015-10-28T07:31:20.941Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-10-28T07:31:20.941Z","status":null,"visitType":"Imaging","lastModified":"2015-10-28T07:31:20.953Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-10-28T07:31:20.953Z","endDate":"2015-10-28T07:31:20.953Z","outPatient":"2015-10-28T07:31:20.953Z","visitType":"2015-10-28T07:31:20.953Z"},"charges":[],"imaging":["DBE152F6-9508-2E12-81AC-39BC2CAFE08C"],"labs":[],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["631f62b5121ccfcd1a8de2bc9d3d252f","8b46887d52e3043d742262fc03ff48b8"]}},{"_id":"visit_2_D845EA6E-C4CD-3657-A6F6-3E40FE02B069","_rev":"1-16657f6b4014bf268d63323ed8832a56","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:50:55.344Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:50:55.344Z","startDate":"2015-11-03T07:50:55.344Z","status":"2015-11-03T07:50:55.344Z","outPatient":"2015-11-03T07:50:55.344Z","endDate":"2015-11-03T07:50:55.344Z","location":"2015-11-03T07:50:55.344Z","examiner":"2015-11-03T07:50:55.344Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_DA661CAB-1BB5-3119-B9DD-0A92D7C3913B","_rev":"1-ecb23bc4c60a32dd627969637f85d1fb","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:19:15.689Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:19:15.689Z","startDate":"2015-11-03T07:19:15.689Z","status":"2015-11-03T07:19:15.689Z","outPatient":"2015-11-03T07:19:15.689Z","endDate":"2015-11-03T07:19:15.689Z","location":"2015-11-03T07:19:15.689Z","examiner":"2015-11-03T07:19:15.689Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E66983BC-BFB9-E361-A59F-AAC966A0FD3B","_rev":"1-8d0f4af9593120f2dfd0371303239e2b","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:15:24.456Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:15:24.456Z","startDate":"2015-11-03T07:15:24.456Z","status":"2015-11-03T07:15:24.456Z","outPatient":"2015-11-03T07:15:24.456Z","endDate":"2015-11-03T07:15:24.456Z","location":"2015-11-03T07:15:24.456Z","examiner":"2015-11-03T07:15:24.456Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E8E7BD06-13EB-AA68-BBE2-51B9EEE85257","_rev":"1-c54a6aea31c6c3805edc706b4ed64d40","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:30:31.501Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:30:31.501Z","startDate":"2015-11-03T07:30:31.501Z","status":"2015-11-03T07:30:31.501Z","outPatient":"2015-11-03T07:30:31.501Z","endDate":"2015-11-03T07:30:31.501Z","location":"2015-11-03T07:30:31.501Z","examiner":"2015-11-03T07:30:31.501Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_E90C9A07-74D2-0589-8DDC-C94B09E0F238","_rev":"1-7a3d4f0d4056960dabad849d1da9bd7c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:22:15.702Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:22:15.702Z","startDate":"2015-11-03T07:22:15.702Z","status":"2015-11-03T07:22:15.702Z","outPatient":"2015-11-03T07:22:15.702Z","endDate":"2015-11-03T07:22:15.702Z","location":"2015-11-03T07:22:15.702Z","examiner":"2015-11-03T07:22:15.702Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_EC9C09F9-676F-AD32-AB61-DDAD615F2632","_rev":"2-8ce10f08748bebcd2df0267258ec2433","data":{"dischargeInfo":null,"endDate":"2015-11-03T14:39:16.671Z","examiner":null,"history":null,"historySince":null,"location":null,"notes":null,"outPatient":true,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-03T14:39:16.671Z","status":null,"visitType":"Lab","lastModified":"2015-11-03T14:39:16.679Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"startDate":"2015-11-03T14:39:16.679Z","endDate":"2015-11-03T14:39:16.679Z","outPatient":"2015-11-03T14:39:16.679Z","visitType":"2015-11-03T14:39:16.679Z"},"charges":[],"imaging":[],"labs":["8F1C615D-8E59-5090-BC4A-BFA41C57FABE"],"medication":[],"procedures":[],"vitals":[]},"_revisions":{"start":2,"ids":["8ce10f08748bebcd2df0267258ec2433","4a113155a529e6200ba18813cd922ad0"]}},{"_id":"visit_2_EF0D793D-346D-242A-8F4D-589448DA49A6","_rev":"1-413ff66d683c532d2be4cfa04632343c","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:26:35.010Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:26:35.010Z","startDate":"2015-11-03T07:26:35.010Z","status":"2015-11-03T07:26:35.010Z","outPatient":"2015-11-03T07:26:35.010Z","endDate":"2015-11-03T07:26:35.010Z","location":"2015-11-03T07:26:35.010Z","examiner":"2015-11-03T07:26:35.010Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}},{"_id":"visit_2_F9D51E3F-E938-1F24-9B19-D76F03E56892","_rev":"1-9e4fb077c716ccd6b149953e4c005aae","data":{"dischargeInfo":null,"endDate":"2015-11-02T22:00:00.000Z","examiner":"Dr Test","history":null,"historySince":null,"location":"Harare","notes":null,"outPatient":false,"primaryDiagnosis":null,"primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-11-02T22:00:00.000Z","status":"Admitted","visitType":"Admission","lastModified":"2015-11-03T07:17:22.667Z","modifiedBy":"hradmin","patient":"B4D3E9EE-6EC0-6F1E-A397-87D9A8F8C13D","modifiedFields":{"visitType":"2015-11-03T07:17:22.667Z","startDate":"2015-11-03T07:17:22.667Z","status":"2015-11-03T07:17:22.667Z","outPatient":"2015-11-03T07:17:22.667Z","endDate":"2015-11-03T07:17:22.667Z","location":"2015-11-03T07:17:22.667Z","examiner":"2015-11-03T07:17:22.667Z"},"charges":[],"imaging":[],"labs":[],"medication":[],"procedures":[],"vitals":[]}}]} +{"seq":152} diff --git a/tests/fixtures/operative.txt b/tests/fixtures/operative.txt new file mode 100644 index 0000000000..9f6a10269c --- /dev/null +++ b/tests/fixtures/operative.txt @@ -0,0 +1,7 @@ +{"version":"1.2.5","db_type":"http","start_time":"2017-03-13T17:54:42.738Z","db_info":{"db_name":"main","doc_count":33,"doc_del_count":0,"update_seq":37,"purge_seq":0,"compact_running":false,"disk_size":98404,"data_size":22857,"instance_start_time":"1489427444801677","disk_format_version":6,"committed_update_seq":37,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} +{"seq":2} +{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}}}]} +{"seq":3} +{"docs":[{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}}},{"_id":"diagnosis_2_56dd3bf6-b39e-4778-b6dd-7f8673ad568e","_rev":"1-5fd319c5141754bf5e6c9cb172bb0d92","data":{"active":true,"date":"2017-03-13T04:00:00.000Z","diagnosis":"Tennis Elbow","secondaryDiagnosis":true,"archived":false,"lastModified":"2017-03-13T17:53:33.294Z","modifiedBy":"Admin User","modifiedFields":{"date":"2017-03-13T17:53:33.294Z","diagnosis":"2017-03-13T17:53:33.294Z","secondaryDiagnosis":"2017-03-13T17:53:33.294Z"}}},{"_id":"diagnosis_2_594cbc26-362a-4b8c-9072-7a01a8473a8f","_rev":"1-8d260e0152865090683362581f62ee1c","data":{"active":true,"date":"2017-03-13T04:00:00.000Z","diagnosis":"Broken Arm","secondaryDiagnosis":false,"archived":false,"lastModified":"2017-03-13T17:53:09.252Z","modifiedBy":"Admin User","modifiedFields":{"date":"2017-03-13T17:53:09.252Z","diagnosis":"2017-03-13T17:53:09.252Z"}}},{"_id":"patient_2_cd572865-dcc0-441e-a2ad-be400dc256da","_rev":"4-23a240576e87d23821b5364dc557a1dd","data":{"admitted":false,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"checkedIn":false,"customForms":{},"dateOfBirth":null,"economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","occupation":null,"history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":null,"archived":false,"lastModified":"2017-03-13T17:52:51.958Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"operativePlans":[],"operationReports":[],"diagnoses":["594cbc26-362a-4b8c-9072-7a01a8473a8f","56dd3bf6-b39e-4778-b6dd-7f8673ad568e"],"allergies":[],"modifiedFields":{"customForms":"2017-03-13T17:52:51.958Z","firstName":"2017-03-13T17:52:51.958Z","middleName":"2017-03-13T17:52:51.958Z","lastName":"2017-03-13T17:52:51.958Z","sex":"2017-03-13T17:52:51.958Z","friendlyId":"2017-03-13T17:52:51.958Z"}},"_revisions":{"start":4,"ids":["23a240576e87d23821b5364dc557a1dd","c5b245740fbcb79be7d7483cd86ec4b2","3f976abe4ecc5911b9dbfaf3099e4419","199c75172e78cce74f87350865b5560a"]}}]} +{"seq":37} diff --git a/tests/fixtures/patient.txt b/tests/fixtures/patient.txt index 5f0189873d..4d386f572a 100644 --- a/tests/fixtures/patient.txt +++ b/tests/fixtures/patient.txt @@ -1,9 +1,9 @@ -{"version":"1.2.5","db_type":"http","start_time":"2017-02-03T15:31:21.760Z","db_info":{"db_name":"main","doc_count":70,"doc_del_count":0,"update_seq":95,"purge_seq":0,"compact_running":false,"disk_size":127080,"data_size":70488,"instance_start_time":"1486135814322062","disk_format_version":6,"committed_update_seq":95,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} +{"version":"1.2.5","db_type":"http","start_time":"2017-03-06T21:58:32.630Z","db_info":{"db_name":"main","doc_count":75,"doc_del_count":0,"update_seq":99,"purge_seq":0,"compact_running":false,"disk_size":118888,"data_size":73539,"instance_start_time":"1488837425622719","disk_format_version":6,"committed_update_seq":99,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}} {"docs":[{"_id":"_design/custom_form_by_type","_rev":"1-ddf0ee75c1e8e859d821a9f5c1ec43b6","version":1,"views":{"custom_form_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'customForm') {\n emit(doc.data.formType);\n }\n }\n }"}}}]} -{"seq":3} -{"docs":[{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}}]} -{"seq":22} -{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-6f596cec9eb82609308fd9d25a9f9df2","version":4,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'gender':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_C47BE127-E509-6322-BB33-2E6ABE03D0F0","_rev":"2-44597ea8b1cdd20dc8d2c0ad9b2edbb6","data":{"allDay":true,"provider":"Dr Nick","location":"Hospital","appointmentType":"Followup","startDate":"2015-12-30T06:00:00.000Z","endDate":"2015-12-30T06:00:00.000Z","notes":null,"status":"Scheduled","lastModified":"2015-12-29T04:14:36.585Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","modifiedFields":{"appointmentType":"2015-12-29T04:14:21.124Z","allDay":"2015-12-29T04:14:21.124Z","startDate":"2015-12-29T04:14:36.585Z","endDate":"2015-12-29T04:14:36.585Z","location":"2015-12-29T04:14:21.124Z","provider":"2015-12-29T04:14:21.124Z"}},"_revisions":{"start":2,"ids":["44597ea8b1cdd20dc8d2c0ad9b2edbb6","953a11c67a694ef2daa469bd8c0f40ec"]}},{"_id":"imaging_2_12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7","_rev":"1-3237f1a60f7ef9869553893a25e91e87","data":{"imagingDate":null,"notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-12-29T04:15:41.380Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:15:41.382Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:15:41.382Z","status":"2015-12-29T04:15:41.382Z","requestedBy":"2015-12-29T04:15:41.382Z","requestedDate":"2015-12-29T04:15:41.382Z"}}},{"_id":"imaging_2_51AFF85A-69C0-97C1-B22C-716A1BA7B80B","_rev":"1-3e1a5d957291144f7ba1e9c0c7c2cb12","data":{"imagingDate":"2015-12-29T04:07:03.693Z","notes":null,"radiologist":"Dr Xray","requestedBy":"Admin User","requestedDate":"2015-12-29T04:07:03.694Z","result":null,"status":"Completed","lastModified":"2015-12-29T04:07:03.744Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:07:03.744Z","status":"2015-12-29T04:07:03.744Z","imagingDate":"2015-12-29T04:07:03.744Z","requestedBy":"2015-12-29T04:07:03.744Z","requestedDate":"2015-12-29T04:07:03.744Z"}}},{"_id":"invLocation_2_0323721B-EDD0-6C91-BB34-52FBEACBA7DE","_rev":"3-f43e02982eff2b35453b4dcf537fec3f","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:13:47.396Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:13:47.396Z"}},"_revisions":{"start":3,"ids":["f43e02982eff2b35453b4dcf537fec3f","e8c15241efd7bb6c8bf891c28558d83b","c2e397e9ebd1266da5de2e1a3033fcc6"]}},{"_id":"invLocation_2_24BB235E-B271-AF61-9A3D-9ACD77CE25AF","_rev":"3-b8964e3b548efa84d5602224e88a1126","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:08:57.289Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:08:57.289Z"}},"_revisions":{"start":3,"ids":["b8964e3b548efa84d5602224e88a1126","dff7e3f8434279a562a3d4ffc0106c6e","2d8c410350e7ecfffd6e496f6f05ca30"]}},{"_id":"invLocation_2_32BCC947-E272-1564-90E1-C6E2ECE14881","_rev":"2-74b9d0e13f10a766c8e02a411b21bc9e","data":{"quantity":12,"location":"Warehouse","aisleLocation":"A1","lastModified":"2015-12-29T03:47:25.988Z","modifiedBy":"Admin User","modifiedFields":{"aisleLocation":"2015-12-29T03:47:25.919Z","location":"2015-12-29T03:47:25.919Z","quantity":"2015-12-29T03:47:25.988Z"}},"_revisions":{"start":2,"ids":["74b9d0e13f10a766c8e02a411b21bc9e","8adc0c9f4543aebccdfce691b8c1199d"]}},{"_id":"invLocation_2_7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","_rev":"3-85e5ea976718b1331eade5d9f567654b","data":{"quantity":0,"location":"Warehouse","aisleLocation":null,"lastModified":"2015-12-29T03:46:41.557Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:13:47.288Z","quantity":"2015-12-29T03:46:41.557Z"}},"_revisions":{"start":3,"ids":["85e5ea976718b1331eade5d9f567654b","eb663365f6944558113da9820789b8fd","ac3af5754777c65209c3d9c7cc03dfb2"]}},{"_id":"invLocation_2_DBCF3E06-B812-B6C7-930E-74F9372D384A","_rev":"3-a15f0e36baae0abfa52ae68b42e3ad0e","data":{"quantity":999998,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-12-29T04:01:16.092Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:08:57.191Z","quantity":"2015-12-29T04:01:16.092Z"}},"_revisions":{"start":3,"ids":["a15f0e36baae0abfa52ae68b42e3ad0e","d365a641356ccd999cf5f91ec842f5a9","e8dfec40fbf6418583392d73b24a9b32"]}},{"_id":"invPurchase_2_05760051-8BD1-ACC0-8013-0C59A545FB8D","_rev":"2-d7477df9559ec794be0e3084f09c310b","data":{"purchaseCost":12,"lotNumber":"","dateReceived":"2015-11-01T05:00:00.000Z","originalQuantity":25,"currentQuantity":0,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T03:46:41.558Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:12:56.853Z","purchaseCost":"2015-12-29T03:12:56.853Z","lotNumber":"2015-12-29T03:12:56.853Z","vendor":"2015-12-29T03:12:56.853Z","vendorItemNo":"2015-12-29T03:12:56.853Z","originalQuantity":"2015-12-29T03:12:56.853Z","currentQuantity":"2015-12-29T03:46:41.558Z","inventoryItem":"2015-12-29T03:12:56.853Z"}},"_revisions":{"start":2,"ids":["d7477df9559ec794be0e3084f09c310b","2b41a3edbfe25818058eca69712b2033"]}},{"_id":"invPurchase_2_155B2B94-6C47-E6B5-BD1E-11F375CB2C29","_rev":"1-8308be24f6677a3a6aefc7cdde9b1c13","data":{"purchaseCost":6,"lotNumber":null,"dateReceived":"2015-12-03T06:00:00.000Z","originalQuantity":12,"currentQuantity":12,"expirationDate":null,"expired":false,"location":"Warehouse","aisleLocation":"A1","giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":"pcs","invoiceNo":"","lastModified":"2015-12-29T03:47:25.866Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:47:25.866Z","distributionUnit":"2015-12-29T03:47:25.866Z","inventoryItem":"2015-12-29T03:47:25.866Z","invoiceNo":"2015-12-29T03:47:25.866Z","originalQuantity":"2015-12-29T03:47:25.866Z","quantityGroups":"2015-12-29T03:47:25.866Z","purchaseCost":"2015-12-29T03:47:25.866Z","vendor":"2015-12-29T03:47:25.866Z","vendorItemNo":"2015-12-29T03:47:25.866Z","location":"2015-12-29T03:47:25.866Z","aisleLocation":"2015-12-29T03:47:25.866Z","currentQuantity":"2015-12-29T03:47:25.866Z"},"quantityGroups":[{"index":0,"unit":"pcs","firstQuantity":true,"quantity":"12"}]}},{"_id":"invPurchase_2_E3B2184F-4ECA-3B76-92C8-437846C2E3DC","_rev":"2-846e30db369e739e0603938b12776d45","data":{"purchaseCost":12345,"lotNumber":null,"dateReceived":"2015-12-01T06:00:00.000Z","originalQuantity":1000000,"currentQuantity":999998,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtc6w3_31","vendor":"ACME INC","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T04:01:16.093Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:08:23.921Z","purchaseCost":"2015-12-29T03:08:23.921Z","vendor":"2015-12-29T03:08:23.921Z","originalQuantity":"2015-12-29T03:08:23.921Z","currentQuantity":"2015-12-29T04:01:16.093Z","inventoryItem":"2015-12-29T03:08:23.921Z"}},"_revisions":{"start":2,"ids":["846e30db369e739e0603938b12776d45","03ddad7882d9ed7041637de509902109"]}},{"_id":"invRequest_2_2A5251B5-1919-CB55-8757-A53DC057A77E","_rev":"1-222c0c115dc924e7d90cbde2b6023ebd","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":null,"markAsConsumed":true,"quantity":1000000,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:08:57.351Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:08:57.351Z","dateCompleted":"2015-12-29T03:08:57.351Z","quantity":"2015-12-29T03:08:57.351Z","deliveryLocation":"2015-12-29T03:08:57.351Z","transactionType":"2015-12-29T03:08:57.351Z","locationsAffected":"2015-12-29T03:08:57.351Z","status":"2015-12-29T03:08:57.351Z","completedBy":"2015-12-29T03:08:57.351Z"},"locationsAffected":[{"name":"No Location","quantity":"1000000"}]}},{"_id":"invRequest_2_6F095231-0D58-E48D-B59F-8D4CB3965802","_rev":"1-f709e83b929a4ac8e25c39de04bb36d9","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.01,"dateCompleted":"2015-12-29T04:01:16.080Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":2,"quantityAtCompletion":1000000,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T04:01:16.251Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":null,"modifiedFields":{"dateCompleted":"2015-12-29T04:01:16.251Z","quantity":"2015-12-29T04:01:16.251Z","transactionType":"2015-12-29T04:01:16.251Z","markAsConsumed":"2015-12-29T04:01:16.251Z","adjustPurchases":"2015-12-29T04:01:16.251Z","costPerUnit":"2015-12-29T04:01:16.251Z","quantityAtCompletion":"2015-12-29T04:01:16.251Z","purchasesAffected":"2015-12-29T04:01:16.251Z","locationsAffected":"2015-12-29T04:01:16.251Z","status":"2015-12-29T04:01:16.251Z","completedBy":"2015-12-29T04:01:16.251Z"},"purchasesAffected":[{"id":"E3B2184F-4ECA-3B76-92C8-437846C2E3DC","quantity":2}],"locationsAffected":[{"name":"Pharmacy","quantity":2}]}},{"_id":"invRequest_2_91481B28-0A00-9C72-9094-E34D6B70442D","_rev":"1-c1b1d2ef55725427ea6f31fafd43a776","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-12-29T03:47:47.911Z","deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":"Pharmacy","markAsConsumed":true,"quantity":2,"quantityAtCompletion":null,"reason":null,"requestedBy":"Admin User","status":"Requested","transactionType":"Request","lastModified":"2015-12-29T03:47:47.912Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:47:47.912Z","quantity":"2015-12-29T03:47:47.912Z","deliveryLocation":"2015-12-29T03:47:47.912Z","expenseAccount":"2015-12-29T03:47:47.912Z","dateRequested":"2015-12-29T03:47:47.912Z","requestedBy":"2015-12-29T03:47:47.912Z","status":"2015-12-29T03:47:47.912Z"}}},{"_id":"invRequest_2_B419E42C-87A8-1AFC-BDEF-3145ED774BE7","_rev":"1-a61eb2eac18550ed06ae528db3de51f0","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Warehouse","expenseAccount":null,"markAsConsumed":true,"quantity":25,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:13:47.447Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:13:47.447Z","dateCompleted":"2015-12-29T03:13:47.447Z","quantity":"2015-12-29T03:13:47.447Z","deliveryLocation":"2015-12-29T03:13:47.447Z","transactionType":"2015-12-29T03:13:47.447Z","locationsAffected":"2015-12-29T03:13:47.447Z","status":"2015-12-29T03:13:47.447Z","completedBy":"2015-12-29T03:13:47.447Z"},"locationsAffected":[{"name":"No Location","quantity":"25"}]}},{"_id":"invRequest_2_CA5F4301-1600-1230-B276-0B3C98402C13","_rev":"1-9c9872e5caf5f80fe4cf434e014fcfe3","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.48,"dateCompleted":"2015-12-28T06:00:00.000Z","dateRequested":"2015-12-29T03:46:41.543Z","deliveryAisle":null,"deliveryLocation":"Ward 1","expenseAccount":"Ward","markAsConsumed":true,"quantity":25,"quantityAtCompletion":25,"reason":null,"requestedBy":"Admin User","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T03:46:41.732Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:46:41.732Z","quantity":"2015-12-29T03:46:41.732Z","dateCompleted":"2015-12-29T03:46:41.732Z","deliveryLocation":"2015-12-29T03:46:41.732Z","expenseAccount":"2015-12-29T03:46:41.732Z","dateRequested":"2015-12-29T03:46:41.732Z","requestedBy":"2015-12-29T03:46:41.732Z","adjustPurchases":"2015-12-29T03:46:41.732Z","costPerUnit":"2015-12-29T03:46:41.732Z","quantityAtCompletion":"2015-12-29T03:46:41.732Z","purchasesAffected":"2015-12-29T03:46:41.732Z","locationsAffected":"2015-12-29T03:46:41.732Z","status":"2015-12-29T03:46:41.732Z","completedBy":"2015-12-29T03:46:41.732Z"},"purchasesAffected":[{"id":"05760051-8BD1-ACC0-8013-0C59A545FB8D","quantity":25}],"locationsAffected":[{"name":"Warehouse","quantity":25}]}},{"_id":"inventory_2_iiqtc6w3_31","_rev":"3-0c0a71f273bf0633cafce271b0f35007","data":{"description":null,"friendlyId":"m00001","name":"Cefazolin 500mg vial (Hazolin)","quantity":999998,"crossReference":null,"inventoryType":"Medication","price":null,"reorderPoint":null,"distributionUnit":"vial","rank":null,"lastModified":"2015-12-29T04:01:16.249Z","modifiedBy":"Admin User","locations":["24BB235E-B271-AF61-9A3D-9ACD77CE25AF","DBCF3E06-B812-B6C7-930E-74F9372D384A"],"purchases":["E3B2184F-4ECA-3B76-92C8-437846C2E3DC"],"modifiedFields":{"name":"2015-12-29T03:08:24.053Z","inventoryType":"2015-12-29T03:08:24.053Z","distributionUnit":"2015-12-29T03:08:24.053Z","quantity":"2015-12-29T04:01:16.249Z","friendlyId":"2015-12-29T03:08:24.053Z"}},"_revisions":{"start":3,"ids":["0c0a71f273bf0633cafce271b0f35007","42bc38c66d9a87103c7871aa9aadb6b5","295e3c0d1de3d7a7d384ae5090d82125"]}},{"_id":"inventory_2_iiqtim0c_ex","_rev":"4-6900f25cb0aa33334fb6c69e4a828718","data":{"description":null,"friendlyId":"s00001","name":"Pumpset Kangaroo 1000ml","quantity":12,"crossReference":null,"inventoryType":"Supply","price":null,"reorderPoint":null,"distributionUnit":"pcs","rank":null,"lastModified":"2015-12-29T03:47:26.017Z","modifiedBy":"Admin User","locations":["0323721B-EDD0-6C91-BB34-52FBEACBA7DE","7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","32BCC947-E272-1564-90E1-C6E2ECE14881"],"purchases":["05760051-8BD1-ACC0-8013-0C59A545FB8D","155B2B94-6C47-E6B5-BD1E-11F375CB2C29"],"modifiedFields":{"name":"2015-12-29T03:12:56.959Z","inventoryType":"2015-12-29T03:12:56.959Z","distributionUnit":"2015-12-29T03:12:56.959Z","quantity":"2015-12-29T03:47:26.017Z","friendlyId":"2015-12-29T03:12:56.959Z"}},"_revisions":{"start":4,"ids":["6900f25cb0aa33334fb6c69e4a828718","03eb3fc36799eb0e78c1d4f5b45e50a0","064996d833372bc743ccd60baa1174b9","1622cc9c6428d24950f02c88112840f4"]}},{"_id":"lab_2_C9274C34-248C-FF7C-9E8B-F3110467C941","_rev":"2-78aaf934410f626a7dc64c8ce640ad17","data":{"labDate":"2015-12-29T04:07:25.725Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:03:22.879Z","result":"Normal","status":"Completed","lastModified":"2015-12-29T04:07:25.725Z","modifiedBy":"Admin User","labType":"A33BFA09-AFBB-CA35-A01C-702B568FFAE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:07:25.725Z","requestedBy":"2015-12-29T04:03:22.927Z","requestedDate":"2015-12-29T04:03:22.927Z","result":"2015-12-29T04:07:25.725Z","labDate":"2015-12-29T04:07:25.725Z"}},"_revisions":{"start":2,"ids":["78aaf934410f626a7dc64c8ce640ad17","0e55563ae178ae5b340c29a50f168925"]}},{"_id":"lab_2_EE3063E6-832D-930D-AD4E-D27341709886","_rev":"1-b0364bd6b060df4a2084ca292de1ad71","data":{"labDate":null,"notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:18:34.699Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:18:34.731Z","modifiedBy":"Admin User","labType":"4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:18:34.731Z","requestedBy":"2015-12-29T04:18:34.731Z","requestedDate":"2015-12-29T04:18:34.731Z"}}},{"_id":"lookup_2_aisle_location_list","_rev":"1-255c62c74fb06e5c13664e9e70aebef5","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["A1"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-499cca90fccff759c62b2fc781010226","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["27001"]}},{"_id":"lookup_2_diagnosis_list","_rev":"1-889e0d198f50d28df33bf522106b9438","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fall from in-line roller-skates, initial encounter"]}},{"_id":"lookup_2_expense_account_list","_rev":"2-3404736b154767f3fe30e297704480be","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward"]},"_revisions":{"start":2,"ids":["3404736b154767f3fe30e297704480be","36426f839aa10324a85e92d34fcf2c26"]}},{"_id":"lookup_2_patient_status_list","_rev":"1-01d7dfb8ec77de492bf913c5c763578c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Scheduled for surgery"]}},{"_id":"lookup_2_physician_list","_rev":"1-99c8212cef905d552ab95fc88b8c3d5b","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Nick"]}}]} -{"seq":75} -{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"lookup_2_procedure_list","_rev":"1-d48989bf01a1ae70a26e397c43266278","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["hip adductor release"]}},{"_id":"lookup_2_radiologists","_rev":"1-f029e944b51dcc7fd6f980d72c7027c7","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Xray"]}},{"_id":"lookup_2_sex","_rev":"2-215b9ef2d7091253f179116902ee61ae","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Female","Male"]},"_revisions":{"start":2,"ids":["215b9ef2d7091253f179116902ee61ae","0cb12aaddee831fd798fd248e108f946"]}},{"_id":"lookup_2_vendor_list","_rev":"1-a2760a7c86532da3f92ac75899b37e06","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME INC"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-d373d65b719c266173d92d3bb8f14e9f","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Hospital"]}},{"_id":"lookup_2_warehouse_list","_rev":"3-86923622f95bb3f49a906cb7cbacdc85","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward 1","Warehouse"]},"_revisions":{"start":3,"ids":["86923622f95bb3f49a906cb7cbacdc85","64a1b3813d337c7000044dbc2de21892","4f316909ed8500d0f80cf20a684ce343"]}},{"_id":"medication_2_7B63E873-D056-CCC5-A69C-60064472A16E","_rev":"1-1ebd1e9a0f4dd4d90b52eb37db7fb493","data":{"notes":null,"prescription":"Twice a day for two days","prescriptionDate":"2015-12-28T06:00:00.000Z","quantity":4,"refills":null,"requestedDate":"2015-12-29T04:16:44.877Z","requestedBy":"Admin User","status":"Requested","lastModified":"2015-12-29T04:16:44.879Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:16:44.879Z","prescription":"2015-12-29T04:16:44.879Z","quantity":"2015-12-29T04:16:44.879Z","status":"2015-12-29T04:16:44.879Z","requestedBy":"2015-12-29T04:16:44.879Z","requestedDate":"2015-12-29T04:16:44.879Z"}}},{"_id":"medication_2_9187CEE0-13EC-1816-A2A4-95E9797999BF","_rev":"1-271cd0960f61b322d66b57a994141733","data":{"notes":null,"prescription":"Once a day for 2 days","prescriptionDate":"2015-12-01T06:00:00.000Z","quantity":2,"refills":null,"requestedDate":"2015-12-29T04:01:16.079Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-12-29T04:01:16.096Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:01:16.096Z","prescription":"2015-12-29T04:01:16.096Z","quantity":"2015-12-29T04:01:16.096Z","status":"2015-12-29T04:01:16.096Z","requestedBy":"2015-12-29T04:01:16.096Z","requestedDate":"2015-12-29T04:01:16.096Z"}}},{"_id":"patient_2_C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","_rev":"4-1c58ffef18d0e8a6cf67f5af11541f71","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":"2013-08-06T05:00:00.000Z","economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":"Scheduled for surgery","lastModified":"2015-12-29T03:53:58.574Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-12-29T03:51:02.781Z","firstName":"2015-12-29T03:51:02.781Z","middleName":"2015-12-29T03:51:02.781Z","lastName":"2015-12-29T03:51:02.781Z","gender":"2015-12-29T03:51:02.781Z","dateOfBirth":"2015-12-29T03:51:02.781Z","status":"2015-12-29T03:53:17.032Z","admitted":"2015-12-29T03:53:58.574Z"}},"_revisions":{"start":4,"ids":["1c58ffef18d0e8a6cf67f5af11541f71","1351af326b99acc03278830f30192916","105429e78d710023d6d490e880a3132a","fa6de36be0214f08f09477729bdfb339"]}},{"_id":"pricing_2_4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","_rev":"1-410ff865070244eac14c5cad5db0ad80","data":{"category":"Lab","expenseAccount":null,"name":"Fasting Blood Sugar (FBS)","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:18:34.703Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:18:34.703Z","category":"2015-12-29T04:18:34.703Z","pricingType":"2015-12-29T04:18:34.703Z"}}},{"_id":"pricing_2_A33BFA09-AFBB-CA35-A01C-702B568FFAE8","_rev":"1-70ff211de7621293ffbd91df901f6d0f","data":{"category":"Lab","expenseAccount":null,"name":"Bleeding Time","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:03:22.884Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:03:22.884Z","category":"2015-12-29T04:03:22.884Z","pricingType":"2015-12-29T04:03:22.884Z"}}},{"_id":"pricing_2_B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","_rev":"1-30c9df5437c85bb21539024c7222d307","data":{"category":"Imaging","expenseAccount":null,"name":"Ankle (Any Single View)","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-12-29T04:07:03.700Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:07:03.700Z","category":"2015-12-29T04:07:03.700Z","pricingType":"2015-12-29T04:07:03.700Z"}}},{"_id":"procCharge_2_0AD46995-188B-EFB9-8A33-E47B3980476C","_rev":"1-3f577e28daa86e12c2ad71799e383c3b","data":{"quantity":1,"dateCharged":"2015-12-29T04:00:00.093Z","lastModified":"2015-12-29T04:00:08.611Z","modifiedBy":"Admin User","medication":"iiqtc6w3_31","pricingItem":null,"modifiedFields":{"dateCharged":"2015-12-29T04:00:08.611Z","quantity":"2015-12-29T04:00:08.611Z"}}},{"_id":"procedure_2_398B4F58-152F-1476-8ED1-329C4D85E25F","_rev":"5-979bd8081e0ae3ccebf595c28bafd145","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"hip adductor release","cptCode":"27001","location":null,"notes":null,"physician":"Dr Nick","procedureDate":"2015-12-01T06:00:00.000Z","timeStarted":null,"timeEnded":null,"lastModified":"2015-12-29T04:00:33.229Z","modifiedBy":"Admin User","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":["0AD46995-188B-EFB9-8A33-E47B3980476C"],"modifiedFields":{"procedureDate":"2015-12-29T03:59:55.401Z","description":"2015-12-29T03:59:37.244Z","physician":"2015-12-29T03:59:37.244Z","anesthesiaType":"2015-12-29T03:59:37.244Z","cptCode":"2015-12-29T04:00:33.229Z"}},"_revisions":{"start":5,"ids":["979bd8081e0ae3ccebf595c28bafd145","561ab91abdd5e0f240a3ec30c9a3e09c","0a938774f0f0e600f15dd29d08b98b50","5570e1e8726f29f430a5de6e81a36e60","6c0abd3cf72cb182b05caa21150fb113"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_inventory_Supply","_rev":"1-538fc2bf7cd4745eea01fcf24ced6164","data":{"prefix":"s","value":1}},{"_id":"sequence_2_patient","_rev":"5-f6fd8c9cb7b07567399a04a72f02822a","data":{"prefix":null,"value":1},"_revisions":{"start":5,"ids":["f6fd8c9cb7b07567399a04a72f02822a","79dabe4ed5c7897e103171a7bf8bf1b6","945c072575a32fca103968a3cd425c31","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_03C7BF8B-04E0-DD9E-9469-96A5604F5340","_rev":"14-09b2a3ac1ac8c343d0f6a6d667bc5357","data":{"dischargeInfo":null,"endDate":"2015-12-29T04:11:00.724Z","examiner":"Dr Nick","history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"paymentState":"pending","primaryDiagnosis":"Fall from in-line roller-skates, initial encounter","primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-12-01T15:53:00.000Z","status":"Admitted","visitType":"Admission","archived":false,"lastModified":"2016-11-02T13:40:50.466Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","vitals":["B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC"],"procedures":["398B4F58-152F-1476-8ED1-329C4D85E25F"],"patientNotes":[],"medication":["9187CEE0-13EC-1816-A2A4-95E9797999BF","7B63E873-D056-CCC5-A69C-60064472A16E"],"labs":["C9274C34-248C-FF7C-9E8B-F3110467C941","EE3063E6-832D-930D-AD4E-D27341709886"],"imaging":["51AFF85A-69C0-97C1-B22C-716A1BA7B80B","12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7"],"charges":[],"modifiedFields":{"visitType":"2015-12-29T03:53:58.543Z","startDate":"2015-12-29T04:11:47.272Z","status":"2016-11-02T13:40:50.466Z","outPatient":"2015-12-29T03:53:58.543Z","primaryDiagnosis":"2015-12-29T03:59:37.312Z","examiner":"2015-12-29T04:06:19.274Z","endDate":"2015-12-29T04:11:47.272Z"}},"_revisions":{"start":14,"ids":["09b2a3ac1ac8c343d0f6a6d667bc5357","c5db061eca43852a9082628407227388","48973daa88a2567931f70586aa5f4b6e","0baeb91a16dad77c0d8e55e6b38e6c8e","e26c621939e57cdf40fe92362f5dac3a","7315d0ff5e6eac570c2b47fd6e9d9406","d1be40a55f4329d18cc6c8f8b8b2d55a","e8567f5b5576aa5d4141f2776b24ab58","d54e63df97dd964288c6dd66d049dae9","210c948fb309be4793ca14cec7f3a335","29e6bb7a6732517b79f8c90fbcebdedd","a83b26f6b056f7c54d917160b366a75b","ebed6471bdd978af39c5acfc3f1f34b7","284cb8e69ca4b392156fe1d22866fcfb"]}},{"_id":"vital_2_B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC","_rev":"1-62233a35020adba2b7d65fd09e5e3cba","data":{"dateRecorded":"2015-12-04T04:08:00.000Z","temperature":36.67,"weight":"57lb","height":"3'6\"","sbp":117,"dbp":76,"heartRate":60,"respiratoryRate":12,"lastModified":"2015-12-29T04:11:11.942Z","modifiedBy":"Admin User","modifiedFields":{"dateRecorded":"2015-12-29T04:11:11.942Z","temperature":"2015-12-29T04:11:11.942Z","weight":"2015-12-29T04:11:11.942Z","height":"2015-12-29T04:11:11.942Z","sbp":"2015-12-29T04:11:11.942Z","dbp":"2015-12-29T04:11:11.942Z","heartRate":"2015-12-29T04:11:11.942Z","respiratoryRate":"2015-12-29T04:11:11.942Z"}}}]} -{"seq":95} +{"seq":5} +{"docs":[{"_id":"_design/inventory_by_friendly_id","_rev":"1-82e24378f074a284cae14da4db5431ed","version":1,"views":{"inventory_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}}]} +{"seq":7} +{"docs":[{"_id":"_design/appointments_by_date","_rev":"1-5df29f1d7dbd39d6b3a2145923ab73cf","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["5df29f1d7dbd39d6b3a2145923ab73cf"]}},{"_id":"_design/appointments_by_date","_rev":"1-178add045be11a7fd6aa7fdf97c8f3f0","version":6,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["178add045be11a7fd6aa7fdf97c8f3f0"]}},{"_id":"_design/appointments_by_date","_rev":"1-03951858f9232df2e774548b0f5fd068","version":4,"views":{"appointments_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var i,\n filterBy = null,\n includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n break;\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]),\n bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["03951858f9232df2e774548b0f5fd068"]}},{"_id":"_design/appointments_by_date","_rev":"3-461875fa3e8aa582009473a4ebccf3bb","version":7,"views":{"appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType !== 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":3,"ids":["461875fa3e8aa582009473a4ebccf3bb","2e78ab0f6da3881df4871d0b028148b9","4c8dd95ad6d36b9b4d86136d5e417f5c"]}},{"_id":"_design/appointments_by_patient","_rev":"1-7232d3292344540b2511e709422e2cbf","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7232d3292344540b2511e709422e2cbf"]}},{"_id":"_design/appointments_by_patient","_rev":"1-9a97acd5b8fd071ad81afc9e730721c5","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate,doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9a97acd5b8fd071ad81afc9e730721c5"]}},{"_id":"_design/appointments_by_patient","_rev":"2-a8bb26daf0329c069a18ec0ce64532cb","version":4,"views":{"appointments_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"appointment\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate,doc._id]);}}}"}},"_revisions":{"start":2,"ids":["a8bb26daf0329c069a18ec0ce64532cb","9868b6586898a48c3fd68722ca3fe1d4"]}},{"_id":"_design/closed_incidents_by_user","_rev":"1-bf16176c13be57af9a4f1a0980710190","version":1,"views":{"closed_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status === \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}}},{"_id":"_design/imaging_by_status","_rev":"1-1a3bab3d2d1403299a9e4ad8dffe5fa1","version":4,"views":{"imaging_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'imaging') {\n var imagingDate = doc.data.imagingDate;\n if (imagingDate && imagingDate !== \"\") {\n imagingDate = new Date(imagingDate);\n if (imagingDate.getTime) {\n imagingDate = imagingDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, imagingDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1a3bab3d2d1403299a9e4ad8dffe5fa1"]}},{"_id":"_design/imaging_by_status","_rev":"1-2feb5103c3f6d149bf98f0adeaa76b38","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["2feb5103c3f6d149bf98f0adeaa76b38"]}},{"_id":"_design/imaging_by_status","_rev":"2-57660077d48a8a4a0c1a3dd6ae214aac","version":4,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"imaging\") {var imagingDate = doc.data.imagingDate;if (imagingDate && imagingDate !== \"\") {imagingDate = new Date(imagingDate);if (imagingDate.getTime) {imagingDate = imagingDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, imagingDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["57660077d48a8a4a0c1a3dd6ae214aac","9236042e1fb9f567d1d527bbb429cd8e"]}},{"_id":"_design/incident_by_date","_rev":"1-59fa59734ee129cff0560b20a95d2d4e","version":1,"views":{"incident_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n var dateOfIncident = doc.data.dateOfIncident;\n if (dateOfIncident && dateOfIncident !== \"\") {\n dateOfIncident = new Date(dateOfIncident);\n if (dateOfIncident.getTime) {\n dateOfIncident = dateOfIncident.getTime();\n }\n }\n emit([dateOfIncident, doc._id]);\n }\n }\n }"}}},{"_id":"_design/incident_by_friendly_id","_rev":"1-885a12b67da47e956bc190fe1fe0d4e6","version":1,"views":{"incident_by_friendly_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n emit([doc.data.friendlyId, doc._id]);\n }\n }\n }"}}},{"_id":"_design/inventory_by_name","_rev":"1-304304d63beaffd8d1ae4ae1cddf4b2b","version":3,"views":{"inventory_by_name":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit([doc.data.name, doc._id]);}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["304304d63beaffd8d1ae4ae1cddf4b2b"]}},{"_id":"_design/inventory_by_name","_rev":"1-91f55ae6bd30f766d9da95bffe054bcb","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["91f55ae6bd30f766d9da95bffe054bcb"]}},{"_id":"_design/inventory_by_name","_rev":"2-6993fbc5ef18283f83c6afe5be9a9351","version":5,"views":{"inventory_by_name":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit([doc.data.name, doc._id]);\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'crossReference':\n case 'description':\n case 'friendlyId':\n case 'name':\n case 'price':\n case 'quantity':\n case 'inventoryType':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["6993fbc5ef18283f83c6afe5be9a9351","c12e4467c9c3ecc8021b660934257f25"]}},{"_id":"_design/inventory_by_type","_rev":"1-003ef699ab0f2b8628c0bf613fabf7a2","version":4,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["003ef699ab0f2b8628c0bf613fabf7a2"]}},{"_id":"_design/inventory_by_type","_rev":"1-18455500e1e86544edceaab01bb511bc","version":5,"views":{"inventory_by_type":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'inventory') {\n emit(doc.data.inventoryType);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["18455500e1e86544edceaab01bb511bc"]}},{"_id":"_design/inventory_by_type","_rev":"1-65423cfcd4b0acd93b58aa2003907c92","version":5,"views":{"inventory_by_type":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"inventory\") {emit(doc.data.inventoryType);}}}"}},"_revisions":{"start":1,"ids":["65423cfcd4b0acd93b58aa2003907c92"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-78939ec45bef330bbfa87763dbbfce37","version":4,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["78939ec45bef330bbfa87763dbbfce37"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-0d7b597aeae746589980b12903768252","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var dateReceived = doc.data.dateReceived;\n if (dateReceived && dateReceived !== \"\") {\n dateReceived = new Date(dateReceived);\n if (dateReceived.getTime) {\n dateReceived = dateReceived.getTime();\n }\n }\n emit([dateReceived, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["0d7b597aeae746589980b12903768252"]}},{"_id":"_design/inventory_purchase_by_date_received","_rev":"1-823be94576112c800022b256ccd9b725","version":5,"views":{"inventory_purchase_by_date_received":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var dateReceived = doc.data.dateReceived;if (dateReceived && dateReceived !== \"\") {dateReceived = new Date(dateReceived);if (dateReceived.getTime) {dateReceived = dateReceived.getTime();}}emit([dateReceived, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["823be94576112c800022b256ccd9b725"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-17bd9d3619ae03155d9929d3ebcd5023","version":4,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["17bd9d3619ae03155d9929d3ebcd5023"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-7aea58304996ccb168865141592a024f","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invPurchase\") {var expirationDate = doc.data.expirationDate;if (expirationDate && expirationDate !== \"\") {expirationDate = new Date(expirationDate);if (expirationDate.getTime) {expirationDate = expirationDate.getTime();}}emit([expirationDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7aea58304996ccb168865141592a024f"]}},{"_id":"_design/inventory_purchase_by_expiration_date","_rev":"1-1f41dd6d030c58884d7013ef9436decb","version":5,"views":{"inventory_purchase_by_expiration_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invPurchase') {\n var expirationDate = doc.data.expirationDate;\n if (expirationDate && expirationDate !== \"\") {\n expirationDate = new Date(expirationDate);\n if (expirationDate.getTime) {\n expirationDate = expirationDate.getTime();\n }\n }\n emit([expirationDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["1f41dd6d030c58884d7013ef9436decb"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-e9eb2d7f1e35296646399c7414525c33","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["e9eb2d7f1e35296646399c7414525c33"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-021f4c24b5b6202594f610cf5d4c63a4","version":5,"views":{"inventory_request_by_item":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["021f4c24b5b6202594f610cf5d4c63a4"]}},{"_id":"_design/inventory_request_by_item","_rev":"1-7e7ef275a9fc15f2b5f328b1479c6097","version":4,"views":{"inventory_request_by_item":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.inventoryItem, doc.data.status, dateCompleted]);}}}"}},"_revisions":{"start":1,"ids":["7e7ef275a9fc15f2b5f328b1479c6097"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-cc0c1e0e01060aa62456d6ea768d8ec7","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invRequest') {\n var dateCompleted = doc.data.dateCompleted;\n if (dateCompleted && dateCompleted !== \"\") {\n dateCompleted = new Date(dateCompleted);\n if (dateCompleted.getTime) {\n dateCompleted = dateCompleted.getTime();\n }\n }\n emit([doc.data.status, dateCompleted, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["cc0c1e0e01060aa62456d6ea768d8ec7"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-187394c79d3206e11e112891f0d63550","version":4,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["187394c79d3206e11e112891f0d63550"]}},{"_id":"_design/inventory_request_by_status","_rev":"1-f4a7252ebf2802c53a572bf150eae05c","version":5,"views":{"inventory_request_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invRequest\") {var dateCompleted = doc.data.dateCompleted;if (dateCompleted && dateCompleted !== \"\") {dateCompleted = new Date(dateCompleted);if (dateCompleted.getTime) {dateCompleted = dateCompleted.getTime();}}emit([doc.data.status, dateCompleted, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["f4a7252ebf2802c53a572bf150eae05c"]}},{"_id":"_design/invoice_by_patient","_rev":"1-9f67a58d4e428614844ac82cb2548268","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["9f67a58d4e428614844ac82cb2548268"]}},{"_id":"_design/invoice_by_patient","_rev":"1-a491390f74ce432d9cfab78291e0753b","version":1,"views":{"invoice_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["a491390f74ce432d9cfab78291e0753b"]}},{"_id":"_design/invoice_by_status","_rev":"1-25a58e1cec7f01d0a7e8da1293f59b69","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25a58e1cec7f01d0a7e8da1293f59b69"]}},{"_id":"_design/invoice_by_status","_rev":"1-d411e6f66f897f0b9b985dc6e5188d85","version":4,"views":{"invoice_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'invoice') {\n var billDate = doc.data.billDate;\n if (billDate && billDate !== \"\") {\n billDate = new Date(billDate);\n if (billDate.getTime) {\n billDate = billDate.getTime();\n }\n }\n emit([doc.data.status, billDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["d411e6f66f897f0b9b985dc6e5188d85"]}},{"_id":"_design/invoice_by_status","_rev":"2-072e2f7f1519a12260fe98c90f794b06","version":4,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"invoice\") {var billDate = doc.data.billDate;if (billDate && billDate !== \"\") {billDate = new Date(billDate);if (billDate.getTime) {billDate = billDate.getTime();}}emit([doc.data.status, billDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["072e2f7f1519a12260fe98c90f794b06","73e3e45673ed0c4f4ae1cee855f216f0"]}},{"_id":"_design/lab_by_status","_rev":"1-16b2c13356e8dac3b3594018f91cccfb","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["16b2c13356e8dac3b3594018f91cccfb"]}},{"_id":"_design/lab_by_status","_rev":"1-7d4de6e219b482171b7ecd485ef72238","version":4,"views":{"lab_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'lab') {\n var labDate = doc.data.labDate;\n if (labDate && labDate !== \"\") {\n labDate = new Date(labDate);\n if (labDate.getTime) {\n labDate = labDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, labDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["7d4de6e219b482171b7ecd485ef72238"]}},{"_id":"_design/lab_by_status","_rev":"2-ef5e8b51b3704c0cb1e525a63c81bd80","version":4,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"lab\") {var labDate = doc.data.labDate;if (labDate && labDate !== \"\") {labDate = new Date(labDate);if (labDate.getTime) {labDate = labDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, labDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["ef5e8b51b3704c0cb1e525a63c81bd80","db4393c6856b98a40afd6ceef31db2a7"]}},{"_id":"_design/medication_by_status","_rev":"1-a6403c53b2db46905b3b1861120c6601","version":4,"views":{"medication_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'medication') {\n var prescriptionDate = doc.data.prescriptionDate;\n if (prescriptionDate && prescriptionDate !== \"\") {\n prescriptionDate = new Date(prescriptionDate);\n if (prescriptionDate.getTime) {\n prescriptionDate = prescriptionDate.getTime();\n }\n }\n var requestedDate = doc.data.requestedDate;\n if (requestedDate && requestedDate !== \"\") {\n requestedDate = new Date(requestedDate);\n if (requestedDate.getTime) {\n requestedDate = requestedDate.getTime();\n }\n }\n emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a6403c53b2db46905b3b1861120c6601"]}},{"_id":"_design/medication_by_status","_rev":"1-09e1d1c201823532161ef48ba23200be","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["09e1d1c201823532161ef48ba23200be"]}},{"_id":"_design/medication_by_status","_rev":"2-9dec70f4b5aeaf7d9b8d70719125c41c","version":4,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"medication\") {var prescriptionDate = doc.data.prescriptionDate;if (prescriptionDate && prescriptionDate !== \"\") {prescriptionDate = new Date(prescriptionDate);if (prescriptionDate.getTime) {prescriptionDate = prescriptionDate.getTime();}}var requestedDate = doc.data.requestedDate;if (requestedDate && requestedDate !== \"\") {requestedDate = new Date(requestedDate);if (requestedDate.getTime) {requestedDate = requestedDate.getTime();}}emit([doc.data.status, requestedDate, prescriptionDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["9dec70f4b5aeaf7d9b8d70719125c41c","36ce9e9853552f5eb646ed26de7184dc"]}},{"_id":"_design/open_incidents_by_user","_rev":"1-34770efd210920a30c96d3787521e8a5","version":1,"views":{"open_incidents_by_user":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'incident') {\n if (doc.data.status !== \"Closed\") {\n emit([doc.data.reportedBy, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n return 0; // Don't sort\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/patient_by_admission","_rev":"1-3c2da4380d257c95ebf4430afa48de3b","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["3c2da4380d257c95ebf4430afa48de3b"]}},{"_id":"_design/patient_by_admission","_rev":"2-cb3270a3d44a370d50128b93179d3503","version":4,"views":{"patient_by_admission":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.admitted === true) {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["cb3270a3d44a370d50128b93179d3503","ee7b6ead26ac6b8b3f106c6d85dc175b"]}},{"_id":"_design/patient_by_display_id","_rev":"1-0b75ee7c82a1aadebd0bc0fd403622fb","version":5,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["0b75ee7c82a1aadebd0bc0fd403622fb"]}},{"_id":"_design/patient_by_display_id","_rev":"1-6f596cec9eb82609308fd9d25a9f9df2","version":4,"views":{"patient_by_display_id":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {if (doc.data.friendlyId) {emit([doc.data.friendlyId, doc._id]);} else if (doc.data.externalPatientId) {emit([doc.data.externalPatientId, doc._id]);} else {emit([doc._id, doc._id]);}}}}"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'gender':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["6f596cec9eb82609308fd9d25a9f9df2"]}},{"_id":"_design/patient_by_display_id","_rev":"1-8a6930002af6d588ecdedd5f07da0230","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":1,"ids":["8a6930002af6d588ecdedd5f07da0230"]}},{"_id":"_design/patient_by_display_id","_rev":"2-88a46c350d8994362cc0e5910f15d726","version":7,"views":{"patient_by_display_id":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n if (doc.data.friendlyId) {\n emit([doc.data.friendlyId, doc._id]);\n } else if (doc.data.externalPatientId) {\n emit([doc.data.externalPatientId, doc._id]);\n } else {\n emit([doc._id, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows.sort(function (a, b) {\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'firstName':\n case 'sex':\n case 'lastName':\n case 'status':\n {\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n }\n case 'dateOfBirth':\n {\n return getCompareDate(a.doc.data.dateOfBirth) - getCompareDate(b.doc.data.dateOfBirth);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"},"_revisions":{"start":2,"ids":["88a46c350d8994362cc0e5910f15d726","c619a041bccecc7e83b05015cc92706e"]}},{"_id":"_design/patient_by_status","_rev":"1-54bc74ff93db4aedff83bc649f766596","version":3,"views":{"patient_by_status":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'patient') {\n emit(doc.data.status);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["54bc74ff93db4aedff83bc649f766596"]}},{"_id":"_design/patient_by_status","_rev":"1-49f3f7f86891fb7d60f0ee1b2db1220b","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":1,"ids":["49f3f7f86891fb7d60f0ee1b2db1220b"]}},{"_id":"_design/patient_by_status","_rev":"2-b56763993297cda52343d99f7fdd1b03","version":3,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}},"_revisions":{"start":2,"ids":["b56763993297cda52343d99f7fdd1b03","ff26a12cdb8747aae5bf26f9af3a1953"]}},{"_id":"_design/photo_by_patient","_rev":"1-727ba2a3d1a106196746643395a859d0","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":1,"ids":["727ba2a3d1a106196746643395a859d0"]}},{"_id":"_design/photo_by_patient","_rev":"1-6a4fad4fa682efbbd058e858c328574f","version":4,"views":{"photo_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'photo') {\n emit(doc.data.patient);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["6a4fad4fa682efbbd058e858c328574f"]}},{"_id":"_design/photo_by_patient","_rev":"2-0ea32da890536de0910ea412a3fa015c","version":4,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}},"_revisions":{"start":2,"ids":["0ea32da890536de0910ea412a3fa015c","e3dc5506f7f370535b85be0adc59c7cc"]}},{"_id":"_design/pricing_by_category","_rev":"1-3d703b5f240ae5838d1f20a8ad0471de","version":5,"views":{"pricing_by_category":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'pricing') {\n emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["3d703b5f240ae5838d1f20a8ad0471de"]}},{"_id":"_design/pricing_by_category","_rev":"1-23d44e44019170eadd086734c87e3976","version":4,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["23d44e44019170eadd086734c87e3976"]}},{"_id":"_design/pricing_by_category","_rev":"1-b34429f4f8aff13ed218f70f039b3591","version":5,"views":{"pricing_by_category":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"pricing\") {emit([doc.data.category, doc.data.name, doc.data.pricingType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["b34429f4f8aff13ed218f70f039b3591"]}},{"_id":"_design/procedure_by_date","_rev":"1-a44decd8f14d01c615cf3f5b8e70f10b","version":4,"views":{"procedure_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'procedure') {\n var procedureDate = doc.data.procedureDate;\n if (procedureDate && procedureDate !== \"\") {\n procedureDate = new Date(procedureDate);\n if (procedureDate.getTime) {\n procedureDate = procedureDate.getTime();\n }\n }\n emit([procedureDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["a44decd8f14d01c615cf3f5b8e70f10b"]}},{"_id":"_design/procedure_by_date","_rev":"1-7c23f1d0feaff1358bee1ddea760daac","version":4,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["7c23f1d0feaff1358bee1ddea760daac"]}},{"_id":"_design/procedure_by_date","_rev":"1-25ccef2a9dff3addd8c0d15cc79c363c","version":3,"views":{"procedure_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"procedure\") {var procedureDate = doc.data.procedureDate;if (procedureDate && procedureDate !== \"\") {procedureDate = new Date(procedureDate);if (procedureDate.getTime) {procedureDate = procedureDate.getTime();}}emit([procedureDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["25ccef2a9dff3addd8c0d15cc79c363c"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-10f81c9287f2db782b8e293e7d9b1cde","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'sequence') {\n emit(doc.data.prefix);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["10f81c9287f2db782b8e293e7d9b1cde"]}},{"_id":"_design/sequence_by_prefix","_rev":"1-4a47589314718c2d8add1266b64b5ea6","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":1,"ids":["4a47589314718c2d8add1266b64b5ea6"]}},{"_id":"_design/sequence_by_prefix","_rev":"2-73756debd255ca93fb25eab24ed9e12a","version":4,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}},"_revisions":{"start":2,"ids":["73756debd255ca93fb25eab24ed9e12a","8ac3a62b4c0b624ebed3b68b27cd197e"]}},{"_id":"_design/surgical_appointments_by_date","_rev":"1-90d8de834de1fe0e154d1cdab8889984","version":1,"views":{"surgical_appointments_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'appointment') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n if (doc.data.appointmentType === 'Surgery') {\n emit([startDate, endDate, doc._id]);\n }\n }\n }\n }"}},"lists":{"sort":"function(head, req) {function keysEqual(keyA, keyB) {for (var i= 0; i < keyA.length; i++) {if (keyA[i] !== keyB[i]) {return false;}}return true;}function getCompareDate(dateString) {if (!dateString || dateString === \"\") {return 0;}return new Date(dateString).getTime();}function compareStrings(aString, bString) {if (!aString) {aString = \"\";}if (!bString) {bString = \"\";}if (aString < bString) {return -1;} else if (aString > bString) {return 1;} else {return 0;}}var row,rows=[],startingPosition = 0;while(row = getRow()) {rows.push(row);}rows = rows.filter(function (row) {\n var filterBy = null;\n var includeRow = true;\n if (req.query && req.query.filterBy) {\n filterBy = JSON.parse(req.query.filterBy);\n }\n if (!filterBy) {\n return true;\n }\n for (var i = 0; i < filterBy.length; i++) {\n var currentValue = row.doc.data[filterBy[i].name];\n if (filterBy[i].name === 'status' && (!currentValue || currentValue === '')) {\n currentValue = 'Scheduled';\n }\n if (currentValue !== filterBy[i].value) {\n includeRow = false;\n break;\n }\n }\n return includeRow;\n });rows.sort(function (a, b) {\n function defaultStatus(value) {\n if (!value || value === '') {\n return 'Scheduled';\n } else {\n return value;\n }\n }\n var sortBy = '';\n if (req.query && req.query.sortKey) {\n sortBy = req.query.sortKey;\n }\n switch (sortBy) {\n case 'appointmentType':\n case 'location':\n case 'provider':\n return compareStrings(a.doc.data[sortBy], b.doc.data[sortBy]);\n case 'date':\n {\n var startDiff = getCompareDate(a.doc.data.startDate) - getCompareDate(b.doc.data.startDate);\n if (startDiff === 0) {\n return getCompareDate(a.doc.data.endDate) - getCompareDate(b.doc.data.endDate);\n } else {\n return startDiff;\n }\n }\n case 'status':\n {\n var aStatus = defaultStatus(a.doc.data[sortBy]);\n var bStatus = defaultStatus(b.doc.data[sortBy]);\n return compareStrings(aStatus, bStatus);\n }\n default:\n {\n return 0; // Don't sort\n }\n }\n });if (req.query.sortDesc) {rows = rows.reverse();}if (req.query.sortStartKey) {var startKey = JSON.parse(req.query.sortStartKey);for (var i=0; i 0) {rows = rows.slice(startingPosition);}send(JSON.stringify({\"rows\" : rows}));}"}},{"_id":"_design/visit_by_date","_rev":"1-fd0a50125860ba3c17844c0567a70d65","version":4,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["fd0a50125860ba3c17844c0567a70d65"]}},{"_id":"_design/visit_by_date","_rev":"1-367a7fa42f1067f645190d560f83ef5e","version":3,"views":{"visit_by_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([startDate, endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["367a7fa42f1067f645190d560f83ef5e"]}},{"_id":"_design/visit_by_date","_rev":"1-db61f993a1e1699c8205fee3434fc4c8","version":4,"views":{"visit_by_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([startDate, endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["db61f993a1e1699c8205fee3434fc4c8"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-57a0b69b2792963e5112bbdd53bbba2d","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["57a0b69b2792963e5112bbdd53bbba2d"]}},{"_id":"_design/visit_by_discharge_date","_rev":"1-b4baca85d54e727966aeb2e8ad172136","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n emit([endDate, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["b4baca85d54e727966aeb2e8ad172136"]}},{"_id":"_design/visit_by_discharge_date","_rev":"2-76f05f3060660ab74749fa0def9cea07","version":2,"views":{"visit_by_discharge_date":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}emit([endDate, doc._id]);}}}"}},"_revisions":{"start":2,"ids":["76f05f3060660ab74749fa0def9cea07","e53c95160dacaf007fe01c01215729ce"]}},{"_id":"_design/visit_by_patient","_rev":"1-f2865c74eefee716937492db914f2ccd","version":4,"views":{"visit_by_patient":{"map":"function(doc) {\n var doctype, uidx;\n if (doc._id && (uidx = doc._id.indexOf('_')) > 0 && !doc.data.archived) {\n doctype = doc._id.substring(0, uidx);\n if (doctype === 'visit') {\n var endDate = doc.data.endDate;\n if (endDate && endDate !== \"\") {\n endDate = new Date(endDate);\n if (endDate.getTime) {\n endDate = endDate.getTime();\n }\n }\n var startDate = doc.data.startDate;\n if (startDate && startDate !== \"\") {\n startDate = new Date(startDate);\n if (startDate.getTime) {\n startDate = startDate.getTime();\n }\n }\n emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);\n }\n }\n }"}},"_revisions":{"start":1,"ids":["f2865c74eefee716937492db914f2ccd"]}},{"_id":"_design/visit_by_patient","_rev":"1-bf45f0e7e8e9123a59095b609570a4ea","version":4,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0 && !doc.data.archived) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["bf45f0e7e8e9123a59095b609570a4ea"]}},{"_id":"_design/visit_by_patient","_rev":"1-412252178488867e2350dcd13da779ea","version":3,"views":{"visit_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"visit\") {var endDate = doc.data.endDate;if (endDate && endDate !== \"\") {endDate = new Date(endDate);if (endDate.getTime) {endDate = endDate.getTime();}}var startDate = doc.data.startDate;if (startDate && startDate !== \"\") {startDate = new Date(startDate);if (startDate.getTime) {startDate = startDate.getTime();}}emit([doc.data.patient, startDate, endDate, doc.data.visitType, doc._id]);}}}"}},"_revisions":{"start":1,"ids":["412252178488867e2350dcd13da779ea"]}},{"_id":"appointment_2_C47BE127-E509-6322-BB33-2E6ABE03D0F0","_rev":"2-44597ea8b1cdd20dc8d2c0ad9b2edbb6","data":{"allDay":true,"provider":"Dr Nick","location":"Hospital","appointmentType":"Followup","startDate":"2015-12-30T06:00:00.000Z","endDate":"2015-12-30T06:00:00.000Z","notes":null,"status":"Scheduled","lastModified":"2015-12-29T04:14:36.585Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","modifiedFields":{"appointmentType":"2015-12-29T04:14:21.124Z","allDay":"2015-12-29T04:14:21.124Z","startDate":"2015-12-29T04:14:36.585Z","endDate":"2015-12-29T04:14:36.585Z","location":"2015-12-29T04:14:21.124Z","provider":"2015-12-29T04:14:21.124Z"}},"_revisions":{"start":2,"ids":["44597ea8b1cdd20dc8d2c0ad9b2edbb6","953a11c67a694ef2daa469bd8c0f40ec"]}},{"_id":"imaging_2_12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7","_rev":"1-3237f1a60f7ef9869553893a25e91e87","data":{"imagingDate":null,"notes":null,"radiologist":"","requestedBy":"Admin User","requestedDate":"2015-12-29T04:15:41.380Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:15:41.382Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:15:41.382Z","status":"2015-12-29T04:15:41.382Z","requestedBy":"2015-12-29T04:15:41.382Z","requestedDate":"2015-12-29T04:15:41.382Z"}}},{"_id":"imaging_2_51AFF85A-69C0-97C1-B22C-716A1BA7B80B","_rev":"1-3e1a5d957291144f7ba1e9c0c7c2cb12","data":{"imagingDate":"2015-12-29T04:07:03.693Z","notes":null,"radiologist":"Dr Xray","requestedBy":"Admin User","requestedDate":"2015-12-29T04:07:03.694Z","result":null,"status":"Completed","lastModified":"2015-12-29T04:07:03.744Z","modifiedBy":"Admin User","imagingType":"B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"radiologist":"2015-12-29T04:07:03.744Z","status":"2015-12-29T04:07:03.744Z","imagingDate":"2015-12-29T04:07:03.744Z","requestedBy":"2015-12-29T04:07:03.744Z","requestedDate":"2015-12-29T04:07:03.744Z"}}},{"_id":"invLocation_2_0323721B-EDD0-6C91-BB34-52FBEACBA7DE","_rev":"3-f43e02982eff2b35453b4dcf537fec3f","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:13:47.396Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:13:47.396Z"}},"_revisions":{"start":3,"ids":["f43e02982eff2b35453b4dcf537fec3f","e8c15241efd7bb6c8bf891c28558d83b","c2e397e9ebd1266da5de2e1a3033fcc6"]}},{"_id":"invLocation_2_24BB235E-B271-AF61-9A3D-9ACD77CE25AF","_rev":"3-b8964e3b548efa84d5602224e88a1126","data":{"quantity":0,"location":null,"aisleLocation":null,"lastModified":"2015-12-29T03:08:57.289Z","modifiedBy":"Admin User","modifiedFields":{"quantity":"2015-12-29T03:08:57.289Z"}},"_revisions":{"start":3,"ids":["b8964e3b548efa84d5602224e88a1126","dff7e3f8434279a562a3d4ffc0106c6e","2d8c410350e7ecfffd6e496f6f05ca30"]}},{"_id":"invLocation_2_32BCC947-E272-1564-90E1-C6E2ECE14881","_rev":"2-74b9d0e13f10a766c8e02a411b21bc9e","data":{"quantity":12,"location":"Warehouse","aisleLocation":"A1","lastModified":"2015-12-29T03:47:25.988Z","modifiedBy":"Admin User","modifiedFields":{"aisleLocation":"2015-12-29T03:47:25.919Z","location":"2015-12-29T03:47:25.919Z","quantity":"2015-12-29T03:47:25.988Z"}},"_revisions":{"start":2,"ids":["74b9d0e13f10a766c8e02a411b21bc9e","8adc0c9f4543aebccdfce691b8c1199d"]}},{"_id":"invLocation_2_7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","_rev":"3-85e5ea976718b1331eade5d9f567654b","data":{"quantity":0,"location":"Warehouse","aisleLocation":null,"lastModified":"2015-12-29T03:46:41.557Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:13:47.288Z","quantity":"2015-12-29T03:46:41.557Z"}},"_revisions":{"start":3,"ids":["85e5ea976718b1331eade5d9f567654b","eb663365f6944558113da9820789b8fd","ac3af5754777c65209c3d9c7cc03dfb2"]}},{"_id":"invLocation_2_DBCF3E06-B812-B6C7-930E-74F9372D384A","_rev":"3-a15f0e36baae0abfa52ae68b42e3ad0e","data":{"quantity":999998,"location":"Pharmacy","aisleLocation":null,"lastModified":"2015-12-29T04:01:16.092Z","modifiedBy":"Admin User","modifiedFields":{"location":"2015-12-29T03:08:57.191Z","quantity":"2015-12-29T04:01:16.092Z"}},"_revisions":{"start":3,"ids":["a15f0e36baae0abfa52ae68b42e3ad0e","d365a641356ccd999cf5f91ec842f5a9","e8dfec40fbf6418583392d73b24a9b32"]}},{"_id":"invPurchase_2_05760051-8BD1-ACC0-8013-0C59A545FB8D","_rev":"2-d7477df9559ec794be0e3084f09c310b","data":{"purchaseCost":12,"lotNumber":"","dateReceived":"2015-11-01T05:00:00.000Z","originalQuantity":25,"currentQuantity":0,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T03:46:41.558Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:12:56.853Z","purchaseCost":"2015-12-29T03:12:56.853Z","lotNumber":"2015-12-29T03:12:56.853Z","vendor":"2015-12-29T03:12:56.853Z","vendorItemNo":"2015-12-29T03:12:56.853Z","originalQuantity":"2015-12-29T03:12:56.853Z","currentQuantity":"2015-12-29T03:46:41.558Z","inventoryItem":"2015-12-29T03:12:56.853Z"}},"_revisions":{"start":2,"ids":["d7477df9559ec794be0e3084f09c310b","2b41a3edbfe25818058eca69712b2033"]}},{"_id":"invPurchase_2_155B2B94-6C47-E6B5-BD1E-11F375CB2C29","_rev":"1-8308be24f6677a3a6aefc7cdde9b1c13","data":{"purchaseCost":6,"lotNumber":null,"dateReceived":"2015-12-03T06:00:00.000Z","originalQuantity":12,"currentQuantity":12,"expirationDate":null,"expired":false,"location":"Warehouse","aisleLocation":"A1","giftInKind":false,"inventoryItem":"iiqtim0c_ex","vendor":"ACME INC","vendorItemNo":"","distributionUnit":"pcs","invoiceNo":"","lastModified":"2015-12-29T03:47:25.866Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:47:25.866Z","distributionUnit":"2015-12-29T03:47:25.866Z","inventoryItem":"2015-12-29T03:47:25.866Z","invoiceNo":"2015-12-29T03:47:25.866Z","originalQuantity":"2015-12-29T03:47:25.866Z","quantityGroups":"2015-12-29T03:47:25.866Z","purchaseCost":"2015-12-29T03:47:25.866Z","vendor":"2015-12-29T03:47:25.866Z","vendorItemNo":"2015-12-29T03:47:25.866Z","location":"2015-12-29T03:47:25.866Z","aisleLocation":"2015-12-29T03:47:25.866Z","currentQuantity":"2015-12-29T03:47:25.866Z"},"quantityGroups":[{"index":0,"unit":"pcs","firstQuantity":true,"quantity":"12"}]}},{"_id":"invPurchase_2_E3B2184F-4ECA-3B76-92C8-437846C2E3DC","_rev":"2-846e30db369e739e0603938b12776d45","data":{"purchaseCost":12345,"lotNumber":null,"dateReceived":"2015-12-01T06:00:00.000Z","originalQuantity":1000000,"currentQuantity":999998,"expirationDate":null,"expired":false,"location":null,"aisleLocation":null,"giftInKind":false,"inventoryItem":"iiqtc6w3_31","vendor":"ACME INC","vendorItemNo":null,"distributionUnit":null,"invoiceNo":null,"lastModified":"2015-12-29T04:01:16.093Z","modifiedBy":"Admin User","modifiedFields":{"dateReceived":"2015-12-29T03:08:23.921Z","purchaseCost":"2015-12-29T03:08:23.921Z","vendor":"2015-12-29T03:08:23.921Z","originalQuantity":"2015-12-29T03:08:23.921Z","currentQuantity":"2015-12-29T04:01:16.093Z","inventoryItem":"2015-12-29T03:08:23.921Z"}},"_revisions":{"start":2,"ids":["846e30db369e739e0603938b12776d45","03ddad7882d9ed7041637de509902109"]}},{"_id":"invRequest_2_2A5251B5-1919-CB55-8757-A53DC057A77E","_rev":"1-222c0c115dc924e7d90cbde2b6023ebd","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":null,"markAsConsumed":true,"quantity":1000000,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:08:57.351Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:08:57.351Z","dateCompleted":"2015-12-29T03:08:57.351Z","quantity":"2015-12-29T03:08:57.351Z","deliveryLocation":"2015-12-29T03:08:57.351Z","transactionType":"2015-12-29T03:08:57.351Z","locationsAffected":"2015-12-29T03:08:57.351Z","status":"2015-12-29T03:08:57.351Z","completedBy":"2015-12-29T03:08:57.351Z"},"locationsAffected":[{"name":"No Location","quantity":"1000000"}]}},{"_id":"invRequest_2_6F095231-0D58-E48D-B59F-8D4CB3965802","_rev":"1-f709e83b929a4ac8e25c39de04bb36d9","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.01,"dateCompleted":"2015-12-29T04:01:16.080Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":null,"expenseAccount":null,"markAsConsumed":true,"quantity":2,"quantityAtCompletion":1000000,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T04:01:16.251Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":null,"modifiedFields":{"dateCompleted":"2015-12-29T04:01:16.251Z","quantity":"2015-12-29T04:01:16.251Z","transactionType":"2015-12-29T04:01:16.251Z","markAsConsumed":"2015-12-29T04:01:16.251Z","adjustPurchases":"2015-12-29T04:01:16.251Z","costPerUnit":"2015-12-29T04:01:16.251Z","quantityAtCompletion":"2015-12-29T04:01:16.251Z","purchasesAffected":"2015-12-29T04:01:16.251Z","locationsAffected":"2015-12-29T04:01:16.251Z","status":"2015-12-29T04:01:16.251Z","completedBy":"2015-12-29T04:01:16.251Z"},"purchasesAffected":[{"id":"E3B2184F-4ECA-3B76-92C8-437846C2E3DC","quantity":2}],"locationsAffected":[{"name":"Pharmacy","quantity":2}]}},{"_id":"invRequest_2_91481B28-0A00-9C72-9094-E34D6B70442D","_rev":"1-c1b1d2ef55725427ea6f31fafd43a776","data":{"adjustPurchases":false,"completedBy":null,"costPerUnit":null,"dateCompleted":null,"dateRequested":"2015-12-29T03:47:47.911Z","deliveryAisle":null,"deliveryLocation":"Pharmacy","expenseAccount":"Pharmacy","markAsConsumed":true,"quantity":2,"quantityAtCompletion":null,"reason":null,"requestedBy":"Admin User","status":"Requested","transactionType":"Request","lastModified":"2015-12-29T03:47:47.912Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:47:47.912Z","quantity":"2015-12-29T03:47:47.912Z","deliveryLocation":"2015-12-29T03:47:47.912Z","expenseAccount":"2015-12-29T03:47:47.912Z","dateRequested":"2015-12-29T03:47:47.912Z","requestedBy":"2015-12-29T03:47:47.912Z","status":"2015-12-29T03:47:47.912Z"}}},{"_id":"invRequest_2_B419E42C-87A8-1AFC-BDEF-3145ED774BE7","_rev":"1-a61eb2eac18550ed06ae528db3de51f0","data":{"adjustPurchases":false,"completedBy":"Admin User","costPerUnit":null,"dateCompleted":"2015-12-01T06:00:00.000Z","dateRequested":null,"deliveryAisle":null,"deliveryLocation":"Warehouse","expenseAccount":null,"markAsConsumed":true,"quantity":25,"quantityAtCompletion":null,"reason":null,"requestedBy":null,"status":"Completed","transactionType":"Transfer","lastModified":"2015-12-29T03:13:47.447Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"adjustPurchases":"2015-12-29T03:13:47.447Z","dateCompleted":"2015-12-29T03:13:47.447Z","quantity":"2015-12-29T03:13:47.447Z","deliveryLocation":"2015-12-29T03:13:47.447Z","transactionType":"2015-12-29T03:13:47.447Z","locationsAffected":"2015-12-29T03:13:47.447Z","status":"2015-12-29T03:13:47.447Z","completedBy":"2015-12-29T03:13:47.447Z"},"locationsAffected":[{"name":"No Location","quantity":"25"}]}},{"_id":"invRequest_2_CA5F4301-1600-1230-B276-0B3C98402C13","_rev":"1-9c9872e5caf5f80fe4cf434e014fcfe3","data":{"adjustPurchases":true,"completedBy":"Admin User","costPerUnit":0.48,"dateCompleted":"2015-12-28T06:00:00.000Z","dateRequested":"2015-12-29T03:46:41.543Z","deliveryAisle":null,"deliveryLocation":"Ward 1","expenseAccount":"Ward","markAsConsumed":true,"quantity":25,"quantityAtCompletion":25,"reason":null,"requestedBy":"Admin User","status":"Completed","transactionType":"Fulfillment","lastModified":"2015-12-29T03:46:41.732Z","modifiedBy":"Admin User","inventoryItem":"iiqtim0c_ex","patient":null,"visit":null,"modifiedFields":{"transactionType":"2015-12-29T03:46:41.732Z","quantity":"2015-12-29T03:46:41.732Z","dateCompleted":"2015-12-29T03:46:41.732Z","deliveryLocation":"2015-12-29T03:46:41.732Z","expenseAccount":"2015-12-29T03:46:41.732Z","dateRequested":"2015-12-29T03:46:41.732Z","requestedBy":"2015-12-29T03:46:41.732Z","adjustPurchases":"2015-12-29T03:46:41.732Z","costPerUnit":"2015-12-29T03:46:41.732Z","quantityAtCompletion":"2015-12-29T03:46:41.732Z","purchasesAffected":"2015-12-29T03:46:41.732Z","locationsAffected":"2015-12-29T03:46:41.732Z","status":"2015-12-29T03:46:41.732Z","completedBy":"2015-12-29T03:46:41.732Z"},"purchasesAffected":[{"id":"05760051-8BD1-ACC0-8013-0C59A545FB8D","quantity":25}],"locationsAffected":[{"name":"Warehouse","quantity":25}]}},{"_id":"inventory_2_iiqtc6w3_31","_rev":"3-0c0a71f273bf0633cafce271b0f35007","data":{"description":null,"friendlyId":"m00001","name":"Cefazolin 500mg vial (Hazolin)","quantity":999998,"crossReference":null,"inventoryType":"Medication","price":null,"reorderPoint":null,"distributionUnit":"vial","rank":null,"lastModified":"2015-12-29T04:01:16.249Z","modifiedBy":"Admin User","locations":["24BB235E-B271-AF61-9A3D-9ACD77CE25AF","DBCF3E06-B812-B6C7-930E-74F9372D384A"],"purchases":["E3B2184F-4ECA-3B76-92C8-437846C2E3DC"],"modifiedFields":{"name":"2015-12-29T03:08:24.053Z","inventoryType":"2015-12-29T03:08:24.053Z","distributionUnit":"2015-12-29T03:08:24.053Z","quantity":"2015-12-29T04:01:16.249Z","friendlyId":"2015-12-29T03:08:24.053Z"}},"_revisions":{"start":3,"ids":["0c0a71f273bf0633cafce271b0f35007","42bc38c66d9a87103c7871aa9aadb6b5","295e3c0d1de3d7a7d384ae5090d82125"]}},{"_id":"inventory_2_iiqtim0c_ex","_rev":"4-6900f25cb0aa33334fb6c69e4a828718","data":{"description":null,"friendlyId":"s00001","name":"Pumpset Kangaroo 1000ml","quantity":12,"crossReference":null,"inventoryType":"Supply","price":null,"reorderPoint":null,"distributionUnit":"pcs","rank":null,"lastModified":"2015-12-29T03:47:26.017Z","modifiedBy":"Admin User","locations":["0323721B-EDD0-6C91-BB34-52FBEACBA7DE","7FD0F94A-6D4E-6365-A4EF-F7B4F8D35C22","32BCC947-E272-1564-90E1-C6E2ECE14881"],"purchases":["05760051-8BD1-ACC0-8013-0C59A545FB8D","155B2B94-6C47-E6B5-BD1E-11F375CB2C29"],"modifiedFields":{"name":"2015-12-29T03:12:56.959Z","inventoryType":"2015-12-29T03:12:56.959Z","distributionUnit":"2015-12-29T03:12:56.959Z","quantity":"2015-12-29T03:47:26.017Z","friendlyId":"2015-12-29T03:12:56.959Z"}},"_revisions":{"start":4,"ids":["6900f25cb0aa33334fb6c69e4a828718","03eb3fc36799eb0e78c1d4f5b45e50a0","064996d833372bc743ccd60baa1174b9","1622cc9c6428d24950f02c88112840f4"]}},{"_id":"lab_2_C9274C34-248C-FF7C-9E8B-F3110467C941","_rev":"2-78aaf934410f626a7dc64c8ce640ad17","data":{"labDate":"2015-12-29T04:07:25.725Z","notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:03:22.879Z","result":"Normal","status":"Completed","lastModified":"2015-12-29T04:07:25.725Z","modifiedBy":"Admin User","labType":"A33BFA09-AFBB-CA35-A01C-702B568FFAE8","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:07:25.725Z","requestedBy":"2015-12-29T04:03:22.927Z","requestedDate":"2015-12-29T04:03:22.927Z","result":"2015-12-29T04:07:25.725Z","labDate":"2015-12-29T04:07:25.725Z"}},"_revisions":{"start":2,"ids":["78aaf934410f626a7dc64c8ce640ad17","0e55563ae178ae5b340c29a50f168925"]}},{"_id":"lab_2_EE3063E6-832D-930D-AD4E-D27341709886","_rev":"1-b0364bd6b060df4a2084ca292de1ad71","data":{"labDate":null,"notes":null,"requestedBy":"Admin User","requestedDate":"2015-12-29T04:18:34.699Z","result":null,"status":"Requested","lastModified":"2015-12-29T04:18:34.731Z","modifiedBy":"Admin User","labType":"4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":[],"modifiedFields":{"status":"2015-12-29T04:18:34.731Z","requestedBy":"2015-12-29T04:18:34.731Z","requestedDate":"2015-12-29T04:18:34.731Z"}}}]} +{"seq":74} +{"docs":[{"_id":"lookup_2_aisle_location_list","_rev":"1-255c62c74fb06e5c13664e9e70aebef5","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["A1"]}},{"_id":"lookup_2_cpt_code_list","_rev":"1-499cca90fccff759c62b2fc781010226","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["27001"]}},{"_id":"lookup_2_diagnosis_list","_rev":"1-889e0d198f50d28df33bf522106b9438","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Fall from in-line roller-skates, initial encounter"]}},{"_id":"lookup_2_expense_account_list","_rev":"2-3404736b154767f3fe30e297704480be","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward"]},"_revisions":{"start":2,"ids":["3404736b154767f3fe30e297704480be","36426f839aa10324a85e92d34fcf2c26"]}},{"_id":"lookup_2_patient_status_list","_rev":"1-01d7dfb8ec77de492bf913c5c763578c","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Scheduled for surgery"]}},{"_id":"lookup_2_physician_list","_rev":"1-99c8212cef905d552ab95fc88b8c3d5b","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Nick"]}},{"_id":"lookup_2_procedure_list","_rev":"1-d48989bf01a1ae70a26e397c43266278","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["hip adductor release"]}},{"_id":"lookup_2_radiologists","_rev":"1-f029e944b51dcc7fd6f980d72c7027c7","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Dr Xray"]}},{"_id":"lookup_2_sex","_rev":"2-215b9ef2d7091253f179116902ee61ae","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Female","Male"]},"_revisions":{"start":2,"ids":["215b9ef2d7091253f179116902ee61ae","0cb12aaddee831fd798fd248e108f946"]}},{"_id":"lookup_2_vendor_list","_rev":"1-a2760a7c86532da3f92ac75899b37e06","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["ACME INC"]}},{"_id":"lookup_2_visit_location_list","_rev":"1-d373d65b719c266173d92d3bb8f14e9f","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Hospital"]}},{"_id":"lookup_2_warehouse_list","_rev":"3-86923622f95bb3f49a906cb7cbacdc85","data":{"importFile":false,"organizeByType":false,"userCanAdd":true,"value":["Pharmacy","Ward 1","Warehouse"]},"_revisions":{"start":3,"ids":["86923622f95bb3f49a906cb7cbacdc85","64a1b3813d337c7000044dbc2de21892","4f316909ed8500d0f80cf20a684ce343"]}},{"_id":"medication_2_7B63E873-D056-CCC5-A69C-60064472A16E","_rev":"1-1ebd1e9a0f4dd4d90b52eb37db7fb493","data":{"notes":null,"prescription":"Twice a day for two days","prescriptionDate":"2015-12-28T06:00:00.000Z","quantity":4,"refills":null,"requestedDate":"2015-12-29T04:16:44.877Z","requestedBy":"Admin User","status":"Requested","lastModified":"2015-12-29T04:16:44.879Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:16:44.879Z","prescription":"2015-12-29T04:16:44.879Z","quantity":"2015-12-29T04:16:44.879Z","status":"2015-12-29T04:16:44.879Z","requestedBy":"2015-12-29T04:16:44.879Z","requestedDate":"2015-12-29T04:16:44.879Z"}}},{"_id":"medication_2_9187CEE0-13EC-1816-A2A4-95E9797999BF","_rev":"1-271cd0960f61b322d66b57a994141733","data":{"notes":null,"prescription":"Once a day for 2 days","prescriptionDate":"2015-12-01T06:00:00.000Z","quantity":2,"refills":null,"requestedDate":"2015-12-29T04:01:16.079Z","requestedBy":"Admin User","status":"Fulfilled","lastModified":"2015-12-29T04:01:16.096Z","modifiedBy":"Admin User","inventoryItem":"iiqtc6w3_31","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","modifiedFields":{"prescriptionDate":"2015-12-29T04:01:16.096Z","prescription":"2015-12-29T04:01:16.096Z","quantity":"2015-12-29T04:01:16.096Z","status":"2015-12-29T04:01:16.096Z","requestedBy":"2015-12-29T04:01:16.096Z","requestedDate":"2015-12-29T04:01:16.096Z"}}},{"_id":"patient_2_C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","_rev":"4-1c58ffef18d0e8a6cf67f5af11541f71","data":{"admitted":true,"address":null,"address2":null,"address3":null,"address4":null,"bloodType":null,"clinic":null,"country":null,"dateOfBirth":"2013-08-06T05:00:00.000Z","economicClassification":null,"email":null,"externalPatientId":null,"familySupport1":null,"familySupport2":null,"familySupport3":null,"familySupport4":null,"familySupport5":null,"friendlyId":"P00001","firstName":"Joe","sex":"Male","history":null,"insurance":null,"lastName":"Bagadonuts","livingArrangement":null,"middleName":"","notes":null,"otherIncome":null,"patientType":null,"parent":null,"phone":null,"placeOfBirth":null,"referredDate":null,"referredBy":null,"religion":null,"socialActionTaken":null,"socialRecommendation":null,"status":"Scheduled for surgery","lastModified":"2015-12-29T03:53:58.574Z","modifiedBy":"Admin User","paymentProfile":null,"payments":[],"modifiedFields":{"friendlyId":"2015-12-29T03:51:02.781Z","firstName":"2015-12-29T03:51:02.781Z","middleName":"2015-12-29T03:51:02.781Z","lastName":"2015-12-29T03:51:02.781Z","gender":"2015-12-29T03:51:02.781Z","dateOfBirth":"2015-12-29T03:51:02.781Z","status":"2015-12-29T03:53:17.032Z","admitted":"2015-12-29T03:53:58.574Z"}},"_revisions":{"start":4,"ids":["1c58ffef18d0e8a6cf67f5af11541f71","1351af326b99acc03278830f30192916","105429e78d710023d6d490e880a3132a","fa6de36be0214f08f09477729bdfb339"]}},{"_id":"pricing_2_4C0FA251-6FEA-8DDA-9DEB-83993EAB25F2","_rev":"1-410ff865070244eac14c5cad5db0ad80","data":{"category":"Lab","expenseAccount":null,"name":"Fasting Blood Sugar (FBS)","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:18:34.703Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:18:34.703Z","category":"2015-12-29T04:18:34.703Z","pricingType":"2015-12-29T04:18:34.703Z"}}},{"_id":"pricing_2_A33BFA09-AFBB-CA35-A01C-702B568FFAE8","_rev":"1-70ff211de7621293ffbd91df901f6d0f","data":{"category":"Lab","expenseAccount":null,"name":"Bleeding Time","price":null,"pricingType":"Lab Procedure","lastModified":"2015-12-29T04:03:22.884Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:03:22.884Z","category":"2015-12-29T04:03:22.884Z","pricingType":"2015-12-29T04:03:22.884Z"}}},{"_id":"pricing_2_B93625F1-3C41-2D3E-94B9-3A8BAF87EBE8","_rev":"1-30c9df5437c85bb21539024c7222d307","data":{"category":"Imaging","expenseAccount":null,"name":"Ankle (Any Single View)","price":null,"pricingType":"Imaging Procedure","lastModified":"2015-12-29T04:07:03.700Z","modifiedBy":"Admin User","pricingOverrides":[],"modifiedFields":{"name":"2015-12-29T04:07:03.700Z","category":"2015-12-29T04:07:03.700Z","pricingType":"2015-12-29T04:07:03.700Z"}}},{"_id":"procCharge_2_0AD46995-188B-EFB9-8A33-E47B3980476C","_rev":"1-3f577e28daa86e12c2ad71799e383c3b","data":{"quantity":1,"dateCharged":"2015-12-29T04:00:00.093Z","lastModified":"2015-12-29T04:00:08.611Z","modifiedBy":"Admin User","medication":"iiqtc6w3_31","pricingItem":null,"modifiedFields":{"dateCharged":"2015-12-29T04:00:08.611Z","quantity":"2015-12-29T04:00:08.611Z"}}},{"_id":"procedure_2_398B4F58-152F-1476-8ED1-329C4D85E25F","_rev":"5-979bd8081e0ae3ccebf595c28bafd145","data":{"anesthesiaType":"","anesthesiologist":null,"assistant":null,"description":"hip adductor release","cptCode":"27001","location":null,"notes":null,"physician":"Dr Nick","procedureDate":"2015-12-01T06:00:00.000Z","timeStarted":null,"timeEnded":null,"lastModified":"2015-12-29T04:00:33.229Z","modifiedBy":"Admin User","visit":"03C7BF8B-04E0-DD9E-9469-96A5604F5340","charges":["0AD46995-188B-EFB9-8A33-E47B3980476C"],"modifiedFields":{"procedureDate":"2015-12-29T03:59:55.401Z","description":"2015-12-29T03:59:37.244Z","physician":"2015-12-29T03:59:37.244Z","anesthesiaType":"2015-12-29T03:59:37.244Z","cptCode":"2015-12-29T04:00:33.229Z"}},"_revisions":{"start":5,"ids":["979bd8081e0ae3ccebf595c28bafd145","561ab91abdd5e0f240a3ec30c9a3e09c","0a938774f0f0e600f15dd29d08b98b50","5570e1e8726f29f430a5de6e81a36e60","6c0abd3cf72cb182b05caa21150fb113"]}},{"_id":"sequence_2_inventory_Medication","_rev":"1-1acccea88a50973cbe8840a31911aa7c","data":{"prefix":"m","value":1}},{"_id":"sequence_2_inventory_Supply","_rev":"1-538fc2bf7cd4745eea01fcf24ced6164","data":{"prefix":"s","value":1}},{"_id":"sequence_2_patient","_rev":"5-f6fd8c9cb7b07567399a04a72f02822a","data":{"prefix":null,"value":1},"_revisions":{"start":5,"ids":["f6fd8c9cb7b07567399a04a72f02822a","79dabe4ed5c7897e103171a7bf8bf1b6","945c072575a32fca103968a3cd425c31","f9a8fd6c55cd4e5fb0064b7767586e05","5bc31ffefa482f2e66299cf0704623c8"]}},{"_id":"visit_2_03C7BF8B-04E0-DD9E-9469-96A5604F5340","_rev":"14-09b2a3ac1ac8c343d0f6a6d667bc5357","data":{"dischargeInfo":null,"endDate":"2015-12-29T04:11:00.724Z","examiner":"Dr Nick","history":null,"historySince":null,"location":null,"notes":null,"outPatient":false,"paymentState":"pending","primaryDiagnosis":"Fall from in-line roller-skates, initial encounter","primaryBillingDiagnosis":null,"primaryBillingDiagnosisId":null,"startDate":"2015-12-01T15:53:00.000Z","status":"Admitted","visitType":"Admission","archived":false,"lastModified":"2016-11-02T13:40:50.466Z","modifiedBy":"Admin User","patient":"C87BFCB2-F772-7A7B-8FC7-AD00C018C32A","vitals":["B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC"],"procedures":["398B4F58-152F-1476-8ED1-329C4D85E25F"],"patientNotes":[],"medication":["9187CEE0-13EC-1816-A2A4-95E9797999BF","7B63E873-D056-CCC5-A69C-60064472A16E"],"labs":["C9274C34-248C-FF7C-9E8B-F3110467C941","EE3063E6-832D-930D-AD4E-D27341709886"],"imaging":["51AFF85A-69C0-97C1-B22C-716A1BA7B80B","12DEDA58-4670-7A74-BA8B-9CC5E5CA82E7"],"charges":[],"modifiedFields":{"visitType":"2015-12-29T03:53:58.543Z","startDate":"2015-12-29T04:11:47.272Z","status":"2016-11-02T13:40:50.466Z","outPatient":"2015-12-29T03:53:58.543Z","primaryDiagnosis":"2015-12-29T03:59:37.312Z","examiner":"2015-12-29T04:06:19.274Z","endDate":"2015-12-29T04:11:47.272Z"}},"_revisions":{"start":14,"ids":["09b2a3ac1ac8c343d0f6a6d667bc5357","c5db061eca43852a9082628407227388","48973daa88a2567931f70586aa5f4b6e","0baeb91a16dad77c0d8e55e6b38e6c8e","e26c621939e57cdf40fe92362f5dac3a","7315d0ff5e6eac570c2b47fd6e9d9406","d1be40a55f4329d18cc6c8f8b8b2d55a","e8567f5b5576aa5d4141f2776b24ab58","d54e63df97dd964288c6dd66d049dae9","210c948fb309be4793ca14cec7f3a335","29e6bb7a6732517b79f8c90fbcebdedd","a83b26f6b056f7c54d917160b366a75b","ebed6471bdd978af39c5acfc3f1f34b7","284cb8e69ca4b392156fe1d22866fcfb"]}},{"_id":"vital_2_B9FDB59B-BA3F-40A2-9D42-2A9B0E7270FC","_rev":"1-62233a35020adba2b7d65fd09e5e3cba","data":{"dateRecorded":"2015-12-04T04:08:00.000Z","temperature":36.67,"weight":"57lb","height":"3'6\"","sbp":117,"dbp":76,"heartRate":60,"respiratoryRate":12,"lastModified":"2015-12-29T04:11:11.942Z","modifiedBy":"Admin User","modifiedFields":{"dateRecorded":"2015-12-29T04:11:11.942Z","temperature":"2015-12-29T04:11:11.942Z","weight":"2015-12-29T04:11:11.942Z","height":"2015-12-29T04:11:11.942Z","sbp":"2015-12-29T04:11:11.942Z","dbp":"2015-12-29T04:11:11.942Z","heartRate":"2015-12-29T04:11:11.942Z","respiratoryRate":"2015-12-29T04:11:11.942Z"}}}]} +{"seq":99} diff --git a/tests/helpers/run-with-pouch-dump.js b/tests/helpers/run-with-pouch-dump.js index 7441651b8d..a3d0ce98f7 100644 --- a/tests/helpers/run-with-pouch-dump.js +++ b/tests/helpers/run-with-pouch-dump.js @@ -75,7 +75,7 @@ function runWithPouchDumpAsyncHelper(app, dumpName, functionToRun) { return new Ember.RSVP.Promise(function(resolve) { promise.then(function() { - db.setMaxListeners(30); + db.setMaxListeners(35); createPouchViews(db, true, dumpName).then(function() { functionToRun(); andThen(function() { diff --git a/tests/unit/controllers/abstract-edit-controller-test.js b/tests/unit/controllers/abstract-edit-controller-test.js index 6042ce5a45..aca22af575 100644 --- a/tests/unit/controllers/abstract-edit-controller-test.js +++ b/tests/unit/controllers/abstract-edit-controller-test.js @@ -116,15 +116,16 @@ test('actions.update exception message', function(assert) { let controller = this.subject(); controller.beforeUpdate = function() { - throw 'Test'; + throw new Error('Test'); }; controller.displayAlert = function stub(title, message) { - alertTitle = title; - alertMessage = message; + console.log('title for display alert is:', title); + alertTitle = title.toString(); + alertMessage = message.toString(); }; controller.send('update'); assert.equal(alertTitle, 'Error!!!!'); - assert.equal(alertMessage, 'An error occurred while attempting to save: "Test"'); + assert.equal(alertMessage, 'An error occurred while attempting to save: Test'); }); From 964018d7a270024b73eef3e7b4417f269868e5aa Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 13 Mar 2017 16:08:51 -0400 Subject: [PATCH 121/124] Fix issues with tests. --- config/deprecation-workflow.js | 8 ++++---- tests/acceptance/incident-test.js | 3 ++- tests/unit/controllers/abstract-edit-controller-test.js | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/deprecation-workflow.js b/config/deprecation-workflow.js index 143788624c..27fb7a737b 100644 --- a/config/deprecation-workflow.js +++ b/config/deprecation-workflow.js @@ -1,9 +1,9 @@ window.deprecationWorkflow = window.deprecationWorkflow || {}; window.deprecationWorkflow.config = { workflow: [ - { handler: "silence", matchId: "ember-application.injected-container" }, - { handler: "silence", matchId: "ember-views.render-double-modify" }, - { handler: "silence", matchId: "ember-metal.binding" }, - { handler: "silence", matchId: "ember-views.did-init-attrs" } + { handler: 'silence', matchId: 'ember-getowner-polyfill.import' }, + { handler: 'silence', matchId: 'ember-metal.binding' }, + { handler: 'silence', matchId: 'ember-views.did-init-attrs' }, + { handler: 'silence', matchId: 'ds.serializer.private-should-serialize-has-many' } ] }; diff --git a/tests/acceptance/incident-test.js b/tests/acceptance/incident-test.js index 4adb4ee614..027e380dd3 100644 --- a/tests/acceptance/incident-test.js +++ b/tests/acceptance/incident-test.js @@ -177,9 +177,10 @@ test('Incident creation and editing', function(assert) { visit('/incident/edit/56c64d71-ba30-4271-b899-f6f6b031f589'); }); andThen(() => { + let incidentDate = moment(1489004400000); assert.equal(currentURL(), '/incident/edit/56c64d71-ba30-4271-b899-f6f6b031f589', 'Incident edit url is correct'); assert.equal(find('.sentinel-event input:checked').length, 1, 'Sentinel Event checkbox is checked'); - assert.equal(find('.incident-date input').val(), '3/8/2017 3:20 PM', 'Date of incident displays'); + assert.equal(find('.incident-date input').val(), incidentDate.format(DATE_TIME_FORMAT), 'Date of incident displays'); assert.equal(find('.incident-department .tt-input').val(), 'Reception', 'Incident department displays'); assert.equal(find('.reported-to input').val(), 'Jane Bagadonuts', 'Reported to displays.'); assert.equal(find('.incident-category option:selected').text().trim(), 'Accident or Injury', 'Category displays'); diff --git a/tests/unit/controllers/abstract-edit-controller-test.js b/tests/unit/controllers/abstract-edit-controller-test.js index aca22af575..6efc38a38d 100644 --- a/tests/unit/controllers/abstract-edit-controller-test.js +++ b/tests/unit/controllers/abstract-edit-controller-test.js @@ -119,7 +119,6 @@ test('actions.update exception message', function(assert) { throw new Error('Test'); }; controller.displayAlert = function stub(title, message) { - console.log('title for display alert is:', title); alertTitle = title.toString(); alertMessage = message.toString(); }; From 79d52a4b3d9f0323aba0d9339e2d2682a6e14206 Mon Sep 17 00:00:00 2001 From: Adeola Badmus Date: Tue, 14 Mar 2017 13:30:45 +0100 Subject: [PATCH 122/124] Implement acceptance tests for OPD Report --- app/medication/edit/controller.js | 2 +- app/reports/edit/template.hbs | 58 ++++---- app/visits/edit/template.hbs | 2 +- tests/acceptance/visit-test.js | 230 +++++++++++++++++++++++++----- 4 files changed, 224 insertions(+), 68 deletions(-) diff --git a/app/medication/edit/controller.js b/app/medication/edit/controller.js index 9aaa6a6666..21c142449a 100644 --- a/app/medication/edit/controller.js +++ b/app/medication/edit/controller.js @@ -35,7 +35,7 @@ export default AbstractEditController.extend(AddNewPatient, FulfillRequest, Inve prescriptionClass: function() { let quantity = this.get('model.quantity'); if (Ember.isEmpty(quantity)) { - return 'required'; + return 'required test-medication-prescription'; } }.property('model.quantity'), diff --git a/app/reports/edit/template.hbs b/app/reports/edit/template.hbs index 78da867d8a..c120ceb334 100644 --- a/app/reports/edit/template.hbs +++ b/app/reports/edit/template.hbs @@ -32,69 +32,69 @@ }} {{/if}} -
      -