public async Task <bool> AddPrescriptionDetails(FullPrescriptionDetailsDTO prescDetails)
        {
            var validPatient = _context.Patient.FromSqlInterpolated($"select * from Patient where patientid = {prescDetails.Patientid}").FirstOrDefault();


            var consultationPresc = _context.ConsultationPrescription
                                    .FromSqlInterpolated($"select * from Consultation_Prescription where patientid = {prescDetails.Patientid} and prescriptionid = {prescDetails.Prescriptionid}")
                                    .FirstOrDefault();

            if (validPatient != null && consultationPresc != null)
            {
                var prescDetailObj = new ConsultationPrescriptionDetails
                {
                    EncounterId        = consultationPresc.Encounterid,
                    Frequencyid        = prescDetails.Frequencyid,
                    Doseformid         = prescDetails.Doseformid,
                    Routeid            = prescDetails.Routeid,
                    Unitid             = prescDetails.Unitid,
                    Icdcode            = prescDetails.Icdcode,
                    EmrPrescription    = prescDetails.EmrPrescription,
                    Encodeddate        = DateTime.Now,
                    Encodedby          = prescDetails.Encodedby,
                    ItemId             = prescDetails.Itemid,
                    Isapprovedrequired = prescDetails.Isapprovedrequired,
                    Locationid         = prescDetails.Locationid,
                    ProviderId         = prescDetails.Providerid,
                    Patientid          = prescDetails.Patientid,
                    Genericid          = prescDetails.Genericid,
                    Strength           = prescDetails.Strength,
                    Startdate          = prescDetails.Startdate,
                    Refill             = prescDetails.Refill,
                    Statusid           = _context.StatusMaster.Where(s => s.Statustype == "PrescriptionPosting" && s.Status == "Pending").Select(s => s.Statusid).FirstOrDefault(),
                    PrescriptionDetail = prescDetails.Prescdetail,
                    Prescriptionid     = prescDetails.Prescriptionid,
                    Qty                    = prescDetails.Qty,
                    Strengthvalue          = prescDetails.Strengthvalue,
                    Dose                   = prescDetails.Dose,
                    Durationtype           = prescDetails.Durationtype,
                    Medicationinstructions = prescDetails.Medicationinstructions,
                    Formularyid            = prescDetails.Formularyid,
                    Doctorid               = prescDetails.Doctorid,
                    Dosetime               = prescDetails.Dosetime,
                    Issubstitutenotallowed = prescDetails.Issubstitutenotallowed,
                    Isactive               = true,
                };

                _context.ConsultationPrescriptionDetails.Add(prescDetailObj);
                await _context.SaveChangesAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public async Task <IActionResult> AddPrescriptionDetails([FromBody] FullPrescriptionDetailsDTO prescDetailsObj)
        {
            var prescDetailsCreated = await _pharmacyManagementRepository.AddPrescriptionDetails(prescDetailsObj);

            if (prescDetailsCreated)
            {
                return(NoContent());
            }
            else
            {
                return(BadRequest());
            }
        }