public async Task <ActionResult> CreatePatient([FromBody] PatientCreate request)
        {
            if (ModelState.IsValid)
            {
                var patientDto = request.ToDto();
                await _context.Create(patientDto);

                return(Ok());
            }

            return(BadRequest("model validation failed"));
        }
        public ActionResult Create(PatientCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new PatientService();

            if (service.CreatePatient(model))
            {
                TempData["SaveResult"] = "New Patient created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Patient could not be created.");
            return(View(model));
        }
示例#3
0
        public Patients_tests()
        {
            _patientController = new PatientController(_IPatientRepository.Object);

            _patientDto = new PatientDto()
            {
                Name         = "Gvidas",
                Surname      = "Nor",
                Address      = "Sauletekio ave. 18., Vilnius",
                BirthDate    = DateTime.Now,
                Email        = "*****@*****.**",
                Password     = "******",
                PersonalCode = "3888888878",
                Phone        = "8655547558",
                RiskLevel    = 2,
                Id           = 2,
            };

            _patientCreate = new PatientCreate()
            {
                Name         = "Gvidas",
                Surname      = "Nor",
                Address      = "Sauletekio ave. 18., Vilnius",
                BirthDate    = DateTime.Now,
                Email        = "*****@*****.**",
                Password     = "******",
                PersonalCode = "3888888878",
                Phone        = "8655547558",
                RiskLevel    = 2
            };

            _patientUpdate = new PatientUpdate()
            {
                Name         = "Gvidas",
                Surname      = "Nor",
                Address      = "Sauletekio ave. 18., Vilnius",
                BirthDate    = DateTime.Now,
                Email        = "*****@*****.**",
                Password     = "******",
                PersonalCode = "3888888878",
                Phone        = "8655547558",
                RiskLevel    = 2
            };
        }
