-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: KM_Prescriptions dosesTime 컬럼 타입 수정 * feat: 한의과 처방 생성 DTO 추가 * feat: 한의과 처방 생성 API 구현 * rename: Prescriptions entity 오타 수정 * refactor: 의과 처방 생성 API 수정
- Loading branch information
Showing
20 changed files
with
216 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
backend/src/km-prescriptions/dto/create-km-prescription.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { PickType } from '@nestjs/mapped-types'; | ||
import { KM_Prescriptions } from '../entity/km-prescriptions.entity'; | ||
import { IsInt, IsNumber, IsOptional, IsString } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class CreateKMPrescriptionDto extends PickType(KM_Prescriptions, [ | ||
'doses', | ||
'dosesCountByDay', | ||
'dosesDay', | ||
'dosesTime', | ||
'memo', | ||
]) { | ||
@ApiProperty({ | ||
description: '1회 투약량', | ||
example: 1, | ||
}) | ||
@IsNumber() | ||
doses: number; | ||
|
||
@ApiProperty({ | ||
description: '1일 복용횟수', | ||
example: 'tid', | ||
}) | ||
@IsString() | ||
dosesCountByDay: string; | ||
|
||
@ApiProperty({ | ||
description: '복용 일수', | ||
example: 5, | ||
}) | ||
@IsInt() | ||
dosesDay: number; | ||
|
||
@ApiProperty({ | ||
description: '복용 시간', | ||
example: '식전', | ||
}) | ||
@IsString() | ||
dosesTime: string; | ||
|
||
@ApiProperty({ | ||
description: '메모', | ||
example: '', | ||
}) | ||
@IsString() | ||
@IsOptional() | ||
memo: string; | ||
|
||
@ApiProperty({ | ||
description: '약품 ID', | ||
example: 1, | ||
}) | ||
@IsNumber() | ||
medicineId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { KM_Prescriptions } from './entity/km-prescriptions.entity'; | ||
import { Repository } from 'typeorm'; | ||
import { CreateKMPrescriptionDto } from './dto/create-km-prescription.dto'; | ||
import { convertDosesCountByDay } from 'src/common/util/convert.util'; | ||
|
||
@Injectable() | ||
export class KmPrescriptionsService {} | ||
export class KmPrescriptionsService { | ||
constructor( | ||
@InjectRepository(KM_Prescriptions) | ||
private readonly prescriptionsRepository: Repository<KM_Prescriptions>, | ||
) {} | ||
|
||
async createPrescription( | ||
chartId: number, | ||
prescriptionDto: CreateKMPrescriptionDto, | ||
) { | ||
const { medicineId, ...restPrescriptionDto } = prescriptionDto; | ||
|
||
return await this.prescriptionsRepository.save({ | ||
...restPrescriptionDto, | ||
dosesTotal: | ||
restPrescriptionDto.doses * | ||
convertDosesCountByDay(restPrescriptionDto.dosesCountByDay) * | ||
restPrescriptionDto.dosesDay, | ||
chart: { id: chartId }, | ||
medicine: { id: medicineId }, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.