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() @JoinColumn()
examination_detail: ExaminationDetail; 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 }) @Column({ type: "text", nullable: true })
examination_detail_name: string; examination_detail_name: string;
/** Denormalized: measurement unit from measurement_unit.unit */
@Column({ nullable: true, length: 256 }) @Column({ nullable: true, length: 256 })
measurement_unit: string; measurement_unit: string;
/** Denormalized: reference range as flat string from reference_range */
@Column({ type: "text", nullable: true }) @Column({ type: "text", nullable: true })
reference_range: string; reference_range: string;
/** The actual examination result value that can be filled */
@Column({ type: "text", nullable: true }) @Column({ type: "text", nullable: true })
examination_result: string; examination_result: string;

View File

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

View File

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

View File

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