Created
August 10, 2016 20:37
-
-
Save jratcliff/efa75d5784da139aff5933423a376891 to your computer and use it in GitHub Desktop.
Protocol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('ProtoManagement.model.studyprotocol.Protocol', { | |
extend: 'ProtoManagement.model.Base', | |
requires: [ | |
'Ext.data.validator.Presence', | |
'ProtoManagement.model.StudySection', | |
'ProtoManagement.model.studyprotocol.Comment', | |
'ProtoManagement.model.studyprotocol.CurrentRevision', | |
'ProtoManagement.model.studyprotocol.Revision', | |
'ProtoManagement.model.studyprotocol.StudyCode', | |
'ProtoManagement.model.studyprotocol.step.BaseStep' | |
], | |
idProperty: 'GUID', | |
fields: [ | |
{ | |
name: 'Name', | |
type: 'string' | |
}, | |
{ | |
name: 'Description', | |
type: 'string' | |
}, | |
{ | |
name: 'CurrentVersion', | |
type: 'int' | |
}, | |
{ | |
name: 'Modality', | |
type: 'string' | |
}, | |
{ | |
name: 'Number', | |
type: 'string' | |
}, | |
{ | |
name: 'IsPersonalized', | |
type: 'bool' | |
}, | |
{ | |
name: 'IntendedSuites', | |
type: 'auto', | |
defaultValue: [] | |
}, | |
{ | |
name: 'PublishedSuites', | |
type: 'auto', | |
defaultValue: [] | |
}, | |
{ | |
name: 'AgeGroup', | |
type: 'string' | |
}, | |
{ | |
name: 'SizeGroup', | |
type: 'string' | |
}, | |
{ | |
name: 'PatientPosition', | |
type: 'string' | |
}, | |
{ | |
name: 'PlanTemplate', | |
type: 'auto', | |
defaultValue: null | |
}, | |
{ | |
name: 'AnatomicalRegion', | |
type: 'string' | |
}, | |
/** | |
* @propety {String} StudySectionName | |
* A non-persisted field needed for sorter and grouper configs since they | |
* appear to not support reading data from a nested object. | |
*/ | |
{ | |
name: 'StudySectionName', | |
mapping: 'StudySection.Name', | |
type: 'string', | |
persist: false // just need for sorting and grouping | |
}, | |
/** | |
* @property {String} StudySectionId | |
* This is a 'dummy' field that represents the foreign key to the primary key (GUID) | |
* on the StudySection model. Since this field does not exist on the data coming | |
* from the server we do not persist this data going back. However, we need this | |
* field defined so we can add the reference to the StudySection object coming from the server. | |
* | |
* The 'associationKey' is used to find and read the data coming from the server. | |
* The 'role' is used when writing the data back to the server. | |
*/ | |
{ | |
name: 'StudySectionId', // the foreignKey to our 'reference' StudySection object | |
persist: false, // we don't persist it since the server never sends this in the first place | |
unique: true, | |
reference: { | |
type: 'StudySection', // our entityName | |
role: 'StudySection', // the property that gets sent back to the server | |
associationKey: 'StudySection', // the property to read the data coming from the server | |
getterName: 'getStudySection', | |
setterName: 'setStudySection' | |
} | |
} | |
], | |
hasOne: [ | |
{ | |
model: 'ProtoManagement.model.studyprotocol.CurrentRevision', | |
foreignKey: 'GUID', | |
name: 'CurrentRevision', | |
associationKey: 'CurrentRevision' | |
} | |
], | |
hasMany: [ | |
{ | |
model: 'ProtoManagement.model.studyprotocol.step.BaseStep', | |
name: 'Steps', | |
associationKey: 'Steps', | |
storeConfig: { | |
sorters : [{ | |
property : 'OrderIndex', | |
direction : 'ASC' | |
}] | |
} | |
}, | |
{ | |
model: 'ProtoManagement.model.studyprotocol.StudyCode', | |
name: 'StudyCodes', | |
associationKey: 'StudyCodes' | |
}, | |
{ | |
model: 'ProtoManagement.model.studyprotocol.Revision', | |
name: 'RevisionHistory', | |
associationKey: 'RevisionHistory', | |
storeConfig: { | |
remoteFilter: false | |
} | |
} | |
], | |
validators: { | |
Name: 'presence', | |
AnatomicalRegion: 'presence' | |
}, | |
proxy: { | |
type: 'rest', | |
url: 'api/study-protocols', | |
reader: { | |
type: 'json', | |
rootProperty: 'data' | |
}, | |
writer: { | |
rootProperty: 'data', | |
writeAllFields: true, | |
nameProperty: 'mapping', | |
expandData: true, | |
dateFormat: 'C', | |
allDataOptions: { | |
associated: true, | |
serialize: true | |
} | |
} | |
}, | |
approve: function (options) { | |
options = options || {} | |
var me = this, | |
proxy = me.getProxy(), | |
url = proxy.getUrl(); | |
protocolId = options.GUID || me.getId(); | |
Ext.Ajax.request( | |
Ext.apply({ | |
method: 'PUT', | |
url: url + '/' + protocolId + '/approve' | |
}, options) | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment