public PostCareMemberResponse InsertCareMember(PostCareMemberRequest request) { try { PostCareMemberResponse response = new PostCareMemberResponse(); if (request.CareMember == null) { throw new Exception("The CareMember property cannot be null in the request."); } if (!atleastOneCareMemberExists(request)) { //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/CareMember/Insert", "PUT")] IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/CareMember/Insert", DDCareMemberUrl, "NG", request.Version, request.ContractNumber, request.PatientId), request.UserId); CareMemberData cmData = new CareMemberData { PatientId = request.CareMember.PatientId, ContactId = request.CareMember.ContactId, TypeId = request.CareMember.TypeId, Primary = request.CareMember.Primary }; PutCareMemberDataResponse dataDomainResponse = client.Put <PutCareMemberDataResponse>(url, new PutCareMemberDataRequest { CareMember = cmData, Context = "NG", ContractNumber = request.ContractNumber, Version = request.Version, UserId = request.UserId, PatientId = request.PatientId } as object); if (dataDomainResponse != null && !(string.IsNullOrEmpty(dataDomainResponse.Id))) { response.Id = dataDomainResponse.Id; response.Version = dataDomainResponse.Version; if (request.CareMember.Primary) { //Upsert the PrimaryCare Manager's ContactId in the CohortPatientView collection. upsertCohortPatientView(request.PatientId, request.CareMember.ContactId, response.Version, request.ContractNumber, request.UserId); } } } return(response); } catch (WebServiceException ex) { throw new WebServiceException("AD:InsertCareMember()::" + ex.Message, ex.InnerException); } }
public void InsertCareMember_Test() { CareMember cm = new CareMember { Id = "-2", PatientId = "55df7b6184ac070e74d95c1a", ContactId = "5325c821072ef705080d3488", Primary = true, TypeId = "530cd571d433231ed4ba969b" }; PostCareMemberRequest request = new PostCareMemberRequest(); request.ContractNumber = "InHealth001"; request.UserId = "5310a9bdd6a4850e0477cade"; request.Version = 1; request.PatientId = "55df7b6184ac070e74d95c1a"; request.Token = "5310a9bdd6a4850e0477cade"; request.CareMember = cm; CareMembersManager nManager = new CareMembersManager(); PostCareMemberResponse response = nManager.InsertCareMember(request); Assert.IsNotNull(response); }