2 * backbone model definitions for Patient Portal
5 * @license http://www.gnu.org/copyleft/lesser.html LGPL
10 * Use emulated HTTP if the server doesn't support PUT/DELETE or application/json requests
12 Backbone.emulateHTTP = false;
13 Backbone.emulateJSON = false;
18 * long polling duration in miliseconds. (5000 = recommended, 0 = disabled)
19 * warning: setting this to a low number will increase server load
21 model.longPollDuration = 0;
24 * whether to refresh the collection immediately after a model is updated
26 model.reloadCollectionOnModelUpdate = true;
30 * a default sort method for sorting collection items. this will sort the collection
31 * based on the orderBy and orderDesc property that was used on the last fetch call
34 model.AbstractCollection = Backbone.Collection.extend({
41 lastResponseText: null,
42 lastRequestParams: null,
43 collectionHasChanged: true,
46 * fetch the collection from the server using the same options and
47 * parameters as the previous fetch
50 this.fetch({ data: this.lastRequestParams })
53 /* uncomment to debug fetch event triggers
54 fetch: function(options) {
55 this.constructor.__super__.fetch.apply(this, arguments);
60 * client-side sorting baesd on the orderBy and orderDesc parameters that
61 * were used to fetch the data from the server. Backbone ignores the
62 * order of records coming from the server so we have to sort them ourselves
64 comparator: function(a,b) {
67 var options = this.lastRequestParams;
69 if (options && options.orderBy) {
71 // lcase the first letter of the property name
72 var propName = options.orderBy.charAt(0).toLowerCase() + options.orderBy.slice(1);
73 var aVal = a.get(propName);
74 var bVal = b.get(propName);
76 if (isNaN(aVal) || isNaN(bVal)) {
77 // treat comparison as case-insensitive strings
78 aVal = aVal ? aVal.toLowerCase() : '';
79 bVal = bVal ? bVal.toLowerCase() : '';
81 // treat comparision as a number
87 result = options.orderDesc ? 1 : -1;
88 } else if (aVal > bVal) {
89 result = options.orderDesc ? -1 : 1;
97 * override parse to track changes and handle pagination
98 * if the server call has returned page data
100 parse: function(response, options) {
102 // the response is already decoded into object form, but it's easier to
103 // compary the stringified version. some earlier versions of backbone did
104 // not include the raw response so there is some legacy support here
105 var responseText = options && options.xhr ? options.xhr.responseText : JSON.stringify(response);
106 this.collectionHasChanged = (this.lastResponseText != responseText);
107 this.lastRequestParams = options ? options.data : undefined;
109 // if the collection has changed then we need to force a re-sort because backbone will
110 // only resort the data if a property in the model has changed
111 if (this.lastResponseText && this.collectionHasChanged) this.sort({ silent:true });
113 this.lastResponseText = responseText;
117 if (response.currentPage) {
118 rows = response.rows;
119 this.totalResults = response.totalResults;
120 this.totalPages = response.totalPages;
121 this.currentPage = response.currentPage;
122 this.pageSize = response.pageSize;
123 this.orderBy = response.orderBy;
124 this.orderDesc = response.orderDesc;
127 this.totalResults = rows.length;
129 this.currentPage = 1;
130 this.pageSize = this.totalResults;
131 this.orderBy = response.orderBy;
132 this.orderDesc = response.orderDesc;
139 * OnsiteDocument Backbone Model
141 model.OnsiteDocumentModel = Backbone.Model.extend({
142 urlRoot: 'api/onsitedocument',
151 patientSignedStatus: '',
152 patientSignedTime: '',
153 authorizeSignedTime: '',
154 acceptSignedStatus: '',
155 authorizingSignator: '',
158 authorizedSignature: '',
159 patientSignature: '',
169 'createDate':new Date(),
171 'patientSignedStatus': '0',
172 'patientSignedTime': '0000-00-00',
173 'authorizeSignedTime': '0000-00-00',
174 'acceptSignedStatus': '0',
175 'authorizingSignator': '',
176 'reviewDate': '0000-00-00',
177 'denialReason': 'New',
178 'authorizedSignature': '',
179 'patientSignature': '',
187 * OnsiteDocument Backbone Collection
189 model.OnsiteDocumentCollection = model.AbstractCollection.extend({
190 url: 'api/onsitedocuments',
191 model: model.OnsiteDocumentModel
195 * OnsitePortalActivity Backbone Model
197 model.OnsitePortalActivityModel = Backbone.Model.extend({
198 urlRoot: 'api/onsiteportalactivity',
216 'date': '0000-00-0000',
220 'pendingAction': 'review',
227 'actionTakenTime': '0000-00-0000',
233 * OnsitePortalActivity Backbone Collection
235 model.OnsitePortalActivityCollection = model.AbstractCollection.extend({
236 url: 'api/onsiteportalactivities',
237 model: model.OnsitePortalActivityModel
240 * OnsiteActivityView Backbone Model
242 model.OnsiteActivityViewModel = Backbone.Model.extend({
243 urlRoot: 'api/onsiteactivityview',
296 'actionTakenTime': new Date(),
326 * OnsiteActivityView Backbone Collection
328 model.OnsiteActivityViewCollection = model.AbstractCollection.extend({
329 url: 'api/onsiteactivityviews',
330 model: model.OnsiteActivityViewModel
334 * Patient Backbone Model
336 model.PatientModel = Backbone.Model.extend({
337 urlRoot: 'api/patient',
361 contactRelationship: '',
401 allowImmInfoShare: '',
402 allowHealthInfoEx: '',
403 allowPatientPortal: '',
406 soapImportStatus: '',
426 'driversLicense': '',
435 'contactRelationship': '',
449 'migrantseasonal': '',
454 'financialReview': '',
462 'hipaaAllowemail': '',
465 'referralSource': '',
474 'allowImmRegUse': '',
475 'allowImmInfoShare': '',
476 'allowHealthInfoEx': '',
477 'allowPatientPortal': '',
479 'deceasedReason': '',
480 'soapImportStatus': '',
481 'cmsportalLogin': '',
490 * Patient Backbone Collection
492 model.PatientCollection = model.AbstractCollection.extend({
493 url: 'api/patientdata',
494 model: model.PatientModel
497 * Portal Patient Edit Backbone Model
499 model.PortalPatientModel = Backbone.Model.extend({
500 urlRoot: 'api/portalpatient',
524 contactRelationship: '',
564 allowImmInfoShare: '',
565 allowHealthInfoEx: '',
566 allowPatientPortal: '',
569 soapImportStatus: '',
589 'driversLicense': '',
598 'contactRelationship': '',
612 'migrantseasonal': '',
617 'financialReview': '',
625 'hipaaAllowemail': '',
628 'referralSource': '',
637 'allowImmRegUse': '',
638 'allowImmInfoShare': '',
639 'allowHealthInfoEx': '',
640 'allowPatientPortal': '',
642 'deceasedReason': '',
643 'soapImportStatus': '',
644 'cmsportalLogin': '',
653 * Portal Patient Backbone Collection
655 model.PortalPatientCollection = model.AbstractCollection.extend({
656 url: 'api/portalpatientdata',
657 model: model.PortalPatientModel
661 * User Backbone Model
663 model.UserModel = Backbone.Model.extend({
713 pwdExpirationDate: '',
716 defaultWarehouse: '',
718 stateLicenseNumber: '',
767 'ssiRelayhealth': '',
770 'pwdExpirationDate': '',
773 'defaultWarehouse': '',
775 'stateLicenseNumber': '',
776 'newcropUserRole': '',
783 * User Backbone Collection
785 model.UserCollection = model.AbstractCollection.extend({
787 model: model.UserModel
791 * InsuranceCompany Backbone Model
793 model.InsuranceCompanyModel = Backbone.Model.extend({
794 urlRoot: 'api/insurancecompany',
802 x12DefaultPartnerId: '',
811 'x12DefaultPartnerId': '',
817 * InsuranceCompany Backbone Collection
819 model.InsuranceCompanyCollection = model.AbstractCollection.extend({
820 url: 'api/insurancecompanies',
821 model: model.InsuranceCompanyModel
825 * InsuranceData Backbone Model
827 model.InsuranceDataModel = Backbone.Model.extend({
828 urlRoot: 'api/insurancedata',
839 subscriberRelationship: '',
842 subscriberStreet: '',
843 subscriberPostalCode: '',
846 subscriberCountry: '',
848 subscriberEmployer: '',
849 subscriberEmployerStreet: '',
850 subscriberEmployerPostalCode: '',
851 subscriberEmployerState: '',
852 subscriberEmployerCountry: '',
853 subscriberEmployerCity: '',
858 acceptAssignment: '',
867 'subscriberLname': '',
868 'subscriberMname': '',
869 'subscriberFname': '',
870 'subscriberRelationship': '',
872 'subscriberDob': new Date(),
873 'subscriberStreet': '',
874 'subscriberPostalCode': '',
875 'subscriberCity': '',
876 'subscriberState': '',
877 'subscriberCountry': '',
878 'subscriberPhone': '',
879 'subscriberEmployer': '',
880 'subscriberEmployerStreet': '',
881 'subscriberEmployerPostalCode': '',
882 'subscriberEmployerState': '',
883 'subscriberEmployerCountry': '',
884 'subscriberEmployerCity': '',
889 'acceptAssignment': '',
895 * InsuranceData Backbone Collection
897 model.InsuranceDataCollection = model.AbstractCollection.extend({
898 url: 'api/insurancedatas',
899 model: model.InsuranceDataModel