Skip to content

Commit f403319

Browse files
Merge 22.4 to develop
2 parents b42b738 + 8a38133 commit f403319

18 files changed

Lines changed: 23645 additions & 993 deletions

File tree

snprc_ehr/package-lock.json

Lines changed: 23543 additions & 970 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

snprc_ehr/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
"eslint-plugin-react": "^7.20.6",
100100
"file-loader": "3.0.1",
101101
"html-webpack-plugin": "3.2.0",
102-
"jest": "^26.4.2",
103-
"jest-cli": "^26.4.2",
102+
"jest": "^26.6.3",
103+
"jest-cli": "^26.6.3",
104104
"jest-teamcity-reporter": "^0.9.0",
105105
"mini-css-extract-plugin": "^0.11.0",
106106
"node-sass": "^6.0.1",

snprc_ehr/resources/queries/ehr/ProtocolLookup.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
PARAMETERS
2+
(
3+
newAssignmentsParm INTEGER DEFAULT 1
4+
)
15
SELECT p.protocol AS Iacuc,
26
p.protocol + ' - ' + RTRIM(p.inves)+ ' -' + RTRIM(p.title) AS DisplayValue,
37
RIGHT(p.protocol, 2) AS Species,
@@ -8,5 +12,6 @@ SELECT p.protocol AS Iacuc,
812
p.maxAnimals AS MaxAnimals
913
FROM ehr.protocol AS p
1014
INNER JOIN snprc_ehr.IacucAssignmentStats as ia on p.protocol = ia.WorkingIacuc
11-
WHERE ia.NumAnimalsAssigned < ia.NumAnimalsAllowed
12-
AND ia.StartDate = p.approve
15+
WHERE ia.NumAnimalsAssigned + newAssignmentsParm < ia.NumAnimalsAllowed
16+
AND ia.StartDate = p.approve
17+

snprc_ehr/resources/queries/snprc_ehr/CurrentSpeciesLookup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ LEFT OUTER JOIN
1212
) as x ON x.species = s.species_code
1313
WHERE s.dateDisabled is null
1414
AND (
15-
age_in_years(x.birth, curdate()) <= 5 OR age_in_months(s.created, curdate()) <= 3
15+
age_in_years(x.birth, curdate()) <= 10 OR age_in_months(s.created, curdate()) <= 3
1616
)

snprc_ehr/resources/source_queries/create_v_labwork_results.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ALTER VIEW [labkey_etl].[v_labwork_results] AS
3131
-- Note: Merged all procedure types into a single query
3232
-- Changes:
3333
--
34-
--
34+
-- 4/11/2022 Fixed NTE concatenation bug
3535
-- ==========================================================================================
3636

