Skip to content

Commit 8e4bd7c

Browse files
authored
24.11 fb environmental cpl bulk uploads (#1362)
* Created a new process to bulk import Environmental CPL Data * Created a new process to bulk import Environmental CPL Data * Created a new process to bulk import Environmental CPL Data * Created a new program to upload data. * Created a new process for uploading bulk entries. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified program to allow bulk uploads onto the Environmental input forms. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess. * Modified Environmental Upload proacess.
1 parent 627107b commit 8e4bd7c

7 files changed

Lines changed: 795 additions & 19 deletions

File tree

onprc_ehr/resources/queries/onprc_ehr/Env_ATP/.qview.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<column name="action" />
88
<column name="test_results"/>
99
<column name="pass_fail"/>
10+
<column name="retest"/>
1011
<column name="performedby"/>
12+
<column name="remarks"/>
1113
<column name="qcstate"/>
1214
<column name="taskid"/>
1315

onprc_ehr/resources/web/onprc_ehr/model/sources/Env_Sanitation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ EHR.model.DataModelManager.registerMetadata('Environmental', {
3737
},
3838
test_results: {
3939
xtype: 'onprc-env_testresults',
40-
header: 'Test Results-',
40+
header: 'Test Results',
4141
columnConfig: {
4242
width: 100
4343
}

onprc_ehr/resources/web/onprc_ehr/window/BulkEnvironmental_ATP_ScanWindow.js

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Ext4.define('ONPRC_EHR.window.BulkEnvironmental_ATP_ScanWindow', {
108108

109109
var cnt = i;
110110

111-
this.processRow(row, recordMap, errors, rowIdx, id, parsed, cnt,servicetype,chargeunit);
111+
this.processRow(row, recordMap, errors, rowIdx, tdate, parsed, cnt,servicetype,chargeunit);
112112
}
113113

114114
Ext4.Msg.hide();
@@ -149,31 +149,53 @@ Ext4.define('ONPRC_EHR.window.BulkEnvironmental_ATP_ScanWindow', {
149149
errors.push('Missing Date');
150150
}
151151

152-
// for (var k = 1; k < 13; k++) // Process only if data exists
153-
//
154-
// {
155-
// if (row[k])
156-
// {
157152

158-
var HeaderObjectID = LABKEY.Utils.generateUUID().toUpperCase();
153+
var HeaderObjectID = LABKEY.Utils.generateUUID().toUpperCase();
154+
var labgroup = Ext4.String.trim(row[3]);
155+
var labretest = Ext4.String.trim(row[7]);
156+
var lablocation = Ext4.String.trim(row[4]);
157+
var labsurface = Ext4.String.trim(row[5]);
158+
var labinitial = Ext4.String.trim(row[6]);
159159

160-
var obj = {
160+
161+
if (!labgroup){
162+
labgroup = '{n/a}'
163+
}
164+
165+
if (!labretest){
166+
labretest = 0;
167+
}
168+
if (!lablocation){
169+
lablocation = 'n/a';
170+
}
171+
if (!labsurface){
172+
labsurface = '(n/a)';
173+
}
174+
175+
if (!labinitial){
176+
labinitial = '[n/a]';
177+
}
178+
179+
180+
181+
182+
var obj = {
161183
date: date,
162-
servicerequested: servicetype,
184+
service_requested: servicetype,
163185
charge_unit: chargeunit,
164186
testing_location:Ext4.String.trim(row[2]), //Area
165-
action:Ext4.String.trim(row[4]), //Area
166-
test_results:Ext4.String.trim(row[3]), //LAB/GROUP
167-
surface_tested:Ext4.String.trim(row[5]), //Surface Tested
168-
retest:Ext4.String.trim(row[7]), //Retest
169-
pass_fail:Ext4.String.trim(row[6]), // Initial
187+
action:lablocation, //Location
188+
test_results:labgroup, //LAB/GROUP
189+
surface_tested:labsurface, //Surface
190+
retest:labretest, //Retest
191+
pass_fail:labinitial, // Initial
170192
objectid: HeaderObjectID,
171-
performedby: Ext4.String.trim(row[1]), //Tech Initials
172-
remarks:Ext4.String.trim(row[8]) //Ccmments
193+
performedby: Ext4.String.trim(row[1]), //Tech
194+
remarks:Ext4.String.trim(row[8]) //Ccmments
173195

174196
};
175197

176-
if (!this.checkRequired(['date', 'servicerequested','charge_unit','testing_location','action','test_results','surface_tested','retest','pass_fail','performedby','retest','surface_tested'], obj, errors, rowIdx))
198+
if (!this.checkRequired(['date', 'service_requested','charge_unit','testing_location','action','test_results','surface_tested','retest','pass_fail','performedby'], obj, errors, rowIdx))
177199
{
178200
recordMap.primaryheader.push(obj);
179201
}
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
/*
2+
* Copyright (c) 2015-2017 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
/**
7+
* @cfg dataEntryPanel Created 4/29/2025 Blasa Environmental CPL Entries
8+
*/
9+
Ext4.define('ONPRC_EHR.window.BulkEnvironmental_CPL_Biological_Window', {
10+
extend: 'Ext.window.Window',
11+
12+
initComponent: function(){
13+
Ext4.apply(this, {
14+
modal: true,
15+
closeAction: 'destroy',
16+
title: 'Bulk Environmental CPL Biological Indicagtors Import',
17+
bodyStyle: 'padding: 5px;',
18+
width: 800,
19+
defaults: {
20+
border: false
21+
},
22+
items: [{
23+
html : 'This allows you to import record using the Environmental_CPL_Biological Indicators_Window Excel form. To import, cut/paste the contents of the excel file (Ctl + A is a good way to select all) into the box below, and click submit.',
24+
style: 'padding-bottom: 10px;'
25+
},{
26+
xtype: 'ldk-linkbutton',
27+
text: '[Download Template]',
28+
scope: this,
29+
style: 'margin-bottom: 10px;',
30+
handler: function(){
31+
window.location = LABKEY.contextPath + '/onprc_ehr/templates/BulkEnvironmental_CPL_Biological_Template.xlsx'
32+
}
33+
},{
34+
xtype: 'textarea',
35+
width: 770,
36+
height: 400,
37+
itemId: 'textField'
38+
}],
39+
buttons: [{
40+
text: 'Submit',
41+
scope: this,
42+
handler: this.onSubmit
43+
},{
44+
text: 'Cancel',
45+
handler: function(btn){
46+
btn.up('window').close();
47+
}
48+
}]
49+
});
50+
51+
52+
this.callParent(arguments);
53+
},
54+
55+
onSubmit: function(){
56+
var text = this.down('#textField').getValue();
57+
if (!text){
58+
Ext4.Msg.alert('Error', 'Must paste the records into the text area');
59+
return;
60+
}
61+
62+
var parsed = LDK.Utils.CSVToArray(Ext4.String.trim(text), '\t');
63+
if (!parsed){
64+
Ext4.Msg.alert('Error', 'There was an error parsing your excel file');
65+
return;
66+
}
67+
68+
if (parsed.length < 2){
69+
Ext4.Msg.alert('Error', 'There are not enough rows in the text, there was an error parsing the excel file');
70+
return;
71+
}
72+
73+
this.doParse(parsed);
74+
},
75+
76+
doParse: function(parsed)
77+
{
78+
var errors = [];
79+
80+
var recordMap = {
81+
primaryheader: [],
82+
};
83+
84+
Ext4.Msg.wait('Please be patient while we Process your data...');
85+
86+
var servicetype = 'Sanitation: Bio-indicator';
87+
var chargeunit = 'Clinpath' ;
88+
89+
90+
var offset = 1;
91+
var rowIdx = offset;
92+
for (var i = offset; i < parsed.length; i++)
93+
{
94+
rowIdx++;
95+
var row = parsed[i];
96+
if (!row || row.length < 2)
97+
{
98+
errors.push('Row ' + rowIdx + ': not enough items in row');
99+
continue;
100+
}
101+
102+
var tdate = parsed[i][1];
103+
if (!tdate)
104+
{
105+
errors.push('Row ' + rowIdx + ': missing date');
106+
return;
107+
}
108+
109+
var cnt = i;
110+
111+
this.processRow(row, recordMap, errors, rowIdx, id, parsed, cnt,servicetype,chargeunit);
112+
}
113+
114+
Ext4.Msg.hide();
115+
116+
if (errors.length)
117+
{
118+
errors = Ext4.unique(errors);
119+
Ext4.Msg.alert('Error', 'There following errors were found:<p>' + errors.join('<br>'));
120+
return;
121+
}
122+
//Main Header
123+
if (recordMap.primaryheader.length)
124+
{
125+
var clientStore = this.dataEntryPanel.storeCollection.getClientStoreByName('Environmental_Assessment');
126+
LDK.Assert.assertNotEmpty('Unable to find procedure store in Environmental_Assessment', clientStore);
127+
128+
var records = [];
129+
for (var i = 0; i < recordMap.primaryheader.length; i++)
130+
{
131+
records.push(clientStore.createModel(recordMap.primaryheader[i]));
132+
}
133+
134+
clientStore.add(records);
135+
}
136+
137+
138+
this.close();
139+
},
140+
141+
processRow: function(row, recordMap, errors, rowIdx,tdate, parsed, cnt,servicetype,chargeunit) {
142+
143+
// Generate labwork Header information
144+
145+
var date = LDK.ConvertUtils.parseDate(this.safeGet(parsed, cnt, 0));
146+
if (!date) {
147+
errors.push('Missing Date');
148+
}
149+
150+
var HeaderObjectID = LABKEY.Utils.generateUUID().toUpperCase();
151+
152+
var obj = {
153+
date: date,
154+
servicer_requested: servicetype,
155+
charge_unit: chargeunit,
156+
testing_location: Ext4.String.trim(row[2]), //Autoclave
157+
test_type: Ext4.String.trim(row[4]), //Initial
158+
test_method: Ext4.String.trim(row[5]), // Testing Method
159+
pass_fail: Ext4.String.trim(row[7]), //Pass/Fail
160+
biological_cycle: Ext4.String.trim(row[8]), //Cycle
161+
biological_BI: Ext4.String.trim(row[9]), //BI#
162+
action: Ext4.String.trim(row[10]), // Action
163+
retest: Ext4.String.trim(row[12]), //Results Read by
164+
objectid: HeaderObjectID,
165+
performedby: Ext4.String.trim(row[14]), //Tech Initials
166+
remarks: Ext4.String.trim(row[15]) //Ccmments
167+
168+
};
169+
170+
if (!this.checkRequired(['date', 'servicerequested','charge_unit','testing_location','action','test_results','retest','pass_fail','performedby','retest'], obj, errors, rowIdx))
171+
{
172+
recordMap.primaryheader.push(obj);
173+
}
174+
175+
},
176+
177+
178+
179+
checkRequired: function(fields, row, errors, rowIdx){
180+
var hasErrors = false,
181+
fieldName;
182+
for (var i=0;i<fields.length;i++){
183+
fieldName = fields[i];
184+
if (Ext4.isEmpty(row[fieldName])){
185+
errors.push('Row ' + rowIdx + ': missing field ' + fieldName);
186+
hasErrors = true;
187+
}
188+
}
189+
190+
return hasErrors;
191+
},
192+
193+
getTime: function(date, timeStr, errors, rowIdx){
194+
if (!date || !timeStr){
195+
return null;
196+
}
197+
198+
var orig = date;
199+
date = LDK.ConvertUtils.parseDate(date);
200+
if (!date){
201+
errors.push('Row ' + rowIdx + ': invalid date format: ' + orig);
202+
return null;
203+
}
204+
205+
timeStr = Ext4.String.leftPad(timeStr, 5, '0'); //expect: HH:mm
206+
var ret = LDK.ConvertUtils.parseDate(Ext4.Date.format(date, LABKEY.extDefaultDateFormat) + ' ' + timeStr);
207+
if (!ret){
208+
errors.push('Row ' + rowIdx + ': invalid time: ' + timeStr);
209+
}
210+
211+
return ret;
212+
},
213+
214+
resolveProjectByName: function(projectName, errors, rowIdx){
215+
if (!projectName){
216+
return null;
217+
}
218+
219+
projectName = Ext4.String.trim(projectName);
220+
var ret = EHR.DataEntryUtils.resolveProjectByName(this.projectStore, projectName);
221+
if (!ret){
222+
errors.push('Row ' + rowIdx + ': unknown project ' + projectName);
223+
}
224+
else {
225+
return ret;
226+
}
227+
},
228+
229+
safeGet: function(parsed, a, b){
230+
if (parsed && parsed.length >= a && parsed[a].length >= b){
231+
return parsed[a][b];
232+
}
233+
else {
234+
console.error('Unable to find position: ' + a + '/' + b);
235+
}
236+
}
237+
});
238+
239+
EHR.DataEntryUtils.registerDataEntryFormButton('ENV_CPL_Boiological_IMPORT', {
240+
text: 'Enviromental CPL Panel Import',
241+
name: 'envCPLBioscan',
242+
itemId: 'envCPLBioscan',
243+
tooltip: 'Click to import using a Environmental CPL Biological Panel template',
244+
handler: function(btn){
245+
var panel = btn.up('ehr-dataentrypanel');
246+
LDK.Assert.assertNotEmpty('Unable to find dataEntryPanel in Environmental CPL Biological Panel button', panel);
247+
248+
Ext4.create('ONPRC_EHR.window.BulkEnvironmental_CPL_Biological_Window', {
249+
dataEntryPanel: panel
250+
}).show();
251+
}
252+
});

0 commit comments

Comments
 (0)