示例#4
0
        public bool CreatePatient(PatientCreate model)
        {
            var entity = new Patient()
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                DOB       = model.DOB,
                Address   = model.Address,
                City      = model.City,
                State     = model.State,
                Zip       = model.Zip,
                Phone     = model.Phone
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Patients.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#5
0
        public ModifyPatientResp CreatePatientNew(Customer customer, PrimaryCarePhysician pcp, BillingAccount billingAccount)
        {
            try
            {
                var client = new KareoServicesClient();

                var requestHeader = new RequestHeader
                {
                    ClientVersion = ClientVersion,
                    CustomerKey   = billingAccount.CustomerKey,
                    User          = billingAccount.UserName,
                    Password      = billingAccount.Password
                };

                // Create the patient to insert.
                var newPatient = new PatientCreate
                {
                    FirstName           = customer.Name.FirstName,
                    MiddleName          = customer.Name.MiddleName,
                    LastName            = customer.Name.LastName,
                    DateofBirth         = customer.DateOfBirth,
                    Gender              = customer.Gender == Gender.Male ? GenderCode.Male : customer.Gender == Gender.Female ? GenderCode.Female : GenderCode.Unknown,
                    MedicalRecordNumber = customer.CustomerId.ToString(),
                    AddressLine1        = customer.Address.StreetAddressLine1,
                    AddressLine2        = customer.Address.StreetAddressLine2,
                    City         = customer.Address.City,
                    State        = customer.Address.StateCode,
                    ZipCode      = customer.Address.ZipCode.Zip,
                    HomePhone    = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.FormatPhoneNumber : string.Empty,
                    WorkPhone    = customer.OfficePhoneNumber != null ? customer.OfficePhoneNumber.FormatPhoneNumber : string.Empty,
                    MobilePhone  = customer.MobilePhoneNumber != null ? customer.MobilePhoneNumber.FormatPhoneNumber : string.Empty,
                    EmailAddress = customer.Email != null?customer.Email.ToString() : string.Empty,
                                       PatientExternalID = customer.CustomerId.ToString()
                };

                // Set the practice we want to add this patient to
                var practice = new PracticeIdentifierReq
                {
                    PracticeName = billingAccount.Name
                };
                newPatient.Practice = practice;

                // Create the case details for the patient
                var patientCase = new PatientCaseCreateReq
                {
                    CaseName = CaseName,
                    //patientCase.PayerScenario
                    Active = true,
                    SendPatientStatements = true
                };
                newPatient.Cases = new[] { patientCase };

                if (pcp != null)
                {
                    newPatient.PrimaryCarePhysician = new PhysicianIdentifierReq
                    {
                        FullName = pcp.Name.FullName
                    };
                }

                // Create the create patient request object
                var request = new CreatePatientReq
                {
                    RequestHeader = requestHeader,
                    Patient       = newPatient
                };

                // Call the Create Patient method
                var response = client.CreatePatient(request);

                // Check the response for an error
                if (response.ErrorResponse.IsError)
                {
                    throw new Exception(response.ErrorResponse.ErrorMessage);
                }

                if (!response.SecurityResponse.SecurityResultSuccess)
                {
                    throw new Exception(response.SecurityResponse.SecurityResult);
                }

                client.Close();

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#6
0
        public ModifyPatientResp CreatePatient(Customer customer, Eligibility eligibility, IEnumerable <InsuranceCompany> insuranceCompanies, PrimaryCarePhysician pcp, BillingAccount billingAccount)
        {
            try
            {
                var client = new KareoServicesClient();

                var requestHeader = new RequestHeader
                {
                    ClientVersion = ClientVersion,
                    CustomerKey   = billingAccount.CustomerKey,
                    User          = billingAccount.UserName,
                    Password      = billingAccount.Password
                };

                // Create the patient to insert.
                var newPatient = new PatientCreate
                {
                    FirstName           = customer.Name.FirstName,
                    MiddleName          = customer.Name.MiddleName,
                    LastName            = customer.Name.MiddleName,
                    DateofBirth         = customer.DateOfBirth,
                    Gender              = customer.Gender == Gender.Male ? GenderCode.Male : customer.Gender == Gender.Female ? GenderCode.Female : GenderCode.Unknown,
                    MedicalRecordNumber = customer.CustomerId.ToString(),
                    AddressLine1        = customer.Address.StreetAddressLine1,
                    AddressLine2        = customer.Address.StreetAddressLine2,
                    City         = customer.Address.City,
                    State        = customer.Address.StateCode,
                    ZipCode      = customer.Address.ZipCode.Zip,
                    HomePhone    = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.FormatPhoneNumber : string.Empty,
                    WorkPhone    = customer.OfficePhoneNumber != null ? customer.OfficePhoneNumber.FormatPhoneNumber : string.Empty,
                    MobilePhone  = customer.MobilePhoneNumber != null ? customer.MobilePhoneNumber.FormatPhoneNumber : string.Empty,
                    EmailAddress = customer.Email != null?customer.Email.ToString() : string.Empty,
                                       PatientExternalID = customer.CustomerId.ToString()
                };

                // Set the practice we want to add this patient to
                var practice = new PracticeIdentifierReq
                {
                    PracticeName = billingAccount.Name
                };

                // Create the case details for the patient
                var patientCase = new PatientCaseCreateReq
                {
                    CaseName = CaseName,
                    //patientCase.PayerScenario
                    Active = true,
                    SendPatientStatements = true
                };

                var eligibleResponse = JsonConvert.DeserializeObject <EligibleResponse>(eligibility.Response);
                InsuranceCompany insuranceCompany = null;
                if (eligibleResponse.PrimaryInsurance != null)
                {
                    insuranceCompany = insuranceCompanies.FirstOrDefault(ic => ic.Code == eligibleResponse.PrimaryInsurance.Id);
                }
                else if (eligibleResponse.Insurance != null)
                {
                    insuranceCompany = insuranceCompanies.FirstOrDefault(ic => ic.Code == eligibleResponse.Insurance.Id);
                }

                if (insuranceCompany == null)
                {
                    insuranceCompany = insuranceCompanies.First(ic => ic.Id == eligibility.InsuranceCompanyId);
                }

                // Create the insurance policies for the patient case
                var primaryPolicy = new InsurancePolicyCreateReq
                {
                    CompanyName       = insuranceCompany.Name,
                    PlanName          = eligibleResponse.Plan.PlanName,
                    PolicyNumber      = eligibleResponse.Demographics.Subscriber.MemberId,
                    PolicyGroupNumber = eligibleResponse.Demographics.Subscriber.GroupId,
                    Copay             = eligibility.CoPayment.ToString("0.00")
                };
                //primaryPolicy.PlanID = eligibleResponse.Plan.PlanNumber;

                patientCase.Policies = new InsurancePolicyCreateReq[] { primaryPolicy };


                newPatient.Practice = practice;
                newPatient.Cases    = new PatientCaseCreateReq[] { patientCase };
                if (pcp != null)
                {
                    newPatient.PrimaryCarePhysician = new PhysicianIdentifierReq
                    {
                        FullName = pcp.Name.FullName
                    };
                }

                // Create the create patient request object
                var request = new CreatePatientReq
                {
                    RequestHeader = requestHeader,
                    Patient       = newPatient
                };

                // Call the Create Patient method
                var response = client.CreatePatient(request);

                // Check the response for an error
                if (response.ErrorResponse.IsError)
                {
                    throw new Exception(response.ErrorResponse.ErrorMessage);
                }

                if (!response.SecurityResponse.SecurityResultSuccess)
                {
                    throw new Exception(response.SecurityResponse.SecurityResult);
                }

                client.Close();

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }