private List <string> AssignMedusaPreparationInstructions(FormularyEditModel src)
 {
     if (src.ProductType.IsNotEmpty() && (string.Compare(src.ProductType, "amp", true) == 0))
     {
         return(src.MedusaPreparationInstructionsEditable != null ? new List <string> {
             src.MedusaPreparationInstructionsEditable
         } : null);
     }
     else if (src.MedusaPreparationInstructions != null)
     {
         return(src.MedusaPreparationInstructions.Select(rec => rec.Id).ToList());
     }
     return(null);
 }
 private List <FormularyLookupAPIModel> AssignTitrationTypes(FormularyEditModel src)
 {
     if (src.ProductType.IsNotEmpty() && (string.Compare(src.ProductType, "amp", true) == 0))
     {
         return(src.TitrationTypesEditableId != null ? new List <FormularyLookupAPIModel> {
             ConvertCodeNameModelWithDefaultsToCodeDescAPI(src.TitrationTypesEditableId)
         } : null);
     }
     else if (src.TitrationTypes != null)
     {
         return(ConvertCodeNameModelsWithDefaultsToCodeDescAPI(src.TitrationTypes));
     }
     return(null);
 }
        private string SetPrescribableSource(FormularyEditModel src)
        {
            if (src == null)
            {
                return(null);
            }

            if (src.OriginalPrescribable == false && src.PrescribableSource != null && string.Compare(src.PrescribableSource, TerminologyConstants.DMD_DATA_SOURCE, true) == 0)
            {
                return(TerminologyConstants.DMD_DATA_SOURCE);
            }
            else
            {
                return(src.Prescribable != src.OriginalPrescribable? TerminologyConstants.MANUAL_DATA_SOURCE: src.PrescribableSource);
            }
        }
        private List <FormularyLocalRouteDetailAPIModel> GetLocalRoutes(FormularyEditModel src)
        {
            var localRoutesAPI = new List <FormularyLocalRouteDetailAPIModel>();

            if (src == null || (!src.LocalLicensedRoute.IsCollectionValid() && !src.LocalUnlicensedRoute.IsCollectionValid()))
            {
                return(null);
            }

            if (src.LocalLicensedRoute.IsCollectionValid())
            {
                src.LocalLicensedRoute.Each(rec =>
                {
                    var localLicensedRouteAPIModel = new FormularyLocalRouteDetailAPIModel
                    {
                        RouteCd          = rec.Id,
                        RouteDesc        = rec.Name,
                        RouteFieldTypeCd = TerminologyConstants.ROUTEFIELDTYPE_NORMAL_CD,
                        Source           = rec.Source
                    };
                    localRoutesAPI.Add(localLicensedRouteAPIModel);
                });
            }

            if (src.LocalUnlicensedRoute.IsCollectionValid())
            {
                src.LocalUnlicensedRoute.Each(rec =>
                {
                    var localUnlicensedRouteAPIModel = new FormularyLocalRouteDetailAPIModel
                    {
                        RouteCd          = rec.Id,
                        RouteDesc        = rec.Name,
                        RouteFieldTypeCd = TerminologyConstants.ROUTEFIELDTYPE_UNLICENSED_CD,
                        Source           = rec.Source
                    };
                    localRoutesAPI.Add(localUnlicensedRouteAPIModel);
                });
            }

            return(localRoutesAPI);
        }
