Exemplo n.º 1
0
        public async Task <IActionResult> PutPrescription(int id, PrescriptionDTO prescription)
        {
            if (id != prescription.Id)
            {
                return(BadRequest());
            }

            var pres = await _context.Prescriptions.FirstOrDefaultAsync(p => p.Id == id);

            pres.medicationId = prescription.Medication.Id;
            pres.patientId    = prescription.Patient.Id;
            pres.dose         = prescription.Dose;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PrescriptionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <PrescriptionDTO> > DeletePrescription(int id)
        {
            var prescription = await _context.Prescriptions.FindAsync(id);

            if (prescription == null)
            {
                return(NotFound());
            }

            var dto = new PrescriptionDTO
            {
                Dose       = prescription.dose,
                Medication = new MedicationDTO
                {
                    Id   = prescription.medicationId,
                    Name = prescription.medication.name
                },
                Id      = id,
                Patient = new PatientDTO
                {
                    FamilyName = prescription.patient.familyName,
                    GivenName  = prescription.patient.firstName,
                    Id         = prescription.patientId,
                }
            };

            _context.Prescriptions.Remove(prescription);
            await _context.SaveChangesAsync();

            return(dto);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <PrescriptionDTO> > GetPrescription(int id)
        {
            var pres = await _context.Prescriptions
                       .Include(p => p.patient.FullName)
                       .Include(p => p.medication.name)
                       .FirstOrDefaultAsync(p => p.Id == id);

            if (pres == null)
            {
                return(NotFound());
            }

            var prescription = new PrescriptionDTO
            {
                Dose       = pres.dose,
                Id         = pres.Id,
                Medication = new MedicationDTO
                {
                    Id   = pres.medicationId,
                    Name = pres.medication.name
                },
                Patient = new PatientDTO
                {
                    FamilyName = pres.patient.familyName,
                    GivenName  = pres.patient.firstName,
                    Id         = pres.patientId
                }
            };

            return(prescription);
        }
        public int insertCorePrescription(PrescriptionDTO newPrescription)
        {
            int flagInsert = new PRESCRIPTIONTableAdapter().insertPrescriptionQuery(
                newPrescription.IdPatient,
                newPrescription.ConclusionMedical,
                newPrescription.Price,
                newPrescription.DayTime
                );

            return(flagInsert);
        }
Exemplo n.º 5
0
        public update_prescription_ui(PrescriptionDTO _prescriptionState)
        {
            this.prescriptionState = _prescriptionState;
            InitializeComponent();

            // ignore auto generate columns
            dgvDelPrescription.AutoGenerateColumns = false;
            dgvDelPrescription.AllowUserToAddRows  = false;
            dgvBackup.AutoGenerateColumns          = false;
            dgvBackup.AllowUserToAddRows           = false;
        }
        public int updateCorePrescription(PrescriptionDTO originalPrescription)
        {
            int flagUpdate = new PRESCRIPTIONTableAdapter().updatePrescriptionQuery(
                originalPrescription.IdPatient,
                originalPrescription.ConclusionMedical,
                originalPrescription.Price,
                originalPrescription.DayTime,
                originalPrescription.IdPrescription
                );

            return(flagUpdate);
        }
Exemplo n.º 7
0
        private void AddLek(object sender, RoutedEventArgs e)
        {
            PrescriptionDTO prescriptionDTO = new PrescriptionDTO(Amount, Freq.ToString(), "opis", new MedicineDTO(ComboBox12.SelectedIndex + 1, TartgetRosource, "", "", 1, "", "", true), DateTime.Now, LoggedInPatient);

            app.PrescriptionController.Save(prescriptionDTO);
            PecepiesList.ItemsSource = app.PrescriptionController.GetAll();

            Medicine_toAdd.Visibility     = Visibility.Hidden;
            NumberTextBox.Visibility      = Visibility.Hidden;
            NumberTextBox_Copy.Visibility = Visibility.Hidden;
            Kol_med.Visibility            = Visibility.Hidden;
            Uc_med.Visibility             = Visibility.Hidden;
            AddMediciniToList.Visibility  = Visibility.Hidden;
        }
Exemplo n.º 8
0
        public async Task <ActionResult <PrescriptionDTO> > PostPrescription(PrescriptionDTO prescription)
        {
            var dbPres = new Prescription
            {
                dose         = prescription.Dose,
                patientId    = prescription.Patient.Id,
                medicationId = prescription.Medication.Id
            };

            _context.Prescriptions.Add(dbPres);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPrescription", new { id = dbPres.Id }, prescription));
        }
Exemplo n.º 9
0
        public async Task <bool> UpdatePrescription(PrescriptionDTO prescription)
        {
            try
            {
                await _prescriptionsClient.PutPrescriptionAsync(prescription.Id, prescription);

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Couldn't update prescription");
                Debug.WriteLine(ex.Message);
                return(false);
            }
        }
Exemplo n.º 10
0
        public async Task <int> AddPrescription(PrescriptionDTO prescription)
        {
            try
            {
                var result = await _prescriptionsClient.PostPrescriptionAsync(prescription);

                return(result.Id);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Couldn't add prescription");
                Debug.WriteLine(ex.Message);
                return(0);
            }
        }
        public int insertPrescription(
            string idPatient,
            string conclusionMedical,
            string price,
            string xtime)
        {
            PrescriptionDTO currentPrescriptionDatarow = new PrescriptionDTO();

            currentPrescriptionDatarow.IdPatient         = Convert.ToInt32(idPatient);
            currentPrescriptionDatarow.ConclusionMedical = Convert.ToString(conclusionMedical);
            currentPrescriptionDatarow.Price             = Convert.ToDecimal(price);
            currentPrescriptionDatarow.DayTime           = Convert.ToDateTime(xtime);

            return(prescriptionDal.insertCorePrescription(currentPrescriptionDatarow));
        }
Exemplo n.º 12
0
 public PrescriptionViewModel Map(PrescriptionDTO Prescription) => _mapper.Map <PrescriptionViewModel>(Prescription);