diff --git a/app/invoices/edit/controller.js b/app/invoices/edit/controller.js
index 0422974981..d2ca2ec60b 100644
--- a/app/invoices/edit/controller.js
+++ b/app/invoices/edit/controller.js
@@ -231,20 +231,20 @@ export default AbstractEditController.extend(NumberFormat, PatientSubmodule, Pub
}.observes('model.visit'),
_addPharmacyCharge: function(charge, medicationItemName) {
- var medicationItem = charge.get(medicationItemName),
- price = medicationItem.get('price'),
- quantity = charge.get('quantity'),
- pharmacyCharges = this.get('pharmacyCharges'),
- pharmacyExpenseAccount = this.get('pharmacyExpenseAccount'),
- pharmacyCharge = this.store.createRecord('line-item-detail', {
+ return charge.getMedicationDetails(medicationItemName).then((medicationDetails) => {
+ let quantity = charge.get('quantity');
+ let pharmacyCharges = this.get('pharmacyCharges');
+ let pharmacyExpenseAccount = this.get('pharmacyExpenseAccount');
+ let pharmacyCharge = this.store.createRecord('line-item-detail', {
id: PouchDB.utils.uuid(),
- name: medicationItem.get('name'),
+ name: medicationDetails.name,
quantity: quantity,
- price: price,
+ price: medicationDetails.price,
department: 'Pharmacy',
expenseAccount: pharmacyExpenseAccount
});
- pharmacyCharges.addObject(pharmacyCharge);
+ pharmacyCharges.addObject(pharmacyCharge);
+ });
},
_addSupplyCharge: function(charge, department) {
@@ -334,8 +334,9 @@ export default AbstractEditController.extend(NumberFormat, PatientSubmodule, Pub
}
}
+ let pharmacyChargePromises = [];
medication.forEach(function(medicationItem) {
- this._addPharmacyCharge(medicationItem, 'inventoryItem');
+ pharmacyChargePromises.push(this._addPharmacyCharge(medicationItem, 'inventoryItem'));
}.bind(this));
this.set('wardCharges', visitCharges.map(this._mapWardCharge.bind(this)));
@@ -344,7 +345,7 @@ export default AbstractEditController.extend(NumberFormat, PatientSubmodule, Pub
var charges = procedure.get('charges');
charges.forEach(function(charge) {
if (charge.get('medicationCharge')) {
- this._addPharmacyCharge(charge, 'medication');
+ pharmacyChargePromises.push(this._addPharmacyCharge(charge, 'medication'));
} else {
this._addSupplyCharge(charge, 'O.R.');
}
@@ -375,45 +376,47 @@ export default AbstractEditController.extend(NumberFormat, PatientSubmodule, Pub
}.bind(this));
}.bind(this));
- lineItem = this.store.createRecord('billing-line-item', {
- id: PouchDB.utils.uuid(),
- name: 'Pharmacy',
- category: 'Hospital Charges'
- });
- lineItem.get('details').addObjects(this.get('pharmacyCharges'));
- lineItems.addObject(lineItem);
+ Ember.RSVP.all(pharmacyChargePromises).then(() => {
+ lineItem = this.store.createRecord('billing-line-item', {
+ id: PouchDB.utils.uuid(),
+ name: 'Pharmacy',
+ category: 'Hospital Charges'
+ });
+ lineItem.get('details').addObjects(this.get('pharmacyCharges'));
+ lineItems.addObject(lineItem);
- lineItem = this.store.createRecord('billing-line-item', {
- id: PouchDB.utils.uuid(),
- name: 'X-ray/Lab/Supplies',
- category: 'Hospital Charges'
- });
- lineItem.get('details').addObjects(this.get('supplyCharges'));
- lineItems.addObject(lineItem);
+ lineItem = this.store.createRecord('billing-line-item', {
+ id: PouchDB.utils.uuid(),
+ name: 'X-ray/Lab/Supplies',
+ category: 'Hospital Charges'
+ });
+ lineItem.get('details').addObjects(this.get('supplyCharges'));
+ lineItems.addObject(lineItem);
- lineItem = this.store.createRecord('billing-line-item', {
- id: PouchDB.utils.uuid(),
- name: 'Ward Items',
- category: 'Hospital Charges'
- });
- lineItem.get('details').addObjects(this.get('wardCharges'));
- lineItems.addObject(lineItem);
+ lineItem = this.store.createRecord('billing-line-item', {
+ id: PouchDB.utils.uuid(),
+ name: 'Ward Items',
+ category: 'Hospital Charges'
+ });
+ lineItem.get('details').addObjects(this.get('wardCharges'));
+ lineItems.addObject(lineItem);
- lineItem = this.store.createRecord('billing-line-item', {
- id: PouchDB.utils.uuid(),
- name: 'Physical Therapy',
- category: 'Hospital Charges'
- });
- lineItems.addObject(lineItem);
+ lineItem = this.store.createRecord('billing-line-item', {
+ id: PouchDB.utils.uuid(),
+ name: 'Physical Therapy',
+ category: 'Hospital Charges'
+ });
+ lineItems.addObject(lineItem);
- lineItem = this.store.createRecord('billing-line-item', {
- id: PouchDB.utils.uuid(),
- name: 'Others/Misc',
- category: 'Hospital Charges'
- });
- lineItems.addObject(lineItem);
+ lineItem = this.store.createRecord('billing-line-item', {
+ id: PouchDB.utils.uuid(),
+ name: 'Others/Misc',
+ category: 'Hospital Charges'
+ });
+ lineItems.addObject(lineItem);
- this.send('update', true);
+ this.send('update', true);
+ });
},
_resolveVisitDescendents: function(results, childNameToResolve) {
diff --git a/app/medication/edit/controller.js b/app/medication/edit/controller.js
index 27db7dfba8..ae03cb40da 100644
--- a/app/medication/edit/controller.js
+++ b/app/medication/edit/controller.js
@@ -136,6 +136,8 @@ export default AbstractEditController.extend(InventorySelection, FulfillRequest,
this._addNewPatient();
reject('creating new patient first');
} else {
+ newMedication.set('medicationTitle', newMedication.get('inventoryItem.name'));
+ newMedication.set('priceOfMedication', newMedication.get('inventoryItem.price'));
newMedication.set('status', 'Requested');
newMedication.set('requestedBy', newMedication.getUserName());
newMedication.set('requestedDate', new Date());
diff --git a/app/medication/edit/template.hbs b/app/medication/edit/template.hbs
index 46fc267947..c4cc909d4f 100644
--- a/app/medication/edit/template.hbs
+++ b/app/medication/edit/template.hbs
@@ -24,7 +24,7 @@
{{#if isFulfilledOrRequested}}
- {{charge.medication.name}} |
+ {{charge.medicationName}} |
{{charge.quantity}} |
{{#if canAddCharge}}
diff --git a/app/procedures/medication/controller.js b/app/procedures/medication/controller.js
index 4841d99eb1..eed546a74c 100644
--- a/app/procedures/medication/controller.js
+++ b/app/procedures/medication/controller.js
@@ -10,15 +10,6 @@ export default AbstractEditController.extend(InventorySelection, {
updateCapability: 'add_charge',
- medicationChanged: function() {
- var model = this.get('model'),
- itemName = model.get('itemName'),
- medication = model.get('medication');
- if (!Ember.isEmpty(medication) && medication.get('name') !== itemName) {
- model.set('itemName', medication.get('name'));
- }
- }.observes('model.medication'),
-
title: function() {
var isNew = this.get('model.isNew');
if (isNew) {
@@ -31,6 +22,11 @@ export default AbstractEditController.extend(InventorySelection, {
var isNew = this.get('model.isNew');
if (isNew) {
this.set('newCharge', true);
+ let model = this.get('model');
+ let inventoryItem = model.get('inventoryItem');
+ model.set('medication', inventoryItem);
+ model.set('medicationTitle', inventoryItem.get('name'));
+ model.set('priceOfMedication', inventoryItem.get('price'));
}
return Ember.RSVP.Promise.resolve();
},
diff --git a/tests/fixtures/billing.txt b/tests/fixtures/billing.txt
index 341dcb50f8..bfc2a5ba75 100644
--- a/tests/fixtures/billing.txt
+++ b/tests/fixtures/billing.txt
@@ -1,9 +1,9 @@
-{"version":"1.2.5","db_type":"http","start_time":"2015-11-13T16:52:13.411Z","db_info":{"db_name":"main","doc_count":74,"doc_del_count":2,"update_seq":153,"purge_seq":0,"compact_running":false,"disk_size":389227,"data_size":43964,"instance_start_time":"1447425812302483","disk_format_version":6,"committed_update_seq":153,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}}
+{"version":"1.2.5","db_type":"http","start_time":"2016-02-09T20:22:21.382Z","db_info":{"db_name":"main","doc_count":77,"doc_del_count":5,"update_seq":94,"purge_seq":0,"compact_running":false,"disk_size":49263,"data_size":45107,"instance_start_time":"1455045032694158","disk_format_version":6,"committed_update_seq":94,"host":"http://localhost:5984/main/","auto_compaction":false,"adapter":"http"}}
{"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}));}"}}]}
+{"seq":1}
+{"docs":[{"_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);}}}"}}}]}
{"seq":2}
-{"docs":[{"_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]);}}}"}}}]}
-{"seq":3}
-{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9868b6586898a48c3fd68722ca3fe1d4","version":3,"views":{"appointments_by_patient":{"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([doc.data.patient, startDate, endDate,doc._id]);}}}"}}},{"_id":"_design/imaging_by_status","_rev":"1-9236042e1fb9f567d1d527bbb429cd8e","version":3,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_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}));}"}},{"_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);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/invoice_by_status","_rev":"1-73e3e45673ed0c4f4ae1cee855f216f0","version":3,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_id":"_design/lab_by_status","_rev":"1-db4393c6856b98a40afd6ceef31db2a7","version":3,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_id":"_design/medication_by_status","_rev":"1-36ce9e9853552f5eb646ed26de7184dc","version":3,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_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}));}"}},{"_id":"_design/patient_by_status","_rev":"1-ff26a12cdb8747aae5bf26f9af3a1953","version":2,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}}},{"_id":"_design/photo_by_patient","_rev":"1-e3dc5506f7f370535b85be0adc59c7cc","version":3,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/sequence_by_prefix","_rev":"1-8ac3a62b4c0b624ebed3b68b27cd197e","version":3,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/visit_by_discharge_date","_rev":"1-e53c95160dacaf007fe01c01215729ce","version":1,"views":{"visit_by_discharge_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();}}emit([endDate, doc._id]);}}}"}}},{"_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]);}}}"}}},{"_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_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_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":"invoice_2_6414F250-C6F0-9B1F-94D7-621A539737AF","_rev":"2-e1898aa278789e1d7c91c4e59289344d","_deleted":true,"_revisions":{"start":2,"ids":["e1898aa278789e1d7c91c4e59289344d","8fad9853ba8f801a3375fb0149c140bf"]}},{"_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_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_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":"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":"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":"2-7ab83617d991bfa730e55757d90c35ad","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","gender":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,"lastModified":"2015-11-12T21:15:12.204Z","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"}},"_revisions":{"start":2,"ids":["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_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":"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":"sequence_2_patient","_rev":"1-5bc31ffefa482f2e66299cf0704623c8","data":{"prefix":null,"value":1}}]}
-{"seq":69}
-{"docs":[{"_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_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":"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_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":"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_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_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_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_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":"1-f441e894d0aaaab3c3c394186e0cad67","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","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"}}},{"_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":"procedure_2_653A07CE-66E2-1DC8-A83C-4A25934559F0","_rev":"3-483b770e04706f935dc6275abf496a3a","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"],"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":3,"ids":["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":"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":153}
+{"docs":[{"_id":"_design/appointments_by_patient","_rev":"1-9868b6586898a48c3fd68722ca3fe1d4","version":3,"views":{"appointments_by_patient":{"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([doc.data.patient, startDate, endDate,doc._id]);}}}"}}},{"_id":"_design/imaging_by_status","_rev":"1-9236042e1fb9f567d1d527bbb429cd8e","version":3,"views":{"imaging_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_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}));}"}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/invoice_by_status","_rev":"1-73e3e45673ed0c4f4ae1cee855f216f0","version":3,"views":{"invoice_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_id":"_design/lab_by_status","_rev":"1-db4393c6856b98a40afd6ceef31db2a7","version":3,"views":{"lab_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_id":"_design/medication_by_status","_rev":"1-36ce9e9853552f5eb646ed26de7184dc","version":3,"views":{"medication_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {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]);}}}"}}},{"_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}));}"}},{"_id":"_design/patient_by_status","_rev":"1-ff26a12cdb8747aae5bf26f9af3a1953","version":2,"views":{"patient_by_status":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"patient\") {emit(doc.data.status);}}}"}}},{"_id":"_design/photo_by_patient","_rev":"1-e3dc5506f7f370535b85be0adc59c7cc","version":3,"views":{"photo_by_patient":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"photo\") {emit(doc.data.patient);}}}"}}},{"_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]);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/sequence_by_prefix","_rev":"1-8ac3a62b4c0b624ebed3b68b27cd197e","version":3,"views":{"sequence_by_prefix":{"map":"function(doc) {var doctype,uidx;if (doc._id && (uidx = doc._id.indexOf(\"_\")) > 0) {doctype = doc._id.substring(0, uidx);if(doctype === \"sequence\") {emit(doc.data.prefix);}}}"}}},{"_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]);}}}"}}},{"_id":"_design/visit_by_discharge_date","_rev":"1-e53c95160dacaf007fe01c01215729ce","version":1,"views":{"visit_by_discharge_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();}}emit([endDate, doc._id]);}}}"}}},{"_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]);}}}"}}},{"_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"}}},{"_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"]}}]}
+{"seq":50}
+{"docs":[{"_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_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":"2-7ab83617d991bfa730e55757d90c35ad","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","gender":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,"lastModified":"2015-11-12T21:15:12.204Z","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"}},"_revisions":{"start":2,"ids":["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":94}
|