1+ import { Entity , PrimaryGeneratedColumn , Column , ManyToOne , OneToMany , CreateDateColumn , UpdateDateColumn } from 'typeorm' ;
2+ import { Patient } from '../../patients/entities/patient.entity' ;
3+ import { Doctor } from '../../doctors/entities/doctor.entity' ;
4+ import { PathologyReport } from './pathology-report.entity' ;
5+ import { PathologyImage } from './pathology-image.entity' ;
6+ import { QualityAssurance } from './quality-assurance.entity' ;
7+
8+ export enum CaseStatus {
9+ RECEIVED = 'received' ,
10+ IN_PROGRESS = 'in_progress' ,
11+ REVIEWED = 'reviewed' ,
12+ COMPLETED = 'completed' ,
13+ ARCHIVED = 'archived'
14+ }
15+
16+ export enum CaseType {
17+ HISTOLOGY = 'histology' ,
18+ CYTOLOGY = 'cytology' ,
19+ MOLECULAR = 'molecular' ,
20+ GENETIC = 'genetic' ,
21+ IMMUNOHISTOCHEMISTRY = 'immunohistochemistry' ,
22+ FLOW_CYTOMETRY = 'flow_cytometry'
23+ }
24+
25+ export enum Priority {
26+ LOW = 'low' ,
27+ NORMAL = 'normal' ,
28+ HIGH = 'high' ,
29+ URGENT = 'urgent' ,
30+ STAT = 'stat'
31+ }
32+
33+ @Entity ( 'pathology_cases' )
34+ export class PathologyCase {
35+ @PrimaryGeneratedColumn ( 'uuid' )
36+ id : string ;
37+
38+ @Column ( { unique : true } )
39+ caseNumber : string ;
40+
41+ @Column ( {
42+ type : 'enum' ,
43+ enum : CaseType
44+ } )
45+ caseType : CaseType ;
46+
47+ @Column ( {
48+ type : 'enum' ,
49+ enum : CaseStatus ,
50+ default : CaseStatus . RECEIVED
51+ } )
52+ status : CaseStatus ;
53+
54+ @Column ( {
55+ type : 'enum' ,
56+ enum : Priority ,
57+ default : Priority . NORMAL
58+ } )
59+ priority : Priority ;
60+
61+ @Column ( 'text' )
62+ clinicalHistory : string ;
63+
64+ @Column ( 'text' )
65+ specimenDescription : string ;
66+
67+ @Column ( )
68+ collectionDate : Date ;
69+
70+ @Column ( )
71+ receivedDate : Date ;
72+
73+ @Column ( { nullable : true } )
74+ expectedCompletionDate : Date ;
75+
76+ @Column ( { nullable : true } )
77+ completedDate : Date ;
78+
79+ @Column ( 'simple-json' , { nullable : true } )
80+ specimenDetails : {
81+ site : string ;
82+ procedure : string ;
83+ fixative : string ;
84+ containerType : string ;
85+ quantity : number ;
86+ grossDescription : string ;
87+ } ;
88+
89+ @Column ( 'simple-json' , { nullable : true } )
90+ clinicalData : {
91+ symptoms : string [ ] ;
92+ previousDiagnosis : string ;
93+ medications : string [ ] ;
94+ relevantHistory : string ;
95+ } ;
96+
97+ @ManyToOne ( ( ) => Patient , patient => patient . pathologyCases )
98+ patient : Patient ;
99+
100+ @ManyToOne ( ( ) => Doctor , doctor => doctor . requestedPathologyCases )
101+ requestingDoctor : Doctor ;
102+
103+ @ManyToOne ( ( ) => Doctor , doctor => doctor . reviewedPathologyCases )
104+ pathologist : Doctor ;
105+
106+ @OneToMany ( ( ) => PathologyReport , ( report : PathologyReport ) => report . pathologyCase )
107+ reports : PathologyReport [ ] ;
108+
109+ @OneToMany ( ( ) => PathologyImage , ( image : PathologyImage ) => image . pathologyCase )
110+ images : PathologyImage [ ] ;
111+
112+ @OneToMany ( ( ) => QualityAssurance , ( qa : QualityAssurance ) => qa . pathologyCase )
113+ qualityAssurances : QualityAssurance [ ] ;
114+
115+ @CreateDateColumn ( )
116+ createdAt : Date ;
117+
118+ @UpdateDateColumn ( )
119+ updatedAt : Date ;
120+ }
0 commit comments