-
Notifications
You must be signed in to change notification settings - Fork 10
/
types.ts
877 lines (791 loc) · 19 KB
/
types.ts
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
import { ReactElement, ReactNode } from 'react'
import {
Bundle,
Claim,
Condition,
DocumentReference,
Encounter,
Extension,
FhirResource,
Group,
ImagingStudy,
MedicationAdministration,
MedicationRequest,
Observation,
OperationOutcome,
Parameters,
Patient,
Period,
Procedure,
QuestionnaireResponse,
Resource
} from 'fhir/r4'
import { AxiosResponse } from 'axios'
import { SearchInputError } from 'types/error'
import {
Comparators,
CriteriaDataKey,
CriteriaType,
PMSIResourceTypes,
ResourceType,
SelectedCriteriaType
} from 'types/requestCriterias'
import { ExportTableType } from 'components/Dashboard/ExportModal/export_table'
import { Hierarchy } from 'types/hierarchy'
import { SearchByTypes } from 'types/searchCriterias'
import { PMSILabel } from 'types/patient'
export enum JobStatus {
new = 'new',
pending = 'pending',
suspended = 'suspended'
}
export enum WebSocketJobStatus {
new = 'new',
pending = 'pending',
suspended = 'suspended',
accepted = 'accepted',
finished = 'finished',
failed = 'failed'
}
export enum CohortJobStatus {
LONG_PENDING = 'long_pending',
FAILED = 'failed',
FINISHED = 'finished',
PENDING = 'pending',
NEW = 'new',
SUSPENDED = 'suspended'
}
export enum LoadingStatus {
FETCHING = 'FETCHING',
IDDLE = 'IDLE',
SUCCESS = 'SUCCESS'
}
export enum TemporalConstraintsKind {
NONE = 'none',
SAME_ENCOUNTER = 'sameEncounter',
DIFFERENT_ENCOUNTER = 'differentEncounter',
PARTIAL_CONSTRAINT = 'partialConstraint',
DIRECT_CHRONOLOGICAL_ORDERING = 'directChronologicalOrdering',
SAME_EPISODE_OF_CARE = 'sameEpisodeOfCare',
DIFFERENT_EPISODE_OF_CARE = 'differentEpisodeOfCare',
PARTIAL_EPISODE_CONSTRAINT = 'partialEpisodeConstraint'
}
export enum CohortCreationError {
ERROR_TITLE = 'error_title',
ERROR_REGEX = 'error_regex'
}
export type Authentication = Token & {
user: User
last_login: string
}
export type Token = {
access_token: string
refresh_token: string
}
export type MaintenanceInfo = {
id: string
insert_datetime: string
update_datetime: string
delete_datetime: string
start_datetime: string
end_datetime: string
maintenance_start: string
maintenance_end: string
active: boolean
subject: string
type: string
message: string
}
export type FHIR_API_Response<T extends Resource> = T | OperationOutcome
export type FHIR_Bundle_Response<T extends FhirResource> = FHIR_API_Response<Bundle<T>>
export type FHIR_API_Promise_Response<T extends Resource> = Promise<AxiosResponse<FHIR_API_Response<T>>>
export type FHIR_Bundle_Promise_Response<T extends FhirResource> = FHIR_API_Promise_Response<Bundle<T>>
export type Back_API_Response<T> = {
results: T[]
next?: string
previous?: string
count: number
}
export type User = {
username?: string
email?: string
firstname?: string
lastname?: string
display_name?: string
}
export type CohortComposition = DocumentReference & {
deidentified?: boolean
idPatient?: string
IPP?: string
encounterStatus?: string
serviceProvider?: string
NDA?: string
event?: {}
parameter?: Parameters[]
title?: string
encounter?: {
id?: string
status?: string
serviceProvider?: string
NDA?: string
event?: {}
parameter?: Parameters[]
title?: string
}[]
}
export type CohortEncounter = Encounter & {
documents?: CohortComposition[]
details?: Encounter[]
}
export type CohortPatient = Patient & {
lastEncounter?: Encounter
lastProcedure?: Procedure
mainDiagnosis?: Condition[]
labResults?: Observation[]
inclusion?: boolean
lastGhm?: Claim
associatedDiagnosis?: Condition[]
lastLabResults?: Observation
}
export type PMSIEntry<T extends Procedure | Condition | Claim> = T & {
documents?: CohortComposition[]
serviceProvider?: string
NDA?: string
}
export type MedicationEntry<T extends MedicationRequest | MedicationAdministration> = T & {
documents?: CohortComposition[]
serviceProvider?: string
NDA?: string
}
export type SimpleCodeType = { code: string; label: string; type: string }
export type CohortGroup = Group & {
id: string
name: string
quantity: number
parentId?: string
subItems?: CohortGroup[]
}
export enum Month {
JANUARY = 'Janvier',
FEBRUARY = 'Février',
MARCH = 'Mars',
APRIL = 'Avril',
MAY = 'Mai',
JUNE = 'Juin',
JULY = 'Juillet',
AUGUST = 'Août',
SEPTEMBER = 'Septembre',
OCTOBER = 'Octobre',
NOVEMBER = 'Novembre',
DECEMBER = 'Décembre'
}
export type Column =
| {
label: string | ReactNode
code?: string
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify'
multiple?: undefined
}
| {
multiple: Column[]
}
export enum ChartCode {
AGE_PYRAMID = 'facet-extension.ageMonth',
GENDER_REPARTITION = 'facet-deceased',
MONTHLY_VISITS = 'facet-_facet.period.startGender',
VISIT_TYPE_REPARTITION = 'facet-class.coding.display'
}
export type SimpleChartDataType = {
label: string
value: number
color: string
size?: number
}
export type GenderRepartitionType = {
female: { deceased: number; alive: number }
male: { deceased: number; alive: number }
unknown: { deceased: number; alive: number }
other: { deceased: number; alive: number }
}
export type AgeRepartitionType = { male: number; female: number; other: number }[]
export type MonthVisiteRepartitionType = {
male: number
maleCount: number
female: number
femaleCount: number
other: number
otherCount: number
}
export type VisiteRepartitionType = {
Janvier: MonthVisiteRepartitionType
Février: MonthVisiteRepartitionType
Mars: MonthVisiteRepartitionType
Avril: MonthVisiteRepartitionType
Mai: MonthVisiteRepartitionType
Juin: MonthVisiteRepartitionType
Juillet: MonthVisiteRepartitionType
Août: MonthVisiteRepartitionType
Septembre: MonthVisiteRepartitionType
Octobre: MonthVisiteRepartitionType
Novembre: MonthVisiteRepartitionType
Décembre: MonthVisiteRepartitionType
}
export type CohortData = {
name?: string
description?: string
cohort?: ScopeElement | ScopeElement[]
totalPatients?: number
originalPatients?: CohortPatient[]
totalDocs?: number
documentsList?: CohortComposition[]
wordcloudData?: never[]
encounters?: Encounter[]
genderRepartitionMap?: GenderRepartitionType
visitTypeRepartitionData?: SimpleChartDataType[]
monthlyVisitData?: VisiteRepartitionType
agePyramidData?: AgeRepartitionType
requestId?: string
favorite?: boolean
uuid?: string
}
export type DocumentsData = {
totalDocs: number
totalAllDocs: number
totalPatientDocs: number
totalAllPatientDocs: number
documentsList: DocumentReference[]
}
export type ImagingData = {
totalImaging: number
totalAllImaging: number
imagingList: CohortImaging[]
}
export type PmsiData = {
totalPMSI: number
totalAllPMSI: number
totalPatientPMSI: number
totalAllPatientsPMSI: number
pmsiList: CohortPMSI[]
}
export type PatientData = {
patient?: CohortPatient
hospit?: (CohortEncounter | Encounter)[]
documents?: CohortComposition[]
documentsTotal?: number
consult?: PMSIEntry<Procedure>[]
consultTotal?: number
diagnostic?: PMSIEntry<Condition>[]
diagnosticTotal?: number
ghm?: PMSIEntry<Claim>[]
ghmTotal?: number
medicationRequest?: MedicationRequest[]
medicationRequestTotal?: number
medicationAdministration?: MedicationAdministration[]
medicationAdministrationTotal?: number
}
export enum CriteriaGroupType {
AND_GROUP = 'andGroup',
AT_LEAST = 'atLeast',
AT_MOST = 'atMost',
EXACTLY = 'exactly',
N_AMONG_M = 'nAmongM',
OR_GROUP = 'orGroup'
}
export type CriteriaGroup = {
id: number
title: string
criteriaIds: number[]
isSubGroup?: boolean
isInclusive?: boolean
} & (
| {
type: CriteriaGroupType.AND_GROUP | CriteriaGroupType.OR_GROUP
}
| {
type: CriteriaGroupType.N_AMONG_M
options: {
operator: Comparators
number: number
timeDelayMin: number
timeDelayMax: number
}
}
)
export type TemporalConstraintsType = {
id?: number
idList: ['All'] | number[]
constraintType: TemporalConstraintsKind
timeRelationMinDuration?: {
years?: number
months?: number
days?: number
hours?: number
}
timeRelationMaxDuration?: {
years?: number
months?: number
days?: number
hours?: number
}
}
export type CriteriaDrawerComponentProps = {
parentId: number | null
criteriaData: CriteriaItemDataCache
selectedCriteria: SelectedCriteriaType | null
onChangeSelectedCriteria: (newCriteria: SelectedCriteriaType) => void
goBack: () => void
}
export type CriteriaItemDataCache = {
criteriaType: string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: { [key in CriteriaDataKey]?: any }
}
export type CriteriaItemType = {
id: CriteriaType
title: string
color: string
fontWeight?: string
components: React.FC<CriteriaDrawerComponentProps> | null
disabled?: boolean
fetch?: { [key in CriteriaDataKey]?: FetchFunctionVariant }
subItems?: CriteriaItemType[]
}
type FetchFunctionVariant =
| (() => Promise<SimpleCodeType[]>)
| ((searchValue?: string, noStar?: boolean, signal?: AbortSignal) => Promise<Hierarchy<any, any>[]>)
export type ValueSet = {
code: string
display: string
}
export type ProjectType = {
uuid: string
name: string
description?: string
created_at?: string
modified_at?: string
favorite?: boolean
owner_id?: string
}
export type RequestType = {
uuid: string
owner?: string
query_snapshots?: QuerySnapshotInfo[]
shared_by?: User
parent_folder?: string
deleted?: string
deleted_by_cascade?: boolean
created_at?: string
modified_at?: string
updated_at?: string
name: string
description?: string
favorite?: boolean
data_type_of_query?: 'PATIENT' | 'ENCOUNTER'
currentSnapshot?: Snapshot
requestId?: string
requestName?: string
shared_query_snapshot?: string[]
usersToShare?: User[]
}
export type QuerySnapshotInfo = {
uuid: string
created_at: string
title: string
has_linked_cohorts: boolean
version: number
}
export type Snapshot = QuerySnapshotInfo & {
owner?: string
request?: string
previous_snapshot: string | null
dated_measures: DatedMeasure[]
cohort_results: Cohort[]
shared_by?: User
deleted?: boolean
deleted_by_cascade?: boolean
modified_at?: string
serialized_query: string
is_active_branch?: boolean
perimeters_ids?: string[]
}
export type RequestQuerySnapshot = Snapshot & {
name: string
insert_datetime: string
update_datetime: string
delete_datetime: string
}
export type CurrentSnapshot = Snapshot & {
navHistoryIndex: number
}
export type DatedMeasure = {
uuid: string
owner: string
request_query_snapshot: string
count_outdated: boolean
cohort_limit: number
deleted: string | null
deleted_by_cascade: boolean
request_job_id: string | null
request_job_status: string | null
request_job_fail_msg: string | null
request_job_duration: string | null
created_at: string
modified_at: string
fhir_datetime: string
measure: number | null
measure_min: number | null
measure_max: number | null
count_task_id: string
mode: 'Snapshot' | 'Global'
}
export type CountCohort = {
date: string
status?: string
uuid: string
shortCohortLimit: number
count_outdated: boolean
jobFailMsg?: string
includePatient?: number
byrequest?: number
}
export type Cohort = {
uuid?: string
owner?: string
result_size?: number
request?: string
request_query_snapshot?: string
dated_measure?: DatedMeasure
dated_measure_global?: DatedMeasure
global_estimate?: boolean
group_id?: string
exportable?: boolean
deleted?: string
deleted_by_cascade?: boolean
request_job_id?: string
request_job_status?: string
request_job_fail_msg?: string
request_job_duration?: string
created_at?: string
modified_at?: string
name?: string
description?: string
favorite?: boolean
create_task_id?: string
type?: 'IMPORT_I2B2' | 'MY_ORGANIZATIONS' | 'MY_PATIENTS' | 'MY_COHORTS'
extension?: Extension[]
rights?: GroupRights
}
export type CohortRights = {
cohort_id: string
rights?: GroupRights
}
export type CohortCreationCounterType = {
uuid?: string
status?: string
includePatient?: number
byrequest?: number
unknownPatient?: number
jobFailMsg?: string
date?: string
cohort_limit?: number
count_outdated?: boolean
}
export type FetchRequest = {
requestName: string
snapshotsHistory: QuerySnapshotInfo[]
json: string
currentSnapshot: Snapshot
count: DatedMeasure
shortCohortLimit: number
count_outdated: boolean
}
export type Export = {
motivation: string
output_format: string
cohort_id: string
provider_source_value: string
target_unix_account: number
tables: { omop_table_name: string }
nominative: boolean
shift_dates: boolean
cohort_fk: string
provider_id: string
owner: string
}
/**
* Patient State Types
*/
export type IPatientDetails = Patient & {
lastEncounter?: Encounter
lastGhm?: Claim | 'loading'
lastProcedure?: Procedure | 'loading'
mainDiagnosis?: Condition[] | 'loading'
}
export type IPatientDocuments = {
loading: boolean
count: number
total: number
list: CohortComposition[]
page: number
options?: {
filters?: {
searchInput: string
nda: string
selectedDocTypes: string[]
startDate: string | null
endDate: string | null
}
sort?: {
by: string
direction: string
}
}
searchInputError?: SearchInputError
}
export type IPatientPmsi<T extends Procedure | Condition | Claim> = {
loading: boolean
count: number
total: number
list: T[]
page: number
options?: {
filters?: {
searchInput: string
nda: string
startDate: string | null
endDate: string | null
code?: string
diagnosticTypes?: string[]
}
sort?: {
by: string
direction: string
}
}
}
export type CohortMedication<T extends MedicationRequest | MedicationAdministration> = T & {
serviceProvider?: string
NDA?: string
}
export type IPatientMedication<T extends MedicationRequest | MedicationAdministration> = {
loading: boolean
count: number
total: number | null
list: T[]
page: number
options?: {
filters?: {
searchInput: string
nda: string
startDate: string | null
endDate: string | null
code?: string
selectedPrescriptionTypes?: { id: string; label: string }[]
selectedAdministrationRoutes?: { id: string; label: string }[]
}
sort?: {
by: string
direction: string
}
}
}
export enum BiologyStatus {
VALIDATED = 'Val'
}
export type CohortQuestionnaireResponse = QuestionnaireResponse & {
serviceProvider?: string
NDA?: string
hospitDates?: Period
}
export type CohortObservation = Observation & {
serviceProvider?: string
NDA?: string
}
export type IPatientObservation<T extends CohortObservation> = {
loading: boolean
count: number
total: number
list: T[]
page: number
options?: {
filters?: {
searchInput: string
nda: string
loinc: string
anabio: string
startDate: string | null
endDate: string | null
}
sort?: {
by: string
direction: string
}
}
}
export type CohortPMSI = (Condition | Procedure | Claim) & {
serviceProvider?: string
idPatient?: string
NDA?: string
IPP?: string
}
export type CohortImaging = ImagingStudy & {
idPatient?: string
serviceProvider?: string
NDA?: string
IPP?: string
}
export type IPatientImaging<T extends CohortImaging> = {
loading: boolean
count: number
total: number
list: T[]
page: number
}
export type TabType<T, TL> = {
label: TL
id: T
icon?: ReactElement
wrapped?: boolean
}
export type PmsiTab = TabType<PMSIResourceTypes, PMSILabel>
export type PmsiTabs = PmsiTab[]
export type DTTB_ResultsType = {
nb: number
total: number
label?: string
}
export type DTTB_SearchBarType = {
type: 'simple' | 'patient' | 'document'
value: string | undefined
onSearch: (newSearch: string, newSearchBy: SearchByTypes) => void
searchBy?: any
error?: SearchInputError
fullWidth?: boolean
}
export type DTTB_ButtonType = {
label: string
icon?: ReactElement
onClick: (args?: any) => void
}
export type HierarchyTree = null | {
code?: Hierarchy<any, any>[]
loading?: number
}
export type HierarchyElementWithSystem = Hierarchy<any, any> & { system?: string }
export type ScopeElement = {
id: string
name: string
source_value: string
type: string
parent_id: string
above_levels_ids: string
inferior_levels_ids: string
cohort_id: string
cohort_size: string
full_path: string
rights?: ReadRightPerimeter
access?: 'Nominatif' | 'Pseudonymisé'
}
export type ReadRightPerimeter = {
perimeter: ScopeElement
read_role: string
right_read_patient_nominative: boolean
right_read_patient_pseudonymized: boolean
right_search_patients_by_ipp: boolean
read_access?: string
read_export?: string
export_access?: string
}
export type GroupRights = {
export_csv_nomi?: boolean
export_csv_pseudo?: boolean
export_jupyter_nomi?: boolean
export_jupyter_pseudo?: boolean
read_patient_nomi?: boolean
read_patient_pseudo?: boolean
}
export type DataRights = {
user_id: string
perimeter_id: number
right_read_patient_nominative: boolean
right_read_patient_pseudonymized: boolean
right_export_csv_nominative: boolean
right_export_csv_pseudonymized: boolean
right_export_jupyter_nominative: boolean
right_export_jupyter_pseudonymized: boolean
right_search_opposed_patients: boolean
right_search_patients_by_ipp: boolean
}
export type AccessExpirationsProps = {
expiring?: boolean
}
export type SimpleStatus = 'success' | 'error' | null
export type AccessExpiration = {
leftDays: number
start_datetime: Date
end_datetime: Date
profile: string
perimeter: string
}
// this is an incomplete type, it should be completed with the other fields
export type UserAccesses = {
role: {
right_full_admin: boolean
}
}
export type CustomError = {
errorType: string
}
export type ExportCSVForm = {
motif: string
conditions: boolean
tables: ExportCSVTable[]
}
export type ExportCSVTable = ExportTableType & {
checked: boolean
fhir_filter: SavedFilter | null
respect_table_relationships: boolean
count: number
}
export type SavedFilter = {
created_at: string
deleted: string
deleted_by_cascade: boolean
fhir_resource: ResourceType
fhir_version: string
filter: string
modified_at: string
name: string
owner: string
uuid: string
}
export enum WebSocketMessageType {
ANY = 'any',
JOB_STATUS = 'job_status',
MAINTENANCE = 'maintenance'
}
export enum WebSocketJobName {
COUNT = 'count',
CREATE = 'create'
}
export type WebSocketMessage<T = {}> = {
type: WebSocketMessageType
} & T
export type WSJobStatus = WebSocketMessage<{
status: WebSocketJobStatus
uuid?: string
details?: string
job_name?: WebSocketJobName
extra_info?: {
group_id?: string
request_job_fail_msg?: string
request_job_status: JobStatus
measure?: number
global?: { measure_min: number; measure_max: number }
}
}> & { type: WebSocketMessageType.JOB_STATUS }
export enum SelectedStatus {
NOT_SELECTED,
SELECTED,
INDETERMINATE
}