Skip to content

Commit 14a7b99

Browse files
Align frequency from formulary with frequency data (#489)
* Create DrugAdministrationRunsClientStore to add frequency handling * Add store to form sections
1 parent 769299d commit 14a7b99

4 files changed

Lines changed: 59 additions & 3 deletions

File tree

nirc_ehr/resources/web/nirc_ehr/data/DrugAdministrationRunsChildClientStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Ext4.define('NIRC_EHR.data.DrugAdministrationRunsChildClientStore', {
3-
extend: 'EHR.data.DrugAdministrationRunsClientStore',
3+
extend: 'NIRC_EHR.data.DrugAdministrationRunsClientStore',
44

55
insert: function(index, records) {
66
var ret = this.callParent(arguments);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Ext4.define('NIRC_EHR.data.DrugAdministrationRunsClientStore', {
2+
extend: 'EHR.data.DrugAdministrationRunsClientStore',
3+
4+
// This override adds a special case for frequency to align formulary frequency.rowid with data frequency.meaning
5+
onRecordUpdate: function (record, modifiedFieldNames) {
6+
if (record.get('code')) {
7+
modifiedFieldNames = modifiedFieldNames || [];
8+
9+
if (modifiedFieldNames.indexOf('code') == -1) {
10+
return;
11+
}
12+
13+
if (!this.formularyStore) {
14+
LDK.Utils.logToServer({
15+
message: 'Unable to find formulary store in DrugAdministrationRunsClientStore'
16+
});
17+
console.error('Unable to find formulary store in DrugAdministrationRunsClientStore');
18+
19+
return;
20+
}
21+
22+
var values = this.formularyStore.getFormularyValues(record.get('code'));
23+
if (!Ext4.Object.isEmpty(values)) {
24+
var params = {};
25+
26+
for (var fieldName in this.fieldMap) {
27+
if (!this.getFields().get(fieldName)) {
28+
continue;
29+
}
30+
31+
if (modifiedFieldNames.indexOf(this.fieldMap[fieldName]) != -1) {
32+
continue;
33+
}
34+
35+
let def = values[fieldName];
36+
37+
// Special case for frequency to align the formulary frequency rowid with data stored as the meaning
38+
if (fieldName.toLowerCase() === 'frequency')
39+
def = values['frequency/meaning']
40+
41+
if (Ext4.isDefined(def)) {
42+
params[this.fieldMap[fieldName]] = def;
43+
}
44+
}
45+
46+
if (!LABKEY.Utils.isEmptyObj(params)) {
47+
record.beginEdit();
48+
record.set(params);
49+
record.endEdit(true);
50+
}
51+
}
52+
}
53+
}
54+
});

nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCTreatmentGivenFormSection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public class NIRCTreatmentGivenFormSection extends BaseFormSection
1111
public NIRCTreatmentGivenFormSection()
1212
{
1313
super("study", "drug", LABEL, "ehr-gridpanel", true, true, true);
14-
setClientStoreClass("EHR.data.DrugAdministrationRunsClientStore");
14+
setClientStoreClass("NIRC_EHR.data.DrugAdministrationRunsClientStore");
1515
addClientDependency(ClientDependency.supplierFromPath("ehr/data/DrugAdministrationRunsClientStore.js"));
16+
addClientDependency(ClientDependency.supplierFromPath("nirc_ehr/data/DrugAdministrationRunsClientStore.js"));
1617
}
1718

1819
public NIRCTreatmentGivenFormSection(boolean isChild, String parentQueryName)

nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCTreatmentOrderFormSection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public class NIRCTreatmentOrderFormSection extends BaseFormSection
1111
public NIRCTreatmentOrderFormSection()
1212
{
1313
super("study", "treatment_order", LABEL, "ehr-gridpanel", true, true, true);
14-
setClientStoreClass("EHR.data.DrugAdministrationRunsClientStore");
14+
setClientStoreClass("NIRC_EHR.data.DrugAdministrationRunsClientStore");
1515
addClientDependency(ClientDependency.supplierFromPath("ehr/data/DrugAdministrationRunsClientStore.js"));
16+
addClientDependency(ClientDependency.supplierFromPath("nirc_ehr/data/DrugAdministrationRunsClientStore.js"));
1617
}
1718

1819
public NIRCTreatmentOrderFormSection(boolean isChild, String parentQueryName)

0 commit comments

Comments
 (0)