Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hospital-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roshan Suvarnkar
hospital-service
Merge requests
!6
added DR update API
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Open
added DR update API
updateDRAPI
into
develop-beta
Overview
9
Commits
12
Pipelines
0
Changes
13
9 open threads
Thread options
Hide all comments
Open
added DR update API
Prathviraj Suryakant Thokal
requested to merge
updateDRAPI
into
develop-beta
3 months ago
Overview
9
Commits
12
Pipelines
0
Changes
13
9 open threads
Thread options
Hide all comments
0
0
Merge request reports
Compare
develop-beta
version 9
8c507ab5
3 months ago
version 8
92b76668
3 months ago
version 7
d27bc12c
3 months ago
version 6
b7980027
3 months ago
version 5
19537d5a
3 months ago
version 4
6c9c0185
3 months ago
version 3
29012cae
3 months ago
version 2
6884657e
3 months ago
version 1
7c5128b0
3 months ago
develop-beta (base)
and
version 9
latest version
3f3aa79b
12 commits,
3 months ago
version 9
8c507ab5
11 commits,
3 months ago
version 8
92b76668
10 commits,
3 months ago
version 7
d27bc12c
9 commits,
3 months ago
version 6
b7980027
6 commits,
3 months ago
version 5
19537d5a
5 commits,
3 months ago
version 4
6c9c0185
4 commits,
3 months ago
version 3
29012cae
3 commits,
3 months ago
version 2
6884657e
2 commits,
3 months ago
version 1
7c5128b0
1 commit,
3 months ago
13 files
+
669
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
src/doctors/doctors.service.ts
0 → 100644
+
125
−
0
View file @ 3f3aa79b
Edit in single-file editor
Open in Web IDE
/**
@file <file name>
@description <description>
@author <Your Name>
@created <YYYY-MM-DD>
**/
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
PrismaService
}
from
'
../prisma/prisma.service
'
;
import
{
Logger
,
AppException
,
errorCode
}
from
'
nest-common-utilities
'
;
import
{
UpdateDoctorsRequestDto
}
from
'
./dto/update-doctors-request.dto
'
;
import
{
UpdateDoctorsResponseDto
}
from
'
./dto/update-doctors-response.dto
'
;
/**
* Service to encapsulate doctors
* domain logic such as create doctor update doctor.
*/
/**
*
*/
@
Injectable
()
export
class
DoctorsService
{
private
logger
=
new
Logger
(
DoctorsService
.
name
);
/**
* Constructs the DoctorsService.
*
* @param prisma - The Prisma service for database interactions.
*/
constructor
(
private
prisma
:
PrismaService
)
{}
/**
* Update the doctor details by using doctor ID
*
* @param {UpdateDoctorsRequestDto} dto - The data transfer
* object containing the doctor information to be updated.
* @returns {Promise<UpdateDoctorsResponseDto>} A promise
* that resolves to the updated doctor's data.
*/
/**
* Updates an existing doctor record by deactivating the old entry and
* creating a new one with updated details.
*
* This method checks if the doctor with the given ID exists. If not,
* it throws an exception. If the doctor exists, it marks the current
* record as inactive, then inserts a new record with the updated data.
*
* @param {UpdateDoctorsRequestDto} dto - The DTO containing updated
* doctor information.
*
* @returns {Promise<UpdateDoctorsResponseDto>} The response containing
* the ID of the newly created doctor record.
*
* @throws {AppException} If no doctor is found with the given ID.
*/
async
updateDoctorById
(
dto
:
UpdateDoctorsRequestDto
,
):
Promise
<
UpdateDoctorsResponseDto
>
{
const
{
doctorId
,
userId
,
doctorName
,
doctorRegNo
,
doctorSpecialityId
,
doctorQualificationId
,
contactNo
,
hprCode
,
emailId
,
panNo
,
address
,
pincode
,
latitude
,
longitude
,
stateId
,
cityId
,
}
=
dto
;
const
existingDoctor
=
await
this
.
prisma
.
doctor_master
.
findUnique
({
where
:
{
id
:
doctorId
},
});
if
(
!
existingDoctor
)
{
throw
new
AppException
(
`Doctor with ID
${
doctorId
}
not found`
,
errorCode
.
DATA_NOT_FOUND
,
);
}
// Deactivate the old doctor record
await
this
.
prisma
.
doctor_master
.
update
({
where
:
{
id
:
doctorId
},
data
:
{
is_active
:
false
,
updated_by
:
userId
,
updated_at
:
new
Date
(),
},
});
const
data
=
{
name
:
doctorName
??
''
,
registration_no
:
doctorRegNo
??
''
,
speciality_id
:
doctorSpecialityId
??
''
,
qualification_id
:
doctorQualificationId
??
''
,
doctor_contact
:
contactNo
??
''
,
hpr_code
:
hprCode
??
''
,
doctor_email_id
:
emailId
??
''
,
pan_no
:
panNo
,
address
:
address
??
''
,
pincode_id
:
pincode
??
''
,
latitude
:
latitude
??
null
,
longitude
:
longitude
??
null
,
state_id
:
stateId
??
''
,
city_id
:
cityId
??
''
,
is_active
:
true
,
created_by
:
userId
??
''
,
updated_by
:
userId
??
''
,
};
//@ts-ignore
const
newDoctor
=
await
this
.
prisma
.
doctor_master
.
create
({
data
});
return
{
doctorId
:
newDoctor
.
id
,
};
}
}
Loading