コード例 #1
0
        public AddBabyResult AddBabyToPregnancy(string patientDfn, string pregnancyIen)
        {
            AddBabyResult returnResult = new AddBabyResult();

            PregnancyListResult pregResult = this.GetPregnancies(patientDfn, pregnancyIen);

            if (!pregResult.Success)
            {
                returnResult.SetResult(pregResult.Success, pregResult.Message);
            }
            else if (pregResult.Pregnancies != null)
            {
                if (pregResult.Pregnancies.Count == 1)
                {
                    PregnancyDetails pregDetail = pregResult.Pregnancies[0];

                    bool okToAdd = true;

                    // *** Do we have a babies object ? ***
                    if (pregDetail.Babies != null)
                    {
                        if (pregDetail.Babies.Count >= 9)
                        {
                            returnResult.SetResult(false, "This pregnancy already has 9 babies.  You cannot add more than 9 babies to a pregnancy.");
                            okToAdd = false;
                        }
                    }

                    if (okToAdd)
                    {
                        // *** Create the save command ***
                        DsioSavePregDetailsCommand saveCommand = new DsioSavePregDetailsCommand(this.broker);

                        // *** Create the dsio pregnancy ***
                        DsioPregnancy dsioPreg = CreateDsioPregnancy(pregDetail);

                        // *** Add the command arguments, addBaby = true ***
                        saveCommand.AddCommandArguments(dsioPreg, true);

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

                        returnResult.SetResult(pregResult.Success, pregResult.Message);

                        // *** Check the status ***
                        if (response.Status == RpcResponseStatus.Success)
                        {
                            //int newBabyNum = -1;
                            //int.TryParse(saveCommand.BabyNumber, out newBabyNum);
                            //pregDetail.Babies.Add(new Baby() { BabyNum = newBabyNum, Ien = saveCommand.BabyIen });
                            returnResult.NewBabyIen    = saveCommand.BabyIen;
                            returnResult.NewBabyNumber = saveCommand.BabyNumber;
                        }
                    }
                }
            }

            return(returnResult);
        }
コード例 #2
0
        public PregnancyResult GetCurrentOrMostRecentPregnancy(string patientDfn)
        {
            // *** Returns the current pregnancy information ***

            PregnancyResult result = new PregnancyResult();

            // *** Get all pregnancies ***
            PregnancyListResult listResult = GetPregnancies(patientDfn, "");

            // *** Add results to return ***
            result.SetResult(listResult.Success, listResult.Message);

            if (result.Success)
            {
                // *** If we have pregnancies, look for a current ***
                if (listResult.Pregnancies != null)
                {
                    if (listResult.Pregnancies.Count > 0)
                    {
                        PregnancyDetails mostRecent = null;
                        foreach (PregnancyDetails preg in listResult.Pregnancies)
                        {
                            if (preg.RecordType == PregnancyRecordType.Current)
                            {
                                result.Pregnancy = preg;
                            }

                            if (mostRecent == null)
                            {
                                mostRecent = preg;
                            }
                            else if (mostRecent.EndDate < preg.EndDate)
                            {
                                mostRecent = preg;
                            }
                        }

                        if (result.Pregnancy == null)
                        {
                            if (mostRecent != null)
                            {
                                result.Pregnancy = mostRecent;
                            }
                        }
                    }
                }

                // *** Add result/message if no current ***
                if (result.Pregnancy == null)
                {
                    result.SetResult(true, "No Pregnancy Data Found");
                }
            }

            return(result);
        }
コード例 #3
0
        public PregnancyListResult GetPregnancies(string patientDfn, string pregnancyIen)
        {
            PregnancyListResult result = new PregnancyListResult();

            // *** Create the command ***
            DsioGetPregDetailsCommand command = new DsioGetPregDetailsCommand(this.broker);

            // *** Add arguments...gets all ***
            command.AddCommandArguments(patientDfn, pregnancyIen);

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

            // *** Add response to result ***
            result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

            // *** Check for success ***
            if (result.Success)
            {
                // *** Loop through the list and create strongly typed pregnancy list ***
                if (command.PregnancyList != null)
                {
                    foreach (DsioPregnancy dsioPreg in command.PregnancyList)
                    {
                        if (result.Pregnancies == null)
                        {
                            result.Pregnancies = new List <PregnancyDetails>();
                        }

                        PregnancyDetails tempPregnancy = CreatePregnancy(dsioPreg);

                        result.Pregnancies.Add(tempPregnancy);
                    }
                }

                // *** If no pregnancies, then nothing found ***
                if (result.Pregnancies == null)
                {
                    result.SetResult(true, "No Pregnancy Data Found");
                }
            }

            return(result);
        }