Example #1
0
        /// <summary>
        /// The get med ins state.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Response"/> .
        /// </returns>
        public Response GetMedInsState(Request request)
        {
            var rq = request.UIRRequest;

            try
            {
                var specFormat = DocumentNumSeparator.SeparateSpecFormat(rq.Document.DocIdent);
                var statement  = new Statement
                {
                    InsuredPersonData =
                        new InsuredPersonDatum
                    {
                        FirstName  = rq.FullName.FirstName,
                        LastName   = rq.FullName.FamilyName,
                        MiddleName = rq.FullName.MiddleName,
                        Birthday   = rq.Birth.BirthDate,
                        Birthplace = rq.Birth.BirthPlace
                    },
                    DocumentUdl = new Document
                    {
                        Series = specFormat[0],
                        Number = specFormat[1]
                    }
                };
                if (rq.InsDate != null)
                {
                    statement.MedicalInsurances = new[] { new MedicalInsurance {
                                                              DateFrom = rq.InsDate.Value
                                                          } };
                }

                return(new Response
                {
                    UIRResponse =
                        new UIRResponse
                    {
                        UIRQueryResponse = ResponseMaping(statement),
                        Ack = Ack.AA.ToString()
                    }
                });
            }
            catch (Exception ex)
            {
                return(new Response
                {
                    UIRResponse =
                        new UIRResponse
                    {
                        UIRQueryResponse = null,
                        Ack = Ack.AE.ToString(),
                        Err = new[] { new Err {
                                          ErrText = ex.Message
                                      } }
                    }
                });
            }
        }
Example #2
0
        /// <summary>
        /// The response maping.
        /// </summary>
        /// <param name="statement">
        /// The statement.
        /// </param>
        /// <returns>
        /// The <see cref="UIRResponseUIRQueryResponse[]"/>.
        /// </returns>
        private UIRResponseUIRQueryResponse[] ResponseMaping(Statement statement)
        {
            var session             = ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession();
            var conceptManager      = ObjectFactory.GetInstance <IConceptCacheManager>();
            var organisationManager = ObjectFactory.GetInstance <IOrganisationCacheManager>();

            // поднимаем все страховки по InsurepPerson.PeriodInsurance.MedicalInsured
            // и мапим это все в ответ
            InsuredPerson person = null;

            return
                (session.QueryOver <MedicalInsurance>()
                 .JoinAlias(x => x.InsuredPerson, () => person)
                 .WhereRestrictionOn(x => person.Id)
                 .IsIn(InsuredPersonsByKeis(statement).Select(m => m.Id).ToArray())
                 .List()
                 .Select(
                     ins =>
                     new UIRResponseUIRQueryResponse
            {
                Insurance =
                    new Insurance
                {
                    InsType =
                        conceptManager.GetById(ins.PolisType.Id)
                        .Code,
                    InsRegion =
                        organisationManager.GetById(ins.Smo.Id)
                        .Parent.Code,
                    MedInsCompanyId =
                        organisationManager.GetById(ins.Smo.Id)
                        .Code,
                    StartDate = ins.DateFrom,
                    EndDate = ins.DateTo,
                    InsId =
                        DocumentNumSeparator.SpecFormat(ins.PolisSeria, ins.PolisNumber)
                },
                Person =
                    new Person
                {
                    MainENP = ins.InsuredPerson.MainPolisNumber,
                    RegionalENP = ins.Statement.NumberPolicy
                }
            })
                 .ToArray());
        }
Example #3
0
        /// <summary>
        /// The get med ins state 2.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Response"/> .
        /// </returns>
        public Response GetMedInsState2(Request2 request)
        {
            var rq = request.UIRRequest2;

            var session = ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession();

            try
            {
                var polisType =
                    session.QueryOver <Concept>()
                    .Where(f => f.Name.Lower() == rq.PolicyType.Lower() || f.ShortName.Lower() == rq.PolicyType.Lower())
                    .List()
                    .SingleOrDefault();
                var polisSeria  = DocumentNumSeparator.SeparateSpecFormat(rq.PolicyNumber)[0];
                var polisNumber = DocumentNumSeparator.SeparateSpecFormat(rq.PolicyNumber)[1];

                var statement = new Statement
                {
                    InsuredPersonData =
                        new InsuredPersonDatum
                    {
                        FirstName  = rq.FullName.FirstName,
                        LastName   = rq.FullName.FamilyName,
                        MiddleName = rq.FullName.MiddleName,
                        Birthday   = rq.Birth.BirthDate,
                        Birthplace = rq.Birth.BirthPlace
                    },
                    MedicalInsurances =
                        session.QueryOver <Organisation>()
                        .Inner.JoinQueryOver(j => j.Parent)
                        .Where(f => f.Code == rq.InsRegion)
                        .List()
                        .Select(
                            m =>
                            new MedicalInsurance
                    {
                        PolisType   = polisType,
                        PolisSeria  = polisSeria,
                        PolisNumber = polisNumber,
                        Smo         = m
                    })
                        .ToList()
                };
                if (rq.InsDate != null)
                {
                    statement.MedicalInsurances[0].DateFrom = rq.InsDate.Value;
                }

                return(new Response
                {
                    UIRResponse =
                        new UIRResponse
                    {
                        UIRQueryResponse = ResponseMaping(statement),
                        Ack = Ack.AA.ToString()
                    }
                });
            }
            catch (Exception ex)
            {
                return(new Response
                {
                    UIRResponse =
                        new UIRResponse
                    {
                        UIRQueryResponse = null,
                        Ack = Ack.AE.ToString(),
                        Err = new[] { new Err {
                                          ErrText = ex.Message
                                      } }
                    }
                });
            }
        }