public void TestGetProgNotes()
        {
            using (RpcBroker broker = GetConnectedBroker())
            {
                this.SignonToBroker(broker, 2);

                TiuDocumentsByContextCommand command = new TiuDocumentsByContextCommand(broker);

                command.AddCommandArgument(TestConfiguration.DefaultPatientDfn);

                RpcResponse response = command.Execute();

                Assert.AreEqual(RpcResponseStatus.Success, response.Status);

                broker.Disconnect();
            }
        }
        //public TiuNoteResult GetLatestProgressNote(string dfn)
        //{
        //    // *** Get latest progress note ***

        //    TiuNoteResult result = new TiuNoteResult();

        //    // *** Check broker ***
        //    if (this.broker != null)
        //    {
        //        // *** Create command to get documents ***
        //        TiuDocumentsByContextCommand command = new TiuDocumentsByContextCommand(this.broker);

        //        // *** Add parameter ***
        //        command.AddCommandArgument(dfn);

        //        // *** Execute command ***
        //        RpcResponse response = command.Execute();

        //        // *** Set return vals ***
        //        result.Success = (response.Status == RpcResponseStatus.Success);
        //        result.Message = response.InformationalMessage;

        //        // *** Check for success ***
        //        if (result.Success)
        //        {
        //            TiuNote latestNote = null;

        //            // *** Check if we have any and loop ***
        //            if (command.Documents != null)
        //                foreach (TiuDocument doc in command.Documents)
        //                {
        //                    // *** Set latest if needed ***
        //                    if (latestNote == null)
        //                        latestNote = GetTiuNote(doc);
        //                    else
        //                    {
        //                        TiuNote tempNote = GetTiuNote(doc);

        //                        // *** Check if newer ***
        //                        if (tempNote.DocumentDateTime > latestNote.DocumentDateTime)
        //                            latestNote = tempNote;
        //                    }
        //                }

        //            // *** Check if we have one after loop ***
        //            if (latestNote != null)
        //            {
        //                // *** Set return ***
        //                result.Note = latestNote;

        //                // *** Create command to get note text ***
        //                TiuGetRecordTextCommand textCommand = new TiuGetRecordTextCommand(this.broker);

        //                // *** Add parameter ***
        //                textCommand.AddCommandArgument(latestNote.Ien);

        //                // *** Execute command ***
        //                response = textCommand.Execute();

        //                // *** Set return value ***
        //                result.Success = (response.Status == RpcResponseStatus.Success);
        //                result.Message = response.InformationalMessage;

        //                if (result.Success)
        //                    result.Note.NoteText = textCommand.RecordText;
        //            }
        //        }
        //    }

        //    return result;
        //}

        //private TiuNote GetTiuNote(TiuDocument document)
        //{
        //    // *** Create tiu note from tiu document ***

        //    TiuNote returnVal = new TiuNote();

        //    returnVal.Ien = document.Ien;
        //    returnVal.DocumentDateTime = Util.GetDateTime(document.DocumentDateTime);
        //    returnVal.Title = document.Title;

        //    return returnVal;
        //}

        //public HasProgressNoteResult HasProgressNote(string dfn)
        //{
        //    // *** Determine if patient has a progress note ***

        //    HasProgressNoteResult result = new HasProgressNoteResult();

        //    // *** Make sure we have broker ***
        //    if (this.broker != null)
        //    {
        //        // *** Create documents command ***
        //        TiuDocumentsByContextCommand command = new TiuDocumentsByContextCommand(this.broker);

        //        // *** Add parameter ***
        //        command.AddCommandArgument(dfn);

        //        // *** Execute command ***
        //        RpcResponse response = command.Execute();

        //        // *** Set return values ***
        //        result.Success = (response.Status == RpcResponseStatus.Success);
        //        result.Message = response.InformationalMessage;

        //        // *** Check result/command for prog notes ***
        //        if (result.Success)
        //            if (command.Documents != null)
        //                if (command.Documents.Count > 0)
        //                    result.HasProgressNote = true;
        //    }

        //    return result;
        //}

        //public TiuNoteResult GetProgressNote(string ien)
        //{
        //    TiuNoteResult result = new TiuNoteResult();

        //    // *** Set return ***
        //    //result.Note = latestNote;

        //    // *** Create command to get note text ***
        //    TiuGetRecordTextCommand textCommand = new TiuGetRecordTextCommand(this.broker);

        //    // *** Add parameter ***
        //    textCommand.AddCommandArgument(ien);

        //    // *** Execute command ***
        //    RpcResponse response = textCommand.Execute();

        //    // *** Set return value ***
        //    result.Success = (response.Status == RpcResponseStatus.Success);
        //    result.Message = response.InformationalMessage;

        //    result.Note = new TiuNote();

        //    if (result.Success)
        //        result.Note.NoteText = textCommand.RecordText;

        //    return result;
        //}

        public NoteListResult GetList(string dfn)
        {
            // *** Get list of progress notes ***

            NoteListResult result = new NoteListResult();

            // *** Check broker ***
            if (this.broker != null)
            {
                // *** Create command to get documents ***
                TiuDocumentsByContextCommand command = new TiuDocumentsByContextCommand(this.broker);

                // *** Add parameter ***
                command.AddCommandArgument(dfn);

                // *** Execute command ***
                RpcResponse response = command.Execute();

                // *** Set return vals ***
                result.Success = (response.Status == RpcResponseStatus.Success);
                result.Message = response.InformationalMessage;

                // *** Check for success ***
                if (result.Success)
                {
                    // *** Check if we have any and loop ***
                    if (command.Documents != null)
                    {
                        foreach (TiuDocument doc in command.Documents)
                        {
                            TiuNote note = GetTiuNote(doc);

                            note.PatientDfn = dfn;

                            result.Notes.Add(note);
                        }
                    }
                }
            }

            return(result);
        }