public IActionResult Treatment(long id) { PatientDetailViewModel patientDetailViewModel = new PatientDetailViewModel(); Patient patient = new Patient(); try { if (User.IsInRole("doctor")) { patient = patientRepository.GetById(id); patient.Treatments = treatmentRepository.GetByPatient(id); } else if (User.IsInRole("patient")) { long patientId = patientRepository.GetPatientIdByTreatmentId(id); patient = patientRepository.GetById(patientId); patient.Treatments = treatmentRepository.GetByPatient(patientId); } foreach (Treatment t in patient.Treatments) { t.TreatmentType = treatmentTypeRepository.GetByTreatmentId(t.TreatmentTypeId); } patientDetailViewModel = patientWithTreatmentsVMC.PatientToViewModel(patient); } catch (Exception Ex) { return(BadRequest(Ex.Message)); } return(View(patientDetailViewModel)); }
public PatientDetail MapPatient(PatientDetailViewModel vmodel) { return(new PatientDetail { Complaints = vmodel.Complaints, ConsultationType = vmodel.ConsultationType, CreatedBy = vmodel.CreatedBy, CreatedByEntity = vmodel.CreatedByEntity, CreatedOn = vmodel.CreatedOn, FileId = vmodel.FileId, Id = vmodel.Id, IsDeleted = vmodel.IsDeleted, ModifiedBy = vmodel.ModifiedBy, ModifiedByEntity = vmodel.ModifiedEntity, ModifiedOn = vmodel.ModifiedOn, PatientAge = vmodel.PatientAge, PatientGender = vmodel.PatientGender, PatientName = vmodel.PatientName, PatientPhone = vmodel.PatientPhone, TenantID = vmodel.TanentId, DoctorId = vmodel.DoctorId, UserID = vmodel.UserID, PreferredTime = Convert.ToInt16(vmodel.PreferredTime), Case = Convert.ToInt16(vmodel.Case) }); }
public Patient ViewModelToPatient(PatientDetailViewModel vm) { Patient patient = new Patient() { Id = vm.Id, }; Comment comment = new Comment() { }; foreach (TreatmentDetailViewModel t in vm.TreatmentDetailViewModels) { Treatment treatment = new Treatment() { Id = t.Id, Name = t.Name, Patient = patient, BeginDate = t.BeginDate, EndDate = t.EndDate, //TreatmentType = t.TypeId, Comments = new List <Comment>(t.Comments), }; patient.AddTreatment(treatment); } return(patient); }
public IHttpActionResult SavePatientDetails(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { PatientDetailViewModel pViewModel = WebCommon.Instance.GetObject <PatientDetailViewModel>(requestCarrier.PayLoad); pViewModel.TanentId = requestCarrier.TanentId; string validationResponse = this._consultationMapper.ValidatePatientDetails(pViewModel); if (string.IsNullOrEmpty(validationResponse)) { var patientDetailModel = this._consultationMapper.MapPatient(pViewModel); patientDetailModel.CreatedBy = (int)requestCarrier.UserId.Value; patientDetailModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); patientDetailModel.ModifiedBy = (int)requestCarrier.UserId.Value; patientDetailModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); patientDetailModel.UserID = (int)requestCarrier.UserId.Value; if (!string.IsNullOrEmpty(patientDetailModel.FileId)) { patientDetailModel.FileId = patientDetailModel.FileId.Replace('|', ','); } else { patientDetailModel.FileId = string.Empty; } var patientResponse = _dataServices.ConsultationService.SavePatientDetails(patientDetailModel); if (patientResponse.Success) { pViewModel.Id = patientResponse.Id; response = new ResponseCarrier() { Status = true, PayLoad = pViewModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = patientResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IActionResult Treatment(long id, PatientDetailViewModel vm) { Comment comment = vm.TreatmentDetailViewModels[0].Description; comment.TreatmentId = id; commentRepository.Insert(comment); return(RedirectToAction("index", "patient")); }
public ActionResult Details(int id) { var viewModel = new PatientDetailViewModel(); viewModel.Patient = _unitofWork.Patients.GetPatient(id); //viewModel.CountAttendance = _unitofWork.Attendances.CountAttendances(id); viewModel.CountAttendance = 0; viewModel.CountAppointments = _unitofWork.Appointments.CountAppointments(id); return(View(viewModel)); }
public PatientDetailPage() { InitializeComponent(); var patient = new Patient { Name = "Item 1", Age = "54" }; patientModel = new PatientDetailViewModel(patient); BindingContext = patientModel; }
public ActionResult Details(int id) { var viewModel = new PatientDetailViewModel() { Patient = _unitOfWork.Patients.GetPatient(id), Appointments = _unitOfWork.Appointments.GetAppointmentWithPatient(id), Attendances = _unitOfWork.Attandences.GetAttendance(id), CountAppointments = _unitOfWork.Appointments.CountAppointments(id), CountAttendance = _unitOfWork.Attandences.CountAttendances(id) }; return(View("Details", viewModel)); }
public async Task <ObjectResult> AddPatient([FromBody] PatientDetailViewModel patientDetailViewModel) { if (ModelState.IsValid) { return(CreateResponse(await _patientProvider.AddPatientAsync(patientDetailViewModel))); } else { return(CreateResponse(new ApiBaseResponse { StatusCode = HttpStatusCode.BadRequest, Error = "Data passed is invalid" })); } }
public PatientDetailPage(Patient patient) { InitializeComponent(); var viewModel = new PatientDetailViewModel(); viewModel.PatientId = patient; BindingContext = viewModel; var patientid = patient.id; MessagingCenter.Send(new PassIdPatient() { idPatient = patientid }, "PatientId"); }
/// <summary> /// Retrives participation consent(s) from Elastic by their status and patientId. /// <para>securityTicket represents the index, elastic type is "patient_details"</para> /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <param name="securityTicket"></param> /// <returns></returns> public static PatientDetailViewModel Get_PatientDetailByParticipationConsentStatus(string id, string status, SessionSecurityTicket securityTicket) { PatientDetailViewModel detail = new PatientDetailViewModel(); var TenantID = securityTicket.TenantID.ToString(); var serializer = new JsonNetSerializer(); var connection = Elastic_Utils.ElsaticConnection(); string elasticType = "patient_details"; string query = QueryBuilderPatients.BuildGetPatientDetailQuery_ByParticipationStatus(id, status); string searchCommand = Commands.Search(TenantID, elasticType).Pretty(); string result = connection.Post(searchCommand, query); var foundResults = serializer.ToSearchResult <PatientDetailViewModel>(result); return(foundResults.Documents.SingleOrDefault()); }
public async Task <IActionResult> Patientprofile(int id) { var user = userManager.Users.First(x => x.Email == User.Identity.Name); if (user == null) { return(RedirectToAction("Login", "Account")); } else { var viewModel = new PatientDetailViewModel() { Patient = _unitOfWork.Patients.GetPatient(id), }; return(View(viewModel)); } }
public PatientDetailViewModel PatientToViewModel(Patient patient) { PatientDetailViewModel vm = new PatientDetailViewModel() { Id = patient.Id, Name = patient.Name, Birth = patient.Birth, Age = patient.GetAge(), Genders = new List <string> { "Man", "Vrouw", "Anders" } }; vm.TreatmentDetailViewModels = new List <TreatmentDetailViewModel>(); foreach (Treatment t in patient.Treatments) { //The first comment is the description //t.Comments.OrderBy(x => x.Date); //List<Comment> comments = new List<Comment>(t.Comments); //Comment description = comments[0]; //comments.RemoveAt(0); TreatmentDetailViewModel treatmentDetailViewModel = new TreatmentDetailViewModel() { Id = t.Id, Name = t.Name, TypeName = t.TreatmentType.Name, TypeId = t.TreatmentType.Id, BeginDate = t.BeginDate, EndDate = t.EndDate, //Comments = comments, //Description = description, //Age = t.GetAge() }; vm.TreatmentDetailViewModels.Add(treatmentDetailViewModel); } return(vm); }
/// <summary> /// This method does the following operations : ///Takes the patient records, converts it to XML and calls the repository for saving the information. /// /// </summary> /// <param name="patientDetailViewModel"></param> /// <returns></returns> public async Task <ApiBaseResponse> AddPatientAsync(PatientDetailViewModel patientDetailViewModel) { var response = new ApiBaseResponse(); try { var patientDetail = new PatientDetail { Record = patientDetailViewModel.SerializeObject() }; await _patientRepository.AddPatientAsync(patientDetail); response.StatusCode = HttpStatusCode.OK; } catch (Exception ex) { response.StatusCode = HttpStatusCode.BadRequest; response.Error = "Error Occured while saving patient information"; _logger.LogError("Error Occured while saving patient information", ex); } return(response); }
public string ValidatePatientDetails(PatientDetailViewModel patientDetailViewModel) { if (string.IsNullOrEmpty(patientDetailViewModel.PatientName)) { return("Patient Name is require"); } if (patientDetailViewModel.PatientGender == ' ') { return("Patient Gender is require"); } if (patientDetailViewModel.PatientAge < 0) { return("Invalid Patient age"); } if (!Validator.PhoneValidation(patientDetailViewModel.PatientPhone.ToString())) { return("Invalid Patient Phone"); } if (string.IsNullOrEmpty(patientDetailViewModel.Complaints)) { return("Patient Complaint require"); } return(string.Empty); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_DO_MD_1321 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here returnValue.Result = Parameter.DoctorID; var temporary_doctor_bpt_id = Guid.Empty; List <Guid> case_ids = new List <Guid>(); var BusinessParticipantID = Guid.Empty; #region PURGE TEMPORARY DOCTOR var temporary_doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, new ORM_HEC_Doctor.Query() { HEC_DoctorID = Parameter.TemporaryDoctorID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (temporary_doctor != null) { temporary_doctor.IsDeleted = true; temporary_doctor.Save(Connection, Transaction); var temporary_doctor_bpt = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { CMN_BPT_BusinessParticipantID = temporary_doctor.BusinessParticipant_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (temporary_doctor_bpt != null) { temporary_doctor_bpt_id = temporary_doctor_bpt.CMN_BPT_BusinessParticipantID; temporary_doctor_bpt.IsDeleted = true; temporary_doctor_bpt.Save(Connection, Transaction); var temporary_doctor_person_info = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query() { CMN_PER_PersonInfoID = temporary_doctor_bpt.IfNaturalPerson_CMN_PER_PersonInfo_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (temporary_doctor_person_info != null) { temporary_doctor_person_info.IsDeleted = true; temporary_doctor_person_info.Save(Connection, Transaction); var temporary_doctor_communication_contact = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, new ORM_CMN_PER_CommunicationContact.Query() { PersonInfo_RefID = temporary_doctor_person_info.CMN_PER_PersonInfoID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var tdc in temporary_doctor_communication_contact) { tdc.IsDeleted = true; tdc.Save(Connection, Transaction); } } } var temporary_doctor_universal_property_value = ORM_HEC_Doctor_UniversalPropertyValue.Query.Search(Connection, Transaction, new ORM_HEC_Doctor_UniversalPropertyValue.Query() { HEC_Doctor_RefID = temporary_doctor.HEC_DoctorID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (temporary_doctor_universal_property_value != null) { temporary_doctor_universal_property_value.IsDeleted = true; temporary_doctor_universal_property_value.Save(Connection, Transaction); var temporary_doctor_universal_property = ORM_HEC_Doctor_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_Doctor_UniversalProperty.Query() { PropertyName = "Comment", HEC_Doctor_UniversalPropertyID = temporary_doctor_universal_property_value.HEC_Doctor_UniversalPropertyValueID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (temporary_doctor_universal_property != null) { temporary_doctor_universal_property.IsDeleted = true; temporary_doctor_universal_property.Save(Connection, Transaction); } } } #endregion #region GET MERGED DOCTOR BPT var merge_doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, new ORM_HEC_Doctor.Query() { HEC_DoctorID = Parameter.DoctorID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (merge_doctor != null) { BusinessParticipantID = merge_doctor.BusinessParticipant_RefID; } else { throw new Exception("Doctor not found"); } #endregion #region LINK AFTERCARES TO MERGED DOCTOR var aftercare_planned_actions = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, IsPerformed = false, IsCancelled = false, ToBePerformedBy_BusinessParticipant_RefID = temporary_doctor_bpt_id }); foreach (var aftercare in aftercare_planned_actions) { aftercare.ToBePerformedBy_BusinessParticipant_RefID = BusinessParticipantID; aftercare.Modification_Timestamp = DateTime.Now; aftercare.Save(Connection, Transaction); var case_id = ORM_HEC_CAS_Case_RelevantPlannedAction.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case_RelevantPlannedAction.Query() { PlannedAction_RefID = aftercare.HEC_ACT_PlannedActionID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (case_id != null) { case_ids.Add(case_id.Case_RefID); } } #endregion #region UPDATE ELASTIC List <Case_Model> cases = new List <Case_Model>(); List <Aftercare_Model> aftercares = new List <Aftercare_Model>(); List <PatientDetailViewModel> patientDetailList = new List <PatientDetailViewModel>(); List <Settlement_Model> settlements = new List <Settlement_Model>(); Dictionary <Guid, CAS_GDDfDID_1608> diagnose_data_cache = new Dictionary <Guid, CAS_GDDfDID_1608>(); Dictionary <Guid, CAS_GDDfDID_1614> drug_data_cache = new Dictionary <Guid, CAS_GDDfDID_1614>(); Dictionary <Guid, DO_GDDfDID_0823> treatment_doctor_data_cache = new Dictionary <Guid, DO_GDDfDID_0823>(); Dictionary <Guid, P_PA_GPDfPID_1124> patient_data_cache = new Dictionary <Guid, P_PA_GPDfPID_1124>(); Dictionary <Guid, DO_GPDfPID_1432> treatment_practice_data_cache = new Dictionary <Guid, DO_GPDfPID_1432>(); var merged_doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = Parameter.DoctorID }, securityTicket).Result.SingleOrDefault(); var doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = Parameter.DoctorID }, securityTicket).Result.SingleOrDefault(); if (doctor_details != null) { foreach (var case_id in case_ids) { var treatment_planned_action = cls_Get_Treatment_Planned_Action_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GTPAfCID_0946() { CaseID = case_id }, securityTicket).Result; if (treatment_planned_action != null) { #region IF CASE SUBMITTED, CREATE AFTERCARE if (treatment_planned_action.is_treatment_performed) { var case_details = cls_Get_Case_Details_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GCDfCID_1435() { CaseID = case_id }, securityTicket).Result; #region CACHE if (!diagnose_data_cache.ContainsKey(case_details.diagnose_id)) { diagnose_data_cache.Add(case_details.diagnose_id, cls_Get_Diagnose_Details_for_DiagnoseID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1608() { DiagnoseID = case_details.diagnose_id }, securityTicket).Result); } var diagnose_details = diagnose_data_cache[case_details.diagnose_id]; if (!drug_data_cache.ContainsKey(case_details.drug_id)) { drug_data_cache.Add(case_details.drug_id, cls_Get_Drug_Details_for_DrugID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1614() { DrugID = case_details.drug_id }, securityTicket).Result); } var drug_details = drug_data_cache[case_details.drug_id]; if (!treatment_doctor_data_cache.ContainsKey(case_details.op_doctor_id)) { treatment_doctor_data_cache.Add(case_details.op_doctor_id, cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = case_details.op_doctor_id }, securityTicket).Result.SingleOrDefault()); } var treatment_doctor_details = treatment_doctor_data_cache[case_details.op_doctor_id]; if (!patient_data_cache.ContainsKey(case_details.patient_id)) { patient_data_cache.Add(case_details.patient_id, cls_Get_Patient_Details_for_PatientID.Invoke(Connection, Transaction, new P_P_PA_GPDfPID_1124() { PatientID = case_details.patient_id }, securityTicket).Result); } var patient_details = patient_data_cache[case_details.patient_id]; if (!treatment_practice_data_cache.ContainsKey(case_details.practice_id)) { treatment_practice_data_cache.Add(case_details.practice_id, cls_Get_Practice_Details_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPDfPID_1432() { PracticeID = case_details.practice_id }, securityTicket).Result.FirstOrDefault()); } var treatment_practice_details = treatment_practice_data_cache[case_details.practice_id]; #endregion if (case_details != null) { #region CREATE NEW AFTERCARE Aftercare_Model aftercare = new Aftercare_Model(); aftercare.hip_ik_number = patient_details.HealthInsurance_IKNumber; aftercare.aftercare_doctor_name = MMDocConnectDocApp.GenericUtils.GetDoctorName(merged_doctor_details); aftercare.diagnose = diagnose_details != null ? diagnose_details.diagnose_name + " (" + diagnose_details.catalog_display_name + ": " + diagnose_details.diagnose_icd_10 + ")" : ""; aftercare.id = case_details.aftercare_planned_action_id.ToString(); aftercare.localization = case_details.localization; aftercare.patient_birthdate = case_details.Patient_BirthDate; aftercare.patient_birthdate_string = case_details.Patient_BirthDate.ToString("dd.MM.yyyy"); aftercare.patient_name = patient_details != null ? patient_details.patient_last_name + ", " + patient_details.patient_first_name : ""; aftercare.practice_id = merged_doctor_details.practice_id.ToString(); aftercare.status = "AC1"; aftercare.treatment_date = case_details.treatment_date; aftercare.treatment_date_day_month = case_details.treatment_date.ToString("dd.MM."); aftercare.treatment_date_month_year = case_details.treatment_date.ToString("MMMM yyyy", new System.Globalization.CultureInfo("de", true)); aftercare.treatment_doctor_name = treatment_doctor_details != null?MMDocConnectDocApp.GenericUtils.GetDoctorName(treatment_doctor_details) : "-"; aftercare.treatment_doctor_practice_name = treatment_doctor_details.practice; aftercare.case_id = case_id.ToString(); aftercare.hip = patient_details.health_insurance_provider; aftercare.patient_insurance_number = patient_details.insurance_id; aftercare.op_lanr = treatment_doctor_details == null ? "" : treatment_doctor_details.lanr; aftercare.ac_lanr = merged_doctor_details.lanr; aftercare.bsnr = treatment_doctor_details == null ? "" : treatment_doctor_details.BSNR; aftercare.aftercare_doctor_account_id = merged_doctor_details.doctor_account_id.ToString(); aftercare.aftercare_doctor_practice_id = Parameter.DoctorID.ToString(); aftercare.treatment_doctor_id = treatment_doctor_details == null ? "" : treatment_doctor_details.id.ToString(); aftercare.diagnose_id = case_details.diagnose_id.ToString(); aftercare.drug_id = case_details.drug_id.ToString(); aftercare.patient_id = case_details.patient_id.ToString(); aftercare.treatment_doctors_practice_id = case_details.practice_id.ToString(); aftercares.Add(aftercare); PatientDetailViewModel patientDetal_elastic = new PatientDetailViewModel(); patientDetal_elastic.id = aftercare.id; patientDetal_elastic.drug_id = aftercare.drug_id; patientDetal_elastic.practice_id = aftercare.practice_id; patientDetal_elastic.case_id = aftercare.case_id; patientDetal_elastic.date = aftercare.treatment_date; patientDetal_elastic.date_string = aftercare.treatment_date.ToString("dd.MM."); patientDetal_elastic.detail_type = "ac"; patientDetal_elastic.diagnose_or_medication = aftercare.diagnose; patientDetal_elastic.doctor = aftercare.aftercare_doctor_name; patientDetal_elastic.localisation = aftercare.localization; patientDetal_elastic.patient_id = aftercare.patient_id; patientDetal_elastic.treatment_doctor_id = aftercare.treatment_doctor_id; patientDetal_elastic.aftercare_doctor_practice_id = aftercare.aftercare_doctor_practice_id; patientDetal_elastic.diagnose_id = aftercare.diagnose_id; patientDetal_elastic.status = "FS0"; patientDetal_elastic.hip_ik = patient_details.HealthInsurance_IKNumber; patientDetailList.Add(patientDetal_elastic); #endregion #region Update settlement var settlement = Get_Settlement.GetSettlementForID(case_details.treatment_planned_action_id.ToString(), securityTicket); if (settlement != null) { settlement.acpractice = merged_doctor_details.practice; settlement.aftercare_doctor_practice_id = merged_doctor_details.id.ToString(); settlements.Add(settlement); } #endregion } } #endregion #region IF CASE NOT SUMBITTED, EDIT AFTERCARE DATA else { var planning_case = Get_Cases.GetCaseforCaseID(case_id.ToString(), securityTicket); planning_case.aftercare_doctor_lanr = merge_doctor.DoctorIDNumber; planning_case.aftercare_doctor_practice_id = merge_doctor.HEC_DoctorID.ToString(); var practice_details = cls_Get_Practice_Details_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPDfPID_1432() { PracticeID = doctor_details.practice_id }, securityTicket).Result.FirstOrDefault(); if (practice_details != null) { planning_case.aftercare_doctors_practice_name = practice_details.practice_name; planning_case.aftercare_name = MMDocConnectDocApp.GenericUtils.GetDoctorName(doctor_details); planning_case.aftercare_practice_bsnr = practice_details.practice_BSNR; planning_case.is_aftercare_doctor = true; } cases.Add(planning_case); } #endregion } } #region UPDATE LAST USED AFTERCARE DOCTORS LIST var types = Elastic_Utils.GetAllTypes(securityTicket.TenantID.ToString()); var length = Guid.Empty.ToString().Length; length += 5; List <string> last_used_types = new List <string>(); for (int i = 0; i < types.Length; i += length) { int index = types.IndexOf("user_", i); if (index != -1 && !last_used_types.Contains(types.Substring(index, length))) { last_used_types.Add(types.Substring(index, length)); } } foreach (var type in last_used_types) { Practice_Doctor_Last_Used_Model new_last_used = new Practice_Doctor_Last_Used_Model(); try { var last_used = Get_Practices_and_Doctors.GetLastUsedDoctorPracticeForID(Parameter.TemporaryDoctorID.ToString(), type, securityTicket); new_last_used.display_name = GenericUtils.GetDoctorName(doctor_details) + "(" + doctor_details.lanr + ")"; new_last_used.id = Parameter.DoctorID.ToString(); new_last_used.practice_id = doctor_details.practice_id.ToString(); new_last_used.date_of_use = last_used.date_of_use; Add_New_Practice_Last_Used.Delete_Practice_Last_Used(securityTicket.TenantID.ToString(), type, Parameter.TemporaryDoctorID.ToString()); Add_New_Practice_Last_Used.Import_Practice_Last_Used_Data_to_ElasticDB(new List <Practice_Doctor_Last_Used_Model>() { new_last_used }, securityTicket.TenantID.ToString(), type.Substring(5)); } catch (Exception ex) { // left empty because it's not really an exception, rather a check whether object with given id exists } } #endregion if (aftercares.Count != 0) { Add_New_Aftercare.Import_Aftercare_Data_to_ElasticDB(aftercares, securityTicket.TenantID.ToString()); } if (patientDetailList.Count != 0) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); } if (cases.Count != 0) { Add_New_Case.Import_Case_Data_to_ElasticDB(cases, securityTicket.TenantID.ToString()); } if (settlements.Count != 0) { Add_new_Settlement.Import_Settlement_to_ElasticDB(settlements, securityTicket.TenantID.ToString()); } Add_New_Practice.Delete_Doctor_Practice(securityTicket.TenantID.ToString(), Parameter.TemporaryDoctorID.ToString()); } else { throw new Exception("Doctor not found"); } return(returnValue); #endregion #endregion UserCode }
protected static FR_CAS_SCCS_1520 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_SCCS_1520 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_CAS_SCCS_1520(); returnValue.Result = new CAS_SCCS_1520(); //Put your code here var Ids_eligible = new List <Guid>(); var StatusOld = DateTime.Now; var StatusNew = DateTime.Now; var settlements = new List <Settlement_Model>(); var patientDetailList = new List <PatientDetailViewModel>(); var itemsForChange = Parameter.ids_to_change.Count(); //filter case eligibility foreach (var id in Parameter.ids_to_change) { if (Parameter.status_to == 8) { var settlementEdit = Get_Settlement.GetSettlementForID(id.ToString(), securityTicket); if (settlementEdit != null) { if (settlementEdit.status == "FS4" || settlementEdit.status == "FS12") { Ids_eligible.Add(id); } } } else if (Parameter.status_to == 9) { var settlementEdit = Get_Settlement.GetSettlementForID(id.ToString(), securityTicket); if (settlementEdit != null) { if (settlementEdit.status == "FS7") { Ids_eligible.Add(id); } } } } var itemsChanged = Ids_eligible.Count; foreach (var ideligible in Ids_eligible) { #region update setttlement elastic var settlementEdit = Get_Settlement.GetSettlementForID(ideligible.ToString(), securityTicket); settlementEdit.status = Parameter.status_to == 8 ? "FS" + 7 : "FS" + 12; settlementEdit.status_date = DateTime.Now; settlements.Add(settlementEdit); PatientDetailViewModel patient_detail = Retrieve_Patients.Get_PatientDetaiForID(settlementEdit.id, securityTicket); if (patient_detail != null) { patient_detail.status = settlementEdit.status; patientDetailList.Add(patient_detail); } #endregion List <CAS_GCTCfCID_1427> casePositions = cls_Get_Case_TransmitionCode_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GCTCfCID_1427() { CaseID = Guid.Parse(settlementEdit.case_id) }, securityTicket).Result.ToList(); var aftercareNum = casePositions.Count(fs => fs.fs_key == "aftercare"); foreach (var item in casePositions) { if (item.fs_key == "treatment") { var StatusForCase = ORM_BIL_BillPosition_TransmitionStatus.Query.Search(Connection, Transaction, new ORM_BIL_BillPosition_TransmitionStatus.Query() { IsDeleted = false, IsActive = true, Tenant_RefID = securityTicket.TenantID, BIL_BillPosition_TransmitionStatusID = item.status_id }).SingleOrDefault(); if (StatusForCase != null) { StatusOld = StatusForCase.Modification_Timestamp; StatusForCase.Modification_Timestamp = DateTime.Now; StatusForCase.IsActive = false; StatusForCase.Save(Connection, Transaction); StatusNew = StatusForCase.Modification_Timestamp; var NewStatusForCase = new ORM_BIL_BillPosition_TransmitionStatus(); NewStatusForCase.IsDeleted = false; NewStatusForCase.Creation_Timestamp = DateTime.Now; NewStatusForCase.Modification_Timestamp = DateTime.Now; NewStatusForCase.Tenant_RefID = securityTicket.TenantID; NewStatusForCase.IsActive = true; NewStatusForCase.BIL_BillPosition_TransmitionStatusID = Guid.NewGuid(); NewStatusForCase.BillPosition_RefID = StatusForCase.BillPosition_RefID; NewStatusForCase.TransmitionCode = Convert.ToInt32(Parameter.status_to) == 9 ? 12 : 7; NewStatusForCase.TransmittedOnDate = DateTime.Now; NewStatusForCase.TransmitionStatusKey = StatusForCase.TransmitionStatusKey; NewStatusForCase.Save(Connection, Transaction); } } else { if ((aftercareNum > 1 && (item.fs_status != 8)) || aftercareNum == 0) { var StatusForCase = ORM_BIL_BillPosition_TransmitionStatus.Query.Search(Connection, Transaction, new ORM_BIL_BillPosition_TransmitionStatus.Query() { IsDeleted = false, IsActive = true, Tenant_RefID = securityTicket.TenantID, BIL_BillPosition_TransmitionStatusID = item.status_id }).SingleOrDefault(); if (StatusForCase != null) { StatusOld = StatusForCase.Modification_Timestamp; StatusForCase.Modification_Timestamp = DateTime.Now; StatusForCase.IsActive = false; StatusForCase.Save(Connection, Transaction); StatusNew = StatusForCase.Modification_Timestamp; var NewStatusForCase = new ORM_BIL_BillPosition_TransmitionStatus(); NewStatusForCase.IsDeleted = false; NewStatusForCase.Creation_Timestamp = DateTime.Now; NewStatusForCase.Modification_Timestamp = DateTime.Now; NewStatusForCase.Tenant_RefID = securityTicket.TenantID; NewStatusForCase.IsActive = true; NewStatusForCase.BIL_BillPosition_TransmitionStatusID = Guid.NewGuid(); NewStatusForCase.BillPosition_RefID = StatusForCase.BillPosition_RefID; NewStatusForCase.TransmitionCode = Convert.ToInt32(Parameter.status_to) == 9 ? 12 : 7; NewStatusForCase.TransmittedOnDate = DateTime.Now; NewStatusForCase.TransmitionStatusKey = StatusForCase.TransmitionStatusKey; NewStatusForCase.Save(Connection, Transaction); } } } } if (settlements.Count != 0) { Add_new_Settlement.Import_Settlement_to_ElasticDB(settlements, securityTicket.TenantID.ToString()); } if (patientDetailList.Count != 0) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); } } returnValue.Result.number_of_ids_changed = itemsChanged; returnValue.Result.number_of_ids_to_change = itemsForChange; returnValue.Result.status_to = Parameter.status_to; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CCtSE_1100 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-DE"); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); //Get statuses from Resources var FS1 = Properties.Resources.FS1; var FS2 = Properties.Resources.FS2; var FS3 = Properties.Resources.FS3; var FS4 = Properties.Resources.FS4; var FS5 = Properties.Resources.FS5; var FS6 = Properties.Resources.FS6; var FS7 = Properties.Resources.FS7; var FS8 = Properties.Resources.FS8; var FS9 = Properties.Resources.FS9; var FS10 = Properties.Resources.FS10; var FS11 = Properties.Resources.FS11; Guid treatment_performed_action_type_id = Guid.Empty; var treatment_performed_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, new ORM_HEC_ACT_ActionType.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, GlobalPropertyMatchingID = "mm.docconect.doc.app.performed.action.treatment" }).SingleOrDefault(); if (treatment_performed_action_type == null) { treatment_performed_action_type = new ORM_HEC_ACT_ActionType(); treatment_performed_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.performed.action.treatment"; treatment_performed_action_type.Creation_Timestamp = DateTime.Now; treatment_performed_action_type.Modification_Timestamp = DateTime.Now; treatment_performed_action_type.Tenant_RefID = securityTicket.TenantID; treatment_performed_action_type.Save(Connection, Transaction); treatment_performed_action_type_id = treatment_performed_action_type.HEC_ACT_ActionTypeID; } else { treatment_performed_action_type_id = treatment_performed_action_type.HEC_ACT_ActionTypeID; } List <Submitted_Case_Model> allCases = Get_All_Cases_With_Custom_Status.Get_All_Submited_Cases_With_Custom_Status("FS2", securityTicket); List <Submitted_Case_Model> allCases_FS11 = Get_All_Cases_With_Custom_Status.Get_All_Submited_Cases_With_Custom_Status("FS11", securityTicket); List <Submitted_Case_Model> newCaseList = new List <Submitted_Case_Model>(); List <Settlement_Model> settlements = new List <Settlement_Model>(); List <PatientDetailViewModel> patientDetailList = new List <PatientDetailViewModel>(); List <DateTime> OldTransmitionDateList = new List <DateTime>(); Dictionary <Guid, int> consentValidToCache = new Dictionary <Guid, int>(); //List<Guid> casesToChange = new List<Guid>(); //List<string> typeList = new List<string>(); List <NegativeResponseModel> NegativeResponseList = new List <NegativeResponseModel>(); var preexaminationsCache = cls_Get_Patient_Preexaminations_on_Tenant.Invoke(Connection, Transaction, securityTicket).Result.GroupBy(t => t.PatientID).ToDictionary(t => t.Key, t => t.GroupBy(c => c.Localization).ToDictionary(d => d.Key, d => d)); DateTime DateForElastic = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); var casesForReport = cls_Get_Cases_For_Report.Invoke(Connection, Transaction, new P_CAS_GCFR_0910() { Status = 2 }, securityTicket).Result; var casesForReport_FS11 = cls_Get_Cases_For_Report.Invoke(Connection, Transaction, new P_CAS_GCFR_0910() { Status = 11 }, securityTicket).Result; Dictionary <string, string> serviceFeeValueCache = new Dictionary <string, string>(); List <CaseForReportModel> caseModelList = new List <CaseForReportModel>(); foreach (var item in Parameter.CasesToBeChanged) { try { var errorCase = casesForReport.SingleOrDefault(i => int.Parse(i.PositionNumber) == int.Parse(item.bill_number)); bool shouldChangeToFS8 = false; if (errorCase == null) { errorCase = casesForReport_FS11.SingleOrDefault(i => int.Parse(i.PositionNumber) == int.Parse(item.bill_number)); shouldChangeToFS8 = true; } var management_fee_value = "-"; if (!string.IsNullOrEmpty(errorCase.BillingCode)) { if (!serviceFeeValueCache.ContainsKey(errorCase.BillingCode)) { var service_fee_value = cls_Get_ServiceFeeValue_for_BillingCode.Invoke(Connection, Transaction, new P_CAS_GSFVfBC_1721() { BillingCode = errorCase.BillingCode }, securityTicket).Result; if (service_fee_value != null) { serviceFeeValueCache.Add(errorCase.BillingCode, service_fee_value.service_fee); } } management_fee_value = serviceFeeValueCache[errorCase.BillingCode]; } var negativeTransmitionQuery = new ORM_BIL_BillPosition_TransmitionStatus.Query(); negativeTransmitionQuery.Tenant_RefID = securityTicket.TenantID; negativeTransmitionQuery.IsDeleted = false; negativeTransmitionQuery.BillPosition_RefID = errorCase.StatusID; var negativeTransmition = ORM_BIL_BillPosition_TransmitionStatus.Query.Search(Connection, Transaction, negativeTransmitionQuery).ToList(); var caseStatusQuery = new ORM_BIL_BillPosition_TransmitionStatus.Query(); caseStatusQuery.Tenant_RefID = securityTicket.TenantID; caseStatusQuery.IsDeleted = false; caseStatusQuery.IsActive = true; caseStatusQuery.BIL_BillPosition_TransmitionStatusID = errorCase.StatusID; var caseStatusOld = ORM_BIL_BillPosition_TransmitionStatus.Query.Search(Connection, Transaction, caseStatusQuery).SingleOrDefault(); if (caseStatusOld == null) { throw new Exception("Transmition status not found for id: " + errorCase.StatusID); } OldTransmitionDateList.Add(caseStatusOld.TransmittedOnDate); caseStatusOld.IsActive = false; caseStatusOld.Save(Connection, Transaction); var caseStatus = new ORM_BIL_BillPosition_TransmitionStatus(); caseStatus.IsDeleted = false; caseStatus.Creation_Timestamp = DateTime.Now; caseStatus.Modification_Timestamp = DateTime.Now; caseStatus.Tenant_RefID = securityTicket.TenantID; caseStatus.IsActive = true; caseStatus.PrimaryComment = item.error_message; caseStatus.BIL_BillPosition_TransmitionStatusID = Guid.NewGuid(); caseStatus.BillPosition_RefID = caseStatusOld.BillPosition_RefID; caseStatus.TransmitionCode = 5; caseStatus.TransmittedOnDate = DateTime.Now;// should we use from edifact? caseStatus.TransmitionStatusKey = caseStatusOld.TransmitionStatusKey; caseStatus.Save(Connection, Transaction); if (shouldChangeToFS8) { caseStatus.IsActive = false; caseStatus.Save(Connection, Transaction); var caseStatus2 = new ORM_BIL_BillPosition_TransmitionStatus(); caseStatus2.IsDeleted = false; caseStatus2.Creation_Timestamp = DateTime.Now; caseStatus2.Modification_Timestamp = DateTime.Now; caseStatus2.Tenant_RefID = securityTicket.TenantID; caseStatus2.IsActive = true; caseStatus2.PrimaryComment = item.error_message; caseStatus2.BIL_BillPosition_TransmitionStatusID = Guid.NewGuid(); caseStatus2.BillPosition_RefID = caseStatusOld.BillPosition_RefID; caseStatus2.TransmitionCode = 8; caseStatus2.TransmittedOnDate = DateTime.Now;// should we use from edifact? caseStatus2.TransmitionStatusKey = caseStatusOld.TransmitionStatusKey; caseStatus2.Save(Connection, Transaction); } Guid caseID = errorCase.CaseID; NegativeResponseModel negativeResponse = new NegativeResponseModel(); negativeResponse.caseID = caseID; //casesToChange.Add(caseID); if (caseStatusOld.TransmitionStatusKey == "aftercare") { negativeResponse.plannedActionID = errorCase.IsAftercareID; negativeResponse.type = "ac"; } //typeList.Add("ac"); else if (caseStatusOld.TransmitionStatusKey == "treatment") { negativeResponse.plannedActionID = errorCase.IsTreatmentID; negativeResponse.type = "op"; } else { negativeResponse.plannedActionID = errorCase.IsTreatmentID; negativeResponse.type = caseStatusOld.TransmitionStatusKey; } //typeList.Add("op"); NegativeResponseList.Add(negativeResponse); P_PA_GPDfPID_1124 patientData = cls_Get_Patient_Details_for_PatientID.Invoke(Connection, Transaction, new P_P_PA_GPDfPID_1124() { PatientID = errorCase.Patient_RefID }, securityTicket).Result; #region Report data CaseForReportModel caseModel = new CaseForReportModel(); caseModel.HIP = patientData.health_insurance_provider; caseModel.ContractID = patientData.contractID; caseModel.HIP_IK = patientData.HealthInsurance_IKNumber; caseModel.PatientInsuranceNumber = patientData.insurance_id; caseModel.PatientGender = patientData.gender; caseModel.PatientStatusNumber = patientData.insurance_status; caseModel.PatientFirstName = patientData.patient_first_name; caseModel.PatientLastName = patientData.patient_last_name; caseModel.PatientBirthday = patientData.birthday; try { if (!consentValidToCache.ContainsKey(patientData.contractID)) { double DurationOfParticipationConsentinMonths = ORM_CMN_CTR_Contract_Parameter.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Parameter.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, ParameterName = "Duration of participation consent – Month", Contract_RefID = patientData.contractID }).SingleOrDefault().IfNumericValue_Value; consentValidToCache.Add(patientData.contractID, Convert.ToInt32(DurationOfParticipationConsentinMonths)); } DateTime participationConsentValidTo = patientData.ParticipationConsent.OrderBy(dt => dt.participation_consent_issue_date).FirstOrDefault().participation_consent_issue_date.AddMonths(consentValidToCache[patientData.contractID]); caseModel.PatientParticipationConsentValidUntil = participationConsentValidTo; } catch (Exception ex) { caseModel.PatientParticipationConsentValidUntil = DateTime.MinValue; } caseModel.CaseNumber = Convert.ToInt32(errorCase.CaseNumber); caseModel.CaseType = errorCase.CodeName; try { caseModel.Drug = cls_Get_Drug_Details_for_DrugID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1614() { DrugID = errorCase.DrugID }, securityTicket).Result.drug_name; } catch (Exception ex) { caseModel.Drug = "-"; } caseModel.Diagnose = errorCase.IM_PotentialDiagnosis_Name; caseModel.DiagnoseCode = errorCase.IM_PotentialDiagnosis_Code; caseModel.Localization = errorCase.IM_PotentialDiagnosisLocalization_Code; P_CAS_GTCfPIDaDIDaLC_1008 parameterDia = new P_CAS_GTCfPIDaDIDaLC_1008(); parameterDia.PatientID = errorCase.Patient_RefID; parameterDia.DiagnoseID = errorCase.CodeForType == "treatment" || errorCase.CodeForType == "preexamination" ? errorCase.TreatmentPerformedDiganoseID : errorCase.AftercasePerformedDiagnoseID; parameterDia.LocalizationCode = errorCase.IM_PotentialDiagnosisLocalization_Code; parameterDia.PerformedDate = errorCase.CodeForType == "treatment" || errorCase.CodeForType == "preexamination" ? errorCase.TreatmentDate : errorCase.AfterCareDate; parameterDia.ActionTypeID = treatment_performed_action_type_id; if (errorCase.CodeForType == "preexamination") { if (preexaminationsCache.ContainsKey(errorCase.Patient_RefID) && preexaminationsCache[errorCase.Patient_RefID].ContainsKey(errorCase.IM_PotentialDiagnosisLocalization_Code)) { caseModel.TreatmentCount = preexaminationsCache[errorCase.Patient_RefID][errorCase.IM_PotentialDiagnosisLocalization_Code].Count(c => c.PreexaminationDate.Date <= errorCase.TreatmentDate.Date); } } else { caseModel.TreatmentCount = cls_Get_Treatment_Count_for_PatientID_And_DiagnoseID_and_LocalizationCode.Invoke(Connection, Transaction, parameterDia, securityTicket).Result.treatment_count; } caseModel.GPOS = errorCase.BillingCode; caseModel.TreatmentDay = errorCase.CodeForType == "treatment" || errorCase.CodeForType == "preexamination" ? errorCase.TreatmentDate : errorCase.AfterCareDate; if (errorCase.CodeForType == "treatment") { caseModel.SurgeryDateForThisCase = errorCase.TreatmentDate; } else if (errorCase.CodeForType == "preexamination") { caseModel.SurgeryDateForThisCase = DateTime.MinValue; } else { CAS_GTdfA_0936 Trdate = cls_Get_Treatment_Date_for_Aftercare.Invoke(Connection, Transaction, new P_CAS_GTdfA_0936() { CaseID = errorCase.CaseID }, securityTicket).Result; if (Trdate != null) { caseModel.SurgeryDateForThisCase = Trdate.TreatmentDate; } } switch (patientData.gender) { case 0: caseModel.PatientSalutation = "Herr"; break; case 1: caseModel.PatientSalutation = "Frau"; break; default: caseModel.PatientSalutation = "-"; break; } if (!shouldChangeToFS8) { caseModel.CurrentStatus = FS5; } else { caseModel.CurrentStatus = FS8; } caseModel.DateOfCurrentStatus = DateTime.Now; if (!shouldChangeToFS8) { caseModel.PreCurrentStatus = FS2; } else { caseModel.PreCurrentStatus = FS11; } caseModel.DateOfPreCurrentStatus = caseStatusOld.TransmittedOnDate; caseModel.InvoiceNumberForTheHIP = Convert.ToInt32(errorCase.PositionNumber); caseModel.AmountForThisGPOS = errorCase.NumberForPayment; caseModel.NumberOfNegativeTry = negativeTransmition.Count.ToString(); caseModel.DateOfTheSubmissionToTheHIP = Parameter.transferToHIPDate; caseModel.FeedBackOfTheHIP = item.transmition_date; caseModel.PaymentDate = DateTime.MinValue; caseModel.DrugOrdered = (errorCase.orderId != Guid.Empty && int.Parse(errorCase.orderStatusCode) != 6) ? "Ja" : "Nein"; caseModel.NoFee = errorCase.IsPatientFeeWaived ? "Ja" : "Nein"; caseModel.InvoiceToPractice = errorCase.SendInvoiceToPractice ? "Ja" : "Nein"; caseModel.OnlyLabelRequired = errorCase.isLabelOnly ? "Ja" : "Nein"; var gposAssignmentCount = cls_Get_Gpos_AssignmentCount_for_GposID.Invoke(Connection, Transaction, new P_CAS_GGPOSACfGPOSID_1252() { GposID = errorCase.GposID }, securityTicket).Result; if (gposAssignmentCount.AssignmentCount != 0) { var is_management_fee_waived = cls_Get_Management_Fee_Property_Value_for_CaseID_and_GposID.Invoke(Connection, Transaction, new P_CAS_GMFPVfCIDaGPOSTID_1749() { CaseID = errorCase.CaseID, GposID = errorCase.GposID }, securityTicket).Result; caseModel.ManagementFee = is_management_fee_waived == null ? "-" : is_management_fee_waived.PropertyValue == "waived" ? "-" : management_fee_value; } else { caseModel.ManagementFee = "-"; } Guid DocID = errorCase.CodeForType == "treatment" || errorCase.CodeForType == "preexamination" ? errorCase.SurgeryDoctor : errorCase.AfterCareDoctor; DO_GDDfDID_0823 doctorData = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = DocID }, securityTicket).Result.First(); caseModel.BSNR = doctorData.BSNR; caseModel.PracticeName = doctorData.practice; caseModel.DocName = doctorData.first_name + " " + doctorData.last_name; caseModel.LANR = doctorData.lanr; caseModel.BankAccountHolder = string.IsNullOrEmpty(doctorData.OwnerText) ? "-" : doctorData.OwnerText; caseModel.BankName = doctorData.BankName == null ? "-" : doctorData.BankName; caseModel.IBAN = doctorData.IBAN == null ? "-" : doctorData.IBAN; caseModel.BIC = doctorData.BICCode == null ? "-" : doctorData.BICCode; caseModelList.Add(caseModel); #endregion } catch (Exception ex) { LogUtils.Logger.LogInfo(new LogUtils.LogEntry(ex.StackTrace)); throw new Exception("Bill position: " + item.bill_number, ex); } } //Change in Elastic--------------------------------------------------------------------------------- for (int k = 0; k < NegativeResponseList.Count; k++) { var errorCase = allCases.SingleOrDefault(i => i.case_id == NegativeResponseList[k].caseID.ToString() && i.type == NegativeResponseList[k].type); if (errorCase == null) { errorCase = allCases_FS11.SingleOrDefault(i => i.case_id == NegativeResponseList[k].caseID.ToString() && i.type == NegativeResponseList[k].type); if (errorCase == null) { continue; } errorCase.status = "FS8"; //Change settlement from Stornierung anhängig to storniert Settlement_Model settlement = Get_Settlement.GetSettlementForID(NegativeResponseList[k].plannedActionID.ToString(), securityTicket); settlement.status = "FS8"; settlements.Add(settlement); PatientDetailViewModel patient_detail = Retrieve_Patients.Get_PatientDetaiForID(settlement.id, securityTicket); if (patient_detail != null) { patient_detail.status = "FS8"; patientDetailList.Add(patient_detail); } } else { errorCase.status = "FS5"; } errorCase.status_date = DateTime.Now; errorCase.status_date_string = DateTime.Now.ToString("dd.MM.yyyy"); newCaseList.Add(errorCase); } if (settlements.Count > 0) { Add_new_Settlement.Import_Settlement_to_ElasticDB(settlements, securityTicket.TenantID.ToString()); } if (patientDetailList.Count > 0) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); } if (newCaseList.Count > 0) { Add_New_Submitted_Case.Import_Submitted_Case_Data_to_ElasticDB(newCaseList, securityTicket.TenantID.ToString()); List <Documents> documentList = new List <Documents>(); string hipID = Parameter.hipId; var healthInsuranceCompanyQuery = new ORM_HEC_HIS_HealthInsurance_Company.Query(); healthInsuranceCompanyQuery.IsDeleted = false; healthInsuranceCompanyQuery.Tenant_RefID = securityTicket.TenantID; healthInsuranceCompanyQuery.HealthInsurance_IKNumber = hipID; var helathInsurance = ORM_HEC_HIS_HealthInsurance_Company.Query.Search(Connection, Transaction, healthInsuranceCompanyQuery).Single(); var businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQuery.CMN_BPT_BusinessParticipantID = helathInsurance.CMN_BPT_BusinessParticipant_RefID; businessParticipantQuery.IsDeleted = false; businessParticipantQuery.Tenant_RefID = securityTicket.TenantID; var businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single(); //Save Edifact string edi_path = System.IO.Path.GetTempPath() + Parameter.edi_name; System.IO.File.WriteAllText(edi_path, Parameter.edi_message); List <string> files = new List <string>(); files.Add(edi_path); string zipPath = System.IO.Path.GetTempPath() + Parameter.edi_name + ".zip"; ZipFIlesUtils.AddToArchive(zipPath, files); string earliestDate = OldTransmitionDateList.OrderBy(d => d).First().ToString("dd.MM.yyyy"); string lastDate = OldTransmitionDateList.OrderBy(d => d).Last().ToString("dd.MM.yyyy"); Documents documentEdifact = new Documents(); documentEdifact.documentName = "Import von " + earliestDate + " - " + lastDate; documentEdifact.documentOutputLocation = zipPath; documentEdifact.receiver = businessParticipant.DisplayName; documentEdifact.mimeType = "Application/Edifact_Error"; documentList.Add(documentEdifact); Documents documentExcel = new Documents(); documentExcel.documentName = "ExcelReport" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm"); documentExcel.documentOutputLocation = GenerateReportCases.CreateCaseXlsReport(caseModelList, documentExcel.documentName); documentExcel.mimeType = UtilMethods.GetMimeType(documentExcel.documentOutputLocation); documentExcel.receiver = "MM"; documentList.Add(documentExcel); foreach (var item in documentList) { MemoryStream ms = new MemoryStream(File.ReadAllBytes(item.documentOutputLocation)); byte[] byteArrayFile = ms.ToArray(); var _providerFactory = ProviderFactory.Instance; var documentProvider = _providerFactory.CreateDocumentServiceProvider(); var uploadedFrom = HttpContext.Current.Request.UserHostAddress; Guid documentID = documentProvider.UploadDocument(byteArrayFile, item.documentOutputLocation, securityTicket.SessionTicket, uploadedFrom); string downloadURL = documentProvider.GenerateImageThumbnailLink(documentID, securityTicket.SessionTicket, false, 200); P_ARCH_UD_1326 parameterDoc = new P_ARCH_UD_1326(); parameterDoc.DocumentID = documentID; parameterDoc.Mime = item.mimeType; parameterDoc.DocumentName = item.documentName; parameterDoc.DocumentDate = DateForElastic; parameterDoc.Receiver = item.receiver; parameterDoc.ContractID = item.ContractID; if (parameterDoc.Mime == "Application/Edifact_Error") { parameterDoc.Description = parameterDoc.DocumentName; } else { parameterDoc.Description = "KV Fehler"; } cls_Upload_Report.Invoke(Connection, Transaction, parameterDoc, securityTicket); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_SP_1436 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here #region DATA var patient_details = cls_Get_Patient_Details_for_PatientID.Invoke(Connection, Transaction, new P_P_PA_GPDfPID_1124() { PatientID = Parameter.patient_id }, securityTicket).Result; if (patient_details == null) { throw new Exception("Patient details not found for ID: " + Parameter.patient_id); } var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, new ORM_HEC_Doctor.Query() { Tenant_RefID = securityTicket.TenantID, HEC_DoctorID = Parameter.treatment_doctor_id, IsDeleted = false }).SingleOrDefault(); if (doctor == null) { throw new Exception("Doctor not found for ID: " + Parameter.treatment_doctor_id); } var doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = Parameter.treatment_doctor_id }, securityTicket).Result.FirstOrDefault(); if (doctor_details == null) { throw new Exception("Doctor details not found for ID: " + Parameter.treatment_doctor_id); } var practice_details = cls_Get_Practice_Details_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPDfPID_1432() { PracticeID = doctor_details.practice_id }, securityTicket).Result.FirstOrDefault(); if (practice_details == null) { throw new Exception("Practice details not found for ID: " + doctor_details.practice_id); } #endregion #region EDIT var preexaminationCase = ORM_HEC_CAS_Case.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_CAS_CaseID = Parameter.case_id }).SingleOrDefault(); if (preexaminationCase == null) { throw new Exception("Case not found; id: " + Parameter.case_id); } preexaminationCase.Patient_BirthDate = patient_details.birthday; preexaminationCase.Patient_FirstName = patient_details.patient_first_name; preexaminationCase.Patient_Gender = patient_details.gender; preexaminationCase.Patient_LastName = patient_details.patient_last_name; preexaminationCase.Patient_RefID = Parameter.patient_id; preexaminationCase.Modification_Timestamp = DateTime.Now; preexaminationCase.Save(Connection, Transaction); var plannedAction = cls_Get_Treatment_Planned_Action_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GTPAfCID_0946() { CaseID = Parameter.case_id }, securityTicket).Result; if (plannedAction == null) { throw new Exception("Planned action not found; case id: " + Parameter.case_id); } var preexaminationPlannedAction = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction.Query() { HEC_ACT_PlannedActionID = plannedAction.planned_action_id, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (preexaminationPlannedAction == null) { throw new Exception("Preexamination planned action not found; case id: " + Parameter.case_id); } preexaminationPlannedAction.Patient_RefID = Parameter.patient_id; preexaminationPlannedAction.Modification_Timestamp = DateTime.Now; preexaminationPlannedAction.PlannedFor_Date = Parameter.treatment_date; preexaminationPlannedAction.ToBePerformedBy_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; preexaminationPlannedAction.Save(Connection, Transaction); var diagnosisIDs = cls_Get_Planned_Action_DiagnosisIDs_for_PlannedActionID.Invoke(Connection, Transaction, new P_CAS_GPADIDsfPAID_1041() { PlannedActionID = preexaminationPlannedAction.HEC_ACT_PlannedActionID }, securityTicket).Result; if (diagnosisIDs == null) { throw new Exception("Diagnosis ids not found for planned action id: " + preexaminationPlannedAction.HEC_ACT_PlannedActionID); } var diagnosisLocalization = ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_ACT_PerformedAction_DiagnosisUpdate_LocalizationID = diagnosisIDs.HEC_ACT_PerformedAction_DiagnosisUpdate_LocalizationID }).SingleOrDefault(); if (diagnosisLocalization == null) { throw new Exception("Diagnosis localization not found for id: " + diagnosisIDs.HEC_ACT_PerformedAction_DiagnosisUpdate_LocalizationID); } diagnosisLocalization.Modification_Timestamp = DateTime.Now; diagnosisLocalization.IM_PotentialDiagnosisLocalization_Code = Parameter.is_left_eye ? "L" : "R"; diagnosisLocalization.Save(Connection, Transaction); #endregion #region ELASTIC try { var settlements = new List <Settlement_Model>(); var treatments = new List <Submitted_Case_Model>(); var patientDetailsList = new List <PatientDetailViewModel>(); #region Settlement var settlement = Get_Settlement.GetSettlementForID(preexaminationPlannedAction.HEC_ACT_PlannedActionID.ToString(), securityTicket); settlement.birthday = patient_details.birthday.ToString("dd.MM.yyyy"); settlement.bsnr = practice_details.practice_BSNR; settlement.doctor = MMDocConnectDocApp.GenericUtils.GetDoctorName(doctor_details); settlement.first_name = patient_details.patient_first_name; settlement.hip = patient_details.health_insurance_provider; settlement.lanr = doctor_details.lanr; settlement.last_name = patient_details.patient_last_name; settlement.localization = Parameter.is_left_eye ? "L" : "R"; settlement.patient_full_name = patient_details.patient_first_name + " " + patient_details.patient_last_name; settlement.patient_id = Parameter.patient_id.ToString(); settlement.patient_insurance_number = patient_details.insurance_id; settlement.practice_id = doctor_details.practice_id.ToString(); settlement.surgery_date = Parameter.treatment_date; settlement.surgery_date_string = Parameter.treatment_date.ToString("dd.MM.yyyy"); settlement.treatment_doctor_id = Parameter.treatment_doctor_id.ToString(); settlements.Add(settlement); #endregion #region MM Treatment var treatment = Get_Submitted_Cases.GetSubmittedCaseforSubmittedCaseID(preexaminationPlannedAction.HEC_ACT_PlannedActionID.ToString(), securityTicket); treatment.doctor_id = Parameter.treatment_doctor_id.ToString(); treatment.doctor_lanr = doctor_details.lanr; treatment.doctor_name = MMDocConnectDocApp.GenericUtils.GetDoctorName(doctor_details); treatment.hip_name = patient_details.health_insurance_provider; treatment.localization = Parameter.is_left_eye ? "L" : "R"; treatment.patient_birthdate = patient_details.birthday; treatment.patient_birthdate_string = patient_details.birthday.ToString("dd.MM.yyyy"); treatment.patient_id = Parameter.patient_id.ToString(); treatment.patient_insurance_number = patient_details.insurance_id; treatment.patient_name = patient_details.patient_last_name + ", " + patient_details.patient_first_name; treatment.practice_bsnr = practice_details.practice_BSNR; treatment.practice_id = practice_details.practiceID.ToString(); treatment.practice_name = practice_details.practice_name; treatment.treatment_date = Parameter.treatment_date; treatment.treatment_date_month_year = Parameter.treatment_date.ToString("MMMM yyyy", new System.Globalization.CultureInfo("de", true)); treatment.treatment_date_string = Parameter.treatment_date.ToString("dd.MM.yyyy"); treatments.Add(treatment); #endregion #region Patient details PatientDetailViewModel patientDetal_elastic = Retrieve_Patients.Get_PatientDetaiForID(preexaminationPlannedAction.HEC_ACT_PlannedActionID.ToString(), securityTicket); patientDetal_elastic.practice_id = settlement.practice_id; patientDetal_elastic.date = settlement.surgery_date; patientDetal_elastic.date_string = settlement.surgery_date_string; patientDetal_elastic.treatment_doctor_id = settlement.treatment_doctor_id; patientDetal_elastic.diagnose_or_medication = settlement.diagnose; patientDetal_elastic.doctor = settlement.doctor; patientDetal_elastic.localisation = settlement.localization; patientDetal_elastic.patient_id = settlement.patient_id; patientDetal_elastic.status = settlement.status; patientDetailsList.Add(patientDetal_elastic); #endregion if (settlements.Any()) { Add_new_Settlement.Import_Settlement_to_ElasticDB(settlements, securityTicket.TenantID.ToString()); } if (treatments.Any()) { Add_New_Submitted_Case.Import_Submitted_Case_Data_to_ElasticDB(treatments, securityTicket.TenantID.ToString()); } if (patientDetailsList.Any()) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailsList, securityTicket.TenantID.ToString()); } } catch (Exception ex) { throw new Exception("Retrieval/Import to elastic failed. " + ex.Message); } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_PA_SPPC_1413 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); List <PatientDetailViewModel> patientDetailList = new List <PatientDetailViewModel>(); PatientDetailViewModel elasticPatientDetailModel = new PatientDetailViewModel(); if (Parameter.participation_id == Guid.Empty) { var InsuranceToBrokerContractQuery = new ORM_HEC_CRT_InsuranceToBrokerContract.Query(); InsuranceToBrokerContractQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContractQuery.IsDeleted = false; InsuranceToBrokerContractQuery.Ext_CMN_CTR_Contract_RefID = Parameter.contract_id; ORM_HEC_CRT_InsuranceToBrokerContract InsuranceToBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, InsuranceToBrokerContractQuery).Single(); ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient InsuranceToBrokerContract_ParticipatingPatient = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient(); InsuranceToBrokerContract_ParticipatingPatient.HEC_CRT_InsuranceToBrokerContract_ParticipatingPatientID = Guid.NewGuid(); InsuranceToBrokerContract_ParticipatingPatient.InsuranceToBrokerContract_RefID = InsuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; InsuranceToBrokerContract_ParticipatingPatient.Creation_Timestamp = DateTime.Now; InsuranceToBrokerContract_ParticipatingPatient.Modification_Timestamp = DateTime.Now; InsuranceToBrokerContract_ParticipatingPatient.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContract_ParticipatingPatient.ValidFrom = Parameter.issue_date; if (Parameter.participation_consent_valid_days != 0) { InsuranceToBrokerContract_ParticipatingPatient.ValidThrough = Parameter.issue_date.AddMonths(Parameter.participation_consent_valid_days); } else { InsuranceToBrokerContract_ParticipatingPatient.ValidThrough = Parameter.contract_ValidTo; } InsuranceToBrokerContract_ParticipatingPatient.Patient_RefID = Parameter.patient_id; InsuranceToBrokerContract_ParticipatingPatient.Save(Connection, Transaction); #region UpdateElastic Patient_Model patientModel = new Patient_Model(); patientModel = Retrieve_Patients.Get_Patient_for_PatientID(Parameter.patient_id.ToString(), securityTicket); var InsuranceToBrokerContract_ParticipatingPatientQuery = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query(); InsuranceToBrokerContract_ParticipatingPatientQuery.IsDeleted = false; InsuranceToBrokerContract_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContract_ParticipatingPatientQuery.Patient_RefID = Parameter.patient_id; var allInsuranceToBrokerContract_ParticipatingPatient = ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query.Search(Connection, Transaction, InsuranceToBrokerContract_ParticipatingPatientQuery).ToList(); var latest_participation_date = allInsuranceToBrokerContract_ParticipatingPatient.OrderByDescending(m => m.ValidFrom).FirstOrDefault(); patientModel.participation_consent_from = latest_participation_date.ValidFrom; patientModel.participation_consent_to = latest_participation_date.ValidThrough; patientModel.has_participation_consent = true; /// elasticPatientDetailModel.id = InsuranceToBrokerContract_ParticipatingPatient.HEC_CRT_InsuranceToBrokerContract_ParticipatingPatientID.ToString(); elasticPatientDetailModel.practice_id = Parameter.practice_id.ToString(); elasticPatientDetailModel.patient_id = Parameter.patient_id.ToString(); elasticPatientDetailModel.date = Parameter.issue_date; elasticPatientDetailModel.date_string = Parameter.issue_date.ToString("dd.MM."); elasticPatientDetailModel.detail_type = "participation"; var insuranceBrokerContractQuery = new ORM_HEC_CRT_InsuranceToBrokerContract.Query(); insuranceBrokerContractQuery.IsDeleted = false; insuranceBrokerContractQuery.Tenant_RefID = securityTicket.TenantID; insuranceBrokerContractQuery.HEC_CRT_InsuranceToBrokerContractID = InsuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; var insuranceBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, insuranceBrokerContractQuery).Single(); var contractQuery = new ORM_CMN_CTR_Contract.Query(); contractQuery.IsDeleted = false; contractQuery.Tenant_RefID = securityTicket.TenantID; contractQuery.CMN_CTR_ContractID = insuranceBrokerContract.Ext_CMN_CTR_Contract_RefID; var contract = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, contractQuery).Single(); var contractParameters = ORM_CMN_CTR_Contract_Parameter.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Parameter.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Contract_RefID = Parameter.contract_id }); var validUntil = contractParameters.Where(t => t.ParameterName == "Duration of participation consent – Month").SingleOrDefault(); var aftercareDays = contractParameters.Where(t => t.ParameterName == "Number of days between surgery and aftercare - Days").SingleOrDefault(); var validUntilDate = validUntil == null || validUntil.IfNumericValue_Value == double.MaxValue ? DateTime.MaxValue : Parameter.issue_date.AddMonths(Convert.ToInt32(validUntil.IfNumericValue_Value)); if (aftercareDays != null && aftercareDays.IfNumericValue_Value != double.MaxValue) { validUntilDate = validUntilDate.AddDays(-Convert.ToInt32(aftercareDays.IfNumericValue_Value)); } var validUntilStr = validUntilDate == DateTime.MaxValue ? "∞" : validUntilDate.ToString("dd.MM.yyyy"); elasticPatientDetailModel.diagnose_or_medication = Properties.Resources.participarionConsent + " " + contract.ContractName + ", " + Properties.Resources.goodUntil + " " + validUntilStr; elasticPatientDetailModel.case_id = contract.CMN_CTR_ContractID.ToString(); patientDetailList.Add(elasticPatientDetailModel); Add_New_Patient.Import_Patients_to_ElasticDB(new List <Patient_Model>() { patientModel }, securityTicket.TenantID.ToString()); Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); #endregion } else { //#EDIT****** //find new contract var InsuranceToBrokerContractQuery = new ORM_HEC_CRT_InsuranceToBrokerContract.Query(); InsuranceToBrokerContractQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContractQuery.IsDeleted = false; InsuranceToBrokerContractQuery.Ext_CMN_CTR_Contract_RefID = Parameter.contract_id; ORM_HEC_CRT_InsuranceToBrokerContract InsuranceToBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, InsuranceToBrokerContractQuery).Single(); var queryParticipant = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query(); queryParticipant.IsDeleted = false; queryParticipant.Tenant_RefID = securityTicket.TenantID; queryParticipant.HEC_CRT_InsuranceToBrokerContract_ParticipatingPatientID = Parameter.participation_id; var InsuranceToBrokerContract_ParticipatingPatient = ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query.Search(Connection, Transaction, queryParticipant).Single(); InsuranceToBrokerContract_ParticipatingPatient.InsuranceToBrokerContract_RefID = InsuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; InsuranceToBrokerContract_ParticipatingPatient.Modification_Timestamp = DateTime.Now; InsuranceToBrokerContract_ParticipatingPatient.ValidFrom = Parameter.issue_date; InsuranceToBrokerContract_ParticipatingPatient.ValidFrom = Parameter.issue_date; if (Parameter.participation_consent_valid_days != 0) { InsuranceToBrokerContract_ParticipatingPatient.ValidThrough = Parameter.issue_date.AddMonths(Parameter.participation_consent_valid_days); } else { InsuranceToBrokerContract_ParticipatingPatient.ValidThrough = Parameter.contract_ValidTo; } InsuranceToBrokerContract_ParticipatingPatient.Save(Connection, Transaction); #region Update Elastic Patient_Model patientModel = new Patient_Model(); patientModel = Retrieve_Patients.Get_Patient_for_PatientID(Parameter.patient_id.ToString(), securityTicket); var InsuranceToBrokerContract_ParticipatingPatientQuery = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query(); InsuranceToBrokerContract_ParticipatingPatientQuery.IsDeleted = false; InsuranceToBrokerContract_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContract_ParticipatingPatientQuery.Patient_RefID = Parameter.patient_id; var allInsuranceToBrokerContract_ParticipatingPatient = ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query.Search(Connection, Transaction, InsuranceToBrokerContract_ParticipatingPatientQuery).ToList(); var latest_participation_date = allInsuranceToBrokerContract_ParticipatingPatient.OrderByDescending(m => m.ValidFrom).FirstOrDefault(); patientModel.participation_consent_from = latest_participation_date.ValidFrom; patientModel.participation_consent_to = latest_participation_date.ValidThrough; patientModel.has_participation_consent = true; var insuranceBrokerContractQuery = new ORM_HEC_CRT_InsuranceToBrokerContract.Query(); insuranceBrokerContractQuery.IsDeleted = false; insuranceBrokerContractQuery.Tenant_RefID = securityTicket.TenantID; insuranceBrokerContractQuery.HEC_CRT_InsuranceToBrokerContractID = InsuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; var insuranceBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, insuranceBrokerContractQuery).Single(); var contractQuery = new ORM_CMN_CTR_Contract.Query(); contractQuery.IsDeleted = false; contractQuery.Tenant_RefID = securityTicket.TenantID; contractQuery.CMN_CTR_ContractID = insuranceBrokerContract.Ext_CMN_CTR_Contract_RefID; var contract = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, contractQuery).Single(); var elasticPatientDetailModel2 = Retrieve_Patients.Get_PatientDetaiForID(Parameter.participation_id.ToString(), securityTicket); if (elasticPatientDetailModel2 != null) { elasticPatientDetailModel2.date = Parameter.issue_date; elasticPatientDetailModel2.date_string = Parameter.issue_date.ToString("dd.MM."); var contractParameters = ORM_CMN_CTR_Contract_Parameter.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Parameter.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Contract_RefID = Parameter.contract_id }); var validUntil = contractParameters.Where(t => t.ParameterName == "Duration of participation consent – Month").SingleOrDefault(); var aftercareDays = contractParameters.Where(t => t.ParameterName == "Number of days between surgery and aftercare - Days").SingleOrDefault(); var validUntilDate = validUntil == null || validUntil.IfNumericValue_Value == double.MaxValue ? DateTime.MaxValue : Parameter.issue_date.AddMonths(Convert.ToInt32(validUntil.IfNumericValue_Value)); if (aftercareDays != null && aftercareDays.IfNumericValue_Value != double.MaxValue) { validUntilDate = validUntilDate.AddDays(-Convert.ToInt32(aftercareDays.IfNumericValue_Value)); } var validUntilStr = validUntilDate == DateTime.MaxValue ? "∞" : validUntilDate.ToString("dd.MM.yyyy"); elasticPatientDetailModel2.diagnose_or_medication = Properties.Resources.participarionConsent + " " + contract.ContractName + ", " + Properties.Resources.goodUntil + " " + validUntilStr; patientDetailList.Add(elasticPatientDetailModel2); } Add_New_Patient.Import_Patients_to_ElasticDB(new List <Patient_Model>() { patientModel }, securityTicket.TenantID.ToString()); if (patientDetailList.Count != 0) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); } #endregion } return(returnValue); #endregion UserCode }
public PatientDetailPage() { InitializeComponent(); BindingContext = new PatientDetailViewModel(); }
public ActionResult Update(PatientDetailViewModel viewmodel) { int id = _patientBL.UpdatePatient(Mapper.Map <LMGEDI.Core.Data.Model.Patient>(viewmodel.patient)); if (viewmodel.patientHistory.PatientAccountHistory != viewmodel.patient.PatientAccount) { viewmodel.patientHistory.Description += "PatientAccount:" + viewmodel.patientHistory.PatientAccountHistory + "||"; } if (viewmodel.patientHistory.PatientFirstHistory != viewmodel.patient.PatientFirst) { viewmodel.patientHistory.Description += "PatientFirst:" + viewmodel.patientHistory.PatientFirstHistory + "||"; } if (viewmodel.patientHistory.PatientLastHistory != viewmodel.patient.PatientLast) { viewmodel.patientHistory.Description += "PatientLast:" + viewmodel.patientHistory.PatientLastHistory + "||"; } if (viewmodel.patientHistory.PatientGenderHistory.Trim() != viewmodel.patient.PatientGender) { viewmodel.patientHistory.Description += "PatientGender:" + viewmodel.patientHistory.PatientGenderHistory.Trim() + "||"; } if (Convert.ToDateTime(viewmodel.patientHistory.PatientDOBHistory).ToString("MM/dd/yyyy") != viewmodel.patient.PatientDOB) { viewmodel.patientHistory.Description += "PatientDOB:" + Convert.ToDateTime(viewmodel.patientHistory.PatientDOBHistory).ToString("MM/dd/yyyy") + "||"; } if (viewmodel.patientHistory.PatientClaimHistory != viewmodel.patient.PatientClaim) { viewmodel.patientHistory.Description += "PatientClaim:" + viewmodel.patientHistory.PatientClaimHistory + "||"; } if (viewmodel.patientHistory.PatientSSNHistory != viewmodel.patient.PatientSSN) { viewmodel.patientHistory.Description += "PatientSSN:" + viewmodel.patientHistory.PatientSSNHistory + "||"; } if (viewmodel.patientHistory.PatientWCABHistory != viewmodel.patient.PatientWCAB) { viewmodel.patientHistory.Description += "PatientWCAB:" + viewmodel.patientHistory.PatientWCABHistory + "||"; } if (viewmodel.patientHistory.PatientEmployerHistory != viewmodel.patient.PatientEmployer) { viewmodel.patientHistory.Description += "PatientEmployer:" + viewmodel.patientHistory.PatientEmployerHistory + "||"; } if (viewmodel.patientHistory.PatientInsuranceHistory != viewmodel.patient.PatientInsurance) { viewmodel.patientHistory.Description += "PatientInsurance:" + viewmodel.patientHistory.PatientInsuranceHistory + "||"; } if (viewmodel.patientHistory.Description != null) { viewmodel.patientHistory.Description = viewmodel.patientHistory.Description.Substring(0, viewmodel.patientHistory.Description.LastIndexOf("||")); int patientHistoryid = _patientHistoryBL.InsertPatientUpdateHistory(Mapper.Map <LMGEDI.Core.Data.Model.PatientHistory>(viewmodel.patientHistory)); } return(Json("Patient Update Successfully")); }
public PatientDetailPage(PatientDetailViewModel patientModel) { InitializeComponent(); BindingContext = this.patientModel = patientModel; }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_OR_COS_0840 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); List <Case_Model> cases = new List <Case_Model>(); List <PatientDetailViewModel> patientDetailList = new List <PatientDetailViewModel>(); List <Order_Model> OrderModelL = new List <Order_Model>(); //Put your code here foreach (var ParameterInstance in Parameter.ParameterArray) { var procurmentHeader = ORM_ORD_PRC_ProcurementOrder_Header.Query.Search(Connection, Transaction, new ORM_ORD_PRC_ProcurementOrder_Header.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, ORD_PRC_ProcurementOrder_HeaderID = ParameterInstance.Order_ID }).Single(); var newOrderStatus = new ORM_ORD_PRC_ProcurementOrder_Status(); newOrderStatus.Tenant_RefID = securityTicket.TenantID; newOrderStatus.Status_Code = ParameterInstance.Status_To; newOrderStatus.Modification_Timestamp = DateTime.Now; newOrderStatus.Save(Connection, Transaction); var newOrderStatusHistory = new ORM_ORD_PRC_ProcurementOrder_StatusHistory(); newOrderStatusHistory.Tenant_RefID = securityTicket.TenantID; newOrderStatusHistory.ProcurementOrder_Status_RefID = newOrderStatus.ORD_PRC_ProcurementOrder_StatusID; newOrderStatusHistory.IsStatus_RejectedBySupplier = true; newOrderStatusHistory.ProcurementOrder_Header_RefID = procurmentHeader.ORD_PRC_ProcurementOrder_HeaderID; newOrderStatusHistory.Save(Connection, Transaction); procurmentHeader.Current_ProcurementOrderStatus_RefID = newOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurmentHeader.Save(Connection, Transaction); #region Update Case Elastic var caseForUpdate = cls_Get_Case_Details_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GCDfCID_1435() { CaseID = ParameterInstance.CaseID }, securityTicket).Result; var patient_details = cls_Get_Patient_Details_for_PatientID.Invoke(Connection, Transaction, new P_P_PA_GPDfPID_1124() { PatientID = caseForUpdate.patient_id }, securityTicket).Result; var diagnose_details = cls_Get_Diagnose_Details_for_DiagnoseID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1608() { DiagnoseID = caseForUpdate.diagnose_id }, securityTicket).Result; var drug_details = cls_Get_Drug_Details_for_DrugID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1614() { DrugID = caseForUpdate.drug_id }, securityTicket).Result; var treatment_doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = caseForUpdate.op_doctor_id }, securityTicket).Result.SingleOrDefault(); var case_status = cls_Check_Case_Status.Invoke(Connection, Transaction, new P_CAS_CCS_1639() { CaseID = ParameterInstance.CaseID }, securityTicket).Result; if (case_status == null) { var case_model_elastic = Get_Cases.GetCaseforCaseID(caseForUpdate.case_id.ToString(), securityTicket); if (case_model_elastic != null) { case_model_elastic.status_drug_order = ParameterInstance.Status_To_Str; case_model_elastic.order_modification_timestamp = caseForUpdate.order_modification_timestamp; case_model_elastic.order_modification_timestamp_string = caseForUpdate.order_modification_timestamp.ToString("dd.MM.yyyy"); cases.Add(case_model_elastic); } } #endregion var orderM = Get_Orders.GetOrderforOrderID(procurmentHeader.ORD_PRC_ProcurementOrder_HeaderID.ToString(), securityTicket); if (orderM != null) { orderM.status_drug_order = ParameterInstance.Status_To_Str; orderM.order_modification_timestamp = DateTime.Now; orderM.order_modification_timestamp_string = DateTime.Now.ToString("dd.MM.yyyy"); OrderModelL.Add(orderM); var patientDetalTreatmentWithOrder = Retrieve_Patients.Get_PatientDetaiForIDandOrderID(orderM.id, securityTicket).Where(i => i.detail_type == "op").SingleOrDefault(); if (patientDetalTreatmentWithOrder == null) { PatientDetailViewModel patient_detail = new PatientDetailViewModel(); patient_detail.case_id = orderM.case_id; patient_detail.date = orderM.treatment_date; patient_detail.date_string = patient_detail.date.ToString("dd.MM."); patient_detail.detail_type = "order"; patient_detail.diagnose_or_medication = orderM.drug; patient_detail.practice_id = orderM.practice_id; patient_detail.id = orderM.id; patient_detail.order_id = orderM.id; patient_detail.case_id = orderM.case_id; patient_detail.order_status = orderM.status_drug_order; patient_detail.patient_id = patient_details.id.ToString(); patient_detail.drug_id = orderM.drug_id; patientDetailList.Add(patient_detail); } else { patientDetalTreatmentWithOrder.date = orderM.treatment_date; patientDetalTreatmentWithOrder.date_string = patientDetalTreatmentWithOrder.date.ToString("dd.MM."); patientDetalTreatmentWithOrder.case_id = orderM.case_id; patientDetalTreatmentWithOrder.order_id = orderM.id; patientDetalTreatmentWithOrder.practice_id = orderM.practice_id; patientDetalTreatmentWithOrder.drug = orderM.drug; patientDetalTreatmentWithOrder.drug_id = orderM.drug_id; patientDetalTreatmentWithOrder.order_status = orderM.status_drug_order; patientDetalTreatmentWithOrder.patient_id = patient_details.id.ToString(); patientDetailList.Add(patientDetalTreatmentWithOrder); } } } if (patientDetailList.Count != 0) { Add_New_Patient.ImportPatientDetailsToElastic(patientDetailList, securityTicket.TenantID.ToString()); } if (OrderModelL.Count != 0) { Add_New_Order.Import_Order_Data_to_ElasticDB(OrderModelL, securityTicket.TenantID.ToString()); } if (cases.Count != 0) { Add_New_Case.Import_Case_Data_to_ElasticDB(cases, securityTicket.TenantID.ToString()); } return(returnValue); #endregion UserCode }
public PatientDetailView(int id) { InitializeComponent(); BindingContext = new PatientDetailViewModel(id); ViewModel.Navigation = Navigation; }