박권수

feat. set medicine api change, model methods add

...@@ -269,6 +269,14 @@ exports.setMedicine = async(ctx) => { ...@@ -269,6 +269,14 @@ exports.setMedicine = async(ctx) => {
269 return; 269 return;
270 } 270 }
271 271
272 +
273 + //new bottleMedicine
274 + let bottleMedicine = new BottleMedicine({
275 + bottleId,
276 + medicineId,
277 + dosage,
278 + });
279 +
272 if(doctorId !== undefined && doctorId !== null && doctorId !== '') { 280 if(doctorId !== undefined && doctorId !== null && doctorId !== '') {
273 const patientInfo = await PatientInfo.findByPatientIdAndDoctorIdAndUseYn(userId, doctorId, 'Y'); 281 const patientInfo = await PatientInfo.findByPatientIdAndDoctorIdAndUseYn(userId, doctorId, 'Y');
274 if(!patientInfo) { 282 if(!patientInfo) {
...@@ -278,14 +286,11 @@ exports.setMedicine = async(ctx) => { ...@@ -278,14 +286,11 @@ exports.setMedicine = async(ctx) => {
278 }; 286 };
279 return; 287 return;
280 } 288 }
289 +
290 + bottleMedicine.setDoctorId(doctorId);
281 } 291 }
282 292
283 - const bottleMedicine = new BottleMedicine({ 293 +
284 - bottleId,
285 - medicineId,
286 - doctorId,
287 - dosage,
288 - });
289 bottleMedicine.save(); 294 bottleMedicine.save();
290 295
291 ctx.status = 200; 296 ctx.status = 200;
......
...@@ -30,5 +30,9 @@ const BottleMedicineSchema = new Schema({ ...@@ -30,5 +30,9 @@ const BottleMedicineSchema = new Schema({
30 } 30 }
31 }); 31 });
32 32
33 +BottleMedicineSchema.methods.setDoctorId = function(doctorId) {
34 + this.doctorId = doctorId;
35 +};
36 +
33 37
34 module.exports = mongoose.model('BottleMedicine', BottleMedicineSchema); 38 module.exports = mongoose.model('BottleMedicine', BottleMedicineSchema);
...\ No newline at end of file ...\ No newline at end of file
......