/// <summary>
        /// Saves the preferences.
        /// </summary>
        /// <param name="siteID">The site at which the preferences are stored.</param>
        /// <param name="label">a label for the preferences.</param>
        /// <param name="userDUZ">The user for whom the preferences are stored. logged in user duz is used if null or empty</param>
        public void SavePreferences(string siteID, string label, string userDUZ, string data)
        {
            Log.Debug("Saving user preferences...");

            if (string.IsNullOrWhiteSpace(siteID))
            {
                throw new MagVixFailureException("Missing parameter: siteID.");
            }

            if (string.IsNullOrWhiteSpace(label))
            {
                throw new MagVixFailureException("Missing parameter: label.");
            }

            if (string.IsNullOrWhiteSpace(data))
            {
                throw new MagVixFailureException("Missing parameter: data.");
            }

            string URI;
            if (string.IsNullOrWhiteSpace(userDUZ))
            {
                // current logged in user
                URI = String.Format("pathology/preferences/{0}/{1}", siteID, label);
            }
            else
            {
                URI = String.Format("pathology/preferences/{0}/{1}/{2}", siteID, label, userDUZ);
            }

            IRestResponse response;
            try
            {
                //string text = string.Format("<restStringType><value>{0}</value></restStringType>", EscapeXml(data));
                RestStringType pref = new RestStringType() { Value = data };
                string body = ResponseParser.SerializeToXml<RestStringType>(pref);

                response = ExecutePost(URI, VixServiceTypes.Pathology, body);
                ValidateRestResponse(response);
            }
            catch (MagResponseParsingFailureException rpf)
            {
                throw new MagVixFailureException("Could not serialize preferences.", rpf);
            }
            catch (MagVixFailureException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MagVixFailureException("Could not complete request to save preferences.", ex);
            }
        }
        /// <summary>
        /// Save supplementary report to VistA
        /// </summary>
        /// <param name="caseURN">Case ID</param>
        /// <param name="datetime">Date time of the supplementary report</param>
        /// <param name="verified">verify the report or not</param>
        /// <param name="data">report content</param>
        public void SaveSupReport(string caseURN, string datetime, bool verified, string data)
        {
            Log.Debug("Saving supplementary report...");

            if (string.IsNullOrWhiteSpace(caseURN))
            {
                throw new MagVixFailureException("Missing parameter: caseURN.");
            }

            if (string.IsNullOrWhiteSpace(datetime))
            {
                throw new MagVixFailureException("Missing parameter: supplementary report date.");
            }

            if (string.IsNullOrWhiteSpace(data))
            {
                throw new MagVixFailureException("Missing parameter: report data");
            }

            string URI = String.Format("pathology/case/supplementalreport/{0}/{1}/{2}", caseURN, datetime, verified);
            IRestResponse response;
            try
            {
                RestStringType supRep = new RestStringType() { Value = data };
                string changes = ResponseParser.SerializeToXml<RestStringType>(supRep);
                response = ExecutePost(URI, VixServiceTypes.Pathology, changes);
                ValidateRestResponse(response);
            }
            catch (MagResponseParsingFailureException rpf)
            {
                throw new MagVixFailureException("Failed to serialize report data.", rpf);
            }
            catch (MagVixFailureException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MagVixFailureException("Could not complete request to save supplementary report.", ex);
            }
        }
        /// <summary>
        /// Save case note to vista
        /// </summary>
        /// <param name="caseURN">case id</param>
        /// <param name="notes">notes to be saved</param>
        public void SaveNotes(string caseURN, string notes)
        {
            Log.Debug("Saving notes for case...");

            if (string.IsNullOrWhiteSpace(caseURN))
            {
                throw new MagVixFailureException("Missing parameter: caseURN.");
            }

            if (notes == null)
            {
                throw new MagVixFailureException("Missing parameter: notes.");
            }

            string URI = String.Format("pathology/case/note/{0}", caseURN);
            IRestResponse response;
            try
            {
                RestStringType notesType = new RestStringType() { Value = notes };
                string body = ResponseParser.SerializeToXml<RestStringType>(notesType);
                response = ExecutePost(URI, VixServiceTypes.Pathology, body);
                ValidateRestResponse(response);
            }
            catch (MagResponseParsingFailureException rpf)
            {
                throw new MagVixFailureException("Cannot serialize notes.", rpf);
            }
            catch (MagVixFailureException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MagVixFailureException("Could not complete request to save notes.", ex);
            }
        }