public static System.Windows.Forms.ListViewItem[] convertReferralToListViewItems(Referral[] reflist)
        {
            ArrayList al = new ArrayList();
            ListViewItem lw;

            foreach (Referral rfl in reflist)
            {
                lw = new ListViewItem(rfl.datum.ToString("yyMMdd"));
                lw.SubItems.Add(rfl.remissid);
                lw.SubItems.Add(rfl.personnr);
                lw.SubItems.Add(rfl.kombikakod);
                if (!ECS.noNULL(rfl.prioritering).Equals("NORMAL"))
                    lw.SubItems.Add(rfl.prioritering);
                else
                    lw.SubItems.Add("");
                lw.Checked = true;
                al.Add(lw);
            }
            return (ListViewItem[])al.ToArray(typeof(ListViewItem));
        }
示例#2
0
        public Referral[] updateTables(Referral[] refList, string compid)
        {
            ArrayList alReturnRef = new ArrayList();
            ArrayList alReferrals = new ArrayList();
            PatientDefenition[] oPatient = null;

            alReferrals.AddRange(refList);

            foreach (Referral r in alReferrals)
            {
                if (!r.remissid.Equals(""))
                {
                    oPatient = oCust.getPatientByPnr(r.personnr.Insert(8, "-"), true, true);

                    // Check if patient exists, if not try to create one
                    if (oPatient.Length == 0)
                    {
                        //ingen kund hittades - skapa denna
                        try
                        {
                            ArrayList alCust = new ArrayList();
                            alCust.Add(r.personnr);
                            createCustomer(alCust);
                            oPatient = oCust.getPatientByPnr(r.personnr.Insert(8, "-"), true, true);
                        }
                        catch
                        {
                            MessageBox.Show("Ett fel inträffade vid upplägg av patient " + r.personnr, "Fel vid upplägg av patient", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                    }

                    try // If an exception is raised or oPatient is emty, don't add order no.
                    {
                        if (oPatient.Length > 0)
                        {
                            Referral r2 = r;
                            r2.orderno = insertReferrals(r, oPatient[0].PatientNo, compid);
                            alReturnRef.Add(r2);
                        }
                    }
                    catch { }
                }
            }

            return (Referral[])alReturnRef.ToArray(typeof(Referral));
        }
示例#3
0
        public bool removeRow(string onr, string row)
        {
            OrderRowDefinitions.OrderRow delRow = new OrderRowDefinitions.OrderRow();
            Referral r = new Referral();

            // Avbryt om ordern är stängd
            if (!isOrderOpen(onr))
                return false;

            delRow = getRow(onr, row);

            // Only if Thord user
            if (Config.IsThordUser)
            {
                r = garpref.getReferralForRemovalOfPart(delRow.OrderNo, delRow.AidNr, row);
            }

            // Om denna rad är den som visas i översikten så visa en annan rad istället.
            if (getViewState(onr, row))
            {
                //string id = mOR.AidID;
                mOR.doDelete(onr, row);
                OrderRowDefinitions.OrderRow[] or = mOR.getAid(onr, delRow.AidNr, false).OrderRows.ToArray(); ;
                if (or.Length > 0)
                    setAsViewInList(or[0].OrderNo, or[0].AidNr, or[0].Rad);
            }
            else
                mOR.doDelete(onr, row);

            // Only if Thord user
            if (Config.IsThordUser)
            {
                if (delRow.CreatedInThord && !r.remissid.Equals(""))
                {
                    thordfunc.sendReferral(r);
                }
            }

            return true;
        }
示例#4
0
        /// <summary>
        /// Fetches Referals with the supplies Ordernumber
        /// </summary>
        /// <param name="ordnr">The ordernumber</param>
        /// <returns></returns>
        public Referral[] getReferrals(String ordnr)
        {
            ArrayList aList = new ArrayList();
            Referral rfl = new Referral();
            Ortoped.GarpFunctions.orderFunc of = new Ortoped.GarpFunctions.orderFunc();
            Ortoped.Definitions.OrderHeadDefinition oOH = of.getOrder(ordnr);

            if (oOH.OrderNo != null)
            {
                rfl.datum = DateTime.ParseExact(oOH.OrderDate, "yyMMdd", new CultureInfo("sv-SE"));
                rfl.ordinator = oOH.SelOrdinator;
                rfl.personnr = oOH.PatientNo;
                rfl.diagnos = oOH.Diagnose;
                rfl.notering = oOH.Notation;
                rfl.kombikakod = oOH.KombikaCode;
                rfl.remissid = oOH.ReferralNo;
            }

            aList.Add(rfl);

            return (Referral[])aList.ToArray(typeof(Referral));
        }
示例#5
0
        /// <summary>
        /// Insert the supplied referal into Garp tables
        /// </summary>
        /// <param name="r"></param>
        public string insertReferrals(Referral r, string knr, string compid)
        {
            sKNR = knr;

            Ortoped.GarpFunctions.orderFunc of = new Ortoped.GarpFunctions.orderFunc();
            Ortoped.Definitions.OrderHeadDefinition newOH = of.addOH(sKNR, compid);

            if (newOH == null)
            {
                MessageBox.Show(null, "Ett fel uppstod vid skapande av order: " + newOH.OrderNo, "Fel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw new Exception("Kunde inte skapa order");
            }

            try
            {
                newOH.Pricelist = "A";
                newOH.DiagnoseCode = r.diagnoskod;
                newOH.ValidFrom = r.giltligfran;
                newOH.SelOrdinator = r.ordinator;
                newOH.ValidYearsCount = int.Parse(r.antalar);
                newOH.InvoiceCustomer = "140";
                newOH.OrderType = compid;
                newOH.KombikaCode = r.kombikakod;
                newOH.ReferralNo = r.remissid;
                newOH.YourReference = r.remissid;
                newOH.Ordination = r.aidtypes + " " + r.ordination;
                newOH.Diagnose = r.diagnos;
                newOH.Priority = r.prioritering;
                if (ECS.noNULL(r.handlaggare).Equals(""))
                    newOH.Notation = r.notering;
                else
                    newOH.Notation = r.notering + " Önskad handläggare: " + r.handlaggare;

                if (!of.saveOH(newOH))
                    throw new Exception("Kunde inte skapa order");
            }
            catch
            {
                MessageBox.Show(null, "Ett fel uppstod vid skapande av order: " + newOH.OrderNo, "Fel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw new Exception("Kunde inte skapa order");
            }
            return newOH.OrderNo;
        }
示例#6
0
        /// <summary>
        /// Fetches garp data and creates instances of referralefinition
        /// </summary>
        /// <param name="ordernr">order number</param>
        /// <returns>Array of New Aid Definitions</returns>
        public Referral getReferralForRemovalOfPart(string ordernr, string aidid, string rowremoval)
        {
            Ortoped.GarpFunctions.orderFunc ohf = new Ortoped.GarpFunctions.orderFunc();
            OrderHeadDefinition oh;
            Referral rf = new Referral();
            oh = ohf.getOrder(ordernr);

            if (!oh.ReferralNo.Equals(""))
            {
                rf.personnr = oh.PatientsSSN;
                rf.remissid = oh.ReferralNo;
                rf.kombikakod = oh.KombikaCode;
                rf.ordinator = oh.SelOrdinator;
                //      rf.datum = oh.Orderdatum;
                rf.diagnos = oh.DiagnoseCode;
                rf.notering = oh.Notation;
                rf.orderno = oh.OrderNo;

                rf.aids = getAids(ordernr, aidid);

                for (int i = 0; i < rf.aids[0].parts.Length; i++)
                {
                    if (rf.aids[0].parts[i].orderno.Equals(ordernr) && rf.aids[0].parts[i].row.Equals(rowremoval))
                        rf.aids[0].parts[i].RemoveMe = true;

                    if (rf.aids[0].parts.Length <= 1)
                        rf.aids[0].RemoveMe = true;
                }
            }
            return rf;
        }
示例#7
0
        /// <summary>
        /// Fetches garp data and creates instances of referralefinition
        /// </summary>
        /// <param name="ordernr">order number</param>
        /// <returns>Array of New Aid Definitions</returns>
        public Referral getReferral(string ordernr, string aidid)
        {
            Ortoped.GarpFunctions.orderFunc ohf = new Ortoped.GarpFunctions.orderFunc();
            OrderHeadDefinition oh;
            Referral rf = new Referral();
            oh = ohf.getOrder(ordernr);

            if (!oh.ReferralNo.Equals(""))
            {
                rf.personnr = oh.PatientsSSN;
                rf.remissid = oh.ReferralNo;
                rf.kombikakod = oh.KombikaCode;
                rf.ordinator = oh.SelOrdinator;
                //      rf.datum = oh.Orderdatum;
                rf.diagnos = oh.DiagnoseCode;
                rf.notering = oh.Notation;
                rf.orderno = oh.OrderNo;

                rf.aids = getAids(ordernr, aidid);
            }

            return rf;
        }
示例#8
0
        /// <summary>
        /// Connect to Thord and change status of referrals to "MOTTAGEN"
        /// </summary>
        /// <param name="refs">Array of referrals</param>
        public void sendTransferedReferrals(Referral[] refs)
        {
            referralupdates refupdate = new referralupdates();
            ReferralUpdateDefinition[] refdef = new ReferralUpdateDefinition[refs.Length];
            int i = 0;

            if (refs.Length != 0)
            {
                foreach (Referral rf in refs)
                {
                    ReferralUpdateDefinition rd = new ReferralUpdateDefinition();

                    rd.referralnumber = rf.remissid;
                    rd.statusSpecified = true;
                    rd.status = ReferralStatusValues.MOTTAGEN;
                    refdef[i] = rd;
                    i++;
                }
                try
                {
                    refupdate.referralupdate = refdef;
                    tdProxy.UpdateReferrals(refupdate);
                }
                catch { }
            }
        }
示例#9
0
        /// <summary>
        /// Connect to Thord and update referrals with new data
        /// </summary>
        /// <param name="refs">Array of Referrals</param>
        /// <param name="garpaids">Array of New Aid Definitions</param>
        public bool sendReferral(Referral referral)
        {
            referralupdates refupdate = new referralupdates();
            ReferralUpdateDefinition[] ru = new ReferralUpdateDefinition[1];
            AidsUpdateDefinition aids = new AidsUpdateDefinition();
            referrals refReturned;
            OrderRowFunc oOR = new OrderRowFunc();

            // If aids exists
            if (referral.aids.Length > 0)
            {
                if (referral.aids[0].CreatedInThord)
                {
                    aids.aidupdate = createAidUpdateObject(referral.aids[0]);
                }
                else
                {
                    aids.newaid = createAidNewObject(referral.aids[0]);
                }
            }

            ru[0] = new ReferralUpdateDefinition();
            ru[0].referralnumber = referral.remissid;
            ru[0].aids = aids;

            refupdate.referralupdate = ru;

            try
            {
                // Talk to the old man
                refReturned = tdProxy.UpdateReferrals(refupdate);

                foreach (AidDefinition ad in refReturned.referral[0].aids.aid)
                {
                    if ((referral.aids[0].orderno.PadRight(6, '_') + referral.aids[0].row.Trim()).Equals(ad.externalaidid))
                    {
                        oOR.updateOid(ad.externalaidid.Substring(0, 6).Replace("_", ""), ad.externalaidid.Substring(6), ad.aidoid.ToString(), "0");

                        // If any parts are present
                        if (ad.parts != null)
                        {
                            foreach (PartDefinition p in ad.parts.part)
                            {
                                oOR.updateOid(p.externalpartid.Substring(0, 6).Replace("_", ""), p.externalpartid.Substring(6), ad.aidoid.ToString(), p.partoid.ToString());
                            }
                        }
                    }

                    // If whole aid should be removed
                    // OBS! This code must exists after ordinary UpdateReferrals, all parts must be
                    // removed before vi can remove the aid.
                    if (referral.aids[0].RemoveMe)
                    {
                        aids = new AidsUpdateDefinition();
                        ru[0] = new ReferralUpdateDefinition();

                        ru[0].referralnumber = referral.remissid;
                        ru[0].aids = aids;
                        refupdate.referralupdate = ru;

                        aids.removeaid = createAidRemoveObject(referral.aids[0]);

                        // Talk to the old man
                        try
                        {
                            refReturned = tdProxy.UpdateReferrals(refupdate);
                            MessageBox.Show("Hjälpmedlet (" + referral.aids[0].aidoid.ToString() + ") har tagits bort från Thord", "Meddelande från Thord");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Vid radering av hjälpmedel uppstod ett fel:\n" + ex.Message, "Meddelande från Thord");
                            Log4Net.Logger.loggError(ex, "THORD: SendReferral/RemoveReferral:", Config.User, "ThordFunction.sendReferral");
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Meddelande från Thord");
                Log4Net.Logger.loggError(ex, "THORD: SendReferral", Config.User, "");
                return false;
            }
        }
示例#10
0
        /// <summary>
        /// Calls Thord and fetches all existing Referrals that matches
        /// the selection
        /// </summary>
        /// <param name="from">Date from</param>
        /// <param name="to">Date to</param>
        /// <param name="rsv">Status value of Referral</param>
        /// <returns>Array of referrals</returns>
        public Referral[] getRefs(DateTime from, DateTime to, ReferralStatusValues1 rsv)
        {
            ArrayList rfList = new ArrayList();
            referralselection rs = new referralselection();
            critera cr = new critera();
            referrals reff = null;

            cr.status = rsv;
            cr.fromDate = from;
            cr.toDate = to;

            #if DEBUG
            cr.fromDateSpecified = true;
            cr.toDateSpecified = true;
            #else
            cr.fromDateSpecified = false;
              cr.toDateSpecified = false;
            #endif

            cr.statusSpecified = true;
            rs.critera = cr;

            try
            {
                reff = tdProxy.GetReferrals(rs);
            }
            catch (Exception e)
            {
                MessageBox.Show(null, "Fel vid kommunikation med Thord:\n\n" + e.Message, "Kommunikationsfel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log4Net.Logger.loggError(e, "Fel vid skapande av proxy", Config.User, "ThordFUnctions.getRefs");
                return null;
            }

            if (reff.referral != null)
            {
                foreach (ReferralDefinition rf in reff.referral)
                {
                    Referral r = new Referral();
                    r.datum = rf.createddate;
                    r.personnr = rf.personnumber;
                    r.remissid = rf.referralnumber;
                    r.prioritering = rf.priority.ToString();

                    try
                    {
                        r.kombikakod = rf.kombika.kombikacode;
                    }
                    catch { }
                    r.status = ECS.noNULL(rf.status.ToString());
                    r.ordinator = ECS.noNULL(rf.prescribername);
                    r.diagnos = ECS.noNULL(rf.diagnosis);
                    r.notering = ECS.noNULL(rf.comment);
                    r.giltligfran = rf.referraldate;
                    r.antalar = ECS.noNULL(rf.validtime.ToString());
                    r.diagnoskod = rf.reducedfunction.ToString();
                    r.handlaggare = ECS.noNULL(rf.desiredadministrator);
                    r.aidtypes = "";

                    //hämta textvärdena för aidtypes, dvs "Inlägg/Fotbädd", "Protes" m.fl
                    if (rf.aidtypes.aidtype.Length > 0)
                    {
                        for (int i = 0; i < rf.aidtypes.aidtype.Length; i++)
                        {
                            switch (rf.aidtypes.aidtype[i])
                            {
                                case 1:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Inlägg/Fotbädd";
                                    else
                                        r.aidtypes = r.aidtypes + ", Inlägg/Forbädd";
                                    break;

                                case 2:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Ortopediska skor/Bekvämskor";
                                    else
                                        r.aidtypes = r.aidtypes + ", Ortopediska skor/Bekvämskor";
                                    break;

                                case 3:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Ortos";
                                    else
                                        r.aidtypes = r.aidtypes + ", Ortos";
                                    break;

                                case 4:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Protes";
                                    else
                                        r.aidtypes = r.aidtypes + ", Protes";
                                    break;

                                case 5:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Behandlingsskor";
                                    else
                                        r.aidtypes = r.aidtypes + ", Behandlingsskor";
                                    break;

                                case 6:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Övrigt";
                                    else
                                        r.aidtypes = r.aidtypes + ", Övrigt";
                                    break;

                                case 7:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Behandlande ortos";
                                    else
                                        r.aidtypes = r.aidtypes + ", Behandlande ortos";
                                    break;

                                case 8:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Bråckband";
                                    else
                                        r.aidtypes = r.aidtypes + ", Bråckband";
                                    break;

                                case 9:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Olikstora skor";
                                    else
                                        r.aidtypes = r.aidtypes + ", Olikstora skor";
                                    break;

                                case 10:
                                    if (r.aidtypes.Length == 0)
                                        r.aidtypes = "Ändring av egna skor";
                                    else
                                        r.aidtypes = r.aidtypes + ", Ändring av egna skor";
                                    break;

                                default:
                                    Console.Write("Denna idkod saknas!");
                                    break;
                            }
                        }
                    }
                    rfList.Add(r);
                }
            }

            return (Referral[])rfList.ToArray(typeof(Referral));
        }