示例#5
0
        public async Task <IActionResult> LoadFormularyDetails(string formularyVersionId)
        {
            const string MMC_CONFIG_KEY = "MMC_Control_Source";

            string token = HttpContext.Session.GetString("access_token");

            var responseTask = TerminologyAPIService.GetFormularyDetailRuleBound(formularyVersionId, token);// TerminologyAPIService.GetFormularyDetail(formularyVersionId, token);

            var terminologyConfigTask = TerminologyAPIService.GetTerminologyConfiguration(MMC_CONFIG_KEY, token);

            await Task.WhenAll(responseTask, terminologyConfigTask);

            var response = await responseTask;

            var terminologyConfigResponse = await terminologyConfigTask;

            if ((response == null || response.StatusCode == DataService.APIModel.StatusCode.Fail) || ((terminologyConfigResponse == null || terminologyConfigResponse.StatusCode == DataService.APIModel.StatusCode.Fail)))
            {
                const string ErrorResponse = "Error getting details for the selected record";
                var          errors        = "";
                if (response.ErrorMessages.IsCollectionValid())
                {
                    errors = string.Join('\n', ErrorResponse, response.ErrorMessages.ToArray());
                }
                if (terminologyConfigResponse.ErrorMessages.IsCollectionValid())
                {
                    errors = string.Join('\n', ErrorResponse, terminologyConfigResponse.ErrorMessages.ToArray());
                }
                _toastNotification.AddErrorToastMessage(errors);

                return(null);
            }

            var formulariesfromAPI = response.Data;

            await FillLookupsToViewBag(formulariesfromAPI.RecStatusCode);

            FormularyEditModel vm = GetFormularyEditModel(formulariesfromAPI);

            return(PartialView(GetFormularyEditView(formulariesfromAPI.ProductType), vm));
        }
            public List <FormularyAdditionalCodeAPIModel> Resolve(FormularyEditModel source, FormularyHeaderAPIModel destination, List <FormularyAdditionalCodeAPIModel> destMember, ResolutionContext context)
            {
                var additionalCodes = new List <FormularyAdditionalCodeAPIModel>();

                if (destination == null)
                {
                    return(additionalCodes);
                }

                if (source.FormularyClassificationCodes.IsCollectionValid())
                {
                    additionalCodes = context.Mapper.Map <List <FormularyAdditionalCodeAPIModel> >(source.FormularyClassificationCodes);
                    additionalCodes.Each(rec => rec.CodeType = "Classification");
                }
                if (source.FormularyIdentificationCodes.IsCollectionValid())
                {
                    var idenCodes = context.Mapper.Map <List <FormularyAdditionalCodeAPIModel> >(source.FormularyIdentificationCodes);
                    idenCodes.Each(rec => rec.CodeType = "Identification");
                    additionalCodes.AddRange(idenCodes);
                }

                return(additionalCodes);
            }
 public AMPFormularyEditValidator(FormularyEditModel model)
 {
     _model = model;
 }
        public void Merge(BulkFormularyEditModel editedData, BulkFormularyEditModel orginalObj, FormularyEditModel modelFromDB)
        {
            editedData.FormularyIdentificationCodes = modelFromDB.FormularyIdentificationCodes;

            editedData.Prescribable = editedData.NullablePrescribable ?? modelFromDB.Prescribable;

            editedData.WitnessingRequired = editedData.NullableWitnessingRequired ?? modelFromDB.WitnessingRequired;

            editedData.Status = editedData.Status ?? modelFromDB.Status;

            editedData.RecStatuschangeMsg = editedData.RecStatuschangeMsg ?? modelFromDB.RecStatuschangeMsg;
        }
        public void Merge(BulkFormularyEditModel editedData, BulkFormularyEditModel orginalObj, FormularyEditModel modelFromDB)
        {
            editedData.FormularyIdentificationCodes = modelFromDB.FormularyIdentificationCodes;

            editedData.FormularyClassificationCodes = modelFromDB.FormularyClassificationCodes;

            if (!editedData.UnlicensedRoute.IsCollectionValid())
            {
                editedData.UnlicensedRoute = modelFromDB.UnlicensedRoute;
            }
            if (!editedData.UnlicensedUse.IsCollectionValid())
            {
                editedData.UnlicensedUse = modelFromDB.UnlicensedUse;
            }
            if (!editedData.LocalLicensedRoute.IsCollectionValid())
            {
                editedData.LocalLicensedRoute = modelFromDB.LocalLicensedRoute;
            }
            if (!editedData.LocalUnlicensedRoute.IsCollectionValid())
            {
                editedData.LocalUnlicensedRoute = modelFromDB.LocalUnlicensedRoute;
            }
            if (!editedData.LocalLicensedUse.IsCollectionValid())
            {
                editedData.LocalLicensedUse = modelFromDB.LocalLicensedUse;
            }
            if (!editedData.LocalUnlicensedUse.IsCollectionValid())
            {
                editedData.LocalUnlicensedUse = modelFromDB.LocalUnlicensedUse;
            }
            if (editedData.RoundingFactorCd.IsEmpty())
            {
                editedData.RoundingFactorCd = modelFromDB.RoundingFactorCd;
            }
            if (!editedData.CustomWarnings.IsCollectionValid())
            {
                editedData.CustomWarnings = modelFromDB.CustomWarnings;
            }
            if (!editedData.Reminders.IsCollectionValid())
            {
                editedData.Reminders = modelFromDB.Reminders;
            }
            if (!editedData.Endorsements.IsCollectionValid())
            {
                editedData.Endorsements = modelFromDB.Endorsements;
            }
            if (editedData.MedusaPreparationInstructionsEditable.IsEmpty())
            {
                if (modelFromDB.MedusaPreparationInstructions.IsCollectionValid())
                {
                    editedData.MedusaPreparationInstructionsEditable = modelFromDB.MedusaPreparationInstructions[0].Id;
                }
            }
            if (!editedData.SideEffects.IsCollectionValid())
            {
                editedData.SideEffects = modelFromDB.SideEffects;
            }
            if (!editedData.Cautions.IsCollectionValid())
            {
                editedData.Cautions = modelFromDB.Cautions;
            }
            editedData.ClinicalTrialMedication = editedData.NullableClinicalTrialMedication ?? modelFromDB.ClinicalTrialMedication;

            editedData.CriticalDrug = editedData.NullableCriticalDrug ?? modelFromDB.CriticalDrug;

            editedData.IVToOral = editedData.NullableIVToOral ?? modelFromDB.IVToOral;

            editedData.ExpensiveMedication = editedData.NullableExpensiveMedication ?? modelFromDB.ExpensiveMedication;

            editedData.HighAlertMedication = editedData.NullableHighAlertMedication ?? modelFromDB.HighAlertMedication;

            editedData.NotForPrn = editedData.NullableNotForPrn ?? modelFromDB.NotForPrn;

            editedData.Prescribable = editedData.NullablePrescribable ?? modelFromDB.Prescribable;

            editedData.OutpatientMedication = editedData.NullableOutpatientMedication ?? modelFromDB.OutpatientMedication;


            if (!editedData.TitrationTypes.IsCollectionValid())
            {
                editedData.TitrationTypes = modelFromDB.TitrationTypes;
            }
            if (orginalObj.RnohFormularyStatuscd == editedData.RnohFormularyStatuscd)
            {
                editedData.RnohFormularyStatuscd = modelFromDB.RnohFormularyStatuscd;
            }

            editedData.IgnoreDuplicateWarnings = editedData.NullableIgnoreDuplicateWarnings ?? modelFromDB.IgnoreDuplicateWarnings;

            editedData.WitnessingRequired = editedData.NullableWitnessingRequired ?? modelFromDB.WitnessingRequired;

            editedData.IsBloodProduct = editedData.NullableIsBloodProduct ?? modelFromDB.IsBloodProduct;

            editedData.IsDiluent = editedData.NullableIsDiluent ?? modelFromDB.IsDiluent;

            editedData.IsCustomControlledDrug = editedData.NullableIsCustomControlledDrug ?? modelFromDB.IsCustomControlledDrug;

            if (!editedData.Diluents.IsCollectionValid())
            {
                editedData.Diluents = modelFromDB.Diluents;
            }

            editedData.IsIndicationMandatory = editedData.NullableIsIndicationMandatory ?? modelFromDB.IsIndicationMandatory;

            editedData.IsGastroResistant = editedData.NullableIsGastroResistant ?? modelFromDB.IsGastroResistant;

            editedData.IsModifiedRelease = editedData.NullableIsModifiedRelease ?? modelFromDB.IsModifiedRelease;

            editedData.Status = editedData.Status ?? modelFromDB.Status;

            editedData.RecStatuschangeMsg = editedData.RecStatuschangeMsg ?? modelFromDB.RecStatuschangeMsg;
        }
