protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SPED_1313 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); returnValue.Result = false; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; var medPro_Credentials = cls_Get_TenantMemershipData.Invoke(Connection, Transaction, securityTicket).Result; var examination = ORM_HEC_ACT_PerformedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_ACT_PerformedActionID = Parameter.ExaminationID }).Single(); #region save foreach (var item in Parameter.newDiagnoses) { if (medPro_Credentials.Credantial != null) { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.Tenant_RefID = securityTicket.TenantID; potentialDiagnosisQuery.PotentialDiagnosisITL = item.DiagnoseITL; var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).SingleOrDefault(); if (potentialDiagnosis == null) { potentialDiagnosis = new ORM_HEC_DIA_PotentialDiagnosis(); potentialDiagnosis.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); potentialDiagnosis.ICD10_Code = item.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.DiagnoseName); } potentialDiagnosis.PotentialDiagnosis_Name = name; potentialDiagnosis.PotentialDiagnosisITL = item.DiagnoseITL; potentialDiagnosis.Tenant_RefID = securityTicket.TenantID; potentialDiagnosis.Creation_Timestamp = DateTime.Now; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); } //check if exists active patient diagnoses (same one) var patientDiagQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagQuery.IsDeleted = false; patientDiagQuery.Tenant_RefID = securityTicket.TenantID; patientDiagQuery.R_IsActive = true; patientDiagQuery.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagQuery.Patient_RefID = Parameter.PatientID; var patientDiagExists = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagQuery).SingleOrDefault(); if (patientDiagExists == null) { ORM_HEC_Patient_Diagnosis patientDiagnoses = new ORM_HEC_Patient_Diagnosis(); patientDiagnoses.HEC_Patient_DiagnosisID = Guid.NewGuid(); patientDiagnoses.Creation_Timestamp = DateTime.Now; patientDiagnoses.Modification_Timestamp = DateTime.Now; patientDiagnoses.R_IsActive = true; patientDiagnoses.Patient_RefID = Parameter.PatientID; patientDiagnoses.Tenant_RefID = securityTicket.TenantID; patientDiagnoses.R_DiagnosedOnDate = examination.IfPerfomed_DateOfAction; patientDiagnoses.R_ScheduledExpiryDate = patientDiagnoses.R_DiagnosedOnDate.AddDays(item.days_valid); patientDiagnoses.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagnoses.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate diagnosisUpdate = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); diagnosisUpdate.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); diagnosisUpdate.Creation_Timestamp = DateTime.Now; diagnosisUpdate.Modification_Timestamp = DateTime.Now; diagnosisUpdate.Tenant_RefID = securityTicket.TenantID; diagnosisUpdate.ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); diagnosisUpdate.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; diagnosisUpdate.HEC_Patient_Diagnosis_RefID = patientDiagnoses.HEC_Patient_DiagnosisID; diagnosisUpdate.HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID; diagnosisUpdate.Save(Connection, Transaction); } } else { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.Tenant_RefID = securityTicket.TenantID; potentialDiagnosisQuery.HEC_DIA_PotentialDiagnosisID = new Guid(item.DiagnoseITL); var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).SingleOrDefault(); //check if exists active patient diagnoses (same one) var patientDiagQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagQuery.IsDeleted = false; patientDiagQuery.Tenant_RefID = securityTicket.TenantID; patientDiagQuery.R_IsActive = true; patientDiagQuery.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; var patientDiagExists = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagQuery).SingleOrDefault(); if (patientDiagExists == null) { ORM_HEC_Patient_Diagnosis patientDiagnoses = new ORM_HEC_Patient_Diagnosis(); patientDiagnoses.HEC_Patient_DiagnosisID = Guid.NewGuid(); patientDiagnoses.Creation_Timestamp = DateTime.Now; patientDiagnoses.Modification_Timestamp = DateTime.Now; patientDiagnoses.R_IsActive = true; patientDiagnoses.Patient_RefID = Parameter.PatientID; patientDiagnoses.Tenant_RefID = securityTicket.TenantID; patientDiagnoses.R_DiagnosedOnDate = DateTime.Now; patientDiagnoses.R_ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); patientDiagnoses.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagnoses.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate diagnosisUpdate = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); diagnosisUpdate.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); diagnosisUpdate.Creation_Timestamp = DateTime.Now; diagnosisUpdate.Modification_Timestamp = DateTime.Now; diagnosisUpdate.Tenant_RefID = securityTicket.TenantID; diagnosisUpdate.ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); diagnosisUpdate.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; diagnosisUpdate.HEC_Patient_Diagnosis_RefID = patientDiagnoses.HEC_Patient_DiagnosisID; diagnosisUpdate.HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID; diagnosisUpdate.Save(Connection, Transaction); } } } #endregion #region negated foreach (var item in Parameter.deletedDiagnoses) { var patientDiagnosesQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagnosesQuery.IsDeleted = false; patientDiagnosesQuery.R_IsNegated = false; patientDiagnosesQuery.R_IsActive = true; patientDiagnosesQuery.Tenant_RefID = securityTicket.TenantID; patientDiagnosesQuery.HEC_Patient_DiagnosisID = item.PatientDiagnoseID; var patientDiagnoses = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagnosesQuery).Single(); patientDiagnoses.R_IsNegated = true; patientDiagnoses.R_IsActive = false; patientDiagnoses.Save(Connection, Transaction); var diagnoseUpdateQuery = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate.Query(); diagnoseUpdateQuery.HEC_Patient_Diagnosis_RefID = item.PatientDiagnoseID; diagnoseUpdateQuery.IsDeleted = false; diagnoseUpdateQuery.IsDiagnosisNegated = false; diagnoseUpdateQuery.Tenant_RefID = securityTicket.TenantID; var patientUpdate = ORM_HEC_ACT_PerformedAction_DiagnosisUpdate.Query.Search(Connection, Transaction, diagnoseUpdateQuery).Single(); patientUpdate.IsDiagnosisNegated = true; patientUpdate.Save(Connection, Transaction); } returnValue.Result = true; #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DI_SD_1633 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); returnValue.Result = Guid.Empty; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; #region Save if (Parameter.DiagnoseID == Guid.Empty) { var potentialDiagnosis = new ORM_HEC_DIA_PotentialDiagnosis(); potentialDiagnosis.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); potentialDiagnosis.ICD10_Code = Parameter.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Name); } potentialDiagnosis.PotentialDiagnosis_Name = name; Dict description = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { description.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Description); } potentialDiagnosis.PotentialDiagnosis_Description = description; potentialDiagnosis.Tenant_RefID = securityTicket.TenantID; potentialDiagnosis.Creation_Timestamp = DateTime.Now; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); ORM_HEC_DIA_PotentialDiagnosis_CatalogCode catalogCode = new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode(); catalogCode.HEC_DIA_PotentialDiagnosis_CatalogCodeID = Guid.NewGuid(); catalogCode.Code = Parameter.DiagnoseICD10; catalogCode.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; catalogCode.PotentialDiagnosis_Catalog_RefID = Parameter.PotentialDiagnosis_CatalogID; catalogCode.Tenant_RefID = securityTicket.TenantID; catalogCode.Save(Connection, Transaction); returnValue.Result = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; } #endregion else { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.HEC_DIA_PotentialDiagnosisID = Parameter.DiagnoseID; var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).Single(); #region Delete if (Parameter.IsDeleted) { ORM_HEC_DIA_PotentialDiagnosis_CatalogCode catalogCode = ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query.Search(Connection, Transaction, new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query { PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); catalogCode.IsDeleted = false; catalogCode.Save(Connection, Transaction); potentialDiagnosis.IsDeleted = true; potentialDiagnosis.Save(Connection, Transaction); } #endregion #region Edit else { potentialDiagnosis.ICD10_Code = Parameter.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Name); } potentialDiagnosis.PotentialDiagnosis_Name = name; Dict description = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { description.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Description); } potentialDiagnosis.PotentialDiagnosis_Description = description; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); } returnValue.Result = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DG_SDfTIDA_10_32 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_HEC_DIA_PotentialDiagnosis(); if (Parameter.HEC_DIA_PotentialDiagnosisID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.HEC_DIA_PotentialDiagnosisID); if (result.Status != FR_Status.Success || item.HEC_DIA_PotentialDiagnosisID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } else { item.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); returnValue.Result = item.HEC_DIA_PotentialDiagnosisID; } if (Parameter.IsDeleted == true) { var query_DiagnosisStates_del = new ORM_HEC_DIA_Diagnosis_State.Query(); query_DiagnosisStates_del.Diagnose_RefID = Parameter.HEC_DIA_PotentialDiagnosisID; var found_DiagnosisStates_del = ORM_HEC_DIA_Diagnosis_State.Query.Search(Connection, Transaction, query_DiagnosisStates_del); var query_Localizations_del = new ORM_HEC_DIA_Diagnosis_Localization.Query(); query_Localizations_del.Diagnosis_RefID = Parameter.HEC_DIA_PotentialDiagnosisID; var found_Localizations_del = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, query_Localizations_del); foreach (var foundState in found_DiagnosisStates_del) { foundState.IsDeleted = true; foundState.Save(Connection, Transaction); } foreach (var foundLocalization in found_Localizations_del) { foundLocalization.IsDeleted = true; foundLocalization.Save(Connection, Transaction); } item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.HEC_DIA_PotentialDiagnosisID)); } //Save Diagnoses Dict diagnosis_nameDict = new Dict("hec_dia_potentialdiagnoses"); diagnosis_nameDict = Parameter.PotentialDiagnosis_Name_DictID; item.Tenant_RefID = securityTicket.TenantID; item.Creation_Timestamp = DateTime.Now; item.ICD10_Code = Parameter.ICD10_Code; //item.PotentialDiagnosis_Name_DictID = diagnosis_nameDict; item.PotentialDiagnosis_Description = Parameter.PotentialDiagnosis_Description; item.Save(Connection, Transaction); // save States foreach (var stateParam in Parameter.DiagnosisStates) { Dict state_nameDict = new Dict("hec_dia_diagnosis_states"); state_nameDict = stateParam.DiagnosisState_Name; var queryState = new ORM_HEC_DIA_Diagnosis_State.Query(); queryState.HEC_DIA_Diagnosis_StateID = stateParam.HEC_DIA_Diagnosis_StateID; queryState.Diagnose_RefID = stateParam.Diagnose_RefID; var stateResult = ORM_HEC_DIA_Diagnosis_State.Query.Search(Connection, Transaction, queryState); //new State if (stateResult.Count == 0) { var state = new ORM_HEC_DIA_Diagnosis_State(); state.HEC_DIA_Diagnosis_StateID = stateParam.HEC_DIA_Diagnosis_StateID; Dict abbrev = new Dict(); state.DiagnosisState_Abbreviation = stateParam.DiagnosisState_Abbreviation; state.DiagnosisState_Name = state_nameDict; state.Diagnose_RefID = item.HEC_DIA_PotentialDiagnosisID; state.Creation_Timestamp = DateTime.Now; state.Tenant_RefID = securityTicket.TenantID; state.IsDeleted = false; state.Save(Connection, Transaction); } else//edit State { if (stateParam.IsDeleted == true) { stateResult[0].IsDeleted = true; stateResult[0].Save(Connection, Transaction); } else { if (stateResult[0].DiagnosisState_Name != null || Parameter.IsDeleted == true) { foreach (var entry in state_nameDict.Contents) { stateResult[0].DiagnosisState_Name.UpdateEntry(entry.LanguageID, entry.Content); } } stateResult[0].DiagnosisState_Abbreviation = stateParam.DiagnosisState_Abbreviation; stateResult[0].Save(Connection, Transaction); } } } //Diagnosis Localization foreach (var localizationParam in Parameter.DiagnosisLocalizations) { Dict localization_nameDict = new Dict("hec_dia_diagnosis_localizations"); localization_nameDict = localizationParam.DiagnosisLocalization_Name; var queryLocalization = new ORM_HEC_DIA_Diagnosis_Localization.Query(); queryLocalization.HEC_DIA_Diagnosis_LocalizationID = localizationParam.HEC_DIA_Diagnosis_LocalizationID; queryLocalization.Diagnosis_RefID = localizationParam.Diagnosis_RefID; var localizationResult = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, queryLocalization); if (localizationResult.Count == 0) { var localization = new ORM_HEC_DIA_Diagnosis_Localization(); localization.HEC_DIA_Diagnosis_LocalizationID = localizationParam.HEC_DIA_Diagnosis_LocalizationID; localization.DiagnosisLocalization_Name = localization_nameDict; localization.Creation_Timestamp = DateTime.Now; localization.Tenant_RefID = securityTicket.TenantID; localization.Diagnosis_RefID = item.HEC_DIA_PotentialDiagnosisID; localization.IsDeleted = false; localization.Save(Connection, Transaction); } else { if (localizationParam.IsDeleted == true || Parameter.IsDeleted == true) { localizationResult[0].IsDeleted = true; localizationResult[0].Save(Connection, Transaction); } else { if (localizationResult[0].DiagnosisLocalization_Name != null) { foreach (var entry in localization_nameDict.Contents) { localizationResult[0].DiagnosisLocalization_Name.UpdateEntry(entry.LanguageID, entry.Content); } } localizationResult[0].Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_MD_SNDaRNIDs_1412[] Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guids(); var allLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); returnValue.Result = Parameter.Select(diag => { var diagnose = cls_Get_DiagnoseID_for_ICD10_and_DiagnoseName.Invoke(Connection, Transaction, new P_MD_GDIDfDN_1408() { DiagnoseICD10 = diag.DiagnoseICD10, DiagnoseNameWithoutSpaces = diag.DiagnoseName.Replace(((char)32).ToString(), string.Empty).Replace(((char)160).ToString(), string.Empty) }, securityTicket).Result; if (diagnose != null) { return(diagnose.DiagnoseID); } else { Dict DiagnoseName = new Dict(ORM_HEC_DIA_PotentialDiagnosis.TableName); for (int i = 0; i < allLanguages.Count; i++) { DiagnoseName.AddEntry(allLanguages[i].CMN_LanguageID, diag.DiagnoseName); } Dict CatalogName = new Dict(ORM_HEC_DIA_PotentialDiagnosis_Catalog.TableName); for (int i = 0; i < allLanguages.Count; i++) { CatalogName.AddEntry(allLanguages[i].CMN_LanguageID, "ICD-10"); } var newDiagnose = new ORM_HEC_DIA_PotentialDiagnosis(); newDiagnose.PotentialDiagnosis_Name = DiagnoseName; newDiagnose.IsDeleted = false; newDiagnose.Tenant_RefID = securityTicket.TenantID; newDiagnose.Creation_Timestamp = DateTime.Now; newDiagnose.Modification_Timestamp = DateTime.Now; newDiagnose.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); newDiagnose.Save(Connection, Transaction); var newDiagnoseCatalog = new ORM_HEC_DIA_PotentialDiagnosis_Catalog(); newDiagnoseCatalog.IsDeleted = false; newDiagnoseCatalog.Catalog_DisplayName = "ICD-10"; newDiagnoseCatalog.Tenant_RefID = securityTicket.TenantID; newDiagnoseCatalog.Creation_Timestamp = DateTime.Now; newDiagnoseCatalog.Modification_Timestamp = DateTime.Now; newDiagnoseCatalog.HEC_DIA_PotentialDiagnosis_CatalogID = Guid.NewGuid(); newDiagnoseCatalog.Catalog_Name = CatalogName; newDiagnoseCatalog.Save(Connection, Transaction); var newDiagnose2CatalogCode = new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode(); newDiagnose2CatalogCode.IsDeleted = false; newDiagnose2CatalogCode.Tenant_RefID = securityTicket.TenantID; newDiagnose2CatalogCode.Creation_Timestamp = DateTime.Now; newDiagnose2CatalogCode.Modification_Timestamp = DateTime.Now; newDiagnose2CatalogCode.PotentialDiagnosis_RefID = newDiagnose.HEC_DIA_PotentialDiagnosisID; newDiagnose2CatalogCode.PotentialDiagnosis_Catalog_RefID = newDiagnoseCatalog.HEC_DIA_PotentialDiagnosis_CatalogID; newDiagnose2CatalogCode.Code = diag.DiagnoseICD10; newDiagnose2CatalogCode.Save(Connection, Transaction); return(newDiagnose.HEC_DIA_PotentialDiagnosisID); } }).ToArray(); return(returnValue); #endregion UserCode }