Exemplo n.º 1
0
        public JsonResult AddPatientProviders(List <PatientFacility> model)
        {
            try
            {
                foreach (var item in model)
                {
                    if (item.DischargedTimestamp.HasValue)
                    {
                        _patientService.DeallocateTeamMember(BaseModel.DecryptId(item.PatientId), BaseModel.DecryptId(item.PatientProviderID));
                    }
                    else
                    {
                        string ICD10 = item.ReasonForAdmissionName.Split(' ')[0];
                        SADFM.Data.Models.ListItem icd10_ListItem = ICD10 == "Unknown"? null : SADFM.Data.DataAccess.ListItem.GetList("ICD10", filter: li => li.Name == ICD10).FirstOrDefault();
                        _patientService.AllocateTeamMember(BaseModel.DecryptId(item.PatientId), BaseModel.DecryptId(item.ProviderId), BaseModel.DecryptId(item.AccountID), icd10_ListItem == null? (Guid?)null : icd10_ListItem.GetId(), icd10_ListItem == null? null : item.ICD10CodeTimestamp);
                    }
                }

                return(Json(new
                {
                    Success = true
                }));
            }
            catch (Exception ex)
            {
                return(Json(new UpdateResult(ex.Message)));
            }
        }
Exemplo n.º 2
0
        public JsonResult NewCase(ViewModels.Case model)
        {
            string ICD10 = model.ICD10ID.Split(' ')[0];

            SADFM.Data.Models.ListItem icd10_ListItem = SADFM.Data.DataAccess.ListItem.GetList("ICD10", filter: li => li.Name == ICD10).FirstOrDefault();
            if (icd10_ListItem == null)
            {
                return(Json(new { Success = false, Error = "Cannot find ICD" }));
            }

            if (model.CaseId == null)
            {
                Data.Models.Account account = UserHelper.GetCurrentAccount();
                Guid accountId = account.GetId();

                SADFM.Data.Case caseObject = new SADFM.Data.Case()
                {
                    ICD10Id = icd10_ListItem.GetId(),
                    CaseId  = Guid.NewGuid(),
                    DateCreatedTimestamp = DateTime.Now,
                    LastUpdateTimestamp  = DateTime.Now,
                    StartDate            = model.StartDate,
                    EndDate             = model.EndDate,
                    PatientId           = SADFM.Data.Models.BaseModel.DecryptId(model.PatientId),
                    LastUpdateAccountId = UserHelper.GetCurrentAccount().GetId(),
                    ImpairmentGroupId   = model.ImpairmentGroupId != null?BaseModel.DecryptNullableId(model.ImpairmentGroupId) : null,
                                              ReferringDoctor               = model.ReferringDoctor,
                                              ReferringDoctorContact        = model.ReferringDoctorContact,
                                              ReferringDoctorEmail          = model.ReferringDoctorEmail,
                                              ReferringDoctorPracticeNumber = model.ReferringDoctorPracticeNumber,
                                              TreatingDoctor               = model.TreatingDoctor,
                                              TreatingDoctorContact        = model.TreatingDoctorContact,
                                              TreatingDoctorEmail          = model.TreatingDoctorEmail,
                                              TreatingDoctorPracticeNumber = model.TreatingDoctorPracticeNumber,
                                              AdmissionStatusId            = SADFM.Data.Models.BaseModel.DecryptNullableId(model.AdmissionStatusId)
                };



                if (UserHelper.GetCurrentAccount().Permissions.Count(x => x.GetClientId() == UserHelper.SelectedClientId && (x.PermissionDescription.Equals("Clinician"))) != 0)
                {
                    caseObject.PatientProviders.Add(new Data.PatientProvider()
                    {
                        AccountId           = UserHelper.GetCurrentAccount().GetId(),
                        AssignedTimestamp   = DateTime.Now,
                        CreatedTimestamp    = DateTime.Now,
                        LastUpdateAccountId = UserHelper.GetCurrentAccount().GetId(),
                        LastUpdateTimestamp = DateTime.Now,
                        ProviderId          = UserHelper.SelectedClientId.Value,
                        PatientProviderId   = Guid.NewGuid(),
                        PatientId           = SADFM.Data.Models.BaseModel.DecryptId(model.PatientId)
                    });
                }

                DataAccess.Account.AddCase(caseObject, UserHelper.GetCurrentAccount().GetId());

                return(Json(new
                {
                    Success = true,
                    Id = caseObject.CaseId.ToString("N")
                }));
            }
            else
            {
                return(Json(DataAccess.Account.UpdateCase(new Data.Case()
                {
                    CaseId = Data.Models.BaseModel.DecryptId(model.CaseId),
                    StartDate = model.StartDate,
                    EndDate = model.EndDate,
                    ICD10Id = icd10_ListItem.GetId(),
                    PatientId = Data.Models.BaseModel.DecryptId(model.PatientId),
                    ImpairmentGroupId = model.ImpairmentGroupId != null ? BaseModel.DecryptNullableId(model.ImpairmentGroupId) : null,
                    ReferringDoctor = model.ReferringDoctor,
                    ReferringDoctorContact = model.ReferringDoctorContact,
                    ReferringDoctorEmail = model.ReferringDoctorEmail,
                    ReferringDoctorPracticeNumber = model.ReferringDoctorPracticeNumber,
                    TreatingDoctor = model.TreatingDoctor,
                    TreatingDoctorContact = model.TreatingDoctorContact,
                    TreatingDoctorEmail = model.TreatingDoctorEmail,
                    TreatingDoctorPracticeNumber = model.TreatingDoctorPracticeNumber,
                    AdmissionStatusId = SADFM.Data.Models.BaseModel.DecryptNullableId(model.AdmissionStatusId)
                }, UserHelper.GetCurrentAccount().GetId())));
            }
        }