Last active
May 1, 2025 07:09
-
-
Save TanjinAlam/90230ba3d888667720c3e1fef38faf99 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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