public IenResult SavePerson(string patientDfn, Person person)
        {
            // *** Performs operations to save the FOF ***

            IenResult result = new IenResult();

            if (this.broker != null)
            {
                // *** Create the command ***

                DsioSavePersonCommand command = new DsioSavePersonCommand(this.broker);

                // *** Get the linked person ***
                DsioLinkedPerson dsioFof = GetDsioPerson(patientDfn, person);

                // *** Add as argument ***
                command.AddCommandArguments(dsioFof);

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

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

                if (result.Success)
                {
                    result.Ien = command.Ien;
                }
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Add command parameters to be passed into the RPC
        /// Add command parameters prior to calling "Execute"
        /// </summary>
        /// <param name="person"></param>
        public void AddCommandArguments(DsioLinkedPerson person)
        {
            // *** Telephone numbers ***
            List <string> telParamList = new List <string>();

            if (person.TelephoneList != null)
            {
                foreach (DsioTelephone tel in person.TelephoneList)
                {
                    telParamList.Add(tel.ToParam());
                }
            }

            //IEN,DFN,NAME,DOB,ADDR,PHONE,EDU,SEX,REL,STATUS,PROB

            // TODO: Implement other fields ? SEX, REL, STATUS, PROB

            this.CommandArgs = new object[]
            {
                person.Ien,
                person.PatientDfn,
                person.Name,
                person.DOB,
                person.Address.ToParameter(),
                telParamList.ToArray(),
                person.YearsSchool,
                "M"
            };
        }
        private DsioLinkedPerson GetDsioPerson(string patientDfn, Person person)
        {
            // *** Gets DSIO person from FOF ***

            DsioLinkedPerson dsioFof = new DsioLinkedPerson();

            // *** Set patient ***
            dsioFof.PatientDfn = patientDfn;

            // *** Set ID, may be empty ***
            dsioFof.Ien = person.Ien;

            // *** Format the name for VistA ***
            dsioFof.Name = string.Format("{0},{1}", person.LastName, person.FirstName);

            // *** Format the DOB for VistA ***
            if (person.DOB.HasValue)
            {
                dsioFof.DOB = person.DOB.Value.ToString(VistaDates.VistADateOnlyFormat);
            }

            // *** Create an address ***
            dsioFof.Address             = new DsioAddress();
            dsioFof.Address.StreetLine1 = person.Address.StreetAddress1;
            dsioFof.Address.StreetLine2 = person.Address.StreetAddress2;
            dsioFof.Address.City        = person.Address.City;
            dsioFof.Address.State       = person.Address.State;
            dsioFof.Address.ZipCode     = person.Address.ZipCode;

            // *** Add years of school ***
            dsioFof.YearsSchool = person.YearsSchool.ToString();

            // *** Add phone numbers ***

            if (!string.IsNullOrWhiteSpace(person.HomePhone))
            {
                dsioFof.TelephoneList.Add(new DsioTelephone()
                {
                    Number = person.HomePhone, Usage = DsioTelephone.HomePhoneUsage
                });
            }

            if (!string.IsNullOrWhiteSpace(person.WorkPhone))
            {
                dsioFof.TelephoneList.Add(new DsioTelephone()
                {
                    Number = person.WorkPhone, Usage = DsioTelephone.WorkPhoneUsage
                });
            }

            if (!string.IsNullOrWhiteSpace(person.MobilePhone))
            {
                dsioFof.TelephoneList.Add(new DsioTelephone()
                {
                    Number = person.MobilePhone, Usage = DsioTelephone.MobilePhoneUsage
                });
            }

            return(dsioFof);
        }
예제 #4
0
        public void TestSavePerson()
        {
            using (RpcBroker broker = this.GetConnectedBroker())
            {
                this.SignonToBroker(broker, 2);

                DsioSavePersonCommand command = new DsioSavePersonCommand(broker);

                DsioLinkedPerson fof = new DsioLinkedPerson();

                fof.PatientDfn = "715";

                DsioAddress addr = new DsioAddress();
                addr.StreetLine1 = "1234 Five Street";
                addr.StreetLine2 = "#3";
                addr.City        = "Seven";
                addr.State       = "SC";
                addr.ZipCode     = "90099";

                fof.Address = addr;

                List <DsioTelephone> telList = new List <DsioTelephone>();
                telList.Add(new DsioTelephone()
                {
                    Number = "800-800-8000", Usage = DsioTelephone.HomePhoneUsage
                });
                telList.Add(new DsioTelephone()
                {
                    Number = "900-900-9000", Usage = DsioTelephone.WorkPhoneUsage
                });
                telList.Add(new DsioTelephone()
                {
                    Number = "700-700-7000", Usage = DsioTelephone.MobilePhoneUsage
                });

                fof.TelephoneList.AddRange(telList);

                string temp = Guid.NewGuid().ToString();

                // TODO: Need random name generator to test this successfully repeatedly...
                fof.Name        = "Test,NamedOB";// +Guid.NewGuid().ToString();
                fof.DOB         = DateTime.Now.Subtract(new TimeSpan(10000, 0, 0, 0)).ToShortDateString();
                fof.YearsSchool = "18";

                command.AddCommandArguments(fof);

                RpcResponse response = command.Execute();

                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
            }
        }
        public void TestAndRetrievePerson()
        {
            using (RpcBroker broker = this.GetConnectedBroker())
            {
                this.SignonToBroker(broker, 2);

                // *** First save the person ***

                DsioSavePersonCommand command = new DsioSavePersonCommand(broker);

                DsioLinkedPerson person = new DsioLinkedPerson()
                {
                    PatientDfn = TestConfiguration.DefaultPatientDfn,
                    Name       = "Third, Today"
                };

                command.AddCommandArguments(person);
                RpcResponse response = command.Execute();
                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsNotNull(command.Ien);

                // *** Then get by ien ***
                DsioGetPersonCommand getCommand = new DsioGetPersonCommand(broker);
                getCommand.AddCommandArguments("", command.Ien);
                response = getCommand.Execute();
                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsNotNull(getCommand.PersonList);
                Assert.IsTrue(getCommand.PersonList.Count > 0);
                Assert.AreEqual(person.Name, getCommand.PersonList[0].Name);
                Assert.AreEqual(person.PatientDfn, getCommand.PersonList[0].PatientDfn);

                // *** Then get by patient ***
                getCommand.PersonList.Clear();
                getCommand.AddCommandArguments(person.PatientDfn, "");
                response = getCommand.Execute();
                Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                Assert.IsNotNull(getCommand.PersonList);
                Assert.IsTrue(getCommand.PersonList.Count > 0);
                //Assert.AreEqual(person.Name, getCommand.PersonList[0].Name);
                //Assert.AreEqual(person.PatientDfn, getCommand.PersonList[0].PatientDfn);
            }
        }
        public void TestSaveBadPerson()
        {
            using (RpcBroker broker = this.GetConnectedBroker())
            {
                this.SignonToBroker(broker, 2);

                DsioSavePersonCommand command = new DsioSavePersonCommand(broker);

                DsioLinkedPerson fof = new DsioLinkedPerson();

                DsioAddress addr = new DsioAddress();
                addr.StreetLine1 = "1234 Five Street";
                addr.City        = "Six";
                addr.State       = "SC";
                addr.ZipCode     = "90099";

                fof.Address = addr;

                List <DsioTelephone> telList = new List <DsioTelephone>();
                telList.Add(new DsioTelephone()
                {
                    Number = "800-800-8000", Usage = DsioTelephone.HomePhoneUsage
                });
                telList.Add(new DsioTelephone()
                {
                    Number = "900-900-9000", Usage = DsioTelephone.WorkPhoneUsage
                });
                telList.Add(new DsioTelephone()
                {
                    Number = "700-700-7000", Usage = DsioTelephone.MobilePhoneUsage
                });

                fof.TelephoneList.AddRange(telList);

                command.AddCommandArguments(fof);

                RpcResponse response = command.Execute();

                Assert.AreEqual(RpcResponseStatus.Fail, response.Status);
            }
        }
        private Person GetPerson(DsioLinkedPerson dsioPerson)
        {
            // *** Translates a dsio person to a strongly typed Person ***

            Person newPerson = new Person();

            // ** Parse the name ***
            newPerson.LastName  = Util.Piece(dsioPerson.Name, ",", 1);
            newPerson.FirstName = Util.Piece(dsioPerson.Name, ",", 2);

            // *** Ien ***
            newPerson.Ien = dsioPerson.Ien;

            // *** Spouse ***
            if (dsioPerson.Ien == "S")
            {
                newPerson.Spouse = true;
            }

            // *** Use standard DOB format ***
            DateTime tempDate = VistaDates.ParseDateString(dsioPerson.DOB, VistaDates.VistADateOnlyFormat);

            if (tempDate != DateTime.MinValue)
            {
                newPerson.DOB = tempDate;
            }

            // *** Years school ***
            int yrs = -1;

            if (int.TryParse(dsioPerson.YearsSchool, out yrs))
            {
                newPerson.YearsSchool = yrs;
            }

            // *** Address ***
            newPerson.Address = new Address();
            newPerson.Address.StreetAddress1 = dsioPerson.Address.StreetLine1;
            newPerson.Address.StreetAddress2 = dsioPerson.Address.StreetLine2;
            newPerson.Address.City           = dsioPerson.Address.City;
            newPerson.Address.State          = dsioPerson.Address.State;
            newPerson.Address.ZipCode        = dsioPerson.Address.ZipCode;

            // *** Loop through telephone numbers and add ***
            foreach (DsioTelephone tel in dsioPerson.TelephoneList)
            {
                switch (tel.Usage)
                {
                case DsioTelephone.HomePhoneUsage:
                    newPerson.HomePhone = tel.Number;
                    break;

                case DsioTelephone.WorkPhoneUsage:
                    newPerson.WorkPhone = tel.Number;
                    break;

                case DsioTelephone.MobilePhoneUsage:
                    newPerson.MobilePhone = tel.Number;
                    break;
                }
            }

            return(newPerson);
        }