-
Notifications
You must be signed in to change notification settings - Fork 3
25.11 fb bsu rounds template #1654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release25.11-SNAPSHOT
Are you sure you want to change the base?
Changes from all commits
a9cfbbc
9e5bfed
55f610b
1902649
5cd622e
508c4d4
adad93c
1df746d
ec9c80d
52cc2b5
4f00354
8a69e2a
2757482
60b8697
b970dbd
926b909
31cd308
87d6c04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| /* Copyright (c) 2014-2019 LabKey Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| /** | ||
| * This window will allow users to query open cases and add records to a task based on them | ||
| */ | ||
| Ext4.define('ONPRC_EHR.window.AddBehaviorCasesWindow', { | ||
| extend: 'EHR.window.AddSurgicalCasesWindow', | ||
| caseCategory: 'Behavior', | ||
| templateName: null, | ||
|
|
||
| allowNoSelection: true, | ||
| showAssignedVetCombo: false, | ||
| showAllowOpen: true, | ||
| defaultRemark: 'BSU Rounds Entered', | ||
|
|
||
| getCases: function(button){ | ||
| Ext4.Msg.wait("Loading..."); | ||
| this.hide(); | ||
|
|
||
| var casesFilterArray = this.getCasesFilterArray(); | ||
| var obsFilterArray = this.getBaseFilterArray(); | ||
| obsFilterArray.push(LABKEY.Filter.create('caseCategory', this.caseCategory, LABKEY.Filter.Types.EQUAL)); | ||
| var includeOpen = this.down('#includeOpen') ? this.down('#includeOpen').getValue() : false; | ||
| if (includeOpen){ | ||
| obsFilterArray.push(LABKEY.Filter.create('caseIsOpen', true, LABKEY.Filter.Types.EQUAL)); | ||
| } | ||
| else { | ||
| obsFilterArray.push(LABKEY.Filter.create('caseIsActive', true, LABKEY.Filter.Types.EQUAL)); | ||
| } | ||
|
|
||
| //find distinct animals matching criteria | ||
| var multi = new LABKEY.MultiRequest(); | ||
|
|
||
| multi.add(LABKEY.Query.selectRows, { | ||
| requiredVersion: 9.1, | ||
| schemaName: 'study', | ||
| queryName: 'latestObservationsForCase', | ||
| columns: 'Id,date,category,area,observation,remark,caseid', | ||
| filterArray: obsFilterArray, | ||
| scope: this, | ||
| success: function(results){ | ||
| this.obsResults = results; | ||
| }, | ||
| failure: LDK.Utils.getErrorCallback() | ||
| }); | ||
|
|
||
| multi.add(LABKEY.Query.selectRows, { | ||
| requiredVersion: 9.1, | ||
| schemaName: 'study', | ||
| queryName: 'cases', | ||
| sort: 'Id/curLocation/location,Id,remark,allProblemCategories', | ||
| columns: 'Id,objectid,remark,allProblemCategories', | ||
| filterArray: casesFilterArray, | ||
| scope: this, | ||
| success: function(results){ | ||
| this.casesResults = results; | ||
| }, | ||
| failure: LDK.Utils.getErrorCallback() | ||
| }); | ||
|
|
||
| multi.send(this.onSuccess, this); | ||
| }, | ||
|
|
||
| //@Override. this is to skip the duplicate case check | ||
| addRecords: function(records){ | ||
| this.doAddRecords(records); | ||
| }, | ||
|
|
||
| //@Override. this is to skip the duplicate case check | ||
| doAddRecords: function(records){ | ||
| this.processObservations(records); | ||
| }, | ||
|
|
||
| //apply previous observations, or inser a blank obs record. | ||
| processObservations: function(caseRecords){ | ||
| //find all distinct IDs with cases. | ||
| var distinctCaseIds = []; | ||
| if (caseRecords && caseRecords.length){ | ||
| Ext4.Array.forEach(caseRecords, function(cr){ | ||
| if (distinctCaseIds.indexOf(cr.get('caseid')) == -1){ | ||
| distinctCaseIds.push(cr.get('caseid')); | ||
| } | ||
| }, this); | ||
| } | ||
|
|
||
| var previousObsMap = {}; | ||
| if (this.obsResults && this.obsResults.rows && this.obsResults.rows.length){ | ||
| Ext4.Array.forEach(this.obsResults.rows, function(sr){ | ||
| //reset variable | ||
| var newobservation = ''; | ||
| var newremark = ''; | ||
| var row = new LDK.SelectRowsRow(sr); | ||
| newobservation = row.getValue('category'); | ||
| newremark = row.getValue('remark'); | ||
|
|
||
| //note: this has been changed to ensure 1 row per case | ||
| var key = row.getValue('caseid'); | ||
| if (!previousObsMap[key]) | ||
| previousObsMap[key] = []; | ||
|
|
||
| previousObsMap[key].push({ | ||
| Id: row.getValue('Id'), | ||
| date: this.recordData.date, | ||
| performedby: this.recordData.performedby, | ||
| caseid: row.getValue('caseid'), | ||
| category: row.getValue('category'), | ||
| area: row.getValue('area'), | ||
| allProblemCategories:row.getValue('allProblemCategories'), | ||
| //dont copy value | ||
| //observation: row.getValue('observation'), | ||
| remark: row.getValue('remark') | ||
| }); | ||
| if (newobservation == "Alopecia Score" && (newremark == null || newremark == "")) { | ||
| previousObsMap[key].push({ | ||
| Id: row.getValue('Id'), | ||
| date: this.recordData.date, | ||
| performedby: this.recordData.performedby, | ||
| caseid: row.getValue('caseid'), | ||
| category: 'Alopecia Regrowth', | ||
| area: row.getValue('area'), | ||
| allProblemCategories:row.getValue('allProblemCategories') | ||
| //dont copy value | ||
| //observation: row.getValue('observation'), | ||
| //remark: row.getValue('remark') | ||
| }); | ||
|
|
||
| } | ||
| }, this); | ||
| } | ||
|
|
||
| var obsRecords = []; | ||
| var obsStore = this.targetStore.storeCollection.getClientStoreByName('Clinical Observations'); | ||
| LDK.Assert.assertNotEmpty('Unable to find Clinical Observations store', obsStore); | ||
|
|
||
| var treatmentRecords = []; | ||
| var treatmentStore = this.targetStore.storeCollection.getClientStoreByName('Drug Administration'); | ||
| LDK.Assert.assertNotEmpty('Unable to find Drug Administration store', treatmentStore); | ||
|
|
||
| Ext4.Array.forEach(caseRecords, function(cr){ | ||
| if (previousObsMap[cr.get('caseid')]){ | ||
| Ext4.Array.forEach(previousObsMap[cr.get('caseid')], function(r){ | ||
| r = Ext4.apply(r, { | ||
| 'Id/curLocation/location': cr.get('Id/curLocation/location') | ||
| }); | ||
|
|
||
| obsRecords.push(obsStore.createModel(r)); | ||
| }, this); | ||
| } | ||
| else { | ||
| obsRecords.push(obsStore.createModel({ | ||
| 'Id/curLocation/location': cr.get('Id/curLocation/location'), | ||
| Id: cr.get('Id'), | ||
| date: this.recordData.date, | ||
| performedby: this.recordData.performedby, | ||
| caseid: cr.get('caseid') | ||
| })); | ||
| } | ||
|
|
||
| treatmentRecords.push(treatmentStore.createModel({ | ||
| Id: cr.get('Id'), | ||
| caseid: cr.get('caseid'), | ||
| date: this.recordData.date, | ||
| performedby: this.recordData.performedby | ||
| })); | ||
| }, this); | ||
|
|
||
| if (obsRecords.length){ | ||
| obsStore.add(obsRecords); | ||
| } | ||
|
|
||
| if (treatmentRecords.length){ | ||
| treatmentStore.add(treatmentRecords); | ||
| } | ||
|
|
||
| Ext4.Msg.hide(); | ||
| this.close(); | ||
| } | ||
| }); | ||
|
|
||
| EHR.DataEntryUtils.registerGridButton('ADDBEHAVIORCASESAMENDED', function(config){ | ||
| return Ext4.Object.merge({ | ||
| text: 'Add Open Cases', | ||
| tooltip: 'Click to automatically add animals with open cases', | ||
| handler: function(btn){ | ||
| var grid = btn.up('gridpanel'); | ||
| if(!grid.store || !grid.store.hasLoaded()){ | ||
| console.log('no store or store hasnt loaded'); | ||
| return; | ||
| } | ||
|
|
||
| var cellEditing = grid.getPlugin('cellediting'); | ||
| if(cellEditing) | ||
| cellEditing.completeEdit(); | ||
|
|
||
| Ext4.create('ONPRC_EHR.window.AddBehaviorCasesWindow', { | ||
| targetStore: grid.store | ||
| }).show(); | ||
| } | ||
| }, config); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1799,6 +1799,16 @@ public void testBehaviorRounds() throws Exception | |
| row.put("objectid", generateGUID()); | ||
| row.put("taskid", generateGUID()); //required for latestObservationsForCase.sql to work | ||
| insertRowsCommand.addRow(row); | ||
|
|
||
| Map<String, Object> row2 = new HashMap<>(); | ||
| row2.put("Id", SUBJECTS[0]); | ||
| row2.put("category", "Alopecia Regrowth"); | ||
| row2.put("date", prepareDate(new Date(), -4, 0)); | ||
| row2.put("caseid", caseId); | ||
| row2.put("observation", "Yes"); | ||
| row2.put("objectid", generateGUID()); | ||
| row2.put("taskid", generateGUID()); //required for latestObservationsForCase.sql to work | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see my comment above about the purpose of this test code. But if I'm misunderstanding and you do need it, I assume you would want the same taskid on this row as the row above so they show in the same form. |
||
| insertRowsCommand.addRow(row2); | ||
Ohsudev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| insertRowsCommand.execute(getApiHelper().getConnection(), getContainerPath()); | ||
|
Comment on lines
+1803
to
1812
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused why you're inserting this manually. Isn't your feature to have this created automatically?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, when BSU open cases are loaded onto the form their entries appear on the main entry form. I updated the program so that every instances of "Alopecia Score", and they have That example repeats on the main form for BSU Prime users to enter the appropriate values. They will both |
||
|
|
||
| Ext4GridRef obsGrid = _helper.getExt4GridForFormSection("Observations"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're calling this against this.obsResults, which doesn't have this column in the selectRows column list above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I added that column to the query.