Example #1
0
        private CdaDocumentData GetDocumentData(DsioCdaDocument dsioDoc)
        {
            // *** Gets strongly typed Cda data from Dsio data ***
            CdaDocumentData returnDocument = new CdaDocumentData();

            // *** Convert Create Date to DateTime ***
            //CultureInfo enUS = new CultureInfo("en-US");
            //DateTime tempDateTime;
            //if (DateTime.TryParseExact(dsioDoc.CreatedOn, RepositoryDates.VistADateFormatOne, enUS, DateTimeStyles.None, out tempDateTime))
            //    returnDocument.CreationDateTime = tempDateTime;
            returnDocument.CreationDateTime = VistaDates.ParseDateString(dsioDoc.CreatedOn, VistaDates.VistADateFormatFour);

            // *** Convert Import/Export to DateTime ***
            //if (DateTime.TryParseExact(dsioDoc.ImportExportDate, RepositoryDates.VistADateFormatOne, enUS, DateTimeStyles.None, out tempDateTime))
            //    returnDocument.ImportDateTime = tempDateTime;
            returnDocument.ImportDateTime = VistaDates.ParseDateString(dsioDoc.ImportExportDate, VistaDates.VistADateFormatFour);

            // *** Get index of value which will match enum ***
            int idx = Array.IndexOf(CdaUtility.DocumentTypeAbbreviation, dsioDoc.DocumentType);

            // *** Convert to enum ***
            if (idx > -1)
            {
                returnDocument.DocumentType = (IheDocumentType)idx;
            }

            // *** Determine if in/out ***
            returnDocument.ExchangeDirection = (dsioDoc.Direction == "IN") ? ExchangeDirection.Inbound : ExchangeDirection.Outbound;

            // *** Populate id's as is ***
            returnDocument.Id  = dsioDoc.Id;
            returnDocument.Ien = dsioDoc.Ien;

            // *** Populate as is ***
            returnDocument.IntendedRecipient = dsioDoc.IntendedRecipient;
            returnDocument.Sender            = dsioDoc.Sender;
            returnDocument.Title             = dsioDoc.Title;

            return(returnDocument);
        }
        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);
            }
        }