Skip to content

Commit

Permalink
feat(BE): 의과 약국 조회 & 차트 상태 수정 API 구현 (#70)
Browse files Browse the repository at this point in the history
* feat: 의과 약국 차트 상태 수정 DTO 추가

* feat: 의과 약국 차트 상태 수정 API 구현

* feat: 의과 약국 조회 API 구현
  • Loading branch information
eeseung authored Jul 7, 2024
1 parent eee1aaf commit b6c7168
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/src/m-charts/dto/update-pharmacy-status-dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IsInt, Max, Min } from 'class-validator';
import { ApiProperty, PickType } from '@nestjs/swagger';
import { M_Charts } from '../entity/m-charts.entity';

export class UpdatePharmacyStatusDto extends PickType(M_Charts, ['status']) {
@ApiProperty({ description: '차트 상태' })
@IsInt()
@Min(4)
@Max(7)
status: number;
}
27 changes: 27 additions & 0 deletions backend/src/m-charts/m-charts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
HttpStatus,
Get,
ParseIntPipe,
Patch,
} from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { MChartsService } from './m-charts.service';
import { MPrescriptionsService } from 'src/m-prescriptions/m-prescriptions.service';
import { CreatePrediagnosisDto } from './dto/create-prediagnosis.dto';
import { CreateMPrescriptionDto } from 'src/m-prescriptions/dto/create-m-prescription.dto';
import { UpdatePharmacyStatusDto } from './dto/update-pharmacy-status-dto';

@ApiTags('의과')
@Controller('m/charts')
Expand Down Expand Up @@ -130,6 +132,31 @@ export class MChartsController {
return this.mChartsService.getTodayChartByPatientId(patientId);
}

@Get(':chartId/pharmacy')
@ApiOperation({
summary: '약국 조회',
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
})
getMChartPharmacy(@Param('chartId', ParseIntPipe) chartId: number) {
return this.mChartsService.getPharmacy(chartId);
}

@Patch(':chartId/status')
@ApiOperation({
summary: '약국 차트 상태 수정',
})
async patchMChartPharmacyStatus(
@Param('chartId', ParseIntPipe) chartId: number,
@Body() updateMChartStatusDto: UpdatePharmacyStatusDto,
) {
return await this.mChartsService.updateStatus(
chartId,
updateMChartStatusDto.status,
);
}

@Post(':chartId/prescriptions')
@ApiOperation({
summary: '처방 생성',
Expand Down
14 changes: 14 additions & 0 deletions backend/src/m-charts/m-charts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,18 @@ export class MChartsService {
],
});
}

async getPharmacy(chartId: number) {
return await this.chartsRepository.findOne({
...DEFAULT_M_CHART_FIND_OPTIONS,
where: {
id: chartId,
},
relations: {
prescriptions: {
medicine: true,
},
},
});
}
}

0 comments on commit b6c7168

Please sign in to comment.