PageRenderTime 47ms CodeModel.GetById 2ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/portal/patient/scripts/model.js

https://bitbucket.org/openemr/openemr
JavaScript | 900 lines | 769 code | 35 blank | 96 comment | 14 complexity | 34a5b0dc3d92e23b96c1709bc55ea143 MD5 | raw file
  1/**
  2 * backbone model definitions for Patient Portal
  3 *
  4 * From phreeze package
  5 * @license http://www.gnu.org/copyleft/lesser.html LGPL
  6 *
  7 */
  8
  9/**
 10 * Use emulated HTTP if the server doesn't support PUT/DELETE or application/json requests
 11 */
 12Backbone.emulateHTTP = false;
 13Backbone.emulateJSON = false;
 14
 15var model = {};
 16
 17/**
 18 * long polling duration in miliseconds.  (5000 = recommended, 0 = disabled)
 19 * warning: setting this to a low number will increase server load
 20 */
 21model.longPollDuration = 0;
 22
 23/**
 24 * whether to refresh the collection immediately after a model is updated
 25 */
 26model.reloadCollectionOnModelUpdate = true;
 27
 28
 29/**
 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
 32 * to the server.
 33 */
 34model.AbstractCollection = Backbone.Collection.extend({
 35	totalResults: 0,
 36	totalPages: 0,
 37	currentPage: 0,
 38	pageSize: 0,
 39	orderBy: '',
 40	orderDesc: false,
 41	lastResponseText: null,
 42	lastRequestParams: null,
 43	collectionHasChanged: true,
 44
 45	/**
 46	 * fetch the collection from the server using the same options and
 47	 * parameters as the previous fetch
 48	 */
 49	refetch: function() {
 50		this.fetch({ data: this.lastRequestParams })
 51	},
 52
 53	/* uncomment to debug fetch event triggers
 54	fetch: function(options) {
 55            this.constructor.__super__.fetch.apply(this, arguments);
 56	},
 57	// */
 58
 59	/**
 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
 63	 */
 64	comparator: function(a,b) {
 65
 66		var result = 0;
 67		var options = this.lastRequestParams;
 68
 69		if (options && options.orderBy) {
 70
 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);
 75
 76			if (isNaN(aVal) || isNaN(bVal)) {
 77				// treat comparison as case-insensitive strings
 78				aVal = aVal ? aVal.toLowerCase() : '';
 79				bVal = bVal ? bVal.toLowerCase() : '';
 80			} else {
 81				// treat comparision as a number
 82				aVal = Number(aVal);
 83				bVal = Number(bVal);
 84			}
 85
 86			if (aVal < bVal) {
 87				result = options.orderDesc ? 1 : -1;
 88			} else if (aVal > bVal) {
 89				result = options.orderDesc ? -1 : 1;
 90			}
 91		}
 92
 93		return result;
 94
 95	},
 96	/**
 97	 * override parse to track changes and handle pagination
 98	 * if the server call has returned page data
 99	 */
100	parse: function(response, options) {
101
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;
108
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 });
112
113		this.lastResponseText = responseText;
114
115		var rows;
116
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;
125		} else {
126			rows = response;
127			this.totalResults = rows.length;
128			this.totalPages = 1;
129			this.currentPage = 1;
130			this.pageSize = this.totalResults;
131			this.orderBy = response.orderBy;
132			this.orderDesc = response.orderDesc;
133		}
134
135		return rows;
136	}
137});
138/**
139 * OnsiteDocument Backbone Model
140 */
141model.OnsiteDocumentModel = Backbone.Model.extend({
142	urlRoot: 'api/onsitedocument',
143	idAttribute: 'id',
144	id: '',
145	pid: '',
146	facility: '',
147	provider: '',
148	encounter: '',
149	createDate: '',
150	docType: '',
151	patientSignedStatus: '',
152	patientSignedTime: '',
153	authorizeSignedTime: '',
154	acceptSignedStatus: '',
155	authorizingSignator: '',
156	reviewDate: '',
157	denialReason: '',
158	authorizedSignature: '',
159	patientSignature: '',
160	fullDocument: '',
161	fileName: '',
162	filePath: '',
163	defaults: {
164		'id': null,
165		'pid': 0,
166		'facility': 0,
167		'provider': 0,
168		'encounter': 0,
169		'createDate':new Date(),
170		'docType': '',
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': '',
180		'fullDocument': '',
181		'fileName': '',
182		'filePath': ''
183	}
184});
185
186/**
187 * OnsiteDocument Backbone Collection
188 */
189model.OnsiteDocumentCollection = model.AbstractCollection.extend({
190	url: 'api/onsitedocuments',
191	model: model.OnsiteDocumentModel
192});
193
194/**
195 * OnsitePortalActivity Backbone Model
196 */
197model.OnsitePortalActivityModel = Backbone.Model.extend({
198	urlRoot: 'api/onsiteportalactivity',
199	idAttribute: 'id',
200	id: '',
201	date: '',
202	patientId: '',
203	activity: '',
204	requireAudit: '',
205	pendingAction: '',
206	actionTaken: '',
207	status: '',
208	narrative: '',
209	tableAction: '',
210	tableArgs: '',
211	actionUser: '',
212	actionTakenTime: '',
213	checksum: '',
214	defaults: {
215		'id': null,
216		'date': '0000-00-0000',
217		'patientId': '0',
218		'activity': '',
219		'requireAudit': '1',
220		'pendingAction': 'review',
221		'actionTaken': '',
222		'status': 'waiting',
223		'narrative': '',
224		'tableAction': '',
225		'tableArgs': '',
226		'actionUser': '0',
227		'actionTakenTime': '0000-00-0000',
228		'checksum': '0'
229	}
230});
231
232/**
233 * OnsitePortalActivity Backbone Collection
234 */
235model.OnsitePortalActivityCollection = model.AbstractCollection.extend({
236	url: 'api/onsiteportalactivities',
237	model: model.OnsitePortalActivityModel
238});
239/**
240 * OnsiteActivityView Backbone Model
241 */
242model.OnsiteActivityViewModel = Backbone.Model.extend({
243	urlRoot: 'api/onsiteactivityview',
244	idAttribute: 'id',
245	id: '',
246	date: '',
247	patientId: '',
248	activity: '',
249	requireAudit: '',
250	pendingAction: '',
251	actionTaken: '',
252	status: '',
253	narrative: '',
254	tableAction: '',
255	tableArgs: '',
256	actionUser: '',
257	actionTakenTime: '',
258	checksum: '',
259	title: '',
260	fname: '',
261	lname: '',
262	mname: '',
263	dob: '',
264	ss: '',
265	street: '',
266	postalCode: '',
267	city: '',
268	state: '',
269	referrerid: '',
270	providerid: '',
271	refProviderid: '',
272	pubpid: '',
273	careTeam: '',
274	username: '',
275	authorized: '',
276	ufname: '',
277	umname: '',
278	ulname: '',
279	facility: '',
280	active: '',
281	utitle: '',
282	physicianType: '',
283	defaults: {
284		'id': null,
285		'date': new Date(),
286		'patientId': '',
287		'activity': '',
288		'requireAudit': '',
289		'pendingAction': '',
290		'actionTaken': '',
291		'status': '',
292		'narrative': '',
293		'tableAction': '',
294		'tableArgs': '',
295		'actionUser': '',
296		'actionTakenTime': new Date(),
297		'checksum': '',
298		'title': '',
299		'fname': '',
300		'lname': '',
301		'mname': '',
302		'dob': new Date(),
303		'ss': '',
304		'street': '',
305		'postalCode': '',
306		'city': '',
307		'state': '',
308		'referrerid': '',
309		'providerid': '',
310		'refProviderid': '',
311		'pubpid': '',
312		'careTeam': '',
313		'username': '',
314		'authorized': '',
315		'ufname': '',
316		'umname': '',
317		'ulname': '',
318		'facility': '',
319		'active': '',
320		'utitle': '',
321		'physicianType': ''
322	}
323});
324
325/**
326 * OnsiteActivityView Backbone Collection
327 */
328model.OnsiteActivityViewCollection = model.AbstractCollection.extend({
329	url: 'api/onsiteactivityviews',
330	model: model.OnsiteActivityViewModel
331});
332
333/**
334 * Patient Backbone Model
335 */
336model.PatientModel = Backbone.Model.extend({
337	urlRoot: 'api/patient',
338	idAttribute: 'id',
339	id: '',
340	title: '',
341	language: '',
342	financial: '',
343	fname: '',
344	lname: '',
345	mname: '',
346	dob: '',
347	street: '',
348	postalCode: '',
349	city: '',
350	state: '',
351	countryCode: '',
352	driversLicense: '',
353	ss: '',
354	occupation: '',
355	phoneHome: '',
356	phoneBiz: '',
357	phoneContact: '',
358	phoneCell: '',
359	pharmacyId: '',
360	status: '',
361	contactRelationship: '',
362	date: '',
363	sex: '',
364	referrer: '',
365	referrerid: '',
366	providerid: '',
367	refProviderid: '',
368	email: '',
369	emailDirect: '',
370	ethnoracial: '',
371	race: '',
372	ethnicity: '',
373	religion: '',
374	interpretter: '',
375	migrantseasonal: '',
376	familySize: '',
377	monthlyIncome: '',
378	billingNote: '',
379	homeless: '',
380	financialReview: '',
381	pubpid: '',
382	pid: '',
383	hipaaMail: '',
384	hipaaVoice: '',
385	hipaaNotice: '',
386	hipaaMessage: '',
387	hipaaAllowsms: '',
388	hipaaAllowemail: '',
389	squad: '',
390	fitness: '',
391	referralSource: '',
392	pricelevel: '',
393	regdate: '',
394	contrastart: '',
395	completedAd: '',
396	adReviewed: '',
397	vfc: '',
398	mothersname: '',
399	guardiansname: '',
400	allowImmRegUse: '',
401	allowImmInfoShare: '',
402	allowHealthInfoEx: '',
403	allowPatientPortal: '',
404	deceasedDate: '',
405	deceasedReason: '',
406	soapImportStatus: '',
407	cmsportalLogin: '',
408	careTeam: '',
409	county: '',
410	industry: '',
411	note: '',
412	defaults: {
413		'id': null,
414		'title': '',
415		'language': '',
416		'financial': '',
417		'fname': '',
418		'lname': '',
419		'mname': '',
420		'dob': '',
421		'street': '',
422		'postalCode': '',
423		'city': '',
424		'state': '',
425		'countryCode': '',
426		'driversLicense': '',
427		'ss': '',
428		'occupation': '',
429		'phoneHome': '',
430		'phoneBiz': '',
431		'phoneContact': '',
432		'phoneCell': '',
433		'pharmacyId': '',
434		'status': '',
435		'contactRelationship': '',
436		'date': new Date().toISOString().slice(0,10),
437		'sex': '',
438		'referrer': '',
439		'referrerid': '',
440		'providerid': '',
441		'refProviderid': '',
442		'email': '',
443		'emailDirect': '',
444		'ethnoracial': '',
445		'race': '',
446		'ethnicity': '',
447		'religion': '',
448		'interpretter': '',
449		'migrantseasonal': '',
450		'familySize': '',
451		'monthlyIncome': '',
452		'billingNote': '',
453		'homeless': '',
454		'financialReview': '',
455		'pubpid': '',
456		'pid': '',
457		'hipaaMail': '',
458		'hipaaVoice': '',
459		'hipaaNotice': '',
460		'hipaaMessage': '',
461		'hipaaAllowsms': '',
462		'hipaaAllowemail': '',
463		'squad': '',
464		'fitness': '',
465		'referralSource': '',
466		'pricelevel': '',
467		'regdate': new Date().toISOString().slice(0,10),
468		'contrastart': '',
469		'completedAd': '',
470		'adReviewed': '',
471		'vfc': '',
472		'mothersname': '',
473		'guardiansname': '',
474		'allowImmRegUse': '',
475		'allowImmInfoShare': '',
476		'allowHealthInfoEx': '',
477		'allowPatientPortal': '',
478		'deceasedDate': '',
479		'deceasedReason': '',
480		'soapImportStatus': '',
481		'cmsportalLogin': '',
482		'careTeam': '',
483		'county': '',
484		'industry': '',
485		'note': ''
486	}
487});
488
489/**
490 * Patient Backbone Collection
491 */
492model.PatientCollection = model.AbstractCollection.extend({
493	url: 'api/patientdata',
494	model: model.PatientModel
495});
496/**
497 * Portal Patient Edit Backbone Model
498 */
499model.PortalPatientModel = Backbone.Model.extend({
500	urlRoot: 'api/portalpatient',
501	idAttribute: 'id',
502	id: '',
503	title: '',
504	language: '',
505	financial: '',
506	fname: '',
507	lname: '',
508	mname: '',
509	dob: '',
510	street: '',
511	postalCode: '',
512	city: '',
513	state: '',
514	countryCode: '',
515	driversLicense: '',
516	ss: '',
517	occupation: '',
518	phoneHome: '',
519	phoneBiz: '',
520	phoneContact: '',
521	phoneCell: '',
522	pharmacyId: '',
523	status: '',
524	contactRelationship: '',
525	date: '',
526	sex: '',
527	referrer: '',
528	referrerid: '',
529	providerid: '',
530	refProviderid: '',
531	email: '',
532	emailDirect: '',
533	ethnoracial: '',
534	race: '',
535	ethnicity: '',
536	religion: '',
537	interpretter: '',
538	migrantseasonal: '',
539	familySize: '',
540	monthlyIncome: '',
541	billingNote: '',
542	homeless: '',
543	financialReview: '',
544	pubpid: '',
545	pid: '',
546	hipaaMail: '',
547	hipaaVoice: '',
548	hipaaNotice: '',
549	hipaaMessage: '',
550	hipaaAllowsms: '',
551	hipaaAllowemail: '',
552	squad: '',
553	fitness: '',
554	referralSource: '',
555	pricelevel: '',
556	regdate: '',
557	contrastart: '',
558	completedAd: '',
559	adReviewed: '',
560	vfc: '',
561	mothersname: '',
562	guardiansname: '',
563	allowImmRegUse: '',
564	allowImmInfoShare: '',
565	allowHealthInfoEx: '',
566	allowPatientPortal: '',
567	deceasedDate: '',
568	deceasedReason: '',
569	soapImportStatus: '',
570	cmsportalLogin: '',
571	careTeam: '',
572	county: '',
573	industry: '',
574	note: '',
575	defaults: {
576		'id': null,
577		'title': '',
578		'language': '',
579		'financial': '',
580		'fname': '',
581		'lname': '',
582		'mname': '',
583		'dob': '',
584		'street': '',
585		'postalCode': '',
586		'city': '',
587		'state': '',
588		'countryCode': '',
589		'driversLicense': '',
590		'ss': '',
591		'occupation': '',
592		'phoneHome': '',
593		'phoneBiz': '',
594		'phoneContact': '',
595		'phoneCell': '',
596		'pharmacyId': '',
597		'status': '',
598		'contactRelationship': '',
599		'date': new Date(),
600		'sex': '',
601		'referrer': '',
602		'referrerid': '',
603		'providerid': '',
604		'refProviderid': '',
605		'email': '',
606		'emailDirect': '',
607		'ethnoracial': '',
608		'race': '',
609		'ethnicity': '',
610		'religion': '',
611		'interpretter': '',
612		'migrantseasonal': '',
613		'familySize': '',
614		'monthlyIncome': '',
615		'billingNote': '',
616		'homeless': '',
617		'financialReview': '',
618		'pubpid': '',
619		'pid': '',
620		'hipaaMail': '',
621		'hipaaVoice': '',
622		'hipaaNotice': '',
623		'hipaaMessage': '',
624		'hipaaAllowsms': '',
625		'hipaaAllowemail': '',
626		'squad': '',
627		'fitness': '',
628		'referralSource': '',
629		'pricelevel': '',
630		'regdate': new Date(),
631		'contrastart': '',
632		'completedAd': '',
633		'adReviewed': '',
634		'vfc': '',
635		'mothersname': '',
636		'guardiansname': '',
637		'allowImmRegUse': '',
638		'allowImmInfoShare': '',
639		'allowHealthInfoEx': '',
640		'allowPatientPortal': '',
641		'deceasedDate': '',
642		'deceasedReason': '',
643		'soapImportStatus': '',
644		'cmsportalLogin': '',
645		'careTeam': '',
646		'county': '',
647		'industry': '',
648		'note': ''
649	}
650});
651
652/**
653 * Portal Patient Backbone Collection
654 */
655model.PortalPatientCollection = model.AbstractCollection.extend({
656	url: 'api/portalpatientdata',
657	model: model.PortalPatientModel
658});/**/
659
660/**
661 * User Backbone Model
662 */
663model.UserModel = Backbone.Model.extend({
664	urlRoot: 'api/user',
665	idAttribute: 'id',
666	id: '',
667	username: '',
668	password: '',
669	authorized: '',
670	info: '',
671	source: '',
672	fname: '',
673	mname: '',
674	lname: '',
675	federaltaxid: '',
676	federaldrugid: '',
677	upin: '',
678	facility: '',
679	facilityId: '',
680	seeAuth: '',
681	active: '',
682	npi: '',
683	title: '',
684	specialty: '',
685	billname: '',
686	email: '',
687	emailDirect: '',
688	eserUrl: '',
689	assistant: '',
690	organization: '',
691	valedictory: '',
692	street: '',
693	streetb: '',
694	city: '',
695	state: '',
696	zip: '',
697	street2: '',
698	streetb2: '',
699	city2: '',
700	state2: '',
701	zip2: '',
702	phone: '',
703	fax: '',
704	phonew1: '',
705	phonew2: '',
706	phonecell: '',
707	notes: '',
708	calUi: '',
709	taxonomy: '',
710	ssiRelayhealth: '',
711	calendar: '',
712	abookType: '',
713	pwdExpirationDate: '',
714	pwdHistory1: '',
715	pwdHistory2: '',
716	defaultWarehouse: '',
717	irnpool: '',
718	stateLicenseNumber: '',
719	newcropUserRole: '',
720	cpoe: '',
721	physicianType: '',
722	defaults: {
723		'id': null,
724		'username': '',
725		'password': '',
726		'authorized': '',
727		'info': '',
728		'source': '',
729		'fname': '',
730		'mname': '',
731		'lname': '',
732		'federaltaxid': '',
733		'federaldrugid': '',
734		'upin': '',
735		'facility': '',
736		'facilityId': '',
737		'seeAuth': '',
738		'active': '',
739		'npi': '',
740		'title': '',
741		'specialty': '',
742		'billname': '',
743		'email': '',
744		'emailDirect': '',
745		'eserUrl': '',
746		'assistant': '',
747		'organization': '',
748		'valedictory': '',
749		'street': '',
750		'streetb': '',
751		'city': '',
752		'state': '',
753		'zip': '',
754		'street2': '',
755		'streetb2': '',
756		'city2': '',
757		'state2': '',
758		'zip2': '',
759		'phone': '',
760		'fax': '',
761		'phonew1': '',
762		'phonew2': '',
763		'phonecell': '',
764		'notes': '',
765		'calUi': '',
766		'taxonomy': '',
767		'ssiRelayhealth': '',
768		'calendar': '',
769		'abookType': '',
770		'pwdExpirationDate': '',
771		'pwdHistory1': '',
772		'pwdHistory2': '',
773		'defaultWarehouse': '',
774		'irnpool': '',
775		'stateLicenseNumber': '',
776		'newcropUserRole': '',
777		'cpoe': '',
778		'physicianType': ''
779	}
780});
781
782/**
783 * User Backbone Collection
784 */
785model.UserCollection = model.AbstractCollection.extend({
786	url: 'api/users',
787	model: model.UserModel
788});
789
790/**
791 * InsuranceCompany Backbone Model
792 */
793model.InsuranceCompanyModel = Backbone.Model.extend({
794	urlRoot: 'api/insurancecompany',
795	idAttribute: 'id',
796	id: '',
797	name: '',
798	attn: '',
799	cmsId: '',
800	freebType: '',
801	x12ReceiverId: '',
802	x12DefaultPartnerId: '',
803	altCmsId: '',
804	defaults: {
805		'id': null,
806		'name': '',
807		'attn': '',
808		'cmsId': '',
809		'freebType': '',
810		'x12ReceiverId': '',
811		'x12DefaultPartnerId': '',
812		'altCmsId': ''
813	}
814});
815
816/**
817 * InsuranceCompany Backbone Collection
818 */
819model.InsuranceCompanyCollection = model.AbstractCollection.extend({
820	url: 'api/insurancecompanies',
821	model: model.InsuranceCompanyModel
822});
823
824/**
825 * InsuranceData Backbone Model
826 */
827model.InsuranceDataModel = Backbone.Model.extend({
828	urlRoot: 'api/insurancedata',
829	idAttribute: 'id',
830	id: '',
831	type: '',
832	provider: '',
833	planName: '',
834	policyNumber: '',
835	groupNumber: '',
836	subscriberLname: '',
837	subscriberMname: '',
838	subscriberFname: '',
839	subscriberRelationship: '',
840	subscriberSs: '',
841	subscriberDob: '',
842	subscriberStreet: '',
843	subscriberPostalCode: '',
844	subscriberCity: '',
845	subscriberState: '',
846	subscriberCountry: '',
847	subscriberPhone: '',
848	subscriberEmployer: '',
849	subscriberEmployerStreet: '',
850	subscriberEmployerPostalCode: '',
851	subscriberEmployerState: '',
852	subscriberEmployerCountry: '',
853	subscriberEmployerCity: '',
854	copay: '',
855	date: '',
856	pid: '',
857	subscriberSex: '',
858	acceptAssignment: '',
859	policyType: '',
860	defaults: {
861		'id': null,
862		'type': '',
863		'provider': '',
864		'planName': '',
865		'policyNumber': '',
866		'groupNumber': '',
867		'subscriberLname': '',
868		'subscriberMname': '',
869		'subscriberFname': '',
870		'subscriberRelationship': '',
871		'subscriberSs': '',
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': '',
885		'copay': '',
886		'date': new Date(),
887		'pid': '',
888		'subscriberSex': '',
889		'acceptAssignment': '',
890		'policyType': ''
891	}
892});
893
894/**
895 * InsuranceData Backbone Collection
896 */
897model.InsuranceDataCollection = model.AbstractCollection.extend({
898	url: 'api/insurancedatas',
899	model: model.InsuranceDataModel
900});