示例#1
0
        public CdaDocumentResult GetDocumentData(string id)
        {
            // *** Get data for a single document (Header and Content) ***

            CdaDocumentResult result = new CdaDocumentResult();

            // *** Check broker ***
            if (this.broker != null)
            {
                // *** Create the command ***
                //DsioIheGetDocCommand command = new DsioIheGetDocCommand(this.broker);
                DsioGetIheContentCommand contentCommand = new DsioGetIheContentCommand(this.broker);

                contentCommand.AddCommandArguments(id);

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

                // *** Record success/message ***
                result.Success = (response.Status == RpcResponseStatus.Success);
                result.Message = response.InformationalMessage;

                // *** If successful continue ***
                if (result.Success)
                {
                    if (contentCommand.Document != null)
                    {
                        // *** Hold the content ***
                        string tempContent = contentCommand.Document.Content;

                        DsioGetIheDocsCommand docCommand = new DsioGetIheDocsCommand(this.broker);

                        docCommand.AddCommandArguments("", id, -1, -1);

                        // *** Execute the command ***
                        response = docCommand.Execute();

                        // *** Add results to return ***
                        result.Success = (response.Status == RpcResponseStatus.Success);
                        result.Message = response.InformationalMessage;

                        // *** If successful continue ***
                        if (result.Success)
                        {
                            if (docCommand.DocumentList != null)
                            {
                                if (docCommand.DocumentList.Count == 1)
                                {
                                    // *** Get the document (header) data ***
                                    result.DocumentData = GetDocumentData(docCommand.DocumentList[0]);

                                    // *** Add the content from previous call ***
                                    result.DocumentData.DocumentContent = tempContent;

                                    // *** Repopulate ien ***
                                    result.DocumentData.Ien = id;
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
        public void TestSaveAndRetrieve(string id)
        {
            using (RpcBroker broker = this.GetConnectedBroker())
            {
                this.SignonToBroker(broker, 2);

                DsioSaveIheDocCommand saveCommand = new DsioSaveIheDocCommand(broker);

                // TODO: Get content somewhere else...
                string content = File.ReadAllText(testFile);

                DateTime createdOn        = DateTime.Now;
                DateTime importExportDate = DateTime.Now;

                // This works...
                DsioCdaDocument doc = new DsioCdaDocument()
                {
                    Ien               = "",
                    Id                = id,
                    PatientDfn        = "126",
                    Direction         = "OUT",
                    CreatedOn         = createdOn.ToString(VistaDates.VistADateFormatFour),
                    ImportExportDate  = importExportDate.ToString(VistaDates.VistADateFormatFour),
                    DocumentType      = "APS",
                    Title             = "Test Title",
                    Sender            = "Test Sender",
                    IntendedRecipient = "Test Recipient",
                    Content           = content
                };

                //saveCommand.AddCommandArguments("", "12345", "715", "OUT", DateTime.Now.ToString(), DateTime.Now.ToString(), "APS", "This is a Test Title", "VA", "Outside Clinic", content);
                saveCommand.AddCommandArguments(
                    doc.Ien, doc.Id, doc.PatientDfn, doc.Direction,
                    doc.CreatedOn, doc.ImportExportDate, doc.DocumentType,
                    doc.Title, doc.Sender, doc.IntendedRecipient, doc.Content);

                RpcResponse response = saveCommand.Execute();

                Assert.IsNotNull(response);
                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsFalse(string.IsNullOrWhiteSpace(saveCommand.Ien));

                string ien = saveCommand.Ien;

                //DsioIheGetDocCommand getCommand = new DsioIheGetDocCommand(broker);
                DsioGetIheDocsCommand getCommand = new DsioGetIheDocsCommand(broker);

                getCommand.AddCommandArguments("", ien, -1, -1);

                response = getCommand.Execute();

                Assert.IsNotNull(response);
                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsNotNull(getCommand.DocumentList);
                Assert.IsTrue(getCommand.DocumentList.Count > 0);
                Assert.AreEqual(doc.Id, getCommand.DocumentList[0].Id);
                Assert.AreEqual(doc.PatientDfn, getCommand.DocumentList[0].PatientDfn);
                Assert.AreEqual(doc.Direction, getCommand.DocumentList[0].Direction);

                string expectedDate = createdOn.ToString("MM/dd/yyyy@HH:mm:ss").ToUpper();
                Assert.AreEqual(expectedDate, getCommand.DocumentList[0].CreatedOn);

                expectedDate = importExportDate.ToString("MM/dd/yyyy@HH:mm:ss").ToUpper();
                Assert.AreEqual(expectedDate, getCommand.DocumentList[0].ImportExportDate);

                Assert.AreEqual(doc.DocumentType, getCommand.DocumentList[0].DocumentType);
                Assert.AreEqual(doc.Title, getCommand.DocumentList[0].Title);
                Assert.AreEqual(doc.Sender, getCommand.DocumentList[0].Sender);
                Assert.AreEqual(doc.IntendedRecipient, getCommand.DocumentList[0].IntendedRecipient);

                DsioGetIheContentCommand contentCommand = new DsioGetIheContentCommand(broker);

                contentCommand.AddCommandArguments(ien);

                response = contentCommand.Execute();

                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsNotNull(contentCommand.Document);
                //Assert.AreEqual(contentCommand.Document.Content, content);
            }
        }