示例#10
0
        public async Task <IActionResult> LoadHistoryFormularyDetails(string previousFormularyVersionId, string currentFormularyVersionId, string previousOrCurrent)
        {
            const string MMC_CONFIG_KEY = "MMC_Control_Source";

            string token = HttpContext.Session.GetString("access_token");

            var previousResponseTask = TerminologyAPIService.GetFormularyDetailRuleBound(previousFormularyVersionId, token);// TerminologyAPIService.GetFormularyDetail(formularyVersionId, token);

            var currentResponseTask = TerminologyAPIService.GetFormularyDetailRuleBound(currentFormularyVersionId, token);

            var terminologyConfigTask = TerminologyAPIService.GetTerminologyConfiguration(MMC_CONFIG_KEY, token);

            await Task.WhenAll(previousResponseTask, terminologyConfigTask);

            await Task.WhenAll(currentResponseTask, terminologyConfigTask);

            var previousResponse = await previousResponseTask;

            var currentResponse = await currentResponseTask;

            var terminologyConfigResponse = await terminologyConfigTask;

            if ((previousResponse == null || previousResponse.StatusCode == DataService.APIModel.StatusCode.Fail) || (currentResponse == null || currentResponse.StatusCode == DataService.APIModel.StatusCode.Fail) || ((terminologyConfigResponse == null || terminologyConfigResponse.StatusCode == DataService.APIModel.StatusCode.Fail)))
            {
                const string ErrorResponse = "Error getting details for the selected record";
                var          errors        = "";
                if (previousResponse.ErrorMessages.IsCollectionValid())
                {
                    errors = string.Join('\n', ErrorResponse, previousResponse.ErrorMessages.ToArray());
                }
                if (currentResponse.ErrorMessages.IsCollectionValid())
                {
                    errors = string.Join('\n', ErrorResponse, currentResponse.ErrorMessages.ToArray());
                }
                if (terminologyConfigResponse.ErrorMessages.IsCollectionValid())
                {
                    errors = string.Join('\n', ErrorResponse, terminologyConfigResponse.ErrorMessages.ToArray());
                }
                _toastNotification.AddErrorToastMessage(errors);

                return(null);
            }

            var previousFormulariesfromAPI = previousResponse.Data;

            var currentFormulariesfromAPI = currentResponse.Data;

            await FillLookupsToViewBag(previousFormulariesfromAPI.RecStatusCode);

            await FillLookupsToViewBag(currentFormulariesfromAPI.RecStatusCode);

            FormularyEditModel previousVM = GetFormularyEditModel(previousFormulariesfromAPI);

            FormularyEditModel currentVM = GetFormularyEditModel(currentFormulariesfromAPI);

            var prevProductName = previousVM.Name;
            var prevProductType = previousVM.ProductType;
            var prevCode        = previousVM.Code;
            var prevCodeSystem  = previousVM.CodeSystem;

            var currProductName = currentVM.Name;
            var currProductType = currentVM.ProductType;
            var currCode        = currentVM.Code;
            var currCodeSystem  = currentVM.CodeSystem;

            var differences = previousVM.Diff(currentVM, ComparisonOptions.All | ComparisonOptions.AllowCollectionsToBeOutOfOrder | ComparisonOptions.AllowEqualsOverride,
                                              ".FormularyVersionIds", ".Excipients.FormularyVersionId", ".FormularyClassificationCodes.FormularyVersionId", ".FormularyIdentificationCodes.FormularyVersionId", ".Ingredients.FormularyVersionId",
                                              ".UnlicensedRoute.Source", ".UnlicensedRoute.SourceColor", ".Route.Source", ".Route.SourceColor", ".LocalLicensedRoute.Source", ".LocalLicensedRoute.SourceColor", ".LocalUnlicensedRoute.Source", ".LocalUnlicensedRoute.SourceColor",
                                              ".Cautions.Source", ".Cautions.SourceColor", ".ContraIndications.Source", ".ContraIndications.SourceColor", ".SideEffects.Source", ".SideEffects.SourceColor", ".SafetyMessages.Source", ".SafetyMessages.SourceColor",
                                              ".LicensedUse.Source", ".LicensedUse.SourceColor", ".UnlicensedUse.Source", ".UnlicensedUse.SourceColor", ".LocalLicensedUse.Source", ".LocalLicensedUse.SourceColor", ".LocalUnlicensedUse.Source", ".LocalUnlicensedUse.SourceColor",
                                              ".FormCd.Source", ".FormCd.SourceColor", ".UnitDoseFormUnits.Source", ".UnitDoseFormUnits.SourceColor", ".UnitDoseUnitOfMeasure.Source", ".UnitDoseUnitOfMeasure.SourceColor", ".Supplier.Source", ".Supplier.SourceColor",
                                              ".TradeFamily.Source", ".TradeFamily.SourceColor", ".MedusaPreparationInstructions.Source", ".MedusaPreparationInstructions.SourceColor", ".ControlledDrugCategories.Source", ".ControlledDrugCategories.SourceColor",
                                              ".TitrationTypes.Source", ".TitrationTypes.SourceColor", ".Diluents.Source", ".Diluents.SourceColor", ".HighAlertMedicationSource", ".BlackTriangleSource", ".PrescribableSource");

            if (differences.Count > 0)
            {
                List <KeyValuePair <string, object> > prevObjects = new List <KeyValuePair <string, object> >();

                foreach (var diff in differences)
                {
                    prevObjects.Add(new KeyValuePair <string, object>(diff.Property, diff.LeftValue));
                }

                FormularyEditModel prevVM = new FormularyEditModel();

                prevVM.Differences = new List <Difference>();

                prevVM.Differences.AddRange(differences);

                var prevVMType = prevVM.GetType();

                foreach (KeyValuePair <string, object> _pair in prevObjects)
                {
                    if (prevVMType.GetProperty(_pair.Key).PropertyType.Name == "List`1")
                    {
                        if (_pair.Value != null)
                        {
                            object instance = Activator.CreateInstance(prevVMType.GetProperty(_pair.Key).PropertyType);

                            IList list = (IList)instance;

                            list.Add(_pair.Value);

                            if (prevVM.GetType().GetProperty(_pair.Key).GetValue(prevVM, null).IsNotNull())
                            {
                                foreach (var value in (dynamic)prevVM.GetType().GetProperty(_pair.Key).GetValue(prevVM, null))
                                {
                                    list.Add(value);
                                }
                                prevVMType.GetProperty(_pair.Key).SetValue(prevVM, list, null);
                            }
                            else
                            {
                                prevVMType.GetProperty(_pair.Key).SetValue(prevVM, list, null);
                            }
                        }
                        else
                        {
                            object instance = Activator.CreateInstance(prevVMType.GetProperty(_pair.Key).PropertyType);

                            IList list = (IList)instance;

                            list.Add(_pair.Value);

                            prevVMType.GetProperty(_pair.Key).SetValue(prevVM, list, null);
                        }
                    }
                    else
                    {
                        prevVMType.GetProperty(_pair.Key).SetValue(prevVM, _pair.Value);
                    }
                }

                previousVM = prevVM;

                previousVM.IsDiff = true;

                previousVM.Name        = prevProductName;
                previousVM.ProductType = prevProductType;
                previousVM.Code        = prevCode;
                previousVM.CodeSystem  = prevCodeSystem;

                List <KeyValuePair <string, object> > currObjects = new List <KeyValuePair <string, object> >();

                foreach (var diff in differences)
                {
                    currObjects.Add(new KeyValuePair <string, object>(diff.Property, diff.RightValue));
                }

                FormularyEditModel currVM = new FormularyEditModel();

                currVM.Differences = new List <Difference>();

                currVM.Differences.AddRange(differences);

                var currVMType = currVM.GetType();

                foreach (KeyValuePair <string, object> _pair in currObjects)
                {
                    if (currVMType.GetProperty(_pair.Key).PropertyType.Name == "List`1")
                    {
                        if (_pair.Value != null)
                        {
                            object instance = Activator.CreateInstance(currVMType.GetProperty(_pair.Key).PropertyType);

                            IList list = (IList)instance;

                            list.Add(_pair.Value);

                            if (currVM.GetType().GetProperty(_pair.Key).GetValue(currVM, null).IsNotNull())
                            {
                                foreach (var value in (dynamic)currVM.GetType().GetProperty(_pair.Key).GetValue(currVM, null))
                                {
                                    list.Add(value);
                                }
                                currVMType.GetProperty(_pair.Key).SetValue(currVM, list, null);
                            }
                            else
                            {
                                currVMType.GetProperty(_pair.Key).SetValue(currVM, list, null);
                            }
                        }
                        else
                        {
                            object instance = Activator.CreateInstance(currVMType.GetProperty(_pair.Key).PropertyType);

                            IList list = (IList)instance;

                            list.Add(_pair.Value);

                            currVMType.GetProperty(_pair.Key).SetValue(currVM, list, null);
                        }
                    }
                    else
                    {
                        currVMType.GetProperty(_pair.Key).SetValue(currVM, _pair.Value);
                    }
                }

                currentVM = currVM;

                currentVM.IsDiff = true;

                currentVM.Name        = currProductName;
                currentVM.ProductType = currProductType;
                currentVM.Code        = currCode;
                currentVM.CodeSystem  = currCodeSystem;
            }
            else
            {
                previousVM = new FormularyEditModel();
                currentVM  = new FormularyEditModel();

                previousVM.IsDiff = false;

                previousVM.Name        = prevProductName;
                previousVM.ProductType = prevProductType;
                previousVM.Code        = prevCode;
                previousVM.CodeSystem  = prevCodeSystem;

                currentVM.IsDiff = false;

                currentVM.Name        = currProductName;
                currentVM.ProductType = currProductType;
                currentVM.Code        = currCode;
                currentVM.CodeSystem  = currCodeSystem;
            }

            if (previousVM.BlackTriangle != currentVM.BlackTriangle)
            {
                previousVM.IsDiffBlackTriangle = true;
                currentVM.IsDiffBlackTriangle  = true;
            }
            else
            {
                previousVM.IsDiffBlackTriangle = false;
                currentVM.IsDiffBlackTriangle  = false;
            }

            if (previousVM.ClinicalTrialMedication != currentVM.ClinicalTrialMedication)
            {
                previousVM.IsDiffClinicalTrialMedication = true;
                currentVM.IsDiffClinicalTrialMedication  = true;
            }
            else
            {
                previousVM.IsDiffClinicalTrialMedication = false;
                currentVM.IsDiffClinicalTrialMedication  = false;
            }

            if (previousVM.CriticalDrug != currentVM.CriticalDrug)
            {
                previousVM.IsDiffCriticalDrug = true;
                currentVM.IsDiffCriticalDrug  = true;
            }
            else
            {
                previousVM.IsDiffCriticalDrug = false;
                currentVM.IsDiffCriticalDrug  = false;
            }

            if (previousVM.EmaAdditionalMonitoring != currentVM.EmaAdditionalMonitoring)
            {
                previousVM.IsDiffEMAAddMontorng = true;
                currentVM.IsDiffEMAAddMontorng  = true;
            }
            else
            {
                previousVM.IsDiffEMAAddMontorng = false;
                currentVM.IsDiffEMAAddMontorng  = false;
            }

            if (previousVM.IsGastroResistant != currentVM.IsGastroResistant)
            {
                previousVM.IsDiffGastroResistant = true;
                currentVM.IsDiffGastroResistant  = true;
            }
            else
            {
                previousVM.IsDiffGastroResistant = false;
                currentVM.IsDiffGastroResistant  = false;
            }

            if (previousVM.IsModifiedRelease != currentVM.IsModifiedRelease)
            {
                previousVM.IsDiffModifiedRelease = true;
                currentVM.IsDiffModifiedRelease  = true;
            }
            else
            {
                previousVM.IsDiffModifiedRelease = false;
                currentVM.IsDiffModifiedRelease  = false;
            }

            if (previousVM.ExpensiveMedication != currentVM.ExpensiveMedication)
            {
                previousVM.IsDiffExpensiveMedication = true;
                currentVM.IsDiffExpensiveMedication  = true;
            }
            else
            {
                previousVM.IsDiffExpensiveMedication = false;
                currentVM.IsDiffExpensiveMedication  = false;
            }

            if (previousVM.HighAlertMedication != currentVM.HighAlertMedication)
            {
                previousVM.IsDiffHighAlertMedication = true;
                currentVM.IsDiffHighAlertMedication  = true;
            }
            else
            {
                previousVM.IsDiffHighAlertMedication = false;
                currentVM.IsDiffHighAlertMedication  = false;
            }

            if (previousVM.IVToOral != currentVM.IVToOral)
            {
                previousVM.IsDiffIVtoOral = true;
                currentVM.IsDiffIVtoOral  = true;
            }
            else
            {
                previousVM.IsDiffIVtoOral = false;
                currentVM.IsDiffIVtoOral  = false;
            }

            if (previousVM.NotForPrn != currentVM.NotForPrn)
            {
                previousVM.IsDiffNotforPRN = true;
                currentVM.IsDiffNotforPRN  = true;
            }
            else
            {
                previousVM.IsDiffNotforPRN = false;
                currentVM.IsDiffNotforPRN  = false;
            }

            if (previousVM.IsBloodProduct != currentVM.IsBloodProduct)
            {
                previousVM.IsDiffBloodProduct = true;
                currentVM.IsDiffBloodProduct  = true;
            }
            else
            {
                previousVM.IsDiffBloodProduct = false;
                currentVM.IsDiffBloodProduct  = false;
            }

            if (previousVM.IsDiluent != currentVM.IsDiluent)
            {
                previousVM.IsDiffDiluent = true;
                currentVM.IsDiffDiluent  = true;
            }
            else
            {
                previousVM.IsDiffDiluent = false;
                currentVM.IsDiffDiluent  = false;
            }

            if (previousVM.Prescribable != currentVM.Prescribable)
            {
                previousVM.IsDiffPrescribable = true;
                currentVM.IsDiffPrescribable  = true;
            }
            else
            {
                previousVM.IsDiffPrescribable = false;
                currentVM.IsDiffPrescribable  = false;
            }

            if (previousVM.OutpatientMedication != currentVM.OutpatientMedication)
            {
                previousVM.IsDiffOutpatientMedication = true;
                currentVM.IsDiffOutpatientMedication  = true;
            }
            else
            {
                previousVM.IsDiffOutpatientMedication = false;
                currentVM.IsDiffOutpatientMedication  = false;
            }

            if (previousVM.SugarFree != currentVM.SugarFree)
            {
                previousVM.IsDiffSugarFree = true;
                currentVM.IsDiffSugarFree  = true;
            }
            else
            {
                previousVM.IsDiffSugarFree = false;
                currentVM.IsDiffSugarFree  = false;
            }

            if (previousVM.GlutenFree != currentVM.GlutenFree)
            {
                previousVM.IsDiffGlutenFree = true;
                currentVM.IsDiffGlutenFree  = true;
            }
            else
            {
                previousVM.IsDiffGlutenFree = false;
                currentVM.IsDiffGlutenFree  = false;
            }

            if (previousVM.PreservativeFree != currentVM.PreservativeFree)
            {
                previousVM.IsDiffPreservativeFree = true;
                currentVM.IsDiffPreservativeFree  = true;
            }
            else
            {
                previousVM.IsDiffPreservativeFree = false;
                currentVM.IsDiffPreservativeFree  = false;
            }

            if (previousVM.CFCFree != currentVM.CFCFree)
            {
                previousVM.IsDiffCFCFree = true;
                currentVM.IsDiffCFCFree  = true;
            }
            else
            {
                previousVM.IsDiffCFCFree = false;
                currentVM.IsDiffCFCFree  = false;
            }

            if (previousVM.UnlicensedMedication != currentVM.UnlicensedMedication)
            {
                previousVM.IsDiffUnlicensedMedication = true;
                currentVM.IsDiffUnlicensedMedication  = true;
            }
            else
            {
                previousVM.IsDiffUnlicensedMedication = false;
                currentVM.IsDiffUnlicensedMedication  = false;
            }

            if (previousVM.ParallelImport != currentVM.ParallelImport)
            {
                previousVM.IsDiffParallelImport = true;
                currentVM.IsDiffParallelImport  = true;
            }
            else
            {
                previousVM.IsDiffParallelImport = false;
                currentVM.IsDiffParallelImport  = false;
            }

            if (previousVM.IgnoreDuplicateWarnings != currentVM.IgnoreDuplicateWarnings)
            {
                previousVM.IsDiffIgnoreDuplicateWarnings = true;
                currentVM.IsDiffIgnoreDuplicateWarnings  = true;
            }
            else
            {
                previousVM.IsDiffIgnoreDuplicateWarnings = false;
                currentVM.IsDiffIgnoreDuplicateWarnings  = false;
            }

            if (previousVM.IsCustomControlledDrug != currentVM.IsCustomControlledDrug)
            {
                previousVM.IsDiffControlledDrug = true;
                currentVM.IsDiffControlledDrug  = true;
            }
            else
            {
                previousVM.IsDiffControlledDrug = false;
                currentVM.IsDiffControlledDrug  = false;
            }

            if (previousVM.IsIndicationMandatory != currentVM.IsIndicationMandatory)
            {
                previousVM.IsDiffIndicationIsMandatory = true;
                currentVM.IsDiffIndicationIsMandatory  = true;
            }
            else
            {
                previousVM.IsDiffIndicationIsMandatory = false;
                currentVM.IsDiffIndicationIsMandatory  = false;
            }

            if (previousVM.WitnessingRequired != currentVM.WitnessingRequired)
            {
                previousVM.IsDiffWitnessingRequired = true;
                currentVM.IsDiffWitnessingRequired  = true;
            }
            else
            {
                previousVM.IsDiffWitnessingRequired = false;
                currentVM.IsDiffWitnessingRequired  = false;
            }

            if (previousOrCurrent.IsEmpty())
            {
                return(null);
            }

            string viewName = string.Empty;

            if (string.Compare(previousOrCurrent, "previous", true) == 0)
            {
                viewName = "_FormularyPreviousDetails";
                return(PartialView(viewName, previousVM));
            }

            if (string.Compare(previousOrCurrent, "current", true) == 0)
            {
                viewName = "_FormularyCurrentDetails";
                return(PartialView(viewName, currentVM));
            }

            return(null);
        }
