Example #1
0
    public void Execute()
        {
            try
            {                 
                //We get the patient's care team               
                var getCareTeamRequest = new GetCareTeamRequest()
                {
                    ContactId = _contactId,
                    ContractNumber = _request.ContractNumber,
                    UserId = _request.UserId,
                    Version = _request.Version
                };
                var careTeamData = _contactEndpointUtil.GetCareTeam(getCareTeamRequest);

                if (careTeamData!=null)
                {
                    _careTeam = Mapper.Map<CareTeam>(careTeamData);

                    // We send a request to the data domain to delete care team by care tam Id  
                    var request = new DeleteCareTeamRequest()
                    {
                        ContactId = _careTeam.ContactId,
                        Id = _careTeam.Id,
                        ContractNumber = _request.ContractNumber,
                        UserId = _request.UserId,
                        Version = _request.Version
                    };
                    _contactEndpointUtil.DeleteCareTeam(request);
                }                
            }
            catch (Exception ex)
            {
                throw new Exception("AD: CareTeamCommand Execute::" + ex.Message, ex.InnerException);
            }
        }
Example #2
0
        public CareTeam GetCareTeam(GetCareTeamRequest request)
        {
            CareTeam careTeam = null;

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (string.IsNullOrEmpty(request.ContactId))
            {
                throw new ArgumentNullException("request.ContactId");
            }
            try
            {
                CareTeamData careTeamData = EndpointUtil.GetCareTeam(request);
                if (careTeamData != null)
                {
                    careTeam = Mapper.Map <CareTeam>(careTeamData);
                    #region Populate Contact object for each care team member.
                    if (careTeam.Members != null && careTeam.Members.Count > 0)
                    {
                        List <string>      contactIds   = careTeam.Members.Select(a => a.ContactId).ToList();
                        List <ContactData> contactsData = EndpointUtil.GetContactsByContactIds(contactIds, request.Version, request.ContractNumber, request.UserId);
                        if (contactsData != null)
                        {
                            foreach (var member in careTeam.Members)
                            {
                                ContactData data = contactsData.FirstOrDefault(c => c.Id == member.ContactId);
                                if (data == null)
                                {
                                    throw new ApplicationException(string.Format("Contact card for a care team member with contact id = {0} was not found", member.ContactId));
                                }
                                else
                                {
                                    member.Contact = Mapper.Map <Contact>(data);
                                }
                            }
                        }
                    }
                    #endregion
                }
                return(careTeam);
            }
            catch (Exception ex) { throw ex; }
        }
Example #3
0
        public GetCareTeamResponse Get(GetCareTeamRequest request)
        {
            GetCareTeamResponse response = new GetCareTeamResponse();

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                ValidateTokenResponse result = null;
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId    = result.UserId;
                    response.CareTeam = ContactManager.GetCareTeam(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    ContactManager.LogException(ex);
                }
            }
            finally
            {
                //List<string> patientIds = new List<string>();
                //patientIds.Add(request.PatientId);
                //if (result != null)
                //{
                //    string browser = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType;
                //    string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress;
                //    AuditUtil.LogAuditData(request, result.SQLUserId, patientIds, browser, hostAddress, request.GetType().Name);
                //}
            }
            return(response);
        }