patients.PatientModel Class
/var/www/azaleahealth.com/branches/docs/source_repo/awa/resources/apps/js/patients/PatientModel.js:19
Constructor
patients.PatientModel
()
Item Index
Methods
- _validateChildCollection
- add
- addRules
- destroy
- difference
- displayName
- enable
- get
- getAllergies
- getAttributeProp
- getDisplay
- getDisplayMethod
- getInsurance
- getName
- getScope
- getTip
- getType
- initializeEvents
- isDisabled
- isIncomplete
- isNotDone
- isValid
- loadPhoto
- objectAccess
- objectFilter
- olderThan
- removeRules
- restore
- set
- setGuarantor
- setGuarantor
- setRules
- store
- subAction
- sync
- toDisplayJSON
- toJSON
- toString
- url
- validate
- youngerThan
Properties
Events
Methods
_validateChildCollection
-
key -
collection -
errors
CAUTION errors param will be modified
Parameters:
-
keyStringAttribute key
-
collectionawa.mvc.CollectionCollection to check
-
errorsObjectObject of errors
Returns:
Indicates this method found errors in the collection
add
-
attribute -
value -
[id] -
[options]
The add method is used primarily for arrays.
Parameters:
-
attributeStringattribute name
-
valueObjectvalue to be added to the array
-
[id]Integer optionalthe specific index
-
[options]Object | String optionalrefer to Backbone.js
Returns:
[description]
addRules
-
key -
rules
appends rules to the model
Parameters:
-
keyObject | Stringdesc
-
rulesObject | Stringdesc
Returns:
[description]
destroy
-
options
Stolen from backbone and completely overridden. Look in method for change
Parameters:
-
optionsObjectconfiguration object with various properties
Returns:
[description]
difference
-
obj
Parameters:
-
objObjectconfiguration object with various properties
Returns:
[description]
displayName
()
type
Override to return the name of the model (i.e. for a patient, it would be their last name, comma, space, and then first name). By default, this returns attribute name, id, then cid.
Returns:
[description]
enable
-
[options]
If the model has a disabledAttribute, this method will automatically re-enable by setting the property to 0
Parameters:
-
[options]Object optionalconfiguration object with various properties
Returns:
[description]
get
-
attr
Get the current value of an attribute from the model Overwritten to create collections and sub models only when needed.
Parameters:
-
attrStringdesc
Returns:
[description]
getAllergies
-
callback
xhr calls to get allergies
Parameters:
-
callbackFunctionCalled on success
Returns:
getAttributeProp
-
attr -
prop
Gets the attribute property for a specified attribute.
Parameters:
-
attrStringAttribute key (i.e pat_fname)
-
propStringProperty key (i.e displayMethod)
Returns:
[description]
getDisplay
-
attr -
options
Like get, but this uses the displayMethod.
Parameters:
-
attrStringdesc
-
optionsObjectdesc
Returns:
[description]
getDisplayMethod
-
attr
returns the displayMethod for a given attribute
Parameters:
-
attrStringdesc
Returns:
[description]
getInsurance
-
config
Parameters:
-
configObjectthis is needed
-
ins_idObjectthis is needed
-
irep_idObjectthis is needed
-
callbackObjectthis is needed
-
Returns:
getName
-
attr -
fullName
Gets the name of an attribute. This can be set by an attribute's attributeProp name. An attribute property can have a getName function to define how to name nested portions NOTE: The containing object of a property should decide the properties name. i.e. if a model has a "period" attribute prop, that should be named in the model, not the period attributeProps returns the attribute if not set.
Parameters:
-
attrStringAttribute key desired. If nothing is provided, the model's displayName is returned.
-
fullNameBooleanIf true returns the full name for nested properties from the context of the root model. i.e. "Encounter Primary Insurance Period Start" v. "Start"
Returns:
attribute name
getScope
-
options
Id this is a nested model inside of a collection or another model, this will provide the extended id to grab it from the root model.
Parameters:
-
optionsObjectdesc
-
[cssSafe]Boolean optionalreplaces attribute separator with dashes for css selection if true
-
[cid]Boolean optionalby default uses cid. if set to false, will use ID instead
-
Returns:
[description]
getTip
-
attr
Gets the tip for an attribute. This can be set by an attribute's attributeProp tip. returns the attribute if not set.
Parameters:
-
attrStringdesc
Returns:
[description]
getType
-
attr
Gets the attribute type (i.e. string, collection, date), the default type is string
Parameters:
-
attrStringdesc
Returns:
[description]
initializeEvents
()
Undefined
Merges in PatientModelEventsMixin and initializes extended events. Should only be called on the shared patient model in an app. In fact, unless you're in the global collection, just don't call this.
Returns:
isDisabled
()
Boolean
Tells whether or not an individual has disabled status.
Returns:
desc
isIncomplete
()
Boolean
Tells whether or not an individual has incomplete status. Override this method if you want to use it in a model.
Returns:
desc
isNotDone
()
Boolean
Tells whether or not an item was not done. Primarily for medical events (i.e. procedures, care plans, prescriptions)
Returns:
desc
isValid
-
Refer
A convenience function for returning boolean values instead of objects
Parameters:
-
ReferObjectto validate() for parameter list and notes.
Returns:
[description]
loadPhoto
-
callback
xhr calls to get photo
Parameters:
-
callbackFunctionCalled on success
Returns:
objectAccess
-
obj -
property
Parameters:
-
objObjectObject to retrieve nested property from
-
propertyStringProperty string to access
Returns:
returns the nested property or undefined
objectFilter
-
object -
iterator
this does something....
Parameters:
-
objectObjectdesc
-
iteratorFunctiondesc
Returns:
[description]
olderThan
-
years
Parameters:
-
yearsIntegerComparing age in years
Returns:
True if patient is older than supplied years
removeRules
-
key -
rules
Replaces all rules for an individual key in a model
Parameters:
-
keyObject | Stringdesc
-
rulesObject | Stringdesc
Returns:
[description]
restore
-
options
The restore method rewinds back to the last created store point.
Parameters:
-
optionsObjectdesc
Returns:
[description]
set
-
attributes -
[options]
The set method does everything outlined in Backbone.js library. It has been overridden to handle building inferred attributes that are outlined in the child class. Sometimes you may want another attribute to update another set in a model. In this case, you may override the set method. If you do, be sure to call super on set so that these processes are handled.
Parameters:
-
attributesObject | Stringrefer to Backbone.js
-
[options]Object | String optionalrefer to Backbone.js
Returns:
[description]
setGuarantor
-
pat
Sets the patient guarantor
Parameters:
-
patpatients.PatientModel | Object | Integer | StringEither the patient model, json format, or the id of the patient that will be set as the guarantor
Returns:
setGuarantor
-
pat
Sets the patient guarantor
Parameters:
-
patpatients.PatientModel | Object | Integer | StringEither the patient model, json format, or the id of the patient that will be set as the guarantor
Returns:
this
setRules
-
key -
rules
set rules to the model for an attribute
Parameters:
-
keyObject | Stringdesc
-
rulesObject | Stringdesc
Returns:
[description]
store
()
type
The store method sets a store point for the model in a stack. Use restore to rewind the model to previous store points. FIFO
Returns:
[description]
subAction
-
options
Call a subaction of a model. (i.e. if you have a document that has a copy action) The url should follow the pattern of resource/:id/:action (documents/2/copy)
var PatientModel = awa.mvc.Model.extend({ urlRoot: awa.url.BAREBONES + 'V1/patients', idAttribute: 'pat_id' });
var model = new PatientModel({pat_id: 75});
//the following will make a GET request to //[barebones_root]V1/patients/75/sync
model.subAction({ type: 'GET', action: 'sync', success: function(){
}
});
Parameters:
-
optionsObjectconfiguration object with various properties
-
actionStringname of action
-
typeStringhttp method to use (POST, GET, DELETE, etc)
-
successFunctiondesc
-
errorFunctiondesc
-
dataObjectdesc
-
Returns:
Avoid using this as it is subject to change.
sync
-
method -
model -
options
Overridden from Backbone.Model.fetch to handle not so restful backend.
Parameters:
-
methodObjectconfiguration object with various properties
-
modelObjectdesc
-
optionsObjectdesc
Returns:
result of api_sync
toDisplayJSON
()
type
Uses the displayRules/Methods that are set in either the displayRules property or the attributeProps to generate a javascript object (w/o getters and setters) that represents the model's data in a displayable format.
Returns:
[description]
toJSON
-
[options]
Overwritten to provide more control on the resulting json output
Parameters:
-
[options]Object optionalOptions object
-
[skipKeys]Array optionalSet of keys to skip.
-
[sync]String optionalIf calling for syncing purposes. see awa.mvc.Model.SYNC
-
Returns:
[description]
toString
()
type
Returns:
[description]
url
()
String
stolen from backbone and altered to not throw exception in case of no urlRoot
Returns:
URL for model instance
validate
-
attributes -
[options]
The validate method does everything outlined in Backbone.js library. It has been overridden to handle the rules set in the attributeProps and the rules property. In some cases, you may want to do extensive validating on attributes that dont fit the model rules functions (i.e. making sure a date of birth is not in the future). Be sure to call the super version of validate to handle the other rules. !!!PLEASE NOTE!!! This method will evaluate all rules if you don't pass in attributes but if you do, then it only validates the ones you pass in. Keep this in mind when overriding this method. passing in a small set of attributes will cause all of the unset variables to be ignored.
Parameters:
-
attributesObject | Stringrefer to Backbone.js
-
[options]Object | String optionalrefer to Backbone.js
Returns:
[description]
youngerThan
-
years
Parameters:
-
yearsIntegerComparing age in years
Returns:
True if patient is younger than supplied years
Properties
__attributePropsProcessed
Boolean
just leave it alone.
Default: false
_stores
Array
Used by the model object to set and access store points.
Default: empty
api
String
Specifies what backend protocol to use to communicate with the server. 'api' will use the old standard of adding the method in the URL. 'barebones' will accomodate barebones
Default: api
className
String
Specifies what backend protocol to use to communicate with the server. 'api' will use the old standard of adding the method in the URL. 'barebones' will accomodate barebones
Default: Model
disabledAttribute
String
Specifies the disabled attribute in the model
Default: undefined
displayRules
Object keys: attribute/field names,
value: name of the function outline in awa.func
that will be called to format the data for output.
Rule set for validation. Used by Form validators.
Default: undefined
inferred
Object keys: attribute/field names, value: Objects
that specify the rules to follow. Used in conjuction with model rule functions
Any attributes that are built with primary data goes here. i.e. a patients full name is derived from the combination of it's first, middle, and last name and the suffix
Default: undefined
name
String
Override to return the name of the model (i.e. for the patient model, it would be Patient).
Default: undefined
pluralName
String
Override to return the plural name of the model. You should only use this if the plural does not just append a 's' (i.e. for the Diagnosis model, it would be Diagnoses).
Default: undefined
rules
Object keys: attribute/field names, value: Objects
that specify the rules to follow. Used in conjuction with jquery forms.
Rule set for validation. Used by Form validators.
Default: undefined
syncBlackList
Array
Lists the attributes that will not be synced back. doesn't prevent anything from being sent if empty or undefined. Given priority of over syncWhiteList
Default: undefined
syncWhiteList
Array
Lists the attributes that can be synced back. sends back all attributes if the list is empty or undefined
Default: undefined
Events
rules
Called when rules change on an individual model