public async Task <PrescriptionResponse> Create(PrescriptionRequest prescriptionRequest)
        {
            var response = new PrescriptionResponse();

            try
            {
                TTAC         tTAC         = new TTAC(_serviceProvider);
                Prescription prescription = new Prescription();
                prescriptionRequest.CopyPropertiesTo(prescription);
                await _PrescriptionRepository.Add(prescription);

                TTACPrescriptionRequest  tTACPrescriptionRequest  = new TTACPrescriptionRequest();
                TTACPrescriptionResponse tTACPrescriptionResponse = new TTACPrescriptionResponse();
                prescriptionRequest.CopyPropertiesTo(tTACPrescriptionRequest);
                tTACPrescriptionRequest.Username = Constants.TTAC_UserName;
                tTACPrescriptionRequest.Password = Constants.TTAC_Password;
                tTACPrescriptionResponse         = await tTAC.CallPrescriptionApi(tTACPrescriptionRequest);

                response.ErrorCode             = tTACPrescriptionResponse.ErrorCode;
                response.ErrorMessage          = tTACPrescriptionResponse.ErrorMessage;
                response.PrescriptionId        = tTACPrescriptionResponse.PrescriptionId;
                prescription.OutErrorCode      = tTACPrescriptionResponse.ErrorCode;
                prescription.OutErrorMessage   = tTACPrescriptionResponse.ErrorMessage;
                prescription.OutPrescriptionId = tTACPrescriptionResponse.PrescriptionId;
                await _PrescriptionRepository.Update(prescription);

                response.HasError = false;
                return(response);
            }
            catch (Exception e)
            {
                _logService.LogText("PrescriptionInternalError" + e.Message.ToString());
                throw new Exception(e.Message);
            }
        }
예제 #2
0
        private void ProcessPrescriptionData(IEnumerable <Prescription> prescriptions, DataOP op, Treatment treatment)
        {
            if (prescriptions == null || treatment == null)
            {
                return;
            }

            foreach (var prescription in prescriptions)
            {
                prescription.TreatmentId = treatment.Id;
                if (DataOP.AddNew == op)
                {
                    _prescriptionRepository.Add(prescription);
                }
                else if (DataOP.EDIT == op)
                {
                    _prescriptionRepository.Update(prescription);
                }
                else if (DataOP.DEL == op)
                {
                    var removeRecord = _prescriptionRepository.GetById(prescription.Id);
                    if (removeRecord != null)
                    {
                        _prescriptionRepository.Delete(removeRecord);
                    }
                }
            }
        }
예제 #3
0
        public bool AddPrescription(int doctorId, PrescriptionDto prescription)
        {
            var entity = mapper.Map(prescription);

            entity.DoctorId = doctorId;

            return(prescriptionRepository.Add(entity));
        }
예제 #4
0
        public ActionResult Add(MyClinic.Infrastructure.PrescriptionAdd itemAdd)
        {
            Prescription itemGet             = new Prescription();
            var          objSessionDiagnosis = Session["diagnosis"] as MyClinic.Infrastructure.Diagnosis;

            this.GetUserProfile();
            bool checkError = true;
            PrescriptionModels         viewModel           = null;
            DTODiagnosis               dtoDiagnosis        = null;
            IEnumerable <MedicineType> medicineTypeRecords = null;

            try
            {
                IMedicineTypeRepository objMedicineType     = new MedicineTypeRepository();
                IDiagnosisRepository    diagnosisRepository = new DiagnosisRepository();
                dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(itemAdd.DiagnosisId);

                /*For Add Diagnosis to Table */
                diagnosisRepository.Add(objSessionDiagnosis);
                itemGet.DiagnosisId = objSessionDiagnosis.Id;
                //Save Image
                SaveUploadImge(Session.SessionID, objSessionDiagnosis.Id);
                if (ModelState.IsValid)
                {
                    var intTotal = 0;
                    if (itemAdd.MedicineId != null)
                    {
                        intTotal = itemAdd.MedicineId.Count();
                    }
                    for (int intIndex = 0; intIndex < intTotal; intIndex++)
                    {
                        int MedicineId = 0;
                        int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId);
                        itemGet.MedicineId = MedicineId;
                        itemGet.Qty        = itemAdd.Qty[intIndex];
                        //itemGet.MedicineType       = itemAdd.MedicineType[intIndex];
                        itemGet.Morning = itemAdd.Morning[intIndex];
                        itemGet.Noon    = itemAdd.Noon[intIndex];
                        itemGet.Night   = itemAdd.Night[intIndex];
                        itemGet.Remark  = itemAdd.Remark[intIndex];
                        itemGet.UsageId = int.Parse(itemAdd.UsageId[intIndex]);
                        itemGet.Status  = (int)MyClinic.Core.Enums.RecordStatus.Active;

                        objPrescription.Add(itemGet);
                    }

                    Session["diagnosis"] = null;
                    /*For Add New Record to LogTable*/
                    logTran.UserId      = this.objProfile.UserId;
                    logTran.ProcessType = "Add Prescription";
                    logTran.Description = "Add Prescription";
                    logTran.LogDate     = DateTime.Now;
                    logRepository.Add(logTran);

                    /*this.GetUserProfile();
                     * var test = this.objProfile;*/
                    return(RedirectToAction("Detail", "Prescription", new { id = itemGet.DiagnosisId }));
                    //checkError = false;
                }
                medicineTypeRecords = objMedicineType.Get();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError("error", Translator.UnexpectedError);
            }
            if (checkError == true)
            {
                viewModel = new PrescriptionModels
                {
                    validAdd            = itemAdd,
                    checkPost           = true,
                    checkError          = checkError,
                    dtoDiagnosis        = dtoDiagnosis,
                    medicineTypeRecords = medicineTypeRecords
                };
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Index", "User"));
            }
        }