Beispiel #1
0
            public void Success()
            {
                PutProgramToPatientRequest request = new PutProgramToPatientRequest
                {
                    UserId            = "123456789012345678901234",
                    Context           = "NG",
                    ContractNumber    = "InHealth001",
                    ContractProgramId = "123456789012345678901111",
                    PatientId         = "222256789012345678902222",
                    Token             = "222256789012349999999999",
                    Version           = 1.0
                };

                ProgramService ps = new ProgramService
                {
                    CommonFormatterUtil = new StubCommonFormatterUtil(),
                    Helpers             = new StubHelper(),
                    ProgramDataManager  = new StubProgramDataManager()
                };

                PutProgramToPatientResponse response = ps.Put(request);
                int control = 1;

                Assert.AreEqual(control, response.Outcome.Result);
            }
Beispiel #2
0
 private PutProgramToPatientResponse FormatExceptionResponse(PutProgramToPatientResponse response, string reason, string errorcode)
 {
     try
     {
         response.Status  = new ResponseStatus(errorcode, reason);
         response.Outcome = new Phytel.API.DataDomain.Program.DTO.Outcome()
         {
             Reason = reason, Result = 0
         };
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("DD:DataProgramManager:FormatExceptionResponse()::" + ex.Message, ex.InnerException);
     }
 }
Beispiel #3
0
        public void PutProgramToPatientTest()
        {
            string userId = "000000000000000000000000";
            PutProgramToPatientRequest request = new PutProgramToPatientRequest {
                PatientId = "5325da17d6a4850adcbba532", CareManagerId = "5325c81f072ef705080d347e", ContractProgramId = "5330920da38116ac180009d2", UserId = userId
            };

            ProgramDataManager pm = new ProgramDataManager {
                Factory = new ProgramRepositoryFactory(), DTOUtility = new DTOUtility {
                    Factory = new ProgramRepositoryFactory()
                }
            };

            PutProgramToPatientResponse response = pm.PutPatientToProgram(request);

            Assert.IsNotNull(response);
        }
Beispiel #4
0
        public PutProgramToPatientResponse Put(PutProgramToPatientRequest request)
        {
            PutProgramToPatientResponse response = new PutProgramToPatientResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ProgramDD:Put()::Unauthorized Access");
                }

                response         = ProgramDataManager.PutPatientToProgram(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
Beispiel #5
0
        public void Put_ContractProgramWithPatient()
        {
            string url               = "http://localhost:8888/Program";
            string token             = "5367fcf4d6a485044ccaf2f9";
            string patientID         = "5325db09d6a4850adcbba812";
            string ContractProgramID = "5330920da38116ac180009d2";
            string userID            = "5325c821072ef705080d3488";
            string contractNumber    = "InHealth001";
            string context           = "NG";
            double version           = 1.0;

            Stopwatch st = new Stopwatch();

            st.Start();

            IRestClient client = new JsonServiceClient();

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("Token: {0}", token));
            string urls = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Programs/?ContractProgramId={5}",
                                                               url,
                                                               "NG",
                                                               version,
                                                               contractNumber,
                                                               patientID,
                                                               ContractProgramID), userID);

            PutProgramToPatientResponse dataDomainResponse =
                client.Put <PutProgramToPatientResponse>(urls, new PutProgramToPatientRequest {
                UserId = userID
            } as object);

            st.Stop();
            string time = st.ElapsedMilliseconds.ToString();

            Assert.AreEqual(dataDomainResponse.Outcome.Result, 0);
            //Assert.AreEqual(ProgramID, response.Program.ProgramID);
        }
        public DTO.PutProgramToPatientResponse PutPatientToProgram(DTO.PutProgramToPatientRequest request)
        {
            DTO.PutProgramToPatientResponse response = new PutProgramToPatientResponse
            {
                Outcome = new DTO.Outcome
                {
                    Reason = "SUccess!",
                    Result = 1
                },
                program = new ProgramInfo
                {
                    ElementState = 1,
                    Id           = request.ContractProgramId,
                    Name         = "Test program",
                    PatientId    = request.PatientId,
                    ProgramState = 1,
                    ShortName    = "short program",
                    Status       = 1
                },
                Version = 1.0
            };

            return(response);
        }
        public PutProgramToPatientResponse AssignPatientToProgram(DTO.PostPatientToProgramsRequest request, string careManagerId)
        {
            PutProgramToPatientResponse response = new PutProgramToPatientResponse
            {
                program = new ProgramInfo
                {
                    Id           = "111111111111111111111111",
                    ShortName    = "shortname",
                    Status       = 1,
                    Name         = "programname",
                    PatientId    = request.PatientId,
                    ElementState = 1,
                    ProgramState = 1
                },
                Outcome = new Outcome
                {
                    Result = 1,
                    Reason = "Success"
                },
                Version = 1.0
            };

            return(response);
        }
Beispiel #8
0
        public PutProgramToPatientResponse PutPatientToProgram(PutProgramToPatientRequest request)
        {
            try
            {
                PutProgramToPatientResponse response = new PutProgramToPatientResponse();
                response.Outcome = new Phytel.API.DataDomain.Program.DTO.Outcome();

                #region validation calls
                if (!IsValidPatientId(request))
                {
                    return(FormatExceptionResponse(response, "Patient does not exist or has an invalid id.", "500"));
                }

                if (!IsValidContractProgramId(request))
                {
                    return(FormatExceptionResponse(response, "ContractProgram does not exist or has an invalid identifier.", "500"));
                }

                if (!IsContractProgramAssignable(request))
                {
                    return(FormatExceptionResponse(response, "ContractProgram is not currently active.", "500"));
                }
                #endregion

                /**********************************/
                List <MEPatientProgram> pp = DTOUtility.FindExistingpatientProgram(request);

                if (!DTOUtility.CanInsertPatientProgram(pp))
                {
                    response.Outcome.Result = 0;
                    response.Outcome.Reason = pp[0].Name + " is already assigned or reassignment is not allowed";
                }
                else
                {
                    MEProgram cp = DTOUtility.GetProgramForDeepCopy(request);

                    var stepIdList = new List <ObjectId>();
                    List <MEResponse> responseList = DTOUtility.GetProgramResponseslist(stepIdList, cp, request);
                    DTOUtils.HydrateResponsesInProgram(cp, responseList, request.UserId);
                    MEPatientProgram nmePp = DTOUtility.CreateInitialMEPatientProgram(request, cp, stepIdList);
                    DTOUtility.InitializePatientProgramAssignment(request, nmePp);
                    List <MEPatientProgramResponse> pprs = DTOUtils.ExtractMEPatientProgramResponses(nmePp, request.ContractNumber, request.UserId);
                    ProgramInfo pi = DTOUtility.SaveNewPatientProgram(request, nmePp);

                    if (pi != null)
                    {
                        response.program = pi;
                        DTOUtility.SavePatientProgramResponses(pprs, request);
                        DTOUtility.InitializeProgramAttributes(request, response);
                    }

                    response.Outcome.Result = 1;
                    response.Outcome.Reason = "Successfully assigned this program for the individual";
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception("DD:DataProgramManager:PutPatientToProgram()::" + ex.Message, ex.InnerException);
            }
        }