Exemple #1
0
 ///<summary>Inserts one Formulary into the database.  Returns the new priKey.</summary>
 internal static long Insert(Formulary formulary)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         formulary.FormularyNum=DbHelper.GetNextOracleKey("formulary","FormularyNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(formulary,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     formulary.FormularyNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(formulary,false);
     }
 }
Exemple #2
0
        ///<summary>Inserts one Formulary into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(Formulary formulary, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                formulary.FormularyNum = ReplicationServers.GetKey("formulary", "FormularyNum");
            }
            string command = "INSERT INTO formulary (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "FormularyNum,";
            }
            command += "Description) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(formulary.FormularyNum) + ",";
            }
            command +=
                "'" + POut.String(formulary.Description) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                formulary.FormularyNum = Db.NonQ(command, true);
            }
            return(formulary.FormularyNum);
        }
Exemple #3
0
 ///<summary>Inserts one Formulary into the database.  Returns the new priKey.</summary>
 internal static long Insert(Formulary formulary)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         formulary.FormularyNum = DbHelper.GetNextOracleKey("formulary", "FormularyNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(formulary, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     formulary.FormularyNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(formulary, false));
     }
 }
        private List <Formulary> getFormularies()
        {
            List <Formulary> result = new List <Formulary>();
            MySqlConnection  sqlCon = Configurations.connection;


            if (sqlCon.State == ConnectionState.Closed)
            {
                sqlCon.Open();
            }
            String       query  = "SELECT * FROM formulary ;";
            MySqlCommand sqlCmd = new MySqlCommand(query, sqlCon);

            sqlCmd.CommandType = CommandType.Text;

            int             count  = Convert.ToInt32(sqlCmd.ExecuteScalar());
            MySqlDataReader reader = sqlCmd.ExecuteReader();

            while (reader.Read())
            {
                Formulary form = new Formulary();

                {
                    form.IdFormulary = reader.GetInt32(0);
                    form.Name        = reader.GetString(1);
                    form.Type        = reader.GetString(3);
                    form.Description = reader.GetString(3);
                };
                result.Add(form);
            }
            reader.Close();
            sqlCon.Close();
            return(result);
        }
Exemple #5
0
        ///<summary>Updates one Formulary in the database.</summary>
        internal static void Update(Formulary formulary)
        {
            string command = "UPDATE formulary SET "
                             + "Description = '" + POut.String(formulary.Description) + "' "
                             + "WHERE FormularyNum = " + POut.Long(formulary.FormularyNum);

            Db.NonQ(command);
        }
Exemple #6
0
 public QuizzPage(int id, int userId)
 {
     InitializeComponent();
     questionList   = getQuestions(id);
     form           = form.getFormById(id);
     formId         = id;
     actualQuestion = 0;
     this.userId    = userId;
     displayQuestion();
 }
Exemple #7
0
        public QuizzQuestionsPage(string id)
        {
            InitializeComponent();
            this.IdForm = Int32.Parse(id);
            List <Question> result = getQuestions();

            questionList.ItemsSource = result;
            DataContext = result;
            form        = form.getFormById(IdForm);
            this.id     = id;
        }
Exemple #8
0
        /// <summary>
        /// This method is used to store a formulary in DB.
        /// </summary>
        /// <param name="formulary">formulary to be inserted/updated.</param>
        public async Task <bool> ProcessFormularyRequest(Formulary formulary)
        {
            _logger.LogInformation(string.Format(CommonConstants.LoggingMessage.DataReceivedFromFormulary, JsonConvert.SerializeObject(formulary)));
            var result = await _formularyRepository.GetFormularyById(formulary.FormularyId);

            if (result == null)
            {
                return(await _formularyRepository.InsertFormulary(formulary));
            }
            else
            {
                return(await _formularyRepository.UpdateFormulary(formulary));
            }
        }
