private List <FormularyRouteDetailAPIModel> GetRoutes(FormularyEditModel src) { var routesAPI = new List <FormularyRouteDetailAPIModel>(); if (src == null || (!src.Route.IsCollectionValid() && !src.UnlicensedRoute.IsCollectionValid())) { return(null); } if (src.Route.IsCollectionValid()) { src.Route.Each(rec => { var routeAPIModel = new FormularyRouteDetailAPIModel { RouteCd = rec.Id, RouteDesc = rec.Name, RouteFieldTypeCd = TerminologyConstants.ROUTEFIELDTYPE_NORMAL_CD, Source = rec.Source }; routesAPI.Add(routeAPIModel); }); } if (src.UnlicensedRoute.IsCollectionValid()) { src.UnlicensedRoute.Each(rec => { var routeAPIModel = new FormularyRouteDetailAPIModel { RouteCd = rec.Id, RouteDesc = rec.Name, RouteFieldTypeCd = TerminologyConstants.ROUTEFIELDTYPE_UNLICENSED_CD, Source = rec.Source }; routesAPI.Add(routeAPIModel); }); } return(routesAPI); }
//private void FormatResponseMessage(TerminiologyAPIResponse<CreateFormularyAPIResponse> response, CreateFormularyAPIRequest requestRow, StringBuilder responseStringBuilder) //{ // if (response.StatusCode != DataService.APIModel.StatusCode.Success) // { // responseStringBuilder.AppendLine($"{requestRow.Code}-{string.Join('\n', response.ErrorMessages.ToArray())}"); // } // else if (response.StatusCode == DataService.APIModel.StatusCode.Success) // { // if (response.Data.Status != null && response.Data.Status.ErrorMessages.IsCollectionValid()) // { // var errors = string.Join('\n', response.Data.Status.ErrorMessages.ToArray()); // responseStringBuilder.AppendLine($"{requestRow.Code}-{errors}"); // } // else // { // responseStringBuilder.AppendLine($"{requestRow.Code}-Success"); // } // } //} private Dictionary <string, Action <DataRow, FormularyHeaderAPIModel> > GetRowData(Dictionary <string, string> colsNames) { const char DataDelimiter = '|'; var dataDictionary = new Dictionary <string, Action <DataRow, FormularyHeaderAPIModel> >(); dataDictionary.Add(ColumnKeyNames.Name, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.Name]].IsNotNull() && dr[colsNames[ColumnKeyNames.Name]].ToString().IsNotEmpty()) { apiModel.Name = dr[colsNames[ColumnKeyNames.Name]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.Code, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.Code]].IsNotNull() && dr[colsNames[ColumnKeyNames.Code]].ToString().IsNotEmpty()) { apiModel.Code = dr[colsNames[ColumnKeyNames.Code]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.Level, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.Level]].IsNotNull() && dr[colsNames[ColumnKeyNames.Level]].ToString().IsNotEmpty()) { apiModel.ProductType = dr[colsNames[ColumnKeyNames.Level]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.ParentCode, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.ParentCode]].IsNotNull() && dr[colsNames[ColumnKeyNames.ParentCode]].ToString().IsNotEmpty()) { apiModel.ParentCode = dr[colsNames[ColumnKeyNames.ParentCode]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.ParentLevel, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.ParentLevel]].IsNotNull() && dr[colsNames[ColumnKeyNames.ParentLevel]].ToString().IsNotEmpty()) { apiModel.ParentProductType = dr[colsNames[ColumnKeyNames.ParentLevel]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.FormCode, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.FormCode]].IsNotNull() && dr[colsNames[ColumnKeyNames.FormCode]].ToString().IsNotEmpty()) { apiModel.Detail.FormCd = dr[colsNames[ColumnKeyNames.FormCode]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.ControlledDrugStatusCode, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.ControlledDrugStatusCode]].IsNotNull() && dr[colsNames[ColumnKeyNames.ControlledDrugStatusCode]].ToString().IsNotEmpty()) { apiModel.Detail.ControlledDrugCategories = new List <FormularyLookupAPIModel> { new FormularyLookupAPIModel { Cd = dr[colsNames[ColumnKeyNames.ControlledDrugStatusCode]]?.ToString()?.Trim() } } } ; }); dataDictionary.Add(ColumnKeyNames.PrescribingStatusCode, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.PrescribingStatusCode]].IsNotNull() && dr[colsNames[ColumnKeyNames.PrescribingStatusCode]].ToString().IsNotEmpty()) { apiModel.Detail.PrescribingStatusCd = dr[colsNames[ColumnKeyNames.PrescribingStatusCode]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.SupplierCode, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.SupplierCode]].IsNotNull() && dr[colsNames[ColumnKeyNames.SupplierCode]].ToString().IsNotEmpty()) { apiModel.Detail.SupplierCd = dr[colsNames[ColumnKeyNames.SupplierCode]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.FORMULARYSTATUS, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.FORMULARYSTATUS]].IsNotNull() && dr[colsNames[ColumnKeyNames.FORMULARYSTATUS]].ToString().IsNotEmpty()) { if (string.Compare(dr[colsNames[ColumnKeyNames.FORMULARYSTATUS]].ToString().Trim(), "yes", true) == 0) { apiModel.Detail.RnohFormularyStatuscd = "001"; } else { apiModel.Detail.RnohFormularyStatuscd = "002"; } //else if (string.Compare(dr[colsNames[ColumnKeyNames.FORMULARYSTATUS]].ToString().Trim(), "no", true) == 0) //{ // apiModel.Detail.RnohFormularyStatuscd = "002"; //} } else { apiModel.Detail.RnohFormularyStatuscd = "002"; } // apiModel.Detail.RnohFormularyStatuscd = string.Compare(dr[colsNames[ColumnKeyNames.FORMULARYSTATUS]].ToString().Trim(), "yes", true) == 0 ? "001" : "002"; }); dataDictionary.Add(ColumnKeyNames.LicensedRouteCodes, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.LicensedRouteCodes]].IsNotNull() && dr[colsNames[ColumnKeyNames.LicensedRouteCodes]].ToString().IsNotEmpty()) { var routeCodes = dr[colsNames[ColumnKeyNames.LicensedRouteCodes]].ToString().Split(DataDelimiter); routeCodes.Each(routeCode => { if (routeCode.IsNotEmpty()) { var routeRequest = new FormularyRouteDetailAPIModel { RouteCd = routeCode, RouteFieldTypeCd = "003"//Normal or Licensed }; apiModel.FormularyRouteDetails.Add(routeRequest); } }); } }); dataDictionary.Add(ColumnKeyNames.UnlicensedRoutesCodes, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.UnlicensedRoutesCodes]].IsNotNull() && dr[colsNames[ColumnKeyNames.UnlicensedRoutesCodes]].ToString().IsNotEmpty()) { var routeCodes = dr[colsNames[ColumnKeyNames.UnlicensedRoutesCodes]].ToString().Split(DataDelimiter); routeCodes.Each(routeCode => { if (routeCode.IsNotEmpty()) { var routeRequest = new FormularyRouteDetailAPIModel { RouteCd = routeCode, RouteFieldTypeCd = "002"//UnLicensed }; apiModel.FormularyRouteDetails.Add(routeRequest); } }); } }); dataDictionary.Add(ColumnKeyNames.CriticalDrug, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.CriticalDrug]].IsNotNull() && dr[colsNames[ColumnKeyNames.CriticalDrug]].ToString().IsNotEmpty()) { apiModel.Detail.CriticalDrug = string.Compare(dr[colsNames[ColumnKeyNames.CriticalDrug]].ToString().Trim(), "yes", true) == 0 ? "1" : "0"; } }); dataDictionary.Add(ColumnKeyNames.CYTOTOXIC, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.CYTOTOXIC]].IsNotNull() && dr[colsNames[ColumnKeyNames.CYTOTOXIC]].ToString().IsNotEmpty()) { apiModel.Detail.Cytotoxic = string.Compare(dr[colsNames[ColumnKeyNames.CYTOTOXIC]].ToString().Trim(), "yes", true) == 0 ? "1" : "0"; } }); dataDictionary.Add(ColumnKeyNames.BLACKTRIANGLE, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.BLACKTRIANGLE]].IsNotNull() && dr[colsNames[ColumnKeyNames.BLACKTRIANGLE]].ToString().IsNotEmpty()) { apiModel.Detail.BlackTriangle = string.Compare(dr[colsNames[ColumnKeyNames.BLACKTRIANGLE]].ToString().Trim(), "yes", true) == 0 ? "1" : "0"; } }); //dataDictionary.Add(ColumnKeyNames.RESTRICTEDPRESCRIBING, (dr, apiModel) => //{ // if (dr[colsNames[ColumnKeyNames.RESTRICTEDPRESCRIBING]].IsNotNull() && dr[colsNames[ColumnKeyNames.RESTRICTEDPRESCRIBING]].ToString().IsNotEmpty()) // apiModel.Detail.RestrictedPrescribing = string.Compare(dr[colsNames[ColumnKeyNames.RESTRICTEDPRESCRIBING]].ToString().Trim(), "yes", true) == 0 ? "1" : "0"; //}); dataDictionary.Add(ColumnKeyNames.NOTESFORRESTRICTION, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.NOTESFORRESTRICTION]].IsNotNull() && dr[colsNames[ColumnKeyNames.NOTESFORRESTRICTION]].ToString().IsNotEmpty()) { apiModel.Detail.RestrictionNote = dr[colsNames[ColumnKeyNames.NOTESFORRESTRICTION]]?.ToString()?.Trim(); } }); dataDictionary.Add(ColumnKeyNames.MEDUSIVGUIDE, (dr, apiModel) => { if (dr[colsNames[ColumnKeyNames.MEDUSIVGUIDE]].IsNotNull() && dr[colsNames[ColumnKeyNames.MEDUSIVGUIDE]].ToString().IsNotEmpty()) { apiModel.Detail.MedusaPreparationInstructions = new List <string> { dr[colsNames[ColumnKeyNames.MEDUSIVGUIDE]]?.ToString()?.Trim() } } ; }); return(dataDictionary); }