Skip to content

Instantly share code, notes, and snippets.

@TanjinAlam
Last active May 1, 2025 07:09
Show Gist options
  • Save TanjinAlam/90230ba3d888667720c3e1fef38faf99 to your computer and use it in GitHub Desktop.
Save TanjinAlam/90230ba3d888667720c3e1fef38faf99 to your computer and use it in GitHub Desktop.
@Get('patient-package/:patientPackageId')
@UseGuards(AuthGuard, RolesGuard)
@UseInterceptors(ResponseInterceptor)
@Roles(UserTypes.ADMIN, UserTypes.AGENT, UserTypes.PATIENT, UserTypes.SSKUSER)
async getPatientSubscriptionPackage(
@Req() req: any,
@Param('patientPackageId') patientPackageId: string,
) {
return {
message: 'Patient subscription package details',
result: await this.subscriptionService.findPatientSubscriptionPackage(
+patientPackageId,
req,
),
};
}
async findPatientSubscriptionPackage(patientPackageId: number, req: any) {
return await this.patientPackageRepository.findOne({
where: {
id: patientPackageId,
},
relations: [
'patient',
'subscriptionPackage',
'packageServices',
'packageServices.service',
'packageServices.histories',
'patientPackageInsurance',
],
});
}
async updatePatientSubscriptionPackage(
patientPackageId: number,
updatePatientPackageDto: UpdatePatientPackageDto,
) {
// const patient = await this.patientRepository.findOne({
// where: {
// id: updatePatientPackageDto.patientId,
// },
// });
//
// if (!patient) {
// throw new NotFoundException('Patient not found');
// }
const patientPackage = await this.patientPackageRepository.findOne({
where: { id: patientPackageId },
});
if (!patientPackage) {
throw new BadRequestException(`Package with this patient not found.`);
}
return await this.patientPackageRepository.save({
...patientPackage,
...updatePatientPackageDto,
});
}
@Put('patient-package/:patientPackageId')
@UseGuards(AuthGuard, RolesGuard)
@UseInterceptors(ResponseInterceptor)
@Roles(UserTypes.ADMIN, UserTypes.AGENT)
async updatePatientSubscriptionPackageStatus(
@Param('patientPackageId') patientPackageId: string,
@Body() updatePatientPackageDto: UpdatePatientPackageDto,
) {
return {
message: 'Patient subscription package updated successfully.',
result: await this.subscriptionService.updatePatientSubscriptionPackage(
+patientPackageId,
updatePatientPackageDto,
),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment