Example #1
0
        public String CreatePrescription(EPrescription prescription)
        {
            String complete = @"FilePrescriptions\Prescription" + DateTime.Now.ToString("dd-MM-yyyy") + "_" + HelperFunctions.GetRandomNumber() + ".txt";

            System.IO.File.WriteAllText(complete, GetTextForPrescription(prescription));
            return(complete);
        }
Example #2
0
        public IActionResult AddEPrescription(EPrescriptionDto dto)
        {
            EPrescription eprescription = EPrescriptionMapper.EPrescriptionDtoToEPrescription(dto);

            App.Instance().EPrescriptionService.AddEntity(eprescription);
            return(Ok());
        }
Example #3
0
 public IActionResult PostHttp(EPrescription prescription)
 {
     if (PrescriptionFileService.SendPrescriptionHttp(prescription))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Example #4
0
        public void Not_found_ePrescription_for_patient()
        {
            EPrescriptionService ePrescriptionService = new EPrescriptionService(CreateStubRepository());

            EPrescription ePrescription = ePrescriptionService.GetEPrescriptionForPatient(7);

            Assert.Null(ePrescription);
        }
        public static EPrescription EPrescriptionDtoToEPrescription(EPrescriptionDto dto)
        {
            EPrescription newEPrescriptions = new EPrescription();

            newEPrescriptions.PatientName    = dto.PatientName;
            newEPrescriptions.MedicamentName = dto.MedicamentName;
            newEPrescriptions.Comment        = dto.Comment;
            newEPrescriptions.PublishingDate = dto.PublishingDate;
            return(newEPrescriptions);
        }
Example #6
0
 private void DefineTypeOfApiKey(EPrescription prescription, RegistrationInPharmacy registrationInPharmacy)
 {
     if (registrationInPharmacy.PharmacyConnectionInfo.ApiKey.Substring(registrationInPharmacy.PharmacyConnectionInfo.ApiKey.Length - 1).Equals("H"))
     {
         new PharmacyHttp(Context).SendPrescription(prescription);
     }
     else
     {
         new PharmacyGrpcSftp(Context).SendPrescription(prescription);
     }
 }
Example #7
0
 public Boolean SendPrescription(EPrescription prescription)
 {
     try
     {
         foreach (RegistrationInPharmacy registrationInPharmacy in HttpRequests.GetPharmacyRegistrations())
         {
             DefineTypeOfApiKey(prescription, registrationInPharmacy);
         }
         return(true);
     }
     catch (Exception e) { return(false); }
 }
        public Boolean SendPrescriptionHttp(EPrescription prescription)
        {
            String prescriptionFile = CreatePrescription(prescription);

            try
            {
                HttpService.UploadPrescriptionFile(prescriptionFile);
                SmptServerService.SendEMailNotification(prescriptionFile, "prescription");
                return(true);
            }
            catch (Exception e) { return(false); }
        }
        public static EPrescriptionDto EPrescriptionToEPresctriptionDto(EPrescription ePrescription)
        {
            EPrescriptionDto dto = new EPrescriptionDto();

            dto.Id             = ePrescription.Id;
            dto.PatientId      = ePrescription.PatientId;
            dto.PatientName    = ePrescription.PatientName;
            dto.Comment        = ePrescription.Comment;
            dto.MedicamentName = ePrescription.MedicamentName;
            dto.PublishingDate = ePrescription.PublishingDate;
            return(dto);
        }
        public Boolean SendPrescriptionSftp(EPrescription prescription)
        {
            String prescriptionFile = CreatePrescription(prescription);

            String[] prescriptionParts = prescriptionFile.Split("\\");

            try {
                SftpService.UploadFile(prescriptionFile, @"\pub\" + prescriptionParts[1]);
                SmptServerService.SendEMailNotification(prescriptionFile, "prescription");
                return(true);
            }
            catch (Exception e) { return(false); }
        }
Example #11
0
        public static IEPrescriptionRepository Create_stub_repository()
        {
            var           stubRepository = new Mock <IEPrescriptionRepository>();
            EPrescription prescription   = new EPrescription("Jankovic", "Pera", "Peric", "12356489", "Paracetamol", 3, "3 times per week");
            EPrescription prescription2  = new EPrescription("Benu", "Zika", "Milic", "11111111", "Brufen", 5, "5 times per week");

            var prescriptions = new List <EPrescription>();

            prescriptions.Add(prescription);
            prescriptions.Add(prescription2);
            stubRepository.Setup(m => m.GetAll()).Returns(prescriptions);

            return(stubRepository.Object);
        }
Example #12
0
 public EPrescription Create(EPrescription prescription)
 {
     dbContext.EPrescriptions.Add(prescription);
     dbContext.SaveChanges();
     return(prescription);
 }
Example #13
0
 public String GetTextForPrescription(EPrescription prescription)
 {
     return(prescription.Pharmacy + " Precription for medicine\n\nPatients name: " + prescription.Name + "\nPatients surname: " + prescription.Surname + "\nPatients medical ID number: " + prescription.MedicalIDNumber + "\nMedication: " + prescription.Medicine + " Quantity: " + prescription.Quantity + "\nUsage: " + prescription.Usage + "\n");
 }
Example #14
0
        public String GeneratePrescriptionForPatient(string medicalIdNumber)
        {
            EPrescription prescription = GetAllForStub().SingleOrDefault(prescriptionIt => (prescriptionIt.MedicalIDNumber.Equals(medicalIdNumber)));

            return(prescription != null ? getTextForPrescription(prescription) : "");
        }
Example #15
0
        public EPrescription Create(EPrescriptionDto dto)
        {
            EPrescription prescription = EPrescriptionAdapter.EPrescriptionDtoToEPresctiption(dto);

            return(EPrescriptionRepository.Create(prescription));
        }