curaflow/backend/prescriptionManager.js

33 lines
1.0 KiB
JavaScript

/**
* PrescriptionManager: Handles digital prescription generation.
*/
class PrescriptionManager {
constructor() {
this.prescriptions = [];
}
generate(patientId, doctorId, medicines, diagnosis) {
const id = `RX-${Date.now()}`;
const prescription = {
id,
patientId,
doctorId,
date: new Date().toISOString(),
diagnosis,
medicines, // Array of { name, dosage, frequency, duration }
};
this.prescriptions.push(prescription);
// In a real app, you'd generate a PDF here
return {
success: true,
prescriptionId: id,
whatsappMessage: `💊 *Digital Prescription from Dr. Sharma*\n\n*Diagnosis:* ${diagnosis}\n\n*Medicines:*\n${medicines.map(m => `- ${m.name}: ${m.dosage} (${m.frequency}) for ${m.duration}`).join('\n')}\n\n_You can show this message at our pharmacy for a 10% discount._`
};
}
}
module.exports = new PrescriptionManager();