Exemplo n.º 1
0
        private IActionResult SendProcurementHTTP(int pro, string phar)
        {
            Pharmacy pharmacy = _pharmacyService.Get(phar);
            string   endpoint = pharmacy.APIEndpoint;

            endpoint = endpoint.Substring(0, endpoint.Length - 5) + "urgent";
            string response = "";
            UrgentMedicationProcurement urgent = _service.Get(pro);

            using HttpClient client = new HttpClient();
            StringContent content = new StringContent(JsonConvert.SerializeObject(urgent), Encoding.UTF8, "application/json");

            var task = client.PostAsync(endpoint, content)
                       .ContinueWith((taskWithResponse) =>
            {
                var message = taskWithResponse.Result;
                var json    = message.Content.ReadAsStringAsync();
                json.Wait();
                response = json.Result;
            });

            task.Wait();

            return(Ok(response));
        }
 public IActionResult GetPharmacies(string query)
 {
     if (!string.IsNullOrEmpty(query) && query != "undefined")
     {
         return(Ok(_pharmacyService.Get().Take(5)));
     }
     query = query.Trim();
     return(Ok(_pharmacyService.Get().Where(e => e.name.Contains(query, StringComparison.OrdinalIgnoreCase) || e.address.Contains(query, StringComparison.OrdinalIgnoreCase))));
 }
        public async void LoadProducts()
        {
            IsBusy = true;
            ObservableCollection <Product> product = new ObservableCollection <Product>();
            ProductPair productPair;

            Products.Clear();
            IEnumerable <Product> getProduct = await _pharmacyService.Get();

            foreach (Product p in getProduct)
            {
                product.Add(p);
            }

            for (int j = 0; j < getProduct.Count(); j += 2)
            {
                if (j + 1 <= product.Count)
                {
                    productPair = new ProductPair(product[j], product[j + 1]);
                    Products.Add(productPair);
                }
            }
            IsBusy  = false;
            product = null;
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Manage(int?page)
        {
            int pageSize   = 25;
            var pharmacies = _pharmacyService.Get();

            return(View(await PaginatedList <mp_pharmacy> .CreateAsync(pharmacies.OrderByDescending(e => e.name).AsNoTracking(), page ?? 1, pageSize)));
        }
        public async Task <IActionResult> PostPrescription(mp_prescription prescription)
        {
            var user_id   = _userManager.GetUserId(HttpContext.User);
            var clinician = _clinicianService.Get().FirstOrDefault(e => e.user_id == user_id);

            prescription.clinician_id = clinician.id;
            prescription.created_by   = user_id;

            var prescription_id = _prescriptionService.AddPrescription(prescription);

            var collection = Request.Form;
            var drugs      = collection["drug"].ToList();
            var dosages    = collection["dosage"].ToList();

            var drug_text = "";

            var prescription_drugs = new List <mp_prescription_drug>();

            for (var i = 0; i < drugs.Count; i++)
            {
                prescription_drugs.Add(new mp_prescription_drug
                {
                    drug            = drugs[i],
                    dosage          = dosages[i],
                    prescription_id = prescription_id
                });

                drug_text += drugs[i] + " " + dosages[i] + ",";
            }

            _prescriptionService.AddPrescriptionDrugs(prescription_drugs);

            //get the profile information
            var profile = _profileService.Get(prescription.profile_id);

            var notification = new mp_notification
            {
                created_by        = "sys_admin",
                created_by_name   = "System Admin",
                notification_type = 7,
                read         = 0,
                user_id      = profile.user_id,
                notification = "Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details.",
                title        = "New Prescription"
            };

            NotificationUtil.Add(notification);

            await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime",
                                              $"Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details.");

            if (prescription.pharmacy_id.HasValue)
            {
                //get the email of the pharmacy
                var pharmacy = _pharmacyService.Get().FirstOrDefault(e => e.id == prescription.pharmacy_id.Value);
                if (pharmacy != null && !string.IsNullOrEmpty(pharmacy.email))
                {
                    await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime",
                                                      $"The following prescriptions have been sent for " + profile.last_name + " " + profile.first_name + " - " + profile.unique_id.ToString("D10") + " .<br/>" + drug_text);
                }
            }

            return(Ok(200));
        }
Exemplo n.º 6
0
 public IActionResult Get(string id)
 {
     return(Ok(_pharmacyService.Get(id)));
 }