Exemple #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <Formulary> TableToList(DataTable table)
        {
            List <Formulary> retVal = new List <Formulary>();
            Formulary        formulary;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                formulary = new Formulary();
                formulary.FormularyNum = PIn.Long(table.Rows[i]["FormularyNum"].ToString());
                formulary.Description  = PIn.String(table.Rows[i]["Description"].ToString());
                retVal.Add(formulary);
            }
            return(retVal);
        }
        private bool SetExceptionTransaction(Facility facility, Formulary formulary, FacilityFormulary facilityFormulary, FacilityStorageSpace storageSpaceInfo, TransactionRequest request, Item item, int quantity, TransactionQueueModel newTransaction)
        {
            var isItemAccepted    = (facilityFormulary != null && facilityFormulary.Approved) ? true : false;
            var isActiveFormulary = (formulary != null && !formulary.IsActive.GetValueOrDefault()) ? false : true;

            if (formulary == null)
            {
                newTransaction.Description = item.ItemName;
                SetTransactionException(newTransaction, CommonConstants.TransactionException.UnknownItemId);
                if (!int.TryParse(item.OrderAmount.Trim(), out quantity))
                {
                    newTransaction.Exception += Environment.NewLine + CommonConstants.TransactionException.InvalidQuantity;
                }
                newTransaction.Quantity = quantity;
                return(true);
            }

            if (!isActiveFormulary)
            {
                SetTransactionException(newTransaction, CommonConstants.TransactionException.InactiveFormularyItem);
                return(true);
            }

            if (facilityFormulary == null)
            {
                SetTransactionException(newTransaction, CommonConstants.TransactionException.FormularyNotMapped);
                return(true);
            }

            if (!isItemAccepted)
            {
                SetTransactionException(newTransaction, CommonConstants.TransactionException.NotApprovedFormularyItem);
                return(true);
            }

            if (quantity <= 0)
            {
                SetTransactionException(newTransaction, CommonConstants.TransactionException.InvalidUnitQuantity);
                return(true);
            }

            if (storageSpaceInfo == null)
            {
                SetTransactionException(newTransaction, CommonConstants.TransactionException.UnassignedLocation);
                return(true);
            }

            return(false);
        }
