Example #1
0
        ///<summary>Gets all of the 'PatNumFroms's linked to the passed-in patNumTo.   Does not recursively look up additional patient links.
        ///The list returned will NOT include the patient passed in unless there is an entry in the database linking them to... themselves.</summary>
        public static List <long> GetPatNumsLinkedTo(long patNumTo, PatientLinkType patLinkType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), patNumTo, patLinkType));
            }
            string command = "SELECT PatNumFrom FROM patientlink "
                             + "WHERE PatNumTo=" + POut.Long(patNumTo) + " "
                             + "AND LinkType=" + POut.Int((int)patLinkType);

            return(Db.GetListLong(command));
        }
Example #2
0
        ///<summary>Gets all the PatNums that are linked to this PatNum and all the PatNums that are linked to those PatNums, etc. Always returns a list
        ///that contains at least the PatNum passed in.</summary>
        public static List <long> GetPatNumsLinkedFromRecursive(long patNumFrom, PatientLinkType patLinkType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), patNumFrom, patLinkType));
            }
            List <long> listPatNums = new List <long> {
                patNumFrom
            };

            AddPatNumsLinkedFromRecursive(patNumFrom, patLinkType, listPatNums);
            return(listPatNums);
        }
Example #3
0
        ///<summary>Deletes all of the entries for the patNumTo passed in of the specified type.</summary>
        public static void DeletePatNumTos(long patNumTo, PatientLinkType patLinkType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), patNumTo, patLinkType);
                return;
            }
            string command = "DELETE FROM patientlink "
                             + "WHERE PatNumTo=" + POut.Long(patNumTo) + " "
                             + "AND LinkType=" + POut.Int((int)patLinkType);

            Db.NonQ(command);
        }
Example #4
0
        ///<summary>Gets links to and from the patients passed in. Not recursive.</summary>
        public static List <PatientLink> GetLinks(List <long> listPatNums, PatientLinkType patLinkType)
        {
            if (listPatNums.Count == 0)
            {
                return(new List <PatientLink>());
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <PatientLink> >(MethodBase.GetCurrentMethod(), listPatNums, patLinkType));
            }
            string command = "SELECT * FROM patientlink "
                             + "WHERE (PatNumTo IN(" + string.Join(",", listPatNums.Select(x => POut.Long(x))) + ") "
                             + "OR PatNumFrom IN(" + string.Join(",", listPatNums.Select(x => POut.Long(x))) + ")) "
                             + "AND LinkType=" + POut.Int((int)patLinkType);

            return(Crud.PatientLinkCrud.SelectMany(command));
        }
Example #5
0
        ///<summary>Gets all the PatNums that are recursively linked to this PatNum and adds them to the list passed in.</summary>
        private static void AddPatNumsLinkedFromRecursive(long patNumFrom, PatientLinkType patLinkType, List <long> listPatNums)
        {
            //No need to check RemotingRole; private method.
            string command = "SELECT PatNumTo FROM patientlink "
                             + "WHERE PatNumFrom=" + POut.Long(patNumFrom) + " "
                             + "AND LinkType=" + POut.Int((int)patLinkType);
            List <long> listPatNumTos = Db.GetListLong(command);

            if (listPatNumTos.Count == 0)
            {
                return;                //Base case
            }
            foreach (long patNumTo in listPatNumTos)
            {
                if (listPatNums.Contains(patNumTo))
                {
                    continue;                    //So that a patient that links to itself does not cause an infinite circle of recursion.
                }
                listPatNums.Add(patNumTo);
                AddPatNumsLinkedFromRecursive(patNumTo, patLinkType, listPatNums);              //Find all the patients that are linked to the "To" patient.
            }
        }
Example #6
0
 ///<summary>Gets links to and from the patient passed in. Not recursive.</summary>
 public static List <PatientLink> GetLinks(long patNum, PatientLinkType patLinkType)
 {
     return(GetLinks(new List <long> {
         patNum
     }, patLinkType));
 }