-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNIRC_EHRModule.java
More file actions
265 lines (237 loc) · 15.8 KB
/
NIRC_EHRModule.java
File metadata and controls
265 lines (237 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
* Copyright (c) 2021 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.nirc_ehr;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.UpgradeCode;
import org.labkey.api.ehr.EHRService;
import org.labkey.api.ehr.SharedEHRUpgradeCode;
import org.labkey.api.ehr.buttons.MarkCompletedButton;
import org.labkey.api.ehr.dataentry.DefaultDataEntryFormFactory;
import org.labkey.api.ehr.demographics.ParentsDemographicsProvider;
import org.labkey.api.ehr.demographics.SourceDemographicsProvider;
import org.labkey.api.ehr.history.DefaultAlopeciaDataSource;
import org.labkey.api.ehr.history.DefaultAnimalRecordFlagDataSource;
import org.labkey.api.ehr.history.DefaultClinicalRemarksDataSource;
import org.labkey.api.ehr.history.DefaultNotesDataSource;
import org.labkey.api.ehr.history.DefaultVitalsDataSource;
import org.labkey.api.ehr.security.EHRDataAdminPermission;
import org.labkey.api.ldk.ExtendedSimpleModule;
import org.labkey.api.ldk.buttons.ShowEditUIButton;
import org.labkey.api.ldk.notification.NotificationService;
import org.labkey.api.module.Module;
import org.labkey.api.module.ModuleContext;
import org.labkey.api.query.DefaultSchema;
import org.labkey.api.query.DetailsURL;
import org.labkey.api.query.QuerySchema;
import org.labkey.api.resource.Resource;
import org.labkey.api.security.roles.RoleManager;
import org.labkey.api.util.NetworkDrive;
import org.labkey.api.view.WebPartFactory;
import org.labkey.api.view.template.ClientDependency;
import org.labkey.nirc_ehr.dataentry.form.*;
import org.labkey.nirc_ehr.demographics.ActiveAssignmentsDemographicsProvider;
import org.labkey.nirc_ehr.demographics.ActiveCasesDemographicsProvider;
import org.labkey.nirc_ehr.demographics.ActiveFlagsDemographicsProvider;
import org.labkey.nirc_ehr.demographics.ActiveTreatmentsDemographicsProvider;
import org.labkey.nirc_ehr.demographics.CagematesDemographicsProvider;
import org.labkey.nirc_ehr.demographics.HousingDemographicsProvider;
import org.labkey.nirc_ehr.demographics.NecropsyStatusDemographicsProvider;
import org.labkey.nirc_ehr.demographics.ProtocolAssignmentDemographicsProvider;
import org.labkey.nirc_ehr.history.*;
import org.labkey.nirc_ehr.notification.NIRCClinicalMoveNotification;
import org.labkey.nirc_ehr.notification.NIRCDeathNotification;
import org.labkey.nirc_ehr.notification.NIRCPregnancyOutcomeNotification;
import org.labkey.nirc_ehr.notification.NIRCProcedureOverdueNotification;
import org.labkey.nirc_ehr.query.NIRC_EHRUserSchema;
import org.labkey.nirc_ehr.security.NIRCEHRVetTechRole;
import org.labkey.nirc_ehr.table.NIRC_EHRCustomizer;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class NIRC_EHRModule extends ExtendedSimpleModule
{
public static final String NAME = "NIRC_EHR";
@Override
public String getName()
{
return NAME;
}
@Override
public @Nullable Double getSchemaVersion()
{
return 26.000;
}
@Override
@NotNull
protected Collection<WebPartFactory> createWebPartFactories()
{
return Collections.emptyList();
}
@Override
protected void init()
{
addController(NIRC_EHRController.NAME, NIRC_EHRController.class);
EHRService ehrService = EHRService.get();
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/nircReports.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCRecentCasesWindow.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCRecentRemarksWindow.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("ehr/sharedReports.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/SnapshotPanel.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/NarrowSnapshotPanel.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/BloodSummaryPanel.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/AnimalDetailsPanel.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCClinicalHistoryWindow.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCCaseHistoryWindow.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/ClinicalHistoryPanel.js"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/CaseHistoryPanel.js"), this);
}
@Override
protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
{
EHRService ehrService = EHRService.get();
ehrService.registerModule(this);
Resource r = getModuleResource("/scripts/nirc_triggers.js");
assert r != null;
EHRService.get().registerTriggerScript(this, r);
EHRService.get().registerTableCustomizer(this, NIRC_EHRCustomizer.class);
ehrService.addModulePreferringTaskFormEditUI(this);
ehrService.registerDemographicsProvider(new ActiveFlagsDemographicsProvider(this));
ehrService.registerDemographicsProvider(new ParentsDemographicsProvider(this));
ehrService.registerDemographicsProvider(new ActiveAssignmentsDemographicsProvider(this));
ehrService.registerDemographicsProvider(new ProtocolAssignmentDemographicsProvider(this));
ehrService.registerDemographicsProvider(new HousingDemographicsProvider(this));
ehrService.registerDemographicsProvider(new CagematesDemographicsProvider(this));
ehrService.registerDemographicsProvider(new CagematesDemographicsProvider(this));
ehrService.registerDemographicsProvider(new ActiveCasesDemographicsProvider(this));
ehrService.registerDemographicsProvider(new ActiveTreatmentsDemographicsProvider(this));
ehrService.registerDemographicsProvider(new SourceDemographicsProvider(this));
ehrService.registerDemographicsProvider(new NecropsyStatusDemographicsProvider(this));
EHRService.get().registerHistoryDataSource(new ArrivalDataSource(this));
EHRService.get().registerHistoryDataSource(new BiopsyDataSource(this));
EHRService.get().registerHistoryDataSource(new BirthDataSource(this));
EHRService.get().registerHistoryDataSource(new BloodDrawDataSource(this));
EHRService.get().registerHistoryDataSource(new BreederDataSource(this));
EHRService.get().registerHistoryDataSource(new DeathDataSource(this));
EHRService.get().registerHistoryDataSource(new DefaultAlopeciaDataSource(this));
EHRService.get().registerHistoryDataSource(new DefaultAnimalRecordFlagDataSource(this));
EHRService.get().registerHistoryDataSource(new DefaultClinicalRemarksDataSource(this));
EHRService.get().registerHistoryDataSource(new DefaultNotesDataSource(this));
EHRService.get().registerHistoryDataSource(new DefaultVitalsDataSource(this));
EHRService.get().registerHistoryDataSource(new DepartureDataSource(this));
EHRService.get().registerHistoryDataSource(new DrugAdminDataSource(this));
EHRService.get().registerHistoryDataSource(new FlagsDataSource(this));
EHRService.get().registerHistoryDataSource(new FosteringDataSource(this));
EHRService.get().registerHistoryDataSource(new ExemptionsDataSource(this));
EHRService.get().registerHistoryDataSource(new HistopathologyDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCCaseCloseDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCCaseOpenDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCClinicalObservationsDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCBehaviorObservationsDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCClinicalRemarksDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCEndTreatmentOrderDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCHousingDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCObservationOrdersDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCVitalsDataSource(this));
EHRService.get().registerHistoryDataSource(new PairingsDataSource(this));
EHRService.get().registerHistoryDataSource(new PhysicalExamDataSource(this));
EHRService.get().registerHistoryDataSource(new PregnancyDataSource(this));
EHRService.get().registerHistoryDataSource(new ProceduresDataSource(this));
EHRService.get().registerHistoryDataSource(new NIRCProcedureOrdersDataSource(this));
EHRService.get().registerHistoryDataSource(new ProjectAssignmentDataSource(this));
EHRService.get().registerHistoryDataSource(new ProtocolDataSource(this));
EHRService.get().registerHistoryDataSource(new SerologyDataSource(this));
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/nirc_ehr_api"), this);
ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/nircOverrides.js"), this);
ehrService.registerActionOverride("animalHistory", this, "views/animalHistory.html");
ehrService.registerActionOverride("participantView", this, "views/participantView.html");
ehrService.registerActionOverride("enterData", this, "views/enterData.html");
ehrService.registerTriggerScriptOption("datasetsToCloseOnNewEntry", List.of("assignment", "protocolAssignment"));
RoleManager.registerRole(new NIRCEHRVetTechRole());
EHRService.get().registerMoreActionsButton(new ShowEditUIButton(this, "ehr", "observation_types", EHRDataAdminPermission.class), "ehr", "observation_types");
EHRService.get().registerMoreActionsButton(new MarkCompletedButton(this, "study", "observation_order", "Set End Date"), "study", "observation_order");
EHRService.get().registerMoreActionsButton(new MarkCompletedButton(this, "study", "flags", "Set End Date"), "study", "flags");
registerDataEntry();
NotificationService.get().registerNotification(new NIRCDeathNotification(this));
NotificationService.get().registerNotification(new NIRCClinicalMoveNotification(this));
NotificationService.get().registerNotification(new NIRCProcedureOverdueNotification(this));
NotificationService.get().registerNotification(new NIRCPregnancyOutcomeNotification(this));
EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.moreReports, "Printable Necropsy Report", this, DetailsURL.fromString("/nirc_ehr-necropsy.view"), "Pathology");
// Ensure N: is mounted if it's configured, as it's being mapped in via a symlink/shortcut, so we can't
// recognize paths using it based solely on their drive letter and mount just-in-time
if (NetworkDrive.getNetworkDrive("N:\\") != null)
{
NetworkDrive.exists(new File("N:\\"));
}
}
private void registerDataEntry()
{
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCAliasFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCAssignmentFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCArrivalFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBirthFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBulkClinicalFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCDepartureFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCDeathNecropsyFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCHousingFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCMedicationTreatmentFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCProjectFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCProtocolFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCPregnancyFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCWeightFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCFlagsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCExemptionsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCNotesFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCCasesFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBehavioralCasesFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBuildingFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCRoomFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCFloorFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCCageFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCClinicalObservationsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCClinicalRoundsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCAnimalTrainingFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCPairingsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBulkBehaviorFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBehaviorRoundsFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCChemistryImportFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCSerologyImportFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCRearrivalFormType.class, this));
}
@Override
protected void registerSchemas()
{
DefaultSchema.registerProvider(NIRC_EHRSchema.NAME, new DefaultSchema.SchemaProvider(this)
{
@Override
public @NotNull QuerySchema createSchema(DefaultSchema schema, Module module)
{
return new NIRC_EHRUserSchema(NIRC_EHRSchema.NAME, null, schema.getUser(), schema.getContainer(), NIRC_EHRSchema.get_instance().getSchema());
}
});
}
@Override
public @NotNull Collection<String> getSchemaNames()
{
return Collections.singleton(NIRC_EHRSchema.NAME);
}
@Override
public @NotNull UpgradeCode getUpgradeCode()
{
return SharedEHRUpgradeCode.getInstance(this);
}
}