Exemple #11
0
        ///<summary>Updates one Formulary in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(Formulary formulary, Formulary oldFormulary)
        {
            string command = "";

            if (formulary.Description != oldFormulary.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(formulary.Description) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE formulary SET " + command
                      + " WHERE FormularyNum = " + POut.Long(formulary.FormularyNum);
            Db.NonQ(command);
        }
Exemple #12
0
 ///<summary>Inserts one Formulary into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Formulary formulary,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         formulary.FormularyNum=ReplicationServers.GetKey("formulary","FormularyNum");
     }
     string command="INSERT INTO formulary (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="FormularyNum,";
     }
     command+="Description) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(formulary.FormularyNum)+",";
     }
     command+=
          "'"+POut.String(formulary.Description)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         formulary.FormularyNum=Db.NonQ(command,true);
     }
     return formulary.FormularyNum;
 }
        private void SetTransactionDetails(TransactionPriority priority, Formulary formulary, Facility facility,
                                           FacilityFormulary facilityFormulary, Destination destination, TransactionRequest incomingRequest,
                                           Item item, int partNo, int orderCount, TransactionQueueModel newTransaction, int quantity)
        {
            var  localNow = DateTime.Now;
            var  utcNow   = DateTime.UtcNow;
            User usr      = new User(UserName.Admin.ToString());

            newTransaction.StatusChangeDT          = localNow;
            newTransaction.StatusChangeUtcDateTime = utcNow;

            if (formulary != null)
            {
                newTransaction.Description = (priority != null && priority.UseInterfaceItemName.GetValueOrDefault()) ? item.ItemName : formulary.Description;
                newTransaction.FormularyId = formulary.FormularyId;
            }
            // Apply ADU Round if Qualifies
            if (quantity > 0 && facility != null && priority != null && destination != null &&
                facilityFormulary != null && (priority.IsAdu != null && (bool)priority.IsAdu) &&
                (facility.AduQtyRounding != null && (bool)facility.AduQtyRounding) &&
                (facilityFormulary.AduQtyRounding != null && (bool)facilityFormulary.AduQtyRounding) &&
                (destination.AduQtyRounding != null && (bool)destination.AduQtyRounding))
            {
                newTransaction.Quantity          = AduQtyRound(quantity);
                newTransaction.QuantityProcessed = newTransaction.Quantity;
                _logger.LogInformation(string.Format(CommonConstants.LoggingMessage.AduQuantity, newTransaction.Quantity, incomingRequest.RequestId));
            }
            else
            {
                newTransaction.Quantity          = quantity;
                newTransaction.QuantityProcessed = newTransaction.Quantity;
            }

            newTransaction.Type    = TransactionType.Pick;
            newTransaction.OrderId = incomingRequest.Order?.OrderNo;
            newTransaction.ItemId  = item.ItemId;

            if (!string.IsNullOrEmpty(item.ComponentStrength))
            {
                newTransaction.Strength = item.ComponentStrength.Trim();
            }

            if (!string.IsNullOrEmpty(item.ComponentStrengthUnits))
            {
                newTransaction.StrengthUnit = item.ComponentStrengthUnits.Trim();
            }

            //set these two to real values for display purposes
            newTransaction.ComponentNumber    = partNo;
            newTransaction.NumberOfComponents = orderCount;

            // Patient info
            SetPatientInfo(newTransaction, incomingRequest);

            newTransaction.FacilityId        = facility.Id;
            newTransaction.IncomingRequestId = incomingRequest.RequestId;

            if (priority != null)
            {
                newTransaction.TranPriorityId = priority.TransactionPriorityId;
            }

            newTransaction.ReceivedDt          = localNow;
            newTransaction.ReceivedUtcDateTime = utcNow;

            if (usr != null)
            {
                newTransaction.RequestedBy = usr.UserName;
            }

            if (!string.IsNullOrEmpty(incomingRequest.Patient?.DeliverToLocation))
            {
                newTransaction.Destination = incomingRequest.Patient.DeliverToLocation.Trim();
            }

            if (!string.IsNullOrEmpty(newTransaction.Exception) &&
                newTransaction.Exception.Length > 80)
            {
                newTransaction.Exception = newTransaction.Exception.Substring(0, 80);
            }

            if (!string.IsNullOrEmpty(item.Concentration))
            {
                newTransaction.Concentration = item.Concentration.Trim();
            }
            if (!string.IsNullOrEmpty(item.TotalDose))
            {
                newTransaction.TotalDose = item.TotalDose.Trim();
            }
            if (!string.IsNullOrEmpty(item.DispenseAmount))
            {
                newTransaction.DispenseAmount = item.DispenseAmount.Trim();
            }
        }
Exemple #14
0
 ///<summary>Converts a DataTable to a list of objects.</summary>
 internal static List<Formulary> TableToList(DataTable table)
 {
     List<Formulary> retVal=new List<Formulary>();
     Formulary formulary;
     for(int i=0;i<table.Rows.Count;i++) {
         formulary=new Formulary();
         formulary.FormularyNum= PIn.Long  (table.Rows[i]["FormularyNum"].ToString());
         formulary.Description = PIn.String(table.Rows[i]["Description"].ToString());
         retVal.Add(formulary);
     }
     return retVal;
 }
Exemple #15
0
 ///<summary>Updates one Formulary in the database.</summary>
 internal static void Update(Formulary formulary)
 {
     string command="UPDATE formulary SET "
         +"Description = '"+POut.String(formulary.Description)+"' "
         +"WHERE FormularyNum = "+POut.Long(formulary.FormularyNum);
     Db.NonQ(command);
 }
