@statengine/siamese 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +5 -5
- package/.eslintrc +18 -18
- package/LICENSE +674 -674
- package/README.md +18 -18
- package/lib/helpers.js +3 -3
- package/package.json +42 -42
- package/src/helpers.js +49 -49
- package/src/index.js +358 -358
- package/src/priorityDispatchCodes.js +985 -985
- package/test/test.helpers.js +487 -487
- package/test/test.js +114 -114
package/test/test.js
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import 'babel-polyfill';
|
|
2
|
-
import {
|
|
3
|
-
expect,
|
|
4
|
-
} from 'chai';
|
|
5
|
-
import IncidentNormalizer from '../src';
|
|
6
|
-
|
|
7
|
-
describe('IncidentNormalizer', () => {
|
|
8
|
-
it('should not geohash invalid coordinates', () => {
|
|
9
|
-
expect(IncidentNormalizer.latLongToGeohash(undefined, 1)).to.be.null;
|
|
10
|
-
expect(IncidentNormalizer.latLongToGeohash(null, 1)).to.be.null;
|
|
11
|
-
expect(IncidentNormalizer.latLongToGeohash(1, undefined)).to.be.null;
|
|
12
|
-
expect(IncidentNormalizer.latLongToGeohash(1, null)).to.be.null;
|
|
13
|
-
|
|
14
|
-
// although unlikely 0,0 is valid
|
|
15
|
-
expect(IncidentNormalizer.latLongToGeohash(0, 0)).to.equal('7zzzzzzzzzzz');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should retrieve shiftly configurations for valid ids', () => {
|
|
19
|
-
expect(IncidentNormalizer.lookupShiftlyConfig('90552')).to.not.equal(null);
|
|
20
|
-
expect(IncidentNormalizer.lookupShiftlyConfig('05102')).to.not.equal(null);
|
|
21
|
-
expect(IncidentNormalizer.lookupShiftlyConfig('000')).to.equal(null);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('calculateUnitStatusExtendedData should calculate event_duration based on latest timestamp (and calculate the other durations correctly)', () => {
|
|
25
|
-
const unitStatus = {
|
|
26
|
-
dispatched: {
|
|
27
|
-
latitude: 38.8703695581824,
|
|
28
|
-
longitude: -77.15635501332166,
|
|
29
|
-
timestamp: '2017-12-30T18:37:11-05:00',
|
|
30
|
-
},
|
|
31
|
-
enroute: {
|
|
32
|
-
latitude: 38.8703695581824,
|
|
33
|
-
longitude: -77.15635501332166,
|
|
34
|
-
timestamp: '2017-12-30T18:37:42-05:00',
|
|
35
|
-
},
|
|
36
|
-
staging: {
|
|
37
|
-
latitude: 38.84776403520299,
|
|
38
|
-
longitude: -77.13305689919378,
|
|
39
|
-
timestamp: '2017-12-30T18:41:42-05:00',
|
|
40
|
-
},
|
|
41
|
-
arrived: {
|
|
42
|
-
latitude: 38.84776403520299,
|
|
43
|
-
longitude: -77.13305689919378,
|
|
44
|
-
timestamp: '2017-12-30T18:43:01-05:00',
|
|
45
|
-
},
|
|
46
|
-
patient_contact: {
|
|
47
|
-
latitude: 38.84776403520299,
|
|
48
|
-
longitude: -77.13305689919378,
|
|
49
|
-
timestamp: '2017-12-30T18:45:01-05:00',
|
|
50
|
-
},
|
|
51
|
-
transport_started: {
|
|
52
|
-
latitude: 38.847789177196,
|
|
53
|
-
longitude: -77.13341200471721,
|
|
54
|
-
timestamp: '2017-12-30T18:50:57-05:00',
|
|
55
|
-
},
|
|
56
|
-
transport_arrived: {
|
|
57
|
-
latitude: 38.88785485040848,
|
|
58
|
-
longitude: -77.12726809345266,
|
|
59
|
-
timestamp: '2017-12-30T19:00:31-05:00',
|
|
60
|
-
},
|
|
61
|
-
cleared: {
|
|
62
|
-
latitude: 38.88785485040848,
|
|
63
|
-
longitude: -77.12726809345266,
|
|
64
|
-
timestamp: '2017-12-30T19:17:31-05:00',
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const times = IncidentNormalizer.calculateUnitStatusExtendedData(unitStatus);
|
|
69
|
-
expect(times.turnout_duration).to.equal(31);
|
|
70
|
-
expect(times.travel_duration).to.equal(240);
|
|
71
|
-
expect(times.response_duration).to.equal(271);
|
|
72
|
-
expect(times.event_duration).to.equal(2420);
|
|
73
|
-
expect(times.at_hospital_duration).to.equal(1020);
|
|
74
|
-
expect(times.transport_duration).to.equal(574);
|
|
75
|
-
expect(times.on_scene_duration).to.equal(555);
|
|
76
|
-
expect(times.staging_duration).to.equal(79);
|
|
77
|
-
expect(times.patient_contact_to_transport_arrived_duration).to.equal(930);
|
|
78
|
-
expect(times.on_scene_to_transport_arrived_duration).to.equal(1129);
|
|
79
|
-
expect(times.on_scene_to_patient_contact).to.equal(199);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('calculateUnitStatusExtendedData should calculate event_duration based on earliest cleared timestamp', () => {
|
|
83
|
-
const unitStatus = {
|
|
84
|
-
dispatched: {
|
|
85
|
-
latitude: 38.8703695581824,
|
|
86
|
-
longitude: -77.15635501332166,
|
|
87
|
-
timestamp: '2017-12-30T18:37:11-05:00',
|
|
88
|
-
},
|
|
89
|
-
enroute: {
|
|
90
|
-
latitude: 38.8703695581824,
|
|
91
|
-
longitude: -77.15635501332166,
|
|
92
|
-
timestamp: '2017-12-30T18:37:42-05:00',
|
|
93
|
-
},
|
|
94
|
-
arrived: {
|
|
95
|
-
latitude: 38.84776403520299,
|
|
96
|
-
longitude: -77.13305689919378,
|
|
97
|
-
timestamp: '2017-12-30T18:43:01-05:00',
|
|
98
|
-
},
|
|
99
|
-
cleared: {
|
|
100
|
-
latitude: 38.847789177196,
|
|
101
|
-
longitude: -77.13341200471721,
|
|
102
|
-
timestamp: '2017-12-30T18:50:57-05:00',
|
|
103
|
-
},
|
|
104
|
-
available: {
|
|
105
|
-
latitude: 38.847789177196,
|
|
106
|
-
longitude: -77.13341200471721,
|
|
107
|
-
timestamp: '2017-12-30T19:50:57-05:00',
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const times = IncidentNormalizer.calculateUnitStatusExtendedData(unitStatus);
|
|
112
|
-
expect(times.event_duration).to.equal(826);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
1
|
+
import 'babel-polyfill';
|
|
2
|
+
import {
|
|
3
|
+
expect,
|
|
4
|
+
} from 'chai';
|
|
5
|
+
import IncidentNormalizer from '../src';
|
|
6
|
+
|
|
7
|
+
describe('IncidentNormalizer', () => {
|
|
8
|
+
it('should not geohash invalid coordinates', () => {
|
|
9
|
+
expect(IncidentNormalizer.latLongToGeohash(undefined, 1)).to.be.null;
|
|
10
|
+
expect(IncidentNormalizer.latLongToGeohash(null, 1)).to.be.null;
|
|
11
|
+
expect(IncidentNormalizer.latLongToGeohash(1, undefined)).to.be.null;
|
|
12
|
+
expect(IncidentNormalizer.latLongToGeohash(1, null)).to.be.null;
|
|
13
|
+
|
|
14
|
+
// although unlikely 0,0 is valid
|
|
15
|
+
expect(IncidentNormalizer.latLongToGeohash(0, 0)).to.equal('7zzzzzzzzzzz');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should retrieve shiftly configurations for valid ids', () => {
|
|
19
|
+
expect(IncidentNormalizer.lookupShiftlyConfig('90552')).to.not.equal(null);
|
|
20
|
+
expect(IncidentNormalizer.lookupShiftlyConfig('05102')).to.not.equal(null);
|
|
21
|
+
expect(IncidentNormalizer.lookupShiftlyConfig('000')).to.equal(null);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('calculateUnitStatusExtendedData should calculate event_duration based on latest timestamp (and calculate the other durations correctly)', () => {
|
|
25
|
+
const unitStatus = {
|
|
26
|
+
dispatched: {
|
|
27
|
+
latitude: 38.8703695581824,
|
|
28
|
+
longitude: -77.15635501332166,
|
|
29
|
+
timestamp: '2017-12-30T18:37:11-05:00',
|
|
30
|
+
},
|
|
31
|
+
enroute: {
|
|
32
|
+
latitude: 38.8703695581824,
|
|
33
|
+
longitude: -77.15635501332166,
|
|
34
|
+
timestamp: '2017-12-30T18:37:42-05:00',
|
|
35
|
+
},
|
|
36
|
+
staging: {
|
|
37
|
+
latitude: 38.84776403520299,
|
|
38
|
+
longitude: -77.13305689919378,
|
|
39
|
+
timestamp: '2017-12-30T18:41:42-05:00',
|
|
40
|
+
},
|
|
41
|
+
arrived: {
|
|
42
|
+
latitude: 38.84776403520299,
|
|
43
|
+
longitude: -77.13305689919378,
|
|
44
|
+
timestamp: '2017-12-30T18:43:01-05:00',
|
|
45
|
+
},
|
|
46
|
+
patient_contact: {
|
|
47
|
+
latitude: 38.84776403520299,
|
|
48
|
+
longitude: -77.13305689919378,
|
|
49
|
+
timestamp: '2017-12-30T18:45:01-05:00',
|
|
50
|
+
},
|
|
51
|
+
transport_started: {
|
|
52
|
+
latitude: 38.847789177196,
|
|
53
|
+
longitude: -77.13341200471721,
|
|
54
|
+
timestamp: '2017-12-30T18:50:57-05:00',
|
|
55
|
+
},
|
|
56
|
+
transport_arrived: {
|
|
57
|
+
latitude: 38.88785485040848,
|
|
58
|
+
longitude: -77.12726809345266,
|
|
59
|
+
timestamp: '2017-12-30T19:00:31-05:00',
|
|
60
|
+
},
|
|
61
|
+
cleared: {
|
|
62
|
+
latitude: 38.88785485040848,
|
|
63
|
+
longitude: -77.12726809345266,
|
|
64
|
+
timestamp: '2017-12-30T19:17:31-05:00',
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const times = IncidentNormalizer.calculateUnitStatusExtendedData(unitStatus);
|
|
69
|
+
expect(times.turnout_duration).to.equal(31);
|
|
70
|
+
expect(times.travel_duration).to.equal(240);
|
|
71
|
+
expect(times.response_duration).to.equal(271);
|
|
72
|
+
expect(times.event_duration).to.equal(2420);
|
|
73
|
+
expect(times.at_hospital_duration).to.equal(1020);
|
|
74
|
+
expect(times.transport_duration).to.equal(574);
|
|
75
|
+
expect(times.on_scene_duration).to.equal(555);
|
|
76
|
+
expect(times.staging_duration).to.equal(79);
|
|
77
|
+
expect(times.patient_contact_to_transport_arrived_duration).to.equal(930);
|
|
78
|
+
expect(times.on_scene_to_transport_arrived_duration).to.equal(1129);
|
|
79
|
+
expect(times.on_scene_to_patient_contact).to.equal(199);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('calculateUnitStatusExtendedData should calculate event_duration based on earliest cleared timestamp', () => {
|
|
83
|
+
const unitStatus = {
|
|
84
|
+
dispatched: {
|
|
85
|
+
latitude: 38.8703695581824,
|
|
86
|
+
longitude: -77.15635501332166,
|
|
87
|
+
timestamp: '2017-12-30T18:37:11-05:00',
|
|
88
|
+
},
|
|
89
|
+
enroute: {
|
|
90
|
+
latitude: 38.8703695581824,
|
|
91
|
+
longitude: -77.15635501332166,
|
|
92
|
+
timestamp: '2017-12-30T18:37:42-05:00',
|
|
93
|
+
},
|
|
94
|
+
arrived: {
|
|
95
|
+
latitude: 38.84776403520299,
|
|
96
|
+
longitude: -77.13305689919378,
|
|
97
|
+
timestamp: '2017-12-30T18:43:01-05:00',
|
|
98
|
+
},
|
|
99
|
+
cleared: {
|
|
100
|
+
latitude: 38.847789177196,
|
|
101
|
+
longitude: -77.13341200471721,
|
|
102
|
+
timestamp: '2017-12-30T18:50:57-05:00',
|
|
103
|
+
},
|
|
104
|
+
available: {
|
|
105
|
+
latitude: 38.847789177196,
|
|
106
|
+
longitude: -77.13341200471721,
|
|
107
|
+
timestamp: '2017-12-30T19:50:57-05:00',
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const times = IncidentNormalizer.calculateUnitStatusExtendedData(unitStatus);
|
|
112
|
+
expect(times.event_duration).to.equal(826);
|
|
113
|
+
});
|
|
114
|
+
});
|