3737
SELECT
@@ -58,7 +58,7 @@ SELECT
5858
REPLACE(
5959
(SELECT RTRIM(LTRIM(nte.comment)) + '**NEWLINE**'
6060
FROM dbo.CLINICAL_PATH_NTE AS nte
61-
WHERE nte.message_id = obr.message_id AND obx.set_id = nte.set_id
61+
WHERE nte.message_id = obr.message_id
6262
ORDER BY CAST(nte.set_id AS INTEGER)
6363
FOR XML PATH ('') -- generates a concatenation of notes
6464

snprc_ehr/src/client/NewAnimalPage/NewAnimalPage.jsx

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ import SaveModal from './components/SaveModal'
3333
import { isBirthdateValid } from './services/validation'
3434
import { uploadAnimalData } from './api/updateAnimalData'
3535
import { getReportPath } from './services/printToPDF'
36+
import { isNonPrimate } from './services/utils'
3637

3738
export default class NewAnimalPage extends React.Component {
3839
state = new NewAnimalState();
3940
debug = constants.debug;
4041
numPanels = constants.numPanels;
4142
selectedSpecies = undefined;
43+
4244
componentDidMount() {
4345
// prevent user from navigating away from page
4446
window.addEventListener('beforeunload', this.beforeunload.bind(this))
@@ -105,11 +107,11 @@ loadLists() {
105107
}
106108
loadListsForSpecies = selectedSpecies => {
107109
const lists = {}
108-
110+
const newAssignments = this.state.numAnimals || 1
109111
async function loadListsAW(species) {
110112
lists.locationList = await fetchLocations(species)
111113
lists.colonyList = await fetchColonies(species)
112-
lists.iacucList = await fetchProtocols(species)
114+
lists.iacucList = await fetchProtocols(species, newAssignments)
113115
lists.pedigreeList = await fetchPedigrees(species)
114116
}
115117

@@ -131,8 +133,34 @@ loadListsForSpecies = selectedSpecies => {
131133
}))
132134
})
133135
};
136+
137+
loadIacucList = (species, newAssignments ) => {
138+
const lists = {}
139+
140+
async function loadListsAW(species, newAssignments) {
141+
lists.iacucList = await fetchProtocols(species, newAssignments)
142+
}
143+
144+
loadListsAW(species, newAssignments)
145+
.then(() => {
146+
this.setState(prevState => ({
147+
...prevState,
148+
iacucList: lists.iacucList
149+
}))
150+
})
151+
.catch(error => {
152+
console.log(`Error in loadIacucList: ${error}`)
153+
this.setState(prevState => ({
154+
...prevState,
155+
errorMessage: error.message,
156+
}))
157+
})
158+
};
159+
134160
disablePanels = () => !(this.state.locationList && this.state.locationList.length > 0);
161+
135162
disableFirstPanel = () => !this.state.selectedOption || !this.state.newAnimalData.species;
163+
136164
handleAcquisitionOptionChange = type => {
137165
fetchAcquisitionTypes(type)
138166
.then(response => this.setState(prevState => ({
@@ -151,38 +179,48 @@ handleAcquisitionOptionChange = type => {
151179
console.log(error)
152180
})
153181
};
154-
handleSpeciesChange = selectedSpecies => {
182+
handleSpeciesChange = selectedSpecies => {
155183
// ignore sub-species change
156184
if (
157185
this.state.newAnimalData.species !== undefined
158-
&& this.state.newAnimalData.species.arcSpeciesCode
159-
!== selectedSpecies.arcSpeciesCode
186+
&& this.state.newAnimalData.species.arcSpeciesCode !== selectedSpecies.arcSpeciesCode
160187
) {
161188
this.selectedSpecies = selectedSpecies
162189
this.setState(prevState => ({
163190
...prevState,
164191
showSpeciesChangeModal: true,
165192
}))
166193
} else {
194+
let nonPrimate = isNonPrimate(selectedSpecies)
167195
this.setState(prevState => ({
168196
...prevState,
169197
isDirty: true,
170198
newAnimalData: {
171199
...prevState.newAnimalData,
172200
species: selectedSpecies,
201+
isNonPrimate: nonPrimate,
173202
},
174203
}))
175204
this.loadListsForSpecies(selectedSpecies)
176205
}
177206
};
178207
handleNumAnimalChange = value => {
179-
this.setState(
208+
const newAssignments = this.state.numAnimals || 1
209+
const species = this.state.newAnimalData.species.arcSpeciesCode
210+
211+
this.setState(
180212
prevState => ({
181213
...prevState,
182214
numAnimals: value
183215
})
184216
)
217+
218+
// see if the protocol list needs to be reloaded
219+
if (value != newAssignments) {
220+
this.loadIacucList(species, value )
185221
}
222+
}
223+
186224
handleDataChange = (property, value) => {
187225
this.setState(
188226
prevState => ({
@@ -385,6 +423,7 @@ handleSaveReset = () => {
385423
};
386424
onSpeciesChangeClick = () => {
387425
const initialState = new NewAnimalState()
426+
let nonPrimate = isNonPrimate(this.selectedSpecies)
388427
this.setState(
389428
prevState => ({
390429
...initialState,
@@ -402,6 +441,7 @@ onSpeciesChangeClick = () => {
402441
...initialState.newAnimalData,
403442
species: this.selectedSpecies,
404443
selectedOption: prevState.newAnimalData.selectedOption,
444+
isNonPrimate: nonPrimate
405445
},
406446
}),
407447
this.loadListsForSpecies(this.selectedSpecies)

snprc_ehr/src/client/NewAnimalPage/api/fetchProtocols.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ const parse = rows => {
77
})
88
}
99

10-
const fetchProtocols = species => {
10+
const fetchProtocols = (species, newAssignments) => {
1111
return new Promise((resolve, reject) => {
1212
request({
13+
parameters: { newAssignmentsParm: newAssignments },
1314
schemaName: 'ehr',
1415
queryName: 'ProtocolLookup',
1516
columns: ['Iacuc', 'DisplayValue', 'Species', 'MaxAnimals'],

snprc_ehr/src/client/NewAnimalPage/components/AcquisitionPanel.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ handlePaste = e => {
5959
e.preventDefault()
6060
}
6161
render() {
62-
const { acquisitionType, acqDate, species, sourceLocation } = this.props.newAnimalData
62+
const { acquisitionType, acqDate, species, sourceLocation, isNonPrimate } = this.props.newAnimalData
6363
const { numAnimals } = this.props
6464
const { selectedOption } = this.props
6565

@@ -122,7 +122,7 @@ render() {
122122
</div>
123123
)}
124124
</div>
125-
{ species && species.arcSpeciesCode === 'MA' && (
125+
{species && isNonPrimate && (
126126
<div className="wizard-panel__row">
127127
<div className="wizard-panel__col">
128128
<label className="field-label">Number of Animals</label>
@@ -147,7 +147,7 @@ render() {
147147
errorMessages={ this.state.errorMessage && (
148148
[{ propTest: this.state.errorMessage, colName: this.state.errorMessage }]
149149
) }
150-
infoMessages={ species && species.arcSpeciesCode === 'MA' && numAnimals && numAnimals !== 1 && [
150+
infoMessages={ species && isNonPrimate && numAnimals && numAnimals !== 1 && [
151151
{ key: 1, value: constants.hamsterWarnings }
152152
] }
153153
messages={

snprc_ehr/src/client/NewAnimalPage/constants/NewAnimalState.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const NewAnimalState = () => {
2828
diet: undefined,
2929
pedigree: undefined,
3030
iacuc: undefined,
31-
sourceLocation: undefined
31+
sourceLocation: undefined,
32+
isNonPrimate: undefined
3233
},
3334
summaryData: [],
3435
speciesList: [],

snprc_ehr/src/client/NewAnimalPage/constants/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export default {
2+
nonPrimateList: 'HAM CAV', // use three-char species code
23
debug: false,
34
numPanels: 5,
45
defaultInstitution: { id: 0, value: 1, label: 'TxBiomed - Texas Biomedical Research Institute' },
56
offSiteAcqCodes: ['22', '23', '25', '97'],
67
hamsterWarnings:
7-
`Hamsters can be acquired in bulk; however, when added in bulk you must ensure all animals:
8+
`Non-primates can be acquired in bulk; however, when added in bulk you must ensure all animals:
89
1) are the same sex
910
2) have the same birth and acquisition dates
1011
3) are in the same location

0 commit comments

Comments
 (0)