示例#11
0
        public async Task <IActionResult> UpdateFormulary(FormularyEditModel editedData)
        {
            BulkFormularyEditModel bulkEditedData = null;

            string token = HttpContext.Session.GetString("access_token");

            var partialView = GetFormularyEditView(editedData.ProductType);

            if (editedData.IsBulkEdit)
            {
                bulkEditedData = editedData as BulkFormularyEditModel;
                partialView    = GetFormularyEditViewForBulkEdit(editedData.ProductType);
            }


            if (!ModelState.IsValid)
            {
                await FillLookupsToViewBag(editedData.OriginalStatus);

                editedData.IsSaveSuccessful = false;
                return(PartialView(partialView, editedData));
            }

            var apiModels = new List <FormularyHeaderAPIModel>();

            var uniqueIds = editedData.FormularyVersionIds;

            foreach (var rec in uniqueIds)
            {
                FormularyHeaderAPIModel apiModel = null;

                if (editedData.IsBulkEdit)
                {
                    var orginalObj = JsonConvert.DeserializeObject <BulkFormularyEditModel>(bulkEditedData.SerializedOriginalObj);

                    var edDataDeserializedObj = _mapper.Map <BulkFormularyEditModel>(bulkEditedData);

                    await MergeOnlyModified(edDataDeserializedObj, orginalObj, rec);

                    apiModel = _mapper.Map <FormularyHeaderAPIModel>(edDataDeserializedObj);
                }
                else
                {
                    apiModel = _mapper.Map <FormularyHeaderAPIModel>(editedData);
                }

                apiModel.FormularyVersionId = rec;
                apiModel.RecStatusCode      = apiModel.RecStatusCode; //editedData.IsBulkEdit ? null : apiModel.RecStatusCode;//For bulk-edit mode - Record status is not editable
                apiModels.Add(apiModel);
            }

            TerminologyAPIResponse <UpdateFormularyAPIResponse> response = await TerminologyAPIService.UpdateFormulary(apiModels, token);

            if (response.StatusCode != DataService.APIModel.StatusCode.Success)
            {
                await FillLookupsToViewBag(editedData.OriginalStatus);

                _toastNotification.AddErrorToastMessage(string.Join('\n', response.ErrorMessages));

                editedData.IsSaveSuccessful = false;

                return(PartialView(partialView, editedData));
            }

            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);

                    _toastNotification.AddInfoToastMessage(errors);

                    await FillLookupsToViewBag(editedData.OriginalStatus);

                    editedData.IsSaveSuccessful = true;

                    return(PartialView(partialView, editedData));
                }
            }

            _toastNotification.AddSuccessToastMessage("Successfully Updated Formulary details");

            editedData.IsSaveSuccessful = true;

            return(Json(null));
        }