protected static FR_L6TR_GTBDpHICfID_1130 Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_GTBDpHICfID_1130 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6TR_GTBDpHICfID_1130(); var allTreatments = cls_Get_TreatmentData_by_IDs.Invoke(Connection, Transaction, new P_L6TR_GTDbID_1422() { TreatmentIDList = Parameter.TreatmentID_List }, securityTicket).Result; returnValue.Result = new L6TR_GTBDpHICfID_1130(); List <L5TR_GTHITID_1730> treatment2HICompany = cls_Get_Treatment_and_HealthInsuranceCompanu_for_TreatmentID.Invoke(Connection, Transaction, new P_L5TR_GTHITID_1730() { TreatmentID = Parameter.TreatmentID_List }, securityTicket).Result.ToList(); List <Guid> insuranceompaniesIDs = treatment2HICompany.Select(t2hic => t2hic.HIS_HealthInsurance_Company_RefID).Distinct().ToList(); var practices = cls_Get_Practice_BaseInfo_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; var patients = cls_Get_AllPatientsSimpleData_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var doctors = cls_Get_AllDoctors_withBankData_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var patientIDs = allTreatments.Select(t => t.HEC_Patient_RefID).Distinct().ToArray(); var followups = cls_Get_Followups_for_Report_byIDs.Invoke(Connection, Transaction, new P_L6TR_GFTfRbIDs_1646() { TreatmentIDs = allTreatments.Select(t => t.HEC_Patient_TreatmentID).ToArray() }, securityTicket).Result; ///counter bill var treatmentCountPerPatient = cls_Get_TreatmentCount_for_PatientIDlist.Invoke(Connection, Transaction, new P_L5TR_GTCfPID_1152() { PatientID = patientIDs }, securityTicket).Result; Dictionary <Guid, int> positionCountPerPatient = new Dictionary <Guid, int>(); foreach (var id in patientIDs) { positionCountPerPatient.Add(id, 0); } var comapnies = new List <L6TR_GTBDpHICfID_1130_HICompany>(); foreach (var HICompanyID in insuranceompaniesIDs) { var postions = new List <L6TR_GTBDpHICfID_1130_Position>(); var treamtnIDsForHIC = treatment2HICompany.Where(thic => thic.HIS_HealthInsurance_Company_RefID == HICompanyID).Select(t => t.HEC_Patient_TreatmentID).ToArray(); foreach (var id in treamtnIDsForHIC) { var treatment = allTreatments.First(t => t.HEC_Patient_TreatmentID == id); var patient = patients.FirstOrDefault(p => p.HEC_PatientID == treatment.HEC_Patient_RefID); var followupsForThisThreatment = followups.Where(f => f.IfTreatmentFollowup_FromTreatment_RefID == treatment.HEC_Patient_TreatmentID).ToArray(); L6TR_GFTfRbIDs_1646 followup = followupsForThisThreatment.Where(f => f.IsTreatmentPerformed == true).OrderBy(f => f.IfTreatmentPerformed_Date).FirstOrDefault(); if (followup == null) { followup = followupsForThisThreatment.Where(f => f.IsScheduled == true).OrderBy(f => f.IfSheduled_Date).FirstOrDefault(); } var doctor = doctors.FirstOrDefault(d => d.HEC_DoctorID == treatment.IfTreatmentPerformed_ByDoctor_RefID); var practice = practices.FirstOrDefault(p => p.HEC_MedicalPractiseID == treatment.TreatmentPractice_RefID); var pos = new L6TR_GTBDpHICfID_1130_Position() { TreatmentID = treatment.HEC_Patient_TreatmentID, FollowupID = followup == null ? Guid.Empty : followup.HEC_Patient_TreatmentID, strDoctorLANR = (doctor != null) ? doctor.LANR : "HEC_Doctor is null!!!!", bTreatmentIsFollowup = false, strPracticeBSNR = practices != null ? practice.BSNR : "x", dtTreatment = treatment.IfTreatmentPerformed_Date, iTreatmentNumber = -1, iPatientSex = 0, iPatientInsuranceState = "xxxxx", dtPatientBirthDate = DateTime.MinValue, PatientFirstName = "x", PatientLastName = "x", PatientInsuranceNumber = "x", cTreatmentLocalization = (treatment.IsTreatmentOfLeftEye) ? "L" : "R", strFollowupPractice = "-", strFollowupDoctor = "-", strFollowupStatus = "Keine Nachuntersuchung geplant." }; if (patient != null) { pos.iTreatmentNumber = treatmentCountPerPatient.FirstOrDefault(t => t.HEC_PatientID == patient.HEC_PatientID).treatmentCount + positionCountPerPatient[treatment.HEC_Patient_RefID]; pos.iPatientSex = patient.Gender; pos.iPatientInsuranceState = (patient.InsuranceStateCode != null) ? patient.InsuranceStateCode : String.Empty; pos.dtPatientBirthDate = patient.BirthDate; pos.PatientFirstName = patient.FirstName; pos.PatientLastName = patient.LastName; pos.PatientInsuranceNumber = (patient.HealthInsurance_Number != null) ? patient.HealthInsurance_Number : String.Empty; } if (followup != null) { pos.strFollowupDoctor = followup.DoctorFirstName + " " + followup.DoctorLastname; pos.dtFollowup = followup.IfTreatmentPerformed_Date; pos.strFollowupPractice = followup.DisplayName; pos.strFollowupStatus = (followup.IsTreatmentPerformed) ? "durchgef�hrt" : "geplant"; } var articles = new List <L6TR_GTBDpHICfID_1130_ArticleInfo>(); foreach (var art in treatment.Article) { articles.Add(new L6TR_GTBDpHICfID_1130_ArticleInfo() { ArticleID = art.CMN_PRO_ProductID, Name = art.Product_Name, PZN = art.Product_Number, Quantity = art.Quantity, }); } pos.ArticleInfos = articles.ToArray(); var diagnosies = new List <L6TR_GTBDpHICfID_1130_DiagnosisInfo>(); foreach (var diag in treatment.RelevantDiagnosis) { diagnosies.Add(new L6TR_GTBDpHICfID_1130_DiagnosisInfo() { cDiagnosisState = diag.DiagnosisState_Abbreviation, DiagnosisID = diag.HEC_Patient_Treatment_RelevantDiagnosisID, strDiagnosisICD10 = diag.ICD10_Code, PatientInsuranceState = diag.DiagnosisState_Name, }); } pos.DiagnosisInfos = diagnosies.ToArray(); postions.Add(pos); positionCountPerPatient[treatment.HEC_Patient_RefID] = positionCountPerPatient[treatment.HEC_Patient_RefID] + 1; } comapnies.Add(new L6TR_GTBDpHICfID_1130_HICompany() { HIS_HealthInsurance_CompanyID = HICompanyID, Positions = postions.ToArray(), HealthInsurance_Number = treatment2HICompany.First(t => t.HIS_HealthInsurance_Company_RefID == HICompanyID).HealthInsurance_IKNumber }); } returnValue.Result.HICompanies = comapnies.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L6TR_GFBDpHICfID_1412 Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_GFBDpHICfID_1412 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6TR_GFBDpHICfID_1412(); var allFollowups = cls_Get_FollowupData_by_IDs.Invoke(Connection, Transaction, new P_L6TR_GFDbID_1420() { TreatmentIDList = Parameter.TreatmentID_List }, securityTicket).Result; if (allFollowups == null || allFollowups.Length == 0) { return(returnValue); } returnValue.Result = new L6TR_GFBDpHICfID_1412() { Data = new L6TR_GTBDpHICfID_1130() }; List <L5TR_GTHITID_1730> treatment2HICompany = cls_Get_Treatment_and_HealthInsuranceCompanu_for_TreatmentID.Invoke(Connection, Transaction, new P_L5TR_GTHITID_1730() { TreatmentID = allFollowups.Select(a => a.HEC_Patient_TreatmentID).ToArray() }, securityTicket).Result.ToList(); List <Guid> insuranceompaniesIDs = treatment2HICompany.Select(t2hic => t2hic.HIS_HealthInsurance_Company_RefID).Distinct().ToList(); var practices = cls_Get_Practice_BaseInfo_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; var patients = cls_Get_AllPatientsSimpleData_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var doctors = cls_Get_AllDoctors_withBankData_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var patientIDs = allFollowups.Select(t => t.HEC_Patient_RefID).Distinct().ToArray(); ///counter bill var treatmentCountPerPatient = cls_Get_TreatmentCount_for_PatientIDlist.Invoke(Connection, Transaction, new P_L5TR_GTCfPID_1152() { PatientID = patientIDs }, securityTicket).Result; var comapnies = new List <L6TR_GTBDpHICfID_1130_HICompany>(); foreach (var HICompanyID in insuranceompaniesIDs) { var positions = new List <L6TR_GTBDpHICfID_1130_Position>(); var treamtnIDsForHIC = treatment2HICompany.Where(thic => thic.HIS_HealthInsurance_Company_RefID == HICompanyID).Select(t => t.HEC_Patient_TreatmentID).ToArray(); var followupIDs = allFollowups.Where(a => treamtnIDsForHIC.Contains(a.HEC_Patient_TreatmentID)).Select(s => s.FollowupID); foreach (var id in followupIDs) { var followup = allFollowups.First(t => t.FollowupID == id); var patient = patients.FirstOrDefault(p => p.HEC_PatientID == followup.HEC_Patient_RefID); var doctor = doctors.FirstOrDefault(d => d.HEC_DoctorID == followup.IfTreatmentPerformed_ByDoctor_RefID); var practice = practices.FirstOrDefault(p => p.HEC_MedicalPractiseID == followup.TreatmentPractice_RefID); var pos = new L6TR_GTBDpHICfID_1130_Position() { TreatmentID = followup.HEC_Patient_TreatmentID, FollowupID = followup.FollowupID, strDoctorLANR = (doctor != null) ? doctor.LANR : "HEC_Doctor is null!!!!", bTreatmentIsFollowup = followup.IsTreatmentFollowup, strPracticeBSNR = practices != null ? practice.BSNR : "x", dtTreatment = followup.IfTreatmentPerformed_Date, iTreatmentNumber = -1, iPatientSex = 0, iPatientInsuranceState = "xxxxx", dtPatientBirthDate = DateTime.MinValue, PatientFirstName = "x", PatientLastName = "x", PatientInsuranceNumber = "x", cTreatmentLocalization = (followup.IsTreatmentOfLeftEye) ? "L" : "R", strFollowupPractice = "-", strFollowupDoctor = "-", strFollowupStatus = "Keine Nachuntersuchung geplant." }; if (patient != null) { pos.iTreatmentNumber = treatmentCountPerPatient.FirstOrDefault(t => t.HEC_PatientID == patient.HEC_PatientID).treatmentCount; pos.iPatientSex = patient.Gender; pos.iPatientInsuranceState = (patient.InsuranceStateCode != null) ? patient.InsuranceStateCode : String.Empty; pos.dtPatientBirthDate = patient.BirthDate; pos.PatientFirstName = patient.FirstName; pos.PatientLastName = patient.LastName; pos.PatientInsuranceNumber = (patient.HealthInsurance_Number != null) ? patient.HealthInsurance_Number : String.Empty; } var articles = new List <L6TR_GTBDpHICfID_1130_ArticleInfo>(); foreach (var art in followup.Article) { articles.Add(new L6TR_GTBDpHICfID_1130_ArticleInfo() { ArticleID = art.CMN_PRO_ProductID, Name = art.Product_Name, PZN = art.Product_Number, Quantity = art.Quantity, }); } pos.ArticleInfos = articles.ToArray(); var diagnosies = new List <L6TR_GTBDpHICfID_1130_DiagnosisInfo>(); foreach (var diag in followup.RelevantDiagnosis) { diagnosies.Add(new L6TR_GTBDpHICfID_1130_DiagnosisInfo() { cDiagnosisState = diag.DiagnosisState_Abbreviation, DiagnosisID = diag.HEC_Patient_Treatment_RelevantDiagnosisID, strDiagnosisICD10 = diag.ICD10_Code, PatientInsuranceState = diag.DiagnosisState_Name, }); } pos.DiagnosisInfos = diagnosies.ToArray(); positions.Add(pos); } comapnies.Add(new L6TR_GTBDpHICfID_1130_HICompany() { HIS_HealthInsurance_CompanyID = HICompanyID, Positions = positions.ToArray(), HealthInsurance_Number = treatment2HICompany.First(t => t.HIS_HealthInsurance_Company_RefID == HICompanyID).HealthInsurance_IKNumber }); } returnValue.Result.Data.HICompanies = comapnies.ToArray(); return(returnValue); #endregion UserCode }