Beispiel #1
0
        /// <summary>
        /// Registers a medication package.
        /// </summary>
        /// <param name="medicationTypeId">medication type id</param>
        /// <param name="expireDate">package expire date</param>
        /// <param name="barcode">package barcode</param>
        /// <returns>generated barcode number</returns>
        public string RegisterPackage(int medicationTypeId, string expireDate, string barcode = "")
        {
            DateTime parsedExpireDate;

            if (!DateTime.TryParse(expireDate, out parsedExpireDate))
            {
                throw new ENETCareException(Properties.Resources.InvalidDateFormat);
            }
            MedicationType medicationType = MedicationTypeDAO.GetMedicationTypeById(medicationTypeId);

            CheckMedicationTypeIsValid(medicationType);
            return(RegisterPackage(medicationType, parsedExpireDate, barcode));
        }
Beispiel #2
0
        /// <summary>
        /// Check whether a package is unexpected and has its status/location updated
        /// </summary>
        /// <param name="medicationTypeId">medication type id</param>
        /// <param name="barcode">package barcode</param>
        /// <returns>true if status/location of the package has been updated, or false if not</returns>
        public bool CheckAndUpdatePackage(int medicationTypeId, string barcode)
        {
            bool updated = false;
            MedicationPackage package = MedicationPackageDAO.FindPackageByBarcode(barcode);

            if (package == null)
            {
                MedicationType medicationType = MedicationTypeDAO.GetMedicationTypeById(medicationTypeId);
                DateTime       expireDate     = medicationType.DefaultExpireDate;
                RegisterPackage(medicationType, expireDate, barcode);
                updated = true;
            }
            else if (package.TypeId != medicationTypeId)
            {
                throw new ENETCareException(Properties.Resources.MedicationTypeNotMatched);
            }
            else if (package.Status != PackageStatus.InStock || package.StockDCId != User.DistributionCentreId)
            {
                ManipulatePackage(package, PackageStatus.InStock, User.DistributionCentreId, null, null);
                MedicationPackageDAO.UpdatePackage(package);
                updated = true;
            }
            return(updated);
        }