private void Line_TouchActivated(object sender, TouchArgs e)
        {
            if (widgetTouchId != Touch.NO_ID)
            {
                // get out of here if we are touching the widgets
                return;
            }

            SelectableLine line = (SelectableLine)sender;
            if (lineArtifactDictionary.ContainsKey(line) == true)
            {
                // container is only highlighted if we are not using the timeline widgets
                highlightedContainer = lineArtifactDictionary[line];
            }

            //Console.WriteLine("line was touched with id " + e.TouchId);
            //SelectableLine line = (SelectableLine)sender;
            //line.Color = Color.Black;
            //line.Selected = true;
        }
        private void library_SelectedArtifactChanged(Artifact selectedArtifact)
        {
            TimelineContainer newContainer = null;
            // change the selected artifact
            foreach (TimelineContainer container in timelineArtifactList)
            {
                if (container.Artifact == selectedArtifact)
                {
                    newContainer = container;
                    break;
                }
            }
            if (newContainer == null)
            {
                return;
            }

            if (selectedContainer != null)
            {
                // deselect the current selected artifact
                selectedContainer.Selected = false;
                selectedContainer.TopCurve.Alpha = ALPHA_RELATED;
                selectedContainer.BottomCurve.Alpha = ALPHA_RELATED;
            }

            // update the selected container
            selectedContainer = newContainer;

            // and change it's status to being selected
            selectedContainer.Selected = true;
            selectedContainer.TopCurve.Alpha = ALPHA_SELECTED;
            selectedContainer.BottomCurve.Alpha = ALPHA_SELECTED;

            // since something was just selected, nothing is highlighted
            highlightedContainer = null;
        }
        public TimelineView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            this.position = position;
            this.size = size;

            // create left and right white fadeouts
            leftWhiteVertices = new VertexPositionColor[6];
            leftWhiteVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.White);
            leftWhiteVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            leftWhiteVertices[2] = new VertexPositionColor(new Vector3(0.005f, 0, 0), Color.Transparent);
            leftWhiteVertices[3] = new VertexPositionColor(new Vector3(0.005f, 1, 0), Color.Transparent);
            leftWhiteVertices[4] = new VertexPositionColor(new Vector3(0, 1, 0), Color.White);
            leftWhiteVertices[5] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.White);
            rightWhiteVertices = new VertexPositionColor[6];
            rightWhiteVertices[0] = new VertexPositionColor(new Vector3(1 - 0.005f, 0, 0), Color.Transparent);
            rightWhiteVertices[1] = new VertexPositionColor(new Vector3(1, 0, 0), Color.White);
            rightWhiteVertices[2] = new VertexPositionColor(new Vector3(3, 0, 0), Color.White);
            rightWhiteVertices[3] = new VertexPositionColor(new Vector3(3, 1, 0), Color.White);
            rightWhiteVertices[4] = new VertexPositionColor(new Vector3(1, 1, 0), Color.White);
            rightWhiteVertices[5] = new VertexPositionColor(new Vector3(1 - 0.005f, 1, 0), Color.Transparent);
            hexWhiteIndices = new int[12];
            hexWhiteIndices[0] = 0;
            hexWhiteIndices[1] = 1;
            hexWhiteIndices[2] = 4;
            hexWhiteIndices[3] = 4;
            hexWhiteIndices[4] = 5;
            hexWhiteIndices[5] = 0;
            hexWhiteIndices[6] = 1;
            hexWhiteIndices[7] = 2;
            hexWhiteIndices[8] = 3;
            hexWhiteIndices[9] = 3;
            hexWhiteIndices[10] = 4;
            hexWhiteIndices[11] = 1;
            // create left and right black quads
            leftBlackVertices = new VertexPositionColor[4];
            leftBlackVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.Black);
            leftBlackVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
            leftBlackVertices[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Black);
            leftBlackVertices[3] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.Black);
            rightBlackVertices = new VertexPositionColor[4];
            rightBlackVertices[0] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Black);
            rightBlackVertices[1] = new VertexPositionColor(new Vector3(3, 0, 0), Color.Black);
            rightBlackVertices[2] = new VertexPositionColor(new Vector3(3, 1, 0), Color.Black);
            rightBlackVertices[3] = new VertexPositionColor(new Vector3(1, 1, 0), Color.Black);
            quadBlackIndices = new int[6];
            quadBlackIndices[0] = 0;
            quadBlackIndices[1] = 1;
            quadBlackIndices[2] = 2;
            quadBlackIndices[3] = 2;
            quadBlackIndices[4] = 3;
            quadBlackIndices[5] = 0;

            titleText = new SelectableText(XNA.Font, "Timeline", new Vector3(0.4f, 0, 0), bookshelf.GlobalTextColor, Color.White);
            titleText.InverseScale(0.8f, size.X, size.Y);

            // arrays to hold tick marks for each timeline
            catalogTicks = new List<TimelineYearTick>();
            useTicks = new List<TimelineYearTick>();
            manufactureTicks = new List<TimelineYearTick>();

            // create a line for each timeline, these will not be interactive elements
            catalogLine = new SelectableLine(new Vector3(0, catalogLineHeight, 0), new Vector3(1, catalogLineHeight, 0), Color.LightGray, lineThickness);
            useLine = new SelectableLine(new Vector3(0, useLineHeight, 0), new Vector3(1, useLineHeight, 0), Color.LightGray, lineThickness);
            manufactureLine = new SelectableLine(new Vector3(0, manufactureLineHeight, 0), new Vector3(1, manufactureLineHeight, 0), Color.LightGray, lineThickness);

            // underneath each timeline, there are three widgets to control zooming and traversing
            catalogWidgets = new SelectableLine[3];
            useWidgets = new SelectableLine[3];
            manufactureWidgets = new SelectableLine[3];
            for (int i = 0; i < 3; i++)
            {
                // create interactive elements and add them to the object manager
                catalogWidgets[i] = new SelectableLine(new Vector3((float)i / 3, catalogLineHeight, 0), new Vector3((float)(i + 1) / 3, catalogLineHeight, 0), new Color(i * 255 / 2, 0, 0), lineThickness * 2);
                useWidgets[i] = new SelectableLine(new Vector3((float)i / 3, useLineHeight, 0), new Vector3((float)(i + 1) / 3, useLineHeight, 0), new Color(0, i * 255 / 2, 0), lineThickness * 2);
                manufactureWidgets[i] = new SelectableLine(new Vector3((float)i / 3, manufactureLineHeight, 0), new Vector3((float)(i + 1) / 3, manufactureLineHeight, 0), new Color(0, 0, i * 255 / 2), lineThickness * 2);
                catalogWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                useWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                manufactureWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                bookshelf.SelectableObjects.AddObject(catalogWidgets[i]);
                bookshelf.SelectableObjects.AddObject(useWidgets[i]);
                bookshelf.SelectableObjects.AddObject(manufactureWidgets[i]);
            }

            // the circles are test objects to show how the timeline range is being manipulated
            catalogCircles = new SelectableEllipse[2];
            useCircles = new SelectableEllipse[2];
            manufactureCircles = new SelectableEllipse[2];
            // these arrays store the left/right for each timeline, along with a left/right offset that is used as a temp variable
            // the order is: L_RANGE, L_OFFSET, R_RANGE, R_OFFSET
            catalogTimelineRange = new float[4] { 0, 0, 1, 1 };
            useTimelineRange = new float[4] { 0, 0, 1, 1 };
            manufactureTimelineRange = new float[4] { 0, 0, 1, 1 };
            catalogCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            catalogCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            useCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            useCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            manufactureCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            manufactureCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);

            topSorted = new List<KeyValuePair<TimelineContainer, float>>();
            bottomSorted = new List<KeyValuePair<TimelineContainer, float>>();

            timelineArtifactList = new List<TimelineContainer>();
            lineArtifactDictionary = new Dictionary<SelectableLine, TimelineContainer>();
            selectedContainer = null;
            highlightedContainer = null;
            relatedContainers = new List<TimelineContainer>();
            InitializeTimelineList();

            animationTimer = new Timer(0.5f);
            animationTimer.FinishEvent += new TimerFinished(AnimationTimerFinished);
        }
        private void InitializeTimelineList()
        {
            catalogMinYear = 10000;
            catalogMaxYear = -10000;
            useMinYear = 10000;
            useMaxYear = -10000;
            manuMinYear = 10000;
            manuMaxYear = -10000;

            foreach (Artifact artifact in bookshelf.Library.Artifacts)
            {
                TimelineContainer newContainer = new TimelineContainer();
                newContainer.Artifact = artifact;

                Color diminishedColor = artifact.Color;
                diminishedColor.A = (byte)(ALPHA_RELATED * 255);

                newContainer.TopCurve = new SelectableCurve(diminishedColor);
                newContainer.BottomCurve = new SelectableCurve(diminishedColor);
                bookshelf.SelectableObjects.AddObject(newContainer.TopCurve);
                bookshelf.SelectableObjects.AddObject(newContainer.BottomCurve);

                float selectableLineThickness = 0.0075f;
                newContainer.TopLine = new SelectableLine(new Vector3(0, catalogLineHeight + lineThickness / 2, 0), new Vector3(0, useLineHeight - lineThickness / 2, 0), Color.LightGray, selectableLineThickness);
                newContainer.TopLine.TouchActivated += new TouchActivatedEventHandler(Line_TouchActivated);
                newContainer.TopLine.TouchReleased += new TouchReleaseEventHandler(Line_TouchReleased);
                newContainer.BottomLine = new SelectableLine(new Vector3(0, useLineHeight + lineThickness / 2, 0), new Vector3(0, manufactureLineHeight - lineThickness / 2, 0), Color.LightGray, selectableLineThickness);
                newContainer.BottomLine.TouchActivated += new TouchActivatedEventHandler(Line_TouchActivated);
                newContainer.BottomLine.TouchReleased += new TouchReleaseEventHandler(Line_TouchReleased);
                //newContainer.BottomLine.TouchActivated += new TouchActivatedEventHandler(Line_TouchActivated);
                bookshelf.SelectableObjects.AddObject(newContainer.TopLine);
                bookshelf.SelectableObjects.AddObject(newContainer.BottomLine);

                float circleRadius = 0.02f;
                newContainer.Circle = new SelectableEllipse(Vector2.Zero, circleRadius, circleRadius * 0.05f, Color.White, new Color(1, 1, 1, 0), Color.Black, artifact.Texture);

                timelineArtifactList.Add(newContainer);
                lineArtifactDictionary.Add(newContainer.TopLine, newContainer);
                lineArtifactDictionary.Add(newContainer.BottomLine, newContainer);

                /*
                // don't bother checking the qualifier of the catalog date. we assume they are exact
                // check usedate qualifier
                switch (artifact.UseDate.DateQualifier)
                {
                    case VagueDate.Qualifier.Before:
                        newContainer.TopCurve.BottomLeftAlpha = 0;
                        newContainer.BottomCurve.TopLeftAlpha = 0;
                        break;
                    case VagueDate.Qualifier.After:
                        newContainer.TopCurve.BottomRightAlpha = 0;
                        newContainer.BottomCurve.TopRightAlpha = 0;
                        break;
                    case VagueDate.Qualifier.Circa:
                        //newContainer.TopCurve.BottomLeftAlpha = 0;
                        //newContainer.TopCurve.BottomRightAlpha = 0;
                        //newContainer.BottomCurve.TopLeftAlpha = 0;
                        //newContainer.BottomCurve.TopRightAlpha = 0;
                        break;
                }
                switch (artifact.ManufactureDate.DateQualifier)
                {
                    case VagueDate.Qualifier.Before:
                        newContainer.BottomCurve.BottomLeftAlpha = 0;
                        break;
                    case VagueDate.Qualifier.After:
                        newContainer.BottomCurve.BottomRightAlpha = 0;
                        break;
                    case VagueDate.Qualifier.Circa:
                        //newContainer.BottomCurve.BottomLeftAlpha = 0;
                        //newContainer.BottomCurve.BottomRightAlpha = 0;
                        break;
                }
                //*/

                float useLength = newContainer.Artifact.UseDate.EndYear + newContainer.Artifact.UseDate.EndError - newContainer.Artifact.UseDate.StartYear - newContainer.Artifact.UseDate.StartError;
                float manuLength = newContainer.Artifact.ManufactureDate.EndYear + newContainer.Artifact.ManufactureDate.EndError - newContainer.Artifact.ManufactureDate.StartYear - newContainer.Artifact.ManufactureDate.StartError;
                topSorted.Add(new KeyValuePair<TimelineContainer, float>(newContainer, useLength));
                bottomSorted.Add(new KeyValuePair<TimelineContainer, float>(newContainer, (useLength + manuLength) / 2));

                // update catalog year limits
                if (artifact.CatalogDate.StartYear < catalogMinYear)
                {
                    catalogMinYear = artifact.CatalogDate.StartYear;
                }
                if (catalogMaxYear < artifact.CatalogDate.EndYear)
                {
                    catalogMaxYear = artifact.CatalogDate.EndYear;
                }
                // update manu year limits
                if (artifact.ManufactureDate.StartYear < manuMinYear)
                {
                    manuMinYear = artifact.ManufactureDate.StartYear;
                }
                if (manuMaxYear < artifact.ManufactureDate.EndYear)
                {
                    manuMaxYear = artifact.ManufactureDate.EndYear;
                }
                // update use year limits
                if (artifact.UseDate.StartYear < useMinYear)
                {
                    useMinYear = artifact.UseDate.StartYear;
                }
                if (useMaxYear < artifact.UseDate.EndYear)
                {
                    useMaxYear = artifact.UseDate.EndYear;
                }
            }

            topSorted.Sort(CompareTimelineArea);
            bottomSorted.Sort(CompareTimelineArea);

            // initialize the catalog timeline ticks
            catalogMinYear = ((int)catalogMinYear / 10) * 10; // round down to the nearest 10
            catalogMaxYear = ((int)catalogMaxYear / 10 + 1) * 10; // round UP to the nearest 10
            for (int i = (int)catalogMinYear; i <= catalogMaxYear; i++)
            {
                Color color;
                if (i % 10 == 0)
                {
                    color = Color.Black;
                }
                else if (i % 5 == 0)
                {
                    color = Color.DimGray;
                }
                else
                {
                    color = Color.DarkGray;
                }
                TimelineYearTick catalogTick = new TimelineYearTick(i, color);
                catalogTick.TickText.InverseScale(0.35f, size.X, size.Y);
                catalogTicks.Add(catalogTick);
            }
            catalogTickSkipScale = ComputeTickScale(catalogTicks.Count, 1, 40, 80, 200);

            // initialize the use timeline ticks
            useMinYear = ((int)useMinYear / 10) * 10; // round down to the nearest 10
            useMaxYear = ((int)useMaxYear / 10 + 1) * 10; // round UP to the nearest 10
            for (int i = (int)useMinYear; i <= useMaxYear; i++)
            {
                // only handle multiples of 5 (ignore 1s)
                if (i % 5 != 0)
                {
                    useTicks.Add(null);
                    continue;
                }

                Color color;
                if (i % 10 == 0)
                {
                    color = Color.Black;
                }
                else if (i % 5 == 0)
                {
                    color = Color.DimGray;
                }
                else
                {
                    color = Color.DarkGray;
                }
                TimelineYearTick useTick = new TimelineYearTick(i, color);
                useTick.TickText.InverseScale(0.35f, size.X, size.Y);
                useTicks.Add(useTick);
            }
            useTickSkipScale = ComputeTickScale(useTicks.Count, 5, 40, 80, 200);

            // manufacture ticks
            manuMinYear = ((int)manuMinYear / 10) * 10; // round down to the nearest 10
            manuMaxYear = ((int)manuMaxYear / 10 + 1) * 10; // round UP to the nearest 10
            for (int i = (int)manuMinYear; i <= manuMaxYear; i+=5)
            {
                Color color;
                if (i % 10 == 0)
                {
                    color = Color.Black;
                }
                else if (i % 5 == 0)
                {
                    color = Color.DimGray;
                }
                else
                {
                    color = Color.DarkGray;
                }
                TimelineYearTick manuTick = new TimelineYearTick(i, color);
                manuTick.TickText.InverseScale(0.35f, size.X, size.Y);
                manufactureTicks.Add(manuTick);
            }
            manufactureTickSkipScale = ComputeTickScale(manufactureTicks.Count, 5, 40, 80, 200);

            UpdateTopCurves();
            UpdateBottomCurves();
        }
        void Line_TouchReleased(object sender, TouchArgs e)
        {
            if (widgetTouchId != Touch.NO_ID)
            {
                // get out of here if we are touching the widgets
                return;
            }

            if (bookshelf.TouchPoints.ContainsKey(e.TouchId) == false)
            {
                // this touch release was caused by a touch up event, so the user has "SELECTED" a certain artifact
                SelectableLine line = (SelectableLine)sender;
                if (lineArtifactDictionary.ContainsKey(line) == true)
                {
                    TimelineContainer container = lineArtifactDictionary[line];
                    bookshelf.Library.SelectedArtifact = container.Artifact;
                }
            }
            else
            {
                // this touch release was caused by the user scrubbing over this line
                // start the fade timer
                highlightedContainer = null;
            }
        }
        public BaseResponse <CasesTimeline> QueryCasesTimeline(long feeNo, string startDate, string endDate, int tag)
        {
            BaseResponse <CasesTimeline> response = new BaseResponse <CasesTimeline>();
            CasesTimeline data = new CasesTimeline();

            data.TimelineContainer = new List <TimelineContainer>();
            data.FEENO             = feeNo;
            data.StartDate         = startDate;
            data.EndDate           = endDate;
            List <SwRegEvalPlan>      swPlan  = new List <SwRegEvalPlan>();
            List <DC_NursingPlanEval> nurPlan = new List <DC_NursingPlanEval>();

            if ((int)MajorType.护理照顾计划 == tag)
            {
                nurPlan = GetHisNursingPlanByDate(feeNo, startDate, endDate).OrderBy(x => x.EVALDATE.HasValue?x.EVALDATE.Value:DateTime.Now).ToList();
            }
            else if ((int)MajorType.社工照顾计划 == tag)
            {
                swPlan = GetHisSocialWokerPlanByDate(feeNo, startDate, endDate).OrderBy(x => x.EVALDATE.HasValue ? x.EVALDATE.Value : DateTime.Now).ToList();
            }
            else
            {
                nurPlan = GetHisNursingPlanByDate(feeNo, startDate, endDate).OrderBy(x => x.EVALDATE.HasValue ? x.EVALDATE.Value : DateTime.Now).ToList();
                swPlan  = GetHisSocialWokerPlanByDate(feeNo, startDate, endDate).OrderBy(x => x.EVALDATE.HasValue ? x.EVALDATE.Value : DateTime.Now).ToList();
            }
            TimelineContainer swContainer = new TimelineContainer();

            swContainer.MajorType = MajorType.社工照顾计划.ToString();
            swContainer.Timeline  = new List <Timeline>();
            swContainer.Tag       = (int)MajorType.社工照顾计划;

            TimelineContainer nurContainer = new TimelineContainer();

            nurContainer.MajorType = MajorType.护理照顾计划.ToString();
            nurContainer.Timeline  = new List <Timeline>();
            nurContainer.Tag       = (int)MajorType.护理照顾计划;

            foreach (SwRegEvalPlan plan in swPlan)
            {
                Timeline timeline = new Timeline();
                timeline.Title     = "需求类别";
                timeline.Title1    = "项目";
                timeline.Header1   = "问题描述";
                timeline.Header2   = "介入方式或资源连接";
                timeline.StartDate = plan.EVALDATE.HasValue ? FormattingDate(plan.EVALDATE.Value) : "";
                if (!string.IsNullOrEmpty(timeline.StartDate))
                {
                    timeline.Month = plan.EVALDATE.Value.Month.ToString();
                    timeline.Day   = plan.EVALDATE.Value.Day.ToString();
                }
                timeline.Plan = new List <TimelineText>();
                timeline.Plan = (from task in plan.TaskGoalsStrategyModel.AsEnumerable()
                                 select new TimelineText
                {
                    MAJORTYPE = "社工",
                    CPDIA = task.CPDIA,
                    QUESTIONDESC = task.QUESTIONDESC,
                    QUESTIONTYPE = task.QUESTIONTYPE,
                    ACTIVITY = new List <string>()
                    {
                        task.PLANACTIVITY
                    },
                }).ToList();

                swContainer.Timeline.Add(timeline);
            }

            foreach (DC_NursingPlanEval plan in nurPlan)
            {
                Timeline timeline = new Timeline();
                timeline.Title     = "评估结果";
                timeline.Header1   = "护理诊断";
                timeline.Header2   = "措施";
                timeline.StartDate = plan.EVALDATE.HasValue ? FormattingDate(plan.EVALDATE.Value) : "";
                if (!string.IsNullOrEmpty(timeline.StartDate))
                {
                    timeline.Month = plan.EVALDATE.Value.Month.ToString();
                    timeline.Day   = plan.EVALDATE.Value.Day.ToString();
                }
                timeline.Plan = new List <TimelineText>();
                if (plan.evalQuetion != null && plan.evalQuetion.Count > 0)
                {
                    for (int i = 0; i < plan.evalQuetion.Count; i++)
                    {
                        if (plan.evalQuetion[i].QUESTIONCODE == "ADL")
                        {
                            timeline.ADLSCORE = plan.evalQuetion[i].SCORE == null ? "尚未评估" : plan.evalQuetion[i].SCORE.ToString() + "分";
                        }
                        else if (plan.evalQuetion[i].QUESTIONCODE == "GDS")
                        {
                            timeline.GODSSCORE = plan.evalQuetion[i].SCORE == null ? "尚未评估" : plan.evalQuetion[i].SCORE.ToString() + "分";
                        }
                        else if (plan.evalQuetion[i].QUESTIONCODE == "IADL")
                        {
                            timeline.IADLSCORE = plan.evalQuetion[i].SCORE == null ? "尚未评估" : plan.evalQuetion[i].SCORE.ToString() + "分";
                        }
                        else if (plan.evalQuetion[i].QUESTIONCODE == "MMSE")
                        {
                            timeline.MMSESCORE = plan.evalQuetion[i].SCORE == null ? "尚未评估" : plan.evalQuetion[i].SCORE.ToString() + "分";
                        }
                    }
                }


                if (plan.regCpl != null && plan.regCpl.Count > 0)
                {
                    timeline.Plan = (from task in plan.regCpl.AsEnumerable()
                                     select new TimelineText
                    {
                        MAJORTYPE = "护理",
                        QUESTIONTYPE = task.CPDIA,
                        ACTIVITY = task.NsCplActivity.Select(x => x.CplActivity).ToList()
                    }).ToList();
                }

                nurContainer.Timeline.Add(timeline);
            }
            string StartDate = "";

            if (swContainer.Timeline.OrderBy(x => x.StartDate).FirstOrDefault() != null)
            {
                int count        = swContainer.Timeline.Count();
                int midDateCount = count / 2;
                if (midDateCount > 0)
                {
                    StartDate = swContainer.Timeline[midDateCount].StartDate;
                }
                else
                {
                    StartDate = swContainer.Timeline[0].StartDate;
                }
            }
            if (nurContainer.Timeline.OrderBy(x => x.StartDate).FirstOrDefault() != null)
            {
                int count        = nurContainer.Timeline.Count();
                int midDateCount = count / 2;
                if (midDateCount > 0)
                {
                    StartDate = nurContainer.Timeline[midDateCount].StartDate;
                }
                else
                {
                    StartDate = nurContainer.Timeline[0].StartDate;
                }
            }

            data.StartDate = StartDate;
            if ((int)MajorType.社工照顾计划 == tag)
            {
                data.TimelineContainer.Add(swContainer);
            }
            else if ((int)MajorType.护理照顾计划 == tag)
            {
                data.TimelineContainer.Add(nurContainer);
            }
            else
            {
                data.TimelineContainer.Add(swContainer);
                data.TimelineContainer.Add(nurContainer);
            }
            response.Data = data;
            return(response);
        }