fix(laboratory): service to examination type relation

This commit is contained in:
avicenan
2026-04-27 17:20:24 +07:00
parent 11b5e647db
commit f1d60807eb
4 changed files with 10 additions and 15 deletions

View File

@ -31,23 +31,15 @@ export class EmrLaboratoryOrderItemResult {
@JoinColumn()
examination_detail: ExaminationDetail;
/** Denormalized: examination type name from examination_type.name */
@Column({ type: "text", nullable: true })
examination_type: string;
/** Denormalized: examination detail name from examination_detail.name */
@Column({ type: "text", nullable: true })
examination_detail_name: string;
/** Denormalized: measurement unit from measurement_unit.unit */
@Column({ nullable: true, length: 256 })
measurement_unit: string;
/** Denormalized: reference range as flat string from reference_range */
@Column({ type: "text", nullable: true })
reference_range: string;
/** The actual examination result value that can be filled */
@Column({ type: "text", nullable: true })
examination_result: string;

View File

@ -32,6 +32,9 @@ export class EmrLaboratoryOrderItem {
@JoinColumn()
service: Service;
@Column({ type: "text", nullable: true })
examination_type_name: string;
@Column({ type: "timestamp", nullable: true })
examination_time: Date;

View File

@ -6,7 +6,7 @@ import {
UpdateDateColumn,
DeleteDateColumn,
ManyToMany,
JoinTable,
OneToMany,
} from 'typeorm';
import { Status } from '../types/status';
@ -29,12 +29,7 @@ export class ExaminationType {
})
status: Status;
@ManyToMany(() => Service, { onDelete: 'NO ACTION' })
@JoinTable({
name: 'examination_type_services',
joinColumn: { name: 'examination_type_id', referencedColumnName: 'id' },
inverseJoinColumn: { name: 'service_id', referencedColumnName: 'id' },
})
@OneToMany(() => Service, (service) => service.examination_type)
services: Service[];
@CreateDateColumn()

View File

@ -17,6 +17,7 @@ import { Room } from './room';
import { ExaminationDetail } from './examination_detail';
import { Status } from '../types/status';
import { ServiceFare } from './service_fare';
import { ExaminationType } from './examination_type';
@Entity('services')
export class Service {
@ -50,6 +51,10 @@ export class Service {
})
rooms: Room[];
@ManyToOne(() => ExaminationType, { onDelete: 'NO ACTION' })
@JoinColumn({ name: 'examination_type_id' })
examination_type: ExaminationType;
@ManyToMany(() => ExaminationDetail, { onDelete: 'NO ACTION' })
@JoinTable({
name: 'service_examinations',