Exemple #16
0
 ///<summary>Updates one Formulary in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
 internal static void Update(Formulary formulary,Formulary oldFormulary)
 {
     string command="";
     if(formulary.Description != oldFormulary.Description) {
         if(command!=""){ command+=",";}
         command+="Description = '"+POut.String(formulary.Description)+"'";
     }
     if(command==""){
         return;
     }
     command="UPDATE formulary SET "+command
         +" WHERE FormularyNum = "+POut.Long(formulary.FormularyNum);
     Db.NonQ(command);
 }
    protected override void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var MedicationId = Request.QueryString["MedicationId"].ToString();
            var PrescriberId = Request.QueryString["PrescriberId"].ToString();
            var ClientId     = ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId.ToString();

            Eligibility objEligibility = new Eligibility();
            string      response       = objEligibility.GetEligibility(ClientId, PrescriberId);

            List <PBM> listpbm      = new List <PBM>();
            Formulary  objFormulary = new Formulary(ClientId, MedicationId);
            objFormulary = objFormulary.GetFormulary();
            if (!IsPostBack)
            {
                BindDropdown(objFormulary);               //Fill the dropdown with all pbm
                int index = objFormulary.DefaultPBMIndex; //pbmListNo represents the pbm having highest formulary status
                ddlPBM.SelectedIndex = index;
            }
            if (objFormulary.Alternative == null && objFormulary.Copays == null && objFormulary.Coverage == null && objFormulary.DefaultPBMName == null &&
                objFormulary.DrugClass == null && objFormulary.DrugType == null && objFormulary.PatientDetails == null)
            {
                Status.Text = objFormulary.FormularyStatus;
            }
            else
            {
                Status.Text = "";
            }

            lbPBMName.Text   = objFormulary.DefaultPBMName;         //Set the PBM Name, DefaultPBMName is the properties that always holds current PBM Name
            lbFormulary.Text = objFormulary.FormularyStatus;        //Formulary Status of Medication, Example:- On Formulary, Prefered Formulary-3 etc
            lbDrugType.Text  = objFormulary.DrugType;               //Drug Type that display Branded or Generic
            lbDrugClass.Text = objFormulary.DrugClass;

            DataTable dtPatient = new DataTable();           //Create a Datatable to store all the patient Details
            dtPatient.Columns.Add("InfoType", typeof(string));
            dtPatient.Columns.Add("Info", typeof(string));
            if (objFormulary.PatientDetails != null)                //Display Patient Details
            {
                Patient objPatient = objFormulary.PatientDetails;   //"PatientDetails" gets the the object of Patient class which  gives all the patient details as  properties
                if (objPatient.LastName != string.Empty)
                {
                    dtPatient.Rows.Add("Patient Name", objPatient.Suffix + " "
                                       + objPatient.FirstName + " " + objPatient.MiddleName + " "
                                       + objPatient.LastName);
                }
                if (objPatient.Address1 != string.Empty || objPatient.City != string.Empty ||
                    objPatient.State != string.Empty || objPatient.Zip != string.Empty)
                {
                    dtPatient.Rows.Add("Address", objPatient.Address1 + "\r\n"
                                       + objPatient.Address2 + "\r\n" + objPatient.City + "\r\n"
                                       + objPatient.State + "\r\n" + objPatient.Zip);
                }
                if (objPatient.Gender != string.Empty)
                {
                    dtPatient.Rows.Add("Gender", objPatient.Gender); //Add Gender to Datatable
                }
                if (objPatient.DOB != string.Empty)
                {
                    dtPatient.Rows.Add("DOB", objPatient.DOB);        //Add DOB to Datatable
                }
            }
            GVPatient.DataSource = dtPatient;
            GVPatient.DataBind();


            #region Copay details
            DataTable dtCop = new DataTable();            //Create a datatable to store all copay
            dtCop = CopayDetails(objFormulary.Copays);    //Copays is a property which is a collection of object of Class Copay
            //CopayDetails() collects all the copay details and keep them Datatable
            GVCOPAY.DataSource = dtCop;
            GVCOPAY.DataBind();
            #endregion

            #region CoverageDetails
            if (objFormulary.Coverage != null)
            {
                DataTable CoverageTable = new DataTable();                 //Create a Coverage Table that holds all the copay details
                CoverageTable    = CoverageDetails(objFormulary.Coverage); //ObjFormulary.Coverage--> Coverage is the property Which is a collection of property
                GVCOV.DataSource = CoverageTable;
                GVCOV.DataBind();
            }

            #endregion

            #region Therapeutic alternative
            DataTable dtTherapeutic = new DataTable();                                                //Create a datatable to holds Therapeutic alternative
            dtTherapeutic.Columns.Add("Therapeutic", typeof(DataTable));                              //Datatable is having a single column of type DataTable

            if (objFormulary.TherapeuticAlternative != null)                                          //TherapeuticAlternative is the propery which is the collection of all the therapeutic Details
            {
                foreach (AlternativeMedication objTherapeutic in objFormulary.TherapeuticAlternative) //objTherapeutic is the object of class AlternativeMedication
                {                                                                                     //which is a set of properties
                    DataTable dtInnerTherapeutic = new DataTable();                                   //Create a DataTable that contains Medication Name, Formulary Status, Drug Type
                    dtInnerTherapeutic.Columns.Add("Type", typeof(string));
                    dtInnerTherapeutic.Columns.Add("Data", typeof(string));
                    dtInnerTherapeutic.Rows.Add("Medication Name:", objTherapeutic.MedicationName); //Medication Name of Therapeutic Medication
                    dtInnerTherapeutic.Rows.Add("FormularyStatus", objTherapeutic.FormularyStatus); //Formulary Status of Therapeutic Medication
                    dtInnerTherapeutic.Rows.Add("Drug Type", objTherapeutic.DrugType);              //

                    DataTable dtCopayTherap = CopayDetails(objTherapeutic.Copays);                  //CopayDetails takes a collection of object of class
                    //Copay and each object have its own properties
                    foreach (DataRow dr in dtCopayTherap.Rows)
                    {
                        dtInnerTherapeutic.ImportRow(dr);               //Import Copay Details to the inner table
                    }
                    dtTherapeutic.Rows.Add(dtInnerTherapeutic);
                    if (objTherapeutic.Coverages != null)
                    {
                        DataTable dtCov = new DataTable();
                        dtCov = CoverageDetails(objTherapeutic.Coverages);
                        foreach (DataRow dr in dtCov.Rows)
                        {
                            dtInnerTherapeutic.ImportRow(dr);
                        }
                        dtTherapeutic.Rows.Add(dtInnerTherapeutic);
                    }
                }

                GVTHALT.DataSource = dtTherapeutic;
                GVTHALT.DataBind();
            }
            #endregion

            #region  alternative
            DataTable dtAlt = new DataTable();
            dtAlt.Columns.Add("ALT", typeof(DataTable));
            if (objFormulary.Alternative != null)
            {
                foreach (AlternativeMedication Alt in objFormulary.Alternative)
                {
                    DataTable dtAlt1 = new DataTable();

                    dtAlt1.Columns.Add("Type", typeof(string));
                    dtAlt1.Columns.Add("Data", typeof(string));
                    dtAlt1.Rows.Add("Medication Name:", Alt.MedicationName);
                    dtAlt1.Rows.Add("FormularyStatus", Alt.FormularyStatus);
                    dtAlt1.Rows.Add("Drug Type", Alt.DrugType);
                    DataTable dtcop = CopayDetails(Alt.Copays);


                    foreach (DataRow dr in dtcop.Rows)   //Add Copay Details
                    {
                        dtAlt1.ImportRow(dr);
                    }

                    //dtAlt.Rows.Add(dtAlt1);
                    if (Alt.Coverages != null)
                    {
                        DataTable dtCov = new DataTable();
                        dtCov = CoverageDetails(Alt.Coverages);
                        foreach (DataRow dr in dtCov.Rows)
                        {
                            dtAlt1.ImportRow(dr);
                        }
                    }
                    dtAlt.Rows.Add(dtAlt1);
                }

                GVALT.DataSource = dtAlt;
                GVALT.DataBind();
                #endregion
            }
        }
        catch (Exception ex) { }
    }
Exemple #18
0
 /// <summary>
 /// This method is used to store a formulary facility in DB.
 /// </summary>
 /// <param name="formulary">formulary facility to be updated.</param>
 public async Task <bool> UpdateFormularyFacility(Formulary formulary)
 {
     _logger.LogInformation(string.Format(CommonConstants.LoggingMessage.DataReceivedFromFormularyFacility, JsonConvert.SerializeObject(formulary)));
     return(await _formularyRepository.UpdateFormularyFacility(formulary));
 }
 private void BindDropdown(Formulary objformulary)
 {
     ddlPBM.DataSource    = objformulary.PBMs; //PBMS is the list of all PBM for a patient
     ddlPBM.DataTextField = "Name";            //Shows PBMNAME
     ddlPBM.DataBind();
 }