Skip to content

Commit 3c23427

Browse files
committed
fix: resolve merge conflicts
1 parent 53d705d commit 3c23427

3 files changed

Lines changed: 2 additions & 68 deletions

File tree

src/controllers/patient.js

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
import Patient from '../models/patient.js';
2-
<<<<<<< HEAD
32
import { createPatientPortalAccount } from '../services/patientPortal.service.js';
4-
=======
5-
import User from '../models/User.js';
6-
import bcrypt from 'bcrypt';
7-
import * as emailService from '../services/email.service.js';
8-
>>>>>>> recovery-branch
93

104
const createPatient = async (req, res, next) => {
115
try {
126
const { name, email, phno, paymentMode } = req.body;
7+
138
console.log(`Creating patient: ${name}, Email: ${email}, PaymentMode: ${paymentMode}`);
149

15-
// Create the patient record
1610
const patient = new Patient(req.body);
1711
await patient.save();
1812

19-
<<<<<<< HEAD
20-
const { email, paymentMethod } = req.body;
21-
22-
if (paymentMethod === "online" && email) {
13+
if (paymentMode === "online" && email) {
2314
await createPatientPortalAccount(email);
2415
}
2516

@@ -28,42 +19,6 @@ const createPatient = async (req, res, next) => {
2819
patient
2920
});
3021

31-
=======
32-
// If online payment, create a patient portal account
33-
if (paymentMode === 'online') {
34-
console.log(`Online payment mode detected for ${email}. Processing portal creation...`);
35-
const existingUser = await User.findOne({ email });
36-
if (!existingUser) {
37-
// Use phone number as default password
38-
const password = phno; // Plain text for the email
39-
const hashedPassword = await bcrypt.hash(password, 10);
40-
41-
await User.create({
42-
name,
43-
email,
44-
password: hashedPassword,
45-
role: 'patient',
46-
status: 'Active',
47-
phno
48-
});
49-
console.log(`Patient portal User record created for: ${email}`);
50-
51-
// Send credentials email
52-
try {
53-
await emailService.sendPortalCredentials(email, name, password);
54-
console.log(`Portal credentials email sent to: ${email}`);
55-
} catch (mailErr) {
56-
console.error(`Failed to send portal credentials email: ${mailErr.message}`);
57-
}
58-
} else {
59-
console.log(`User account already exists for: ${email}. Skipping portal creation.`);
60-
}
61-
} else {
62-
console.log(`Payment mode is '${paymentMode}'. Skipping portal creation.`);
63-
}
64-
65-
res.status(201).json(patient);
66-
>>>>>>> recovery-branch
6722
} catch (err) {
6823
console.error(`Error in createPatient: ${err.message}`);
6924
next(err);

src/models/User.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ const userSchema = new mongoose.Schema({
9090
role: {
9191
type: String,
9292
required: true,
93-
<<<<<<< HEAD
9493
enum: ['admin', 'doctor','receptionist','billing','patient']
95-
=======
96-
enum: ['admin', 'doctor','receptionist','billing', 'patient']
97-
>>>>>>> recovery-branch
9894
},
9995

10096
name: { type: String },

src/services/email.service.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export const sendOTPEmail = async (email, otp) => {
6262
});
6363
};
6464

65-
<<<<<<< HEAD
6665
export const sendCredentialsEmail = async (email, password) => {
6766
await transporter.sendMail({
6867
from: `"HMS Team" <${process.env.GMAIL_EMAIL}>`,
@@ -87,22 +86,6 @@ export const sendCredentialsEmail = async (email, password) => {
8786
<p style="font-size:12px;color:#888;">
8887
This email was generated automatically.
8988
</p>
90-
=======
91-
export const sendPortalCredentials = async (email, name, password) => {
92-
await transporter.sendMail({
93-
from: `"HMS Team" <${process.env.GMAIL_EMAIL}>`,
94-
to: email,
95-
subject: 'Your HMS Patient Portal Account Details',
96-
html: `
97-
<div style="font-family: Arial, sans-serif; padding: 20px;">
98-
<h2>Welcome to HMS, ${name}!</h2>
99-
<p>Your patient portal account has been created successfully.</p>
100-
<p><strong>Username/Email:</strong> ${email}</p>
101-
<p><strong>Temporary Password:</strong> ${password}</p>
102-
<p style="color: #555;">Please log in to the portal and change your password for security.</p>
103-
<hr />
104-
<p style="font-size: 12px; color: #888;">© ${new Date().getFullYear()} HMS Team.</p>
105-
>>>>>>> recovery-branch
10689
</div>
10790
`
10891
});

0 commit comments

Comments
 (0)