diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Configuration/MoodleApiConfig.cs b/AdminUI/LearningHub.Nhs.AdminUI/Configuration/MoodleApiConfig.cs new file mode 100644 index 000000000..88b8c8d9e --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Configuration/MoodleApiConfig.cs @@ -0,0 +1,33 @@ +namespace LearningHub.Nhs.AdminUI.Configuration +{ + /// + /// The Moodle Settings. + /// + public class MoodleApiConfig + { + /// + /// Gets or sets the base url for the Moodle service. + /// + public string BaseUrl { get; set; } = null!; + + /// + /// Gets or sets the Web service Rest Format. + /// + public string MoodleWSRestFormat { get; set; } = null!; + + /// + /// Gets or sets the token. + /// + public string WSToken { get; set; } = null!; + + /// + /// Gets or sets the token. + /// + public string ApiPath { get; set; } = "webservice/rest/server.php"; + + /// + /// Gets or sets the token. + /// + public string CoursePath { get; set; } = "course/view.php"; + } +} diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/CatalogueController.cs b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/CatalogueController.cs index d03f1f84c..508684668 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/CatalogueController.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/CatalogueController.cs @@ -1,28 +1,28 @@ namespace LearningHub.Nhs.AdminUI.Controllers { - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.Drawing; - using System.Linq; - using System.Net.Mail; - using System.Text.RegularExpressions; - using System.Threading.Tasks; using LearningHub.Nhs.AdminUI.Configuration; using LearningHub.Nhs.AdminUI.Extensions; using LearningHub.Nhs.AdminUI.Interfaces; using LearningHub.Nhs.AdminUI.Models; using LearningHub.Nhs.Models.Catalogue; using LearningHub.Nhs.Models.Common; - using LearningHub.Nhs.Models.Common.Enums; + using LearningHub.Nhs.Models.Moodle; using LearningHub.Nhs.Models.Paging; using LearningHub.Nhs.Models.Resource; using LearningHub.Nhs.Models.User; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Linq; + using System.Net; + using System.Text.RegularExpressions; + using System.Threading.Tasks; /// /// Defines the . @@ -65,6 +65,11 @@ public class CatalogueController : BaseController /// private readonly IProviderService providerService; + /// + /// Defines the moodleApiService. + /// + private readonly IMoodleApiService moodleApiService; + /// /// Defines the _settings. /// @@ -98,6 +103,7 @@ public class CatalogueController : BaseController /// The userService. /// The fileService. /// The providerService. + /// The moodleApiService. /// The logger. /// The options. /// The websettings. @@ -107,6 +113,7 @@ public CatalogueController( IUserGroupService userGroupService, IFileService fileService, IProviderService providerService, + IMoodleApiService moodleApiService, ILogger logger, IOptions options, IOptions websettings) @@ -116,6 +123,7 @@ public CatalogueController( this.userGroupService = userGroupService; this.fileService = fileService; this.providerService = providerService; + this.moodleApiService = moodleApiService; this.logger = logger; this.websettings = websettings; this.settings = options.Value; @@ -254,6 +262,38 @@ public async Task CatalogueOwner(int id) return this.View(vm); } + /// + /// The CatalogueOwner. + /// + /// The id. + /// The . + [HttpGet] + [Route("MoodleCategory/{id}")] + public async Task MoodleCategory(int id) + { + var vm = await this.catalogueService.GetCatalogueAsync(id); + if (vm == null) + { + return this.RedirectToAction("Error"); + } + + var categories = await this.moodleApiService.GetAllMoodleCategoriesAsync(); + + vm.MoodleCategories = categories; + + // Build hierarchical select list + var selectList = BuildList(categories, parentId: null, depth: 0); + foreach (var item in selectList) + { + item.Text = WebUtility.HtmlDecode(item.Text); + } + vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text"); + this.ViewData["CatalogueName"] = vm.Name; + this.ViewData["id"] = id; + + return this.View(vm); + } + /// /// The UserGroups. /// @@ -678,6 +718,77 @@ public async Task AddUserGroupsToCatalogue(int catalogueNodeId, i } } + /// + /// The AddCategoryToCatalogue. + /// + /// The catalogueViewModel. + /// The . + [HttpPost] + [Route("AddCategoryToCatalogue")] + public async Task AddCategoryToCatalogue(CatalogueViewModel catalogueViewModel) + { + if (catalogueViewModel.SelectedCategoryId == 0) + { + this.ModelState.AddModelError("SelectedCategoryId", "Please select a category."); + } + var vm = await this.catalogueService.GetCatalogueAsync(catalogueViewModel.CatalogueNodeVersionId); + vm.SelectedCategoryId = catalogueViewModel.SelectedCategoryId; + var vr = await this.catalogueService.AddCategoryToCatalogue(vm); + if (vr.Success) + { + var categories = await this.moodleApiService.GetAllMoodleCategoriesAsync(); + vm.MoodleCategories = categories; + // Build hierarchical select list + var selectList = BuildList(categories, parentId: null, depth: 0); + + foreach (var item in selectList) + { + item.Text = WebUtility.HtmlDecode(item.Text); + } + + vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text"); + return this.View("MoodleCategory", vm); + } + else + { + this.ViewBag.ErrorMessage = $"Category Update failed."; + return this.View("MoodleCategory", vm); + } + } + + /// + /// The RemoveCategoryFromCatalogue. + /// + /// The categoryId/>. + /// The CatalogueNodeVersionId. + /// The . + [HttpGet] + [Route("RemoveCategoryFromCatalogue/{categoryId}/{catalogueNodeVersionId}")] + public async Task RemoveCategoryFromCatalogue(int categoryId, int catalogueNodeVersionId) + { + var vm = await this.catalogueService.GetCatalogueAsync(catalogueNodeVersionId); + vm.SelectedCategoryId = categoryId; + var vr = await this.catalogueService.RemoveCategoryFromCatalogue(vm); + if (vr.Success) + { + var categories = await this.moodleApiService.GetAllMoodleCategoriesAsync(); + vm.MoodleCategories = categories; + vm.SelectedCategoryId = 0; + // Build hierarchical select list + var selectList = BuildList(categories, parentId: null, depth: 0); + foreach (var item in selectList) + { + item.Text = WebUtility.HtmlDecode(item.Text); + } + vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text"); + return this.View("MoodleCategory", vm); + } + else + { + this.ViewBag.ErrorMessage = $"Category update failed."; + return this.View("MoodleCategory", vm); + } + } /// /// The CreateCatalogue. /// @@ -978,5 +1089,34 @@ private void ValidateCatalogueOwnerVm(CatalogueOwnerViewModel vm) this.ModelState.AddModelError("Notes", "The notes are required."); } } + + private List BuildList(IEnumerable allCategories, int? parentId, int depth) + { + var selectList = new List(); + + // Handle both null and 0 as top-level depending on Moodle data + var children = allCategories + .Where(c => c.Parent == parentId || (parentId == null && (c.Parent == 0 || c.Parent == 0))) + .OrderBy(c => c.Name) + .ToList(); + + foreach (var child in children) + { + // Indent with non-breaking spaces so browser keeps them + string indent = new string('\u00A0', depth * 3); + + selectList.Add(new SelectListItem + { + Value = child.Id.ToString(), + Text = $"{indent}{child.Name}" + }); + + // Recursively add nested children + selectList.AddRange(BuildList(allCategories, child.Id, depth + 1)); + } + + return selectList; + } + } } diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/ICatalogueService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/ICatalogueService.cs index f6bffaec9..b54694e93 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/ICatalogueService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/ICatalogueService.cs @@ -69,5 +69,19 @@ public interface ICatalogueService /// The catalogue owner. /// The . Task UpdateCatalogueOwnerAsync(CatalogueOwnerViewModel catalogueOwner); + + /// + /// AddCategoryToCatalogue + /// + /// The catalogue. + /// + Task AddCategoryToCatalogue(CatalogueViewModel catalogue); + + /// + /// RemoveCategoryFromCatalogue + /// + /// The catalogue. + /// + Task RemoveCategoryFromCatalogue(CatalogueViewModel catalogue); } } diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IMoodleApiService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IMoodleApiService.cs new file mode 100644 index 000000000..d8c384757 --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IMoodleApiService.cs @@ -0,0 +1,26 @@ +namespace LearningHub.Nhs.AdminUI.Interfaces +{ + using System.Collections.Generic; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Moodle; + using LearningHub.Nhs.Models.Moodle.API; + + /// + /// IMoodleApiService. + /// + public interface IMoodleApiService + { + /// + /// GetMoodleUserIdByUsernameAsync. + /// + /// The current LH User Id. + /// A representing the result of the asynchronous operation. + Task GetMoodleUserIdByUsernameAsync(int currentUserId); + + /// + /// GetEnrolledCoursesAsync. + /// + /// List of MoodleCategory. + Task> GetAllMoodleCategoriesAsync(); + } +} diff --git a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj index 126c014ef..39e4b25da 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj +++ b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj @@ -89,7 +89,7 @@ - + diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Models/CatalogueNavViewModel.cs b/AdminUI/LearningHub.Nhs.AdminUI/Models/CatalogueNavViewModel.cs index 502206549..4cf605e72 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Models/CatalogueNavViewModel.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Models/CatalogueNavViewModel.cs @@ -34,6 +34,11 @@ public enum CatalogueNavPage /// Defines the Catalogue Owner. /// CatalogueOwner, + + /// + /// Defines the Category. + /// + Category } /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs index 1039a3673..4f95fe9fb 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs @@ -106,6 +106,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur services.AddTransient(); services.AddTransient(); services.AddScoped(); + services.AddScoped(); // web settings binding var webSettings = new WebSettings(); diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs index 2ac0088d9..8db4e0aaf 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs @@ -1,14 +1,20 @@ namespace LearningHub.Nhs.AdminUI.Services { + using System; using System.Collections.Generic; using System.Net; + using System.Net.Http; + using System.Text; using System.Threading.Tasks; using LearningHub.Nhs.AdminUI.Helpers; using LearningHub.Nhs.AdminUI.Interfaces; using LearningHub.Nhs.Models.Catalogue; using LearningHub.Nhs.Models.Common; + using LearningHub.Nhs.Models.Enums; using LearningHub.Nhs.Models.Paging; using LearningHub.Nhs.Models.Provider; + using LearningHub.Nhs.Models.User; + using LearningHub.Nhs.Models.Validation; using Newtonsoft.Json; /// @@ -132,5 +138,25 @@ public async Task UpdateCatalogueOwnerAsync(CatalogueOwnerViewModel { return await this.facade.PutAsync("Catalogue/UpdateCatalogueOwner", catalogueOwner); } + + /// + /// The AddUserGroupsToCatalogue. + /// + /// The CatalogueViewModel. + /// The . + public async Task AddCategoryToCatalogue(CatalogueViewModel catalogue) + { + return await this.facade.PostAsync("Catalogue/AddCategoryToCatalogue", catalogue); + } + + /// + /// The RemoveCategoryFromCatalogue. + /// + /// The CatalogueViewModel. + /// The . + public async Task RemoveCategoryFromCatalogue(CatalogueViewModel catalogue) + { + return await this.facade.PostAsync("Catalogue/RemoveCategoryFromCatalogue", catalogue); + } } } diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/MoodleApiService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/MoodleApiService.cs new file mode 100644 index 000000000..febd41a5e --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/MoodleApiService.cs @@ -0,0 +1,99 @@ +namespace LearningHub.Nhs.AdminUI.Services +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using LearningHub.Nhs.AdminUI.Configuration; + using LearningHub.Nhs.AdminUI.Interfaces; + using LearningHub.Nhs.Models.Moodle; + using LearningHub.Nhs.Models.Moodle.API; + using Microsoft.Extensions.Options; + using Newtonsoft.Json; + + /// + /// MoodleApiService. + /// + public class MoodleApiService : IMoodleApiService + { + private readonly IOpenApiHttpClient openApiHttpClient; + private readonly MoodleApiConfig configuration; + + /// + /// Initializes a new instance of the class. + /// + /// The Open Api Http Client. + /// configuration. + public MoodleApiService(IOpenApiHttpClient openApiHttpClient, IOptions configuration) + { + this.openApiHttpClient = openApiHttpClient; + this.configuration = configuration.Value; + } + + /// + /// GetMoodleUserIdByUsernameAsync. + /// + /// current User Id. + /// UserId from Moodle. + public async Task GetMoodleUserIdByUsernameAsync(int currentUserId) + { + int moodleUserId = 0; + + try + { + var client = await this.openApiHttpClient.GetClientAsync(); + + var request = $"Moodle/GetMoodleUserId/{currentUserId}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + moodleUserId = JsonConvert.DeserializeObject(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return moodleUserId; + } + catch (Exception ex) + { + return moodleUserId; + } + } + + /// + /// GetAllMoodleCategoriesAsync. + /// + /// A representing the result of the asynchronous operation. + public async Task> GetAllMoodleCategoriesAsync() + { + List viewmodel = new List(); + + try + { + var client = await this.openApiHttpClient.GetClientAsync(); + + var request = $"Moodle/GetAllMoodleCategories"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject>(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + catch (Exception ex) + { + return viewmodel; + } + } + } +} diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Styles/nhsuk/common.scss b/AdminUI/LearningHub.Nhs.AdminUI/Styles/nhsuk/common.scss index 65d34f7e7..8f51a7b40 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Styles/nhsuk/common.scss +++ b/AdminUI/LearningHub.Nhs.AdminUI/Styles/nhsuk/common.scss @@ -7,4 +7,11 @@ .menu-font { font-size: 19px !important; -} \ No newline at end of file +} +.nhs-item-row { + display: flex; + justify-content: space-between; + align-items: center; +} + + diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/MoodleCategory.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/MoodleCategory.cshtml new file mode 100644 index 000000000..81ea1901d --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/MoodleCategory.cshtml @@ -0,0 +1,121 @@ +@model LearningHub.Nhs.Models.Catalogue.CatalogueViewModel +@inject Microsoft.Extensions.Options.IOptions _settings +@using LearningHub.Nhs.Models.Enums +@using Newtonsoft.Json +@{ + var page = CatalogueNavPage.Category; + ViewData["Title"] = "Manage Category"; + var selectedCategoryName = Model.MoodleCategorySelectList + .FirstOrDefault(c => c.Value == Model.SelectedCategoryId.ToString())?.Text; + var errorHasOccurred = !ViewData.ModelState.IsValid; +} +@section SideMenu { + @{ + await Html.RenderPartialAsync("_NavSection"); + } +} + +
+
+

@Model.Name

+
+
+ +@{ + await Html.RenderPartialAsync("_CatalogueNav.cshtml", new CatalogueNavViewModel { Page = page, CatalogueId = Model.CatalogueNodeVersionId }); +} + +
+
+ + + + + +
+
+

Manage category

+
+
+
+
+
+ @if (Model.SelectedCategoryId > 0) + { +
+
+ + @selectedCategoryName + + Change + Remove +
+
+ } + +
+
+ @if (errorHasOccurred) + { + + Error: Please select a category. + + } +
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+ +@section Scripts { + +} \ No newline at end of file diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/_CatalogueNav.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/_CatalogueNav.cshtml index be71c5771..c7ca0ab8a 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/_CatalogueNav.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/_CatalogueNav.cshtml @@ -5,6 +5,7 @@ var foldersActive = (Model.Page == CatalogueNavPage.Folders) ? "active" : ""; var userGroupsActive = (Model.Page == CatalogueNavPage.UserGroups) ? "active" : ""; var catalogueOwnerActive = (Model.Page == CatalogueNavPage.CatalogueOwner) ? "active" : ""; + var categoryActive = (Model.Page == CatalogueNavPage.Category) ? "active" : ""; }
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json b/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json index 95a04b8bc..17b29013c 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json +++ b/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json @@ -59,6 +59,11 @@ "JWTPrimaryKeySecret": "", "MKPlayerLicence": "", "MediaKindStorageConnectionString": "" + }, + "MoodleAPIConfig": { + "BaseUrl": "https://moodle-test.test-learninghub.org.uk/", + "MoodleWSRestFormat": "json", + "WSToken": "" } }, "ConnectionStrings": { diff --git a/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj b/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj index a423f7061..695e93e2d 100644 --- a/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj +++ b/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj @@ -9,11 +9,10 @@ True - - + diff --git a/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs b/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs index 12d9973ac..b6c3e82f6 100644 --- a/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs @@ -11,6 +11,7 @@ using LearningHub.Nhs.Models.Dashboard; using LearningHub.Nhs.Models.Enums; using LearningHub.Nhs.Models.Hierarchy; + using LearningHub.Nhs.Models.Moodle; using LearningHub.Nhs.Models.Search; using LearningHub.Nhs.Models.User; using LearningHub.Nhs.WebUI.Configuration; @@ -35,6 +36,7 @@ public class CatalogueController : BaseController private readonly IDashboardService dashboardService; private readonly ISearchService searchService; private readonly ICacheService cacheService; + private readonly ICategoryService categoryService; private LearningHubAuthServiceConfig authConfig; private ICatalogueService catalogueService; private IUserService userService; @@ -57,6 +59,7 @@ public class CatalogueController : BaseController /// Dashboard service. /// HierarchyService. /// userGroupService. + /// categoryService. public CatalogueController( IHttpClientFactory httpClientFactory, IWebHostEnvironment hostingEnvironment, @@ -69,7 +72,8 @@ public CatalogueController( ICacheService cacheService, IDashboardService dashboardService, IHierarchyService hierarchyService, - IUserGroupService userGroupService) + IUserGroupService userGroupService, + ICategoryService categoryService) : base(hostingEnvironment, httpClientFactory, logger, settings.Value) { this.authConfig = authConfig; @@ -81,6 +85,7 @@ public CatalogueController( this.dashboardService = dashboardService; this.hierarchyService = hierarchyService; this.userGroupService = userGroupService; + this.categoryService = categoryService; } /// @@ -187,12 +192,13 @@ public IActionResult CatalogueWithAuthentication(string reference) /// The tab name to display. /// The nodeId of the current folder. If not supplied, catalogue root contents are displayed. /// The SearchRequestViewModel. + /// The moodleCategoryId. /// IActionResult. [AllowAnonymous] [ServiceFilter(typeof(SsoLoginFilterAttribute))] [HttpGet] [Route("catalogue/{reference}/{tab?}")] - public async Task IndexAsync(string reference, string tab, int? nodeId, SearchRequestViewModel search) + public async Task IndexAsync(string reference, string tab, int? nodeId, SearchRequestViewModel search, int? moodleCategoryId) { if (tab == null || (tab == "search" && !this.User.Identity.IsAuthenticated)) { @@ -206,7 +212,8 @@ public async Task IndexAsync(string reference, string tab, int? n this.ViewBag.ActiveTab = tab; var catalogue = await this.catalogueService.GetCatalogueAsync(reference); - + var catalogueCategoryId = await this.categoryService.GetCatalogueVersionCategoryAsync(catalogue.Id); + catalogue.SelectedCategoryId = catalogueCategoryId; if (catalogue == null) { return this.RedirectToAction("Error", "Home"); @@ -242,31 +249,85 @@ public async Task IndexAsync(string reference, string tab, int? n } } - if (tab == "browse") + if (nodeId.HasValue) + { + // if nodeId has a value it means the user is looking at a subfolder of the catalogue. + // Get the folder name and description, plus folder path data needed for the breadcrumbs. + viewModel.NodeDetails = await this.hierarchyService.GetNodeDetails(nodeId.Value); + viewModel.NodePathNodes = await this.hierarchyService.GetNodePathNodes(viewModel.NodeDetails.NodePathId); + } + else + { + // Otherwise user is looking at catalogue root. + nodeId = catalogue.NodeId; + + viewModel.NodePathNodes = new List + { + new NodeViewModel { Name = catalogue.Name }, + }; + } + + bool includeEmptyFolder = viewModel.UserGroups.Any(x => x.RoleId == (int)RoleEnum.LocalAdmin || x.RoleId == (int)RoleEnum.Editor || x.RoleId == (int)RoleEnum.Previewer) || this.User.IsInRole("Administrator"); + var nodeContents = await this.hierarchyService.GetNodeContentsForCatalogueBrowse(nodeId.Value, includeEmptyFolder); + viewModel.NodeContents = nodeContents; + + int categoryId = moodleCategoryId ?? await this.categoryService.GetCatalogueVersionCategoryAsync(catalogue.Id); + if (categoryId > 0) { - if (nodeId.HasValue) + var response = await this.categoryService.GetCoursesByCategoryIdAsync(categoryId); + viewModel.Courses = response.Courses; + + var subCategories = await this.categoryService.GetSubCategoryByCategoryIdAsync(categoryId); + viewModel.SubCategories = subCategories; + + if (moodleCategoryId.HasValue) { - // if nodeId has a value it means the user is looking at a subfolder of the catalogue. - // Get the folder name and description, plus folder path data needed for the breadcrumbs. - viewModel.NodeDetails = await this.hierarchyService.GetNodeDetails(nodeId.Value); - viewModel.NodePathNodes = await this.hierarchyService.GetNodePathNodes(viewModel.NodeDetails.NodePathId); + var moodleCategories = await this.categoryService.GetAllMoodleCategoriesAsync(); + + // Start with the selected category + var breadcrumbCategory = moodleCategories.FirstOrDefault(x => x.Id == moodleCategoryId); + + List categories = new List(); + categories.Insert(0, new MoodleCategory + { + Id = catalogue.NodeId, + Name = catalogue.Name, + }); + + while (breadcrumbCategory != null) + { + // Add the current category to the breadcrumb list + categories.Insert(1, breadcrumbCategory); + + // If there's no parent, stop + if (breadcrumbCategory.Parent == 0 || breadcrumbCategory.Parent == catalogueCategoryId) + { + break; + } + + // Move up one level + breadcrumbCategory = moodleCategories.FirstOrDefault(x => x.Id == breadcrumbCategory.Parent); + } + + viewModel.MoodleCategories = categories; } else { // Otherwise user is looking at catalogue root. nodeId = catalogue.NodeId; - viewModel.NodePathNodes = new List + viewModel.MoodleCategories = new List { - new NodeViewModel { Name = catalogue.Name }, + new MoodleCategory { Name = catalogue.Name }, }; } - - bool includeEmptyFolder = viewModel.UserGroups.Any(x => x.RoleId == (int)RoleEnum.LocalAdmin || x.RoleId == (int)RoleEnum.Editor || x.RoleId == (int)RoleEnum.Previewer) || this.User.IsInRole("Administrator"); - var nodeContents = await this.hierarchyService.GetNodeContentsForCatalogueBrowse(nodeId.Value, includeEmptyFolder); - viewModel.NodeContents = nodeContents; } - else if (tab == "search") + else + { + viewModel.Catalogue.SelectedCategoryId = 0; + } + + if (tab == "search") { if (viewModel.SearchResults == null) { @@ -299,6 +360,24 @@ public async Task IndexAsync(string reference, string tab, int? n return this.View(viewModel); } + /// + /// GetCourses. + /// + /// The CatalogueNodeVerstionId. + /// The reference. + /// The tab. + /// IActionResult. + [AllowAnonymous] + [ServiceFilter(typeof(SsoLoginFilterAttribute))] + [HttpGet] + [Route("GetCourses/{catalogueNodeVerstionId}/{reference}/{tab}")] + public async Task GetCourses(int catalogueNodeVerstionId, string reference, string tab) + { + var categoryId = await this.categoryService.GetCatalogueVersionCategoryAsync(catalogueNodeVerstionId); + var response = await this.categoryService.GetCoursesByCategoryIdAsync(categoryId); + return this.PartialView("Courses", response.Courses); + } + /// /// Handles sort and filter functionality in Search tab. /// Based on SearchController.IndexPost method. diff --git a/LearningHub.Nhs.WebUI/Helpers/HtmFormatlHelper.cs b/LearningHub.Nhs.WebUI/Helpers/HtmFormatlHelper.cs new file mode 100644 index 000000000..04e8aac9d --- /dev/null +++ b/LearningHub.Nhs.WebUI/Helpers/HtmFormatlHelper.cs @@ -0,0 +1,27 @@ +namespace LearningHub.Nhs.WebUI.Helpers +{ + using HtmlAgilityPack; + + /// + /// HtmFormatlHelper. + /// + public static class HtmFormatlHelper + { + /// + /// StripHtmlTags. + /// + /// html. + /// string. + public static string StripHtmlTags(string html) + { + if (string.IsNullOrEmpty(html)) + { + return string.Empty; + } + + var doc = new HtmlDocument(); + doc.LoadHtml(html); + return doc.DocumentNode.InnerText; + } + } +} diff --git a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs b/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs index 9f60a93dc..762695dd9 100644 --- a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs +++ b/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs @@ -8,6 +8,7 @@ using HtmlAgilityPack; using LearningHub.Nhs.Models.Enums; using LearningHub.Nhs.Models.Hierarchy; + using LearningHub.Nhs.Models.Moodle; using Microsoft.AspNetCore.Mvc.Rendering; /// @@ -496,5 +497,30 @@ public static string GetPillColour(string filename) return breadcrumbs; } + + /// + /// Returns breadcrumb tuple data ready to be passed into the _Breadcrumbs partial view when being used to display a folder path. + /// + /// The list of folder nodes to display. + /// The URL reference of the catalogue. + /// A list of tuples, composed of Title and Url. + public static List<(string Title, string Url)> GetBreadcrumbsForCourses(List moodleCategories, string catalogueUrl) + { + // Create breadcrumb tuple data + var breadcrumbs = new List<(string Title, string Url)> { ("Home", "/") }; + + for (int i = 0; i < moodleCategories.Count; i++) + { + string nodeUrl = $"/catalogue/{catalogueUrl}/courses"; + if (i > 0) + { + nodeUrl += $"?moodleCategoryId={moodleCategories[i].Id}"; + } + + breadcrumbs.Add((moodleCategories[i].Name, nodeUrl)); + } + + return breadcrumbs; + } } } diff --git a/LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs b/LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs index e7770fd86..42f4ecb39 100644 --- a/LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs +++ b/LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using LearningHub.Nhs.Models.Catalogue; + using LearningHub.Nhs.Models.Entities.Hierarchy; using LearningHub.Nhs.Models.Validation; /// diff --git a/LearningHub.Nhs.WebUI/Interfaces/ICategoryService.cs b/LearningHub.Nhs.WebUI/Interfaces/ICategoryService.cs new file mode 100644 index 000000000..37e87d072 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Interfaces/ICategoryService.cs @@ -0,0 +1,43 @@ +namespace LearningHub.Nhs.WebUI.Interfaces +{ + using System.Collections.Generic; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Catalogue; + using LearningHub.Nhs.Models.Entities.Hierarchy; + using LearningHub.Nhs.Models.Moodle; + using LearningHub.Nhs.Models.Moodle.API; + using LearningHub.Nhs.Models.Validation; + + /// + /// Defines the . + /// + public interface ICategoryService + { + /// + /// GetCatalogue version category. + /// + /// catalogueNodeVersionId. + /// A representing the result of the asynchronous operation. + Task GetCatalogueVersionCategoryAsync(int catalogueNodeVersionId); + + /// + /// GetCoursesByCategoryIdAsync. + /// + /// categoryId. + /// A representing the result of the asynchronous operation. + Task GetCoursesByCategoryIdAsync(int categoryId); + + /// + /// GetSubCategoryByCategoryIdAsync. + /// + /// categoryId. + /// A representing the result of the asynchronous operation. + Task> GetSubCategoryByCategoryIdAsync(int categoryId); + + /// + /// GetAllMoodleCategoriesAsync. + /// + /// A representing the result of the asynchronous operation. + Task> GetAllMoodleCategoriesAsync(); + } +} diff --git a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj index ac23486b8..39df64b2a 100644 --- a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj +++ b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj @@ -113,7 +113,7 @@ - + diff --git a/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs b/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs index b9fd30dca..51c66fde4 100644 --- a/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs +++ b/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using LearningHub.Nhs.Models.Catalogue; using LearningHub.Nhs.Models.Hierarchy; + using LearningHub.Nhs.Models.Moodle; + using LearningHub.Nhs.Models.Moodle.API; using LearningHub.Nhs.Models.User; using LearningHub.Nhs.WebUI.Models.Search; @@ -46,5 +48,20 @@ public class CatalogueIndexViewModel /// Gets or sets the search result view model. /// public SearchResultViewModel SearchResults { get; set; } + + /// + /// Gets or sets the courses in the catalogue. + /// + public List Courses { get; set; } + + /// + /// Gets or sets the courses in the catalogue. + /// + public List SubCategories { get; set; } + + /// + /// Gets or sets the moodle categories. + /// + public List MoodleCategories { get; set; } } } diff --git a/LearningHub.Nhs.WebUI/Scripts/vuesrc/catalogue/managecatalogue.vue b/LearningHub.Nhs.WebUI/Scripts/vuesrc/catalogue/managecatalogue.vue index d76b0bef1..e0dd9f406 100644 --- a/LearningHub.Nhs.WebUI/Scripts/vuesrc/catalogue/managecatalogue.vue +++ b/LearningHub.Nhs.WebUI/Scripts/vuesrc/catalogue/managecatalogue.vue @@ -24,7 +24,7 @@

Catalogue Management

-
+

You are managing the following catalogue and can invite users to request access.

diff --git a/LearningHub.Nhs.WebUI/Services/CategoryService.cs b/LearningHub.Nhs.WebUI/Services/CategoryService.cs new file mode 100644 index 000000000..b68a794ca --- /dev/null +++ b/LearningHub.Nhs.WebUI/Services/CategoryService.cs @@ -0,0 +1,156 @@ +namespace LearningHub.Nhs.WebUI.Services +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Text; + using System.Threading.Tasks; + using LearningHub.Nhs.Caching; + using LearningHub.Nhs.Models.Catalogue; + using LearningHub.Nhs.Models.Common; + using LearningHub.Nhs.Models.Entities.Hierarchy; + using LearningHub.Nhs.Models.Moodle; + using LearningHub.Nhs.Models.Moodle.API; + using LearningHub.Nhs.Models.User; + using LearningHub.Nhs.Models.Validation; + using LearningHub.Nhs.WebUI.Interfaces; + using Microsoft.Extensions.Logging; + using Newtonsoft.Json; + + /// + /// The catalogue service. + /// + public class CategoryService : BaseService, ICategoryService + { + private readonly ICacheService cacheService; + + /// + /// Initializes a new instance of the class. + /// + /// The learning hub http client. + /// The Open Api Http Client. + /// The logger. + /// The cacheService. + public CategoryService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, ICacheService cacheService) + : base(learningHubHttpClient, openApiHttpClient, logger) + { + this.cacheService = cacheService; + } + + /// + /// GetCatalogue version category. + /// + /// The catalogueNodeVersionId. + /// A representing the result of the asynchronous operation. + public async Task GetCatalogueVersionCategoryAsync(int catalogueNodeVersionId) + { + var client = await this.OpenApiHttpClient.GetClientAsync(); + + var request = $"category/GetCatalogueVersionCategory/{catalogueNodeVersionId}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + var categoryId = 0; + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + categoryId = Convert.ToInt32(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return categoryId; + } + + /// + /// Get sub categories by category id. + /// + /// The categoryId. + /// A representing the result of the asynchronous operation. + public async Task> GetSubCategoryByCategoryIdAsync(int categoryId) + { + List viewmodel = new List { }; + + var client = await this.OpenApiHttpClient.GetClientAsync(); + + var request = $"category/GetSubCategoryByCategoryId/{categoryId}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject>(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + + /// + /// Get courses by category id. + /// + /// The categoryId. + /// A representing the result of the asynchronous operation. + public async Task GetCoursesByCategoryIdAsync(int categoryId) + { + MoodleCoursesResponseModel viewmodel = new MoodleCoursesResponseModel { }; + + var client = await this.OpenApiHttpClient.GetClientAsync(); + + var request = $"category/GetCoursesByCategoryId/{categoryId}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + + /// + /// GetAllMoodleCategoriesAsync. + /// + /// A representing the result of the asynchronous operation. + public async Task> GetAllMoodleCategoriesAsync() + { + List viewmodel = new List(); + + try + { + var client = await this.OpenApiHttpClient.GetClientAsync(); + + var request = $"Moodle/GetAllMoodleCategories"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject>(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + catch (Exception ex) + { + return viewmodel; + } + } + } +} diff --git a/LearningHub.Nhs.WebUI/Services/UserService.cs b/LearningHub.Nhs.WebUI/Services/UserService.cs index e0e4261f5..467a82a04 100644 --- a/LearningHub.Nhs.WebUI/Services/UserService.cs +++ b/LearningHub.Nhs.WebUI/Services/UserService.cs @@ -97,7 +97,7 @@ public async Task> GetActiveContentAsync() { List viewmodel = null; - var client = await this.OpenApiHttpClient.GetClientAsync(); + var client = await this.LearningHubHttpClient.GetClientAsync(); var request = "User/GetActiveContent"; var response = await client.GetAsync(request).ConfigureAwait(false); diff --git a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs index 9fd65bd60..6ed258354 100644 --- a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs +++ b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs @@ -82,6 +82,7 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/Courses.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/Courses.cshtml new file mode 100644 index 000000000..f8c67dc63 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Views/Catalogue/Courses.cshtml @@ -0,0 +1,43 @@ +@using LearningHub.Nhs.Models.Enums; +@using LearningHub.Nhs.Models.Moodle; +@using LearningHub.Nhs.Models.Moodle.API +@using LearningHub.Nhs.WebUI.Models.Catalogue; +@using LearningHub.Nhs.WebUI.Helpers; +@model CatalogueIndexViewModel; +@inject LearningHub.Nhs.WebUI.Interfaces.IMoodleApiService moodleApiService; +@{ + string GetMoodleCourseUrl(int courseId) + { + return moodleApiService.GetCourseUrl(courseId); + } +} +
+
+
+

Courses

+ @foreach (MoodleSubCategoryResponseModel item in Model.SubCategories) + { + +
+ } + @foreach (Course item in Model.Courses) + { +
+

@item.Displayname

+
+
Type: Course
+
+ @HtmFormatlHelper.StripHtmlTags(item.Summary) +
+
+
+
+ } +
+
+
diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml index 03ef6c173..1384acfb9 100644 --- a/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml +++ b/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml @@ -5,6 +5,7 @@ @using LearningHub.Nhs.Models.Enums; @using Microsoft.AspNetCore.Mvc.Routing; @model CatalogueIndexViewModel; + @{ ViewData["Title"] = "Catalogue"; @@ -19,73 +20,90 @@ return IsInRole(RoleEnum.LocalAdmin) || IsInRole(RoleEnum.Editor) || IsInRole(RoleEnum.Reader) || this.User.IsInRole("Administrator"); } - bool IsInRole(RoleEnum role) - { - return Model.UserGroups.Any(x => x.RoleId == (int)role); - } + bool IsInRole(RoleEnum role) + { + return Model.UserGroups.Any(x => x.RoleId == (int)role); + } + + string GetBannerUrl() + { + if (!string.IsNullOrEmpty(Model.Catalogue.BannerUrl)) + { + return GetFileLink(Model.Catalogue.BannerUrl); + } + return string.Empty; + } + + string GetFileLink(string fileName) + { + return "/api/catalogue/download-image/" + Uri.EscapeDataString(fileName); + } - string GetBannerUrl() - { - if (!string.IsNullOrEmpty(Model.Catalogue.BannerUrl)) + string GetActiveTabName() { - return GetFileLink(Model.Catalogue.BannerUrl); + switch (ViewBag.ActiveTab) + { + case "courses": + return "Courses"; + case "about": + return "About"; + case "search": + return "Search catalogue"; + case "browse": + default: + return "Resources"; + } } - return string.Empty; - } - string GetFileLink(string fileName) - { - return "/api/catalogue/download-image/" + Uri.EscapeDataString(fileName); - } + if (ViewBag.ActiveTab == "courses") + { + if (Model.Catalogue.SelectedCategoryId == 0 || + (Model.Catalogue.SelectedCategoryId > 0 && + (Model.Courses == null || !Model.Courses.Any()) && + (Model.SubCategories == null || !Model.SubCategories.Any()))) + { + ViewBag.ActiveTab = "browse"; + } + } - string GetActiveTabName() - { - switch (ViewBag.ActiveTab) + List<(string Title, string Url)> breadcrumbs; + if (ViewBag.ActiveTab == "browse") + { + breadcrumbs = UtilityHelper.GetBreadcrumbsForFolderNodes(Model.NodePathNodes.SkipLast(1).ToList(), Model.Catalogue.Url); + } + else if (ViewBag.ActiveTab == "courses" && Model.Catalogue.SelectedCategoryId > 0) + { + breadcrumbs = UtilityHelper.GetBreadcrumbsForCourses(Model.MoodleCategories, Model.Catalogue.Url); + } + else { - case "about": - return "About"; - case "search": - return "Search catalogue"; - case "browse": - default: - return "Browse"; + breadcrumbs = new List<(string Title, string Url)> { ("Home", "/") }; } - } - - List<(string Title, string Url)> breadcrumbs; - if (ViewBag.ActiveTab == "browse") - { - breadcrumbs = UtilityHelper.GetBreadcrumbsForFolderNodes(Model.NodePathNodes.SkipLast(1).ToList(), Model.Catalogue.Url); - } - else - { - breadcrumbs = new List<(string Title, string Url)> { ("Home", "/") }; - } - - var restrictedAccessVm = new RestrictedAccessBannerViewModel - { - TitleText = "Access to this catalogue is restricted", - BodyText = "This catalogue has been restricted to a limited group of users. You can request access from the catalogue administrator.", - CatalogueNodeVersionId = Model.Catalogue.Id, - RestrictedAccess = Model.Catalogue.RestrictedAccess, - HasCatalogueAccess = Unlocked(), - CatalogueAccessRequest = Model.CatalogueAccessRequest, - UserGroups = Model.UserGroups - }; - - var provider = Model.Catalogue.Providers?.FirstOrDefault(); - var hasBadge = !string.IsNullOrWhiteSpace(Model.Catalogue.BadgeUrl); + + var restrictedAccessVm = new RestrictedAccessBannerViewModel + { + TitleText = "Access to this catalogue is restricted", + BodyText = "This catalogue has been restricted to a limited group of users. You can request access from the catalogue administrator.", + CatalogueNodeVersionId = Model.Catalogue.Id, + RestrictedAccess = Model.Catalogue.RestrictedAccess, + HasCatalogueAccess = Unlocked(), + CatalogueAccessRequest = Model.CatalogueAccessRequest, + UserGroups = Model.UserGroups + }; + + var provider = Model.Catalogue.Providers?.FirstOrDefault(); + var hasBadge = !string.IsNullOrWhiteSpace(Model.Catalogue.BadgeUrl); } -@section styles{ +@section styles { }
- - + + @* Admin banner *@ @if (CanManage()) @@ -98,68 +116,75 @@
} -
+
- @* Catalogue header *@ -
- - @if (Model.Catalogue.Hidden) - { -
-
-
Catalogue preview
-
-
- } - @if (ViewBag.ActiveTab == "browse" && Model.NodeDetails != null) - { - @Model.Catalogue.Name - } - -
- @if (provider != null) - { - @provider.Name catalogue badge - } - else if (hasBadge) - { - Provider's catalogue badgeTest - } + @* Catalogue header *@ +
+ + @if (Model.Catalogue.Hidden) + { +
+
+
Catalogue preview
+
+
+ } + @if (ViewBag.ActiveTab == "browse" && Model.NodeDetails != null) + { + @Model.Catalogue.Name + } -

@(ViewBag.ActiveTab == "browse" && Model.NodeDetails != null ? Model.NodeDetails.Name : Model.Catalogue.Name)

-
- - @if (ViewBag.UserAuthenticated && Model.Catalogue.RestrictedAccess && Unlocked()) - { -

Access granted you have been granted access to view resources in this catalogue

- } - - @if (ViewBag.UserAuthenticated) - { - - } +
+ @if (provider != null) + { + @provider.Name catalogue badge + } + else if (hasBadge) + { + Provider's catalogue badgeTest + } - @if (!string.IsNullOrEmpty(Model.Catalogue.BannerUrl) && Model.NodeDetails == null) - { - banner image - } +

@(ViewBag.ActiveTab == "browse" && Model.NodeDetails != null ? Model.NodeDetails.Name : Model.Catalogue.Name)

+
+ + @if (ViewBag.UserAuthenticated && Model.Catalogue.RestrictedAccess && Unlocked()) + { +

Access granted you have been granted access to view resources in this catalogue

+ } + + @if (ViewBag.UserAuthenticated) + { + + } - @if (Model.NodeDetails != null && !string.IsNullOrEmpty(Model.NodeDetails.Description)) - { -
- @Html.Raw(Model.NodeDetails.Description) + @if (!string.IsNullOrEmpty(Model.Catalogue.BannerUrl) && Model.NodeDetails == null) + { + banner image + } + + @if (Model.NodeDetails != null && !string.IsNullOrEmpty(Model.NodeDetails.Description)) + { +
+ @Html.Raw(Model.NodeDetails.Description) +
+ } + + @if (Model.MoodleCategories != null) + { +
+ @Html.Raw(Model.MoodleCategories.Last().Description) +
+ }
- } -
@* Tab header *@
} + else if (ViewBag.ActiveTab == "courses") + { +
+ +
+ } else if (ViewBag.ActiveTab == "about") {
diff --git a/LearningHub.Nhs.WebUI/Views/Policies/AcceptableUsePolicy.cshtml b/LearningHub.Nhs.WebUI/Views/Policies/AcceptableUsePolicy.cshtml index 57f026a98..1b37e2979 100644 --- a/LearningHub.Nhs.WebUI/Views/Policies/AcceptableUsePolicy.cshtml +++ b/LearningHub.Nhs.WebUI/Views/Policies/AcceptableUsePolicy.cshtml @@ -1,128 +1,138 @@ @inject Microsoft.Extensions.Options.IOptions options @{ - ViewData["Title"] = "Acceptable Use Policy"; + ViewData["Title"] = "Acceptable Use Policy"; } -@section styles{ +@section styles { }
-
-

ACCEPTABLE USE POLICY

-
-
-
-

1 General

-

1.1 This Acceptable Use Policy sets out how we permit you to use any of our Platforms. Your compliance with this Acceptable Use Policy is a condition of your use of the Platform.

-

1.2 Capitalised terms have the meaning given to them in the terms of use for the Platform which are available at https://learninghub.nhs.uk/policies/terms-and-conditions.

-

2 Acceptable use

-

2.1 You are permitted to use the Platform as set out in the Terms and for the purpose of personal study.

-

2.2 You must not use any part of the Content on the Platform for commercial purposes without obtaining a licence to do so from us or our licensors.

-

2.3 If you print off, copy, download, share or repost any part of the Platform in breach of this Acceptable Use Policy, your right to use the Platform will cease immediately and you must, at our option, return or destroy any copies of the materials you have made.

-

2.4 Our status (and that of any identified contributors) as the authors of Content on the Platform must always be acknowledged (except in respect of Third-Party Content).

-

3 Prohibited uses

-

3.1 You may not use the Platform:

-

3.1.1 in any way that breaches any applicable local, national or international law or regulation;

-

3.1.2 in any way that is unlawful or fraudulent or has any unlawful or fraudulent purpose or effect;

-

3.1.3 in any way that infringes the rights of, or restricts or inhibits the use and enjoyment of this site by any third party;

-

3.1.4 for the purpose of harming or attempting to harm minors in any way;

-

3.1.5 to bully, insult, intimidate or humiliate any person;

-

3.1.6 to send, knowingly receive, upload, download, use or re-use any material which does not comply with our Content Standards as set out in paragraph 4;

-

3.1.7 to transmit, or procure the sending of, any unsolicited or unauthorised advertising or promotional material or any other form of similar solicitation (spam), or any unwanted or repetitive content that may cause disruption to the Platform or diminish the user experience, of the Platform’s usefulness or relevant to others;

-

3.1.8 to do any act or thing with the intention of disrupting the Platform in any way, including uploading any malware or links to malware, or introduce any virus, trojan, worm, logic bomb or other material that is malicious or technologically harmful or other potentially damaging items into the Platform;

-

3.1.9 to knowingly transmit any data, send or upload any material that contains viruses, Trojan horses, worms, time-bombs, keystroke loggers, spyware, adware or any other harmful programs or similar computer code designed to adversely affect the operation of any computer software or hardware; or

-

3.1.10 to upload terrorist content.

-

3.2 You also agree:

-

3.2.1 to follow any reasonable instructions given to you by us in connection with your use of the Platform;

-

3.2.2 to respect the rights and dignity of others, in order to maintain the ethos and good reputation of the NHS, the public good generally and the spirit of cooperation between those studying and working within the health and care sector. In particular, you must act in a professional manner with regard to all other users of the Platform at all times;

-

3.2.3 not to modify or attempt to modify any of the Content, save:

-

3.2.3.1 in respect of Contributions;

-

3.2.3.2 where you are the editor of a catalogue within the Learning Hub, you may alter Content within that catalogue;

-

3.2.4 not to download or copy any of the Content to electronic or photographic media;

-

3.2.5 not to reproduce any part of the Content by any means or under any format other than as a reasonable aid to your personal study;

-

3.2.6 not to reproduce, duplicate, copy or re-sell any Content in contravention of the provisions of this Acceptable Use Policy; and

-

3.2.7 not to use tools that automatically perform actions on your behalf;

-

3.2.8 not to upload any content that infringes the intellectual property rights, privacy rights or any other rights of any person or organisation; and

-

3.2.9 not to attempt to disguise your identity or that of your organisation;

-

3.2.10 not to access without authority, interfere with, damage or disrupt:

-

3.2.10.1 any part of the Platform;

-

3.2.10.2 any equipment or network on which the Platform is stored;

-

3.2.10.3 any software used in the provision of the Platform;

-

3.2.10.4 the server on which the Platform is stored;

-

3.2.10.5 any computer or database connected to the Platform; or

-

3.2.10.6 any equipment or network or software owned or used by any third party.

-

3.2.11 not to attack the Platform via a denial-of-service attack or a distributed denial-of-service attack.

-

4 Content standards

-

4.1 The content standards set out in this paragraph 4 (Content Standards) apply to any and all Contributions.

-

4.2 The Content Standards must be complied with in spirit as well as to the letter. The Content Standards apply to each part of any Contribution as well as to its whole.

-

4.3 We will determine, in our discretion, whether a Contribution breaches the Content Standards.

-

4.4 A Contribution must:

-

4.4.1 be accurate (where it states facts);

-

4.4.2 be genuinely held (where it states opinions); and

-

4.4.3 comply with the law applicable in England and Wales and in any country from which it is posted.

-

4.5 A Contribution must not:

-

4.5.1 contain misinformation that is likely to harm users, patients/service users, health and care workers, or the general public’s wellbeing, safety, trust and reputation, including the reputation of the NHS or any part of it. This could include false and misleading information relating to disease prevention and treatment, conspiracy theories, content that encourages discrimination, harassment or physical violence, content originating from misinformation campaigns, and content edited or manipulated in such a way as to constitute misinformation;

-

4.5.2 contain any content or link to any content:

-

4.5.2.1 which is created for advertising, promotional or other commercial purposes, including links, logos and business names;

-

4.5.2.2 which requires a subscription or payment to gain access to such content;

-

4.5.2.3 in which the user has a commercial interest;

-

4.5.2.4 which promotes a business name and/or logo;

-

4.5.2.5 which contains a link to an app via iOS or Google Play; or

-

4.5.2.6 which has as its purpose or effect the collection and sharing of personal data;

-

4.5.3 be irrelevant to the purpose or aims of the Platform or while addressing relevant subject matter, contain an irrelevant, unsuitable or inappropriate slant (for example relating to potentially controversial opinions or beliefs of any kind intended to influence others);

-

4.5.4 be defamatory of any person;

-

4.5.5 be obscene, offensive, hateful or inflammatory, or contain any profanity;

-

4.5.6 bully, insult, intimidate or humiliate;

-

4.5.7 encourage suicide, substance abuse, eating disorders or other acts of self-harm. Content related to self-harm for the purposes of therapy, education and the promotion of general wellbeing may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

-

4.5.8 feature sexual imagery purely intended to stimulate sexual arousal. Non-pornographic content relating to sexual health and related issues, surgical procedures and the results of surgical procedures, breastfeeding, therapy, education and the promotion of general wellbeing may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

-

4.5.9 include child sexual abuse material. Content relating to safeguarding which addresses the subject of child sexual abuse may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

-

4.5.10 incite or glorify violence including content designed principally for the purposes of causing reactions of shock or disgust;

-

4.5.11 promote discrimination or discriminate in respect of the protected characteristics set out in the Equality Act 2010, being age, disability, gender reassignment, marriage and civil partnership, pregnancy and maternity, race, nationality, religion or belief, sex, and sexual orientation;

-

4.5.12 infringe any copyright, database right or trade mark of any other person;

-

4.5.13 be likely to deceive any person;

-

4.5.14 breach any legal duty owed to a third party, such as a contractual duty or a duty of confidence;

-

4.5.15 promote any illegal content or activity, including but not limited to the encouragement, promotion, justification, praise or provision of aid to dangerous persons or organisations, including extremists, terrorists and terrorist organisations and those engaged in any form of criminal activity;

-

4.5.16 be in contempt of court;

-

4.5.17 be threatening, abuse or invade another's privacy, or cause annoyance, inconvenience or needless anxiety;

-

4.5.18 be likely to harass, bully, shame, degrade, upset, embarrass, alarm or annoy any other person;

-

4.5.19 impersonate any person or misrepresent your identity or affiliation with any person;

-

4.5.20 advocate, promote, incite any party to commit, or assist any unlawful or criminal act such as (by way of example only) copyright infringement or computer misuse;

-

4.5.21 contain a statement which you know or believe, or have reasonable grounds for believing, that members of the public to whom the statement is, or is to be, published are likely to understand as a direct or indirect encouragement or other inducement to the commission, preparation or instigation of acts of terrorism;

-

4.5.22 contain harmful material;

-

4.5.23 give the impression that the Contribution emanates from us, if this is not the case; or

-

4.5.24 disclose any third party’s confidential information, identity, personally identifiable information or personal data (including data concerning health).

-

4.6 You acknowledge and accept that, when using the Platform and accessing the Content, some Content that has been uploaded by third parties may be factually inaccurate, or the topics addressed by the Content may be offensive, indecent, or objectionable in nature. We are not responsible (legally or otherwise) for any claim you may have in relation to the Content.

-

4.7 When producing Content to upload to the Platform, we encourage you to implement NICE guideline recommendations and ensure that sources of evidence are valid (for example, by peer review).

-

5 Metadata

-

When making any Contribution, you must where prompted include a sufficient description of the Content so that other users can understand the description, source, and age of the Content. For example, if Content has been quality assured, then the relevant information should be posted in the appropriate field. All metadata fields on the Platform must be completed appropriately before initiating upload. Including the correct information is important in order to help other users locate the Content (otherwise the Content may not appear in search results for others to select).

-

6 Updates

-

You must update each Contribution at least once every 3 (three) years, or update or remove it should it cease to be relevant or become outdated or revealed or generally perceived to be unsafe or otherwise unsuitable for inclusion on the Platform.

-

7 Accessibility

-

Where practicable, all Contributions should aim to meet the accessibility standards as described in our Accessibility Statement - https://learninghub.nhs.uk/Home/Accessibility and as set out in the AA Standard Web Content Accessibility Guidelines v2.1 found here: - https://www.w3.org/TR/WCAG21/.

-

8 Rules about linking to the Platform

-

8.1 The Platform must not be framed on any other site.

-

8.2 You may directly link to any Content that is hosted on the Platform, however, please be aware that not all links will continue to be available indefinitely. We will use our best efforts to ensure that all links are valid at the time of creating the related Content but cannot be held responsible for any subsequent changes to the link address or related Content.

-

9 No text or data mining, or web scraping

-

9.1 You shall not conduct, facilitate, authorize or permit any text or data mining or web scraping in relation to the Platform or any services provided via, or in relation to, the Platform. This includes using (or permitting, authorizing or attempting the use of):

-

9.1.1 any "robot", "bot", "spider", "scraper" or other automated device, program, tool, algorithm, code, process or methodology to access, obtain, copy, monitor or republish any portion of the Platform or any data, Content, information or services accessed via the same; and/or

-

9.1.2 any automated analytical technique aimed at analyzing text and data in digital form to generate information which includes but is not limited to patterns, trends, and correlations.

-

9.2 The provisions in this paragraph should be treated as an express reservation of our rights in this regard, including for the purposes of Article 4(3) of Digital Copyright Directive ((EU) 2019/790).

-

9.3 This paragraph shall not apply insofar as (but only to the extent that) we are unable to exclude or limit text or data mining or web scraping activity by contract under the laws which are applicable to us.

-

10 Breach of this Acceptable Use Policy

-

Failure to comply with this Acceptable Use Policy constitutes a material breach of this Acceptable Use Policy upon which you are permitted to use the Platform and may result in our taking all or any of the following actions:

-

10.1 immediate, temporary, or permanent withdrawal of your right to use the Platform;

-

10.2 immediate, temporary, or permanent removal of any Contribution uploaded by you to the Platform;

-

10.3 issue of a warning to you;

-

10.4 legal proceedings against you for reimbursement of all costs on an indemnity basis (including, but not limited to, reasonable administrative and legal costs) resulting from the breach, and/or further legal action against you;

-

10.5 disclosure of such information to law enforcement authorities as we reasonably feel is necessary or as required by law; and/or

-

10.6 any other action we reasonably deem appropriate.

-
-
-
- @await Html.PartialAsync("~/Views/Shared/_PageReviewPartial.cshtml", new PageReviewModel { LastReviewedDate = new DateTime(2023, 6, 01), NextReviewDate = new DateTime(2026, 8, 16) }) -
+
+

ACCEPTABLE USE POLICY

+
+
+
+

1 General

+

1.1 This Acceptable Use Policy sets out how we permit you to use any of our Platforms. Your compliance with this Acceptable Use Policy is a condition of your use of the Platform.

+

1.2 Unless otherwise defined within this Acceptable Use Policy, capitalised terms have the meaning given to them in the terms of use for the Platform which are available at https://learninghub.nhs.uk/policies/terms-and-conditions.

+

2 Acceptable use

+

2.1 You are permitted to use the Platform as set out in the Terms and for the purpose of personal study.

+

2.2 You must not use any part of the Content on the Platform for commercial purposes without obtaining a licence to do so from us or our licensors.

+

2.3 If you print off, copy, download, share or repost any part of the Platform in breach of this Acceptable Use Policy, your right to use the Platform will cease immediately and you must, at our option, return or destroy any copies of the materials you have made.

+

2.4 Our status (and that of any identified contributors) as the authors of Content on the Platform must always be acknowledged (except in respect of Third-Party Content).

+

3 Prohibited uses

+

3.1 You may not use the Platform:

+

3.1.1 in any way that breaches any applicable local, national or international law or regulation;

+

3.1.2 in any way that is unlawful or fraudulent or has any unlawful or fraudulent purpose or effect;

+

3.1.3 in any way that infringes the rights of, or restricts or inhibits the use and enjoyment of this site by any third party;

+

3.1.4 for the purpose of harming or attempting to harm minors in any way;

+

3.1.5 to bully, insult, intimidate or humiliate any person;

+

3.1.6 to send, knowingly receive, upload, download, use or re-use any material which does not comply with our Content Standards as set out in paragraph 4;

+

3.1.7 to transmit, or procure the sending of, any unsolicited or unauthorised advertising or promotional material or any other form of similar solicitation (spam), or any unwanted or repetitive content that may cause disruption to the Platform or diminish the user experience, of the Platform’s usefulness or relevant to others;

+

3.1.8 to do any act or thing with the intention of disrupting the Platform in any way, including uploading any malware or links to malware, or introduce any virus, trojan, worm, logic bomb or other material that is malicious or technologically harmful or other potentially damaging items into the Platform;

+

3.1.9 to knowingly transmit any data, send or upload any material that contains viruses, Trojan horses, worms, time-bombs, keystroke loggers, spyware, adware or any other harmful programs or similar computer code designed to adversely affect the operation of any computer software or hardware; or

+

3.1.10 to upload terrorist content.

+

3.2 You also agree:

+

3.2.1 to follow any reasonable instructions given to you by us in connection with your use of the Platform;

+

3.2.2 to respect the rights and dignity of others, in order to maintain the ethos and good reputation of the NHS, the public good generally and the spirit of cooperation between those studying and working within the health and care sector. In particular, you must act in a professional manner with regard to all other users of the Platform at all times;

+

3.2.3 not to modify or attempt to modify any of the Content, save:

+

3.2.3.1 in respect of Contributions;

+

3.2.3.2 where you are the editor of a catalogue within the Learning Hub, you may alter Content within that catalogue;

+

3.2.4 not to download or copy any of the Content to electronic or photographic media;

+

3.2.5 not to reproduce any part of the Content by any means or under any format other than as a reasonable aid to your personal study;

+

3.2.6 not to reproduce, duplicate, copy or re-sell any Content in contravention of the provisions of this Acceptable Use Policy; and

+

3.2.7 not to use tools that automatically perform actions on your behalf;

+

3.2.8 not to upload any content that infringes the intellectual property rights, privacy rights or any other rights of any person or organisation; and

+

3.2.9 not to attempt to disguise your identity or that of your organisation;

+

3.2.10 not to access without authority, interfere with, damage or disrupt:

+

3.2.10.1 any part of the Platform;

+

3.2.10.2 any equipment or network on which the Platform is stored;

+

3.2.10.3 any software used in the provision of the Platform;

+

3.2.10.4 the server on which the Platform is stored;

+

3.2.10.5 any computer or database connected to the Platform; or

+

3.2.10.6 any equipment or network or software owned or used by any third party.

+

3.2.11 not to attack the Platform via a denial-of-service attack or a distributed denial-of-service attack.

+

4 Content standards

+

4.1 The content standards set out in this paragraph 4 (Content Standards) apply to any and all Contributions.

+

4.2 The Content Standards must be complied with in spirit as well as to the letter. The Content Standards apply to each part of any Contribution as well as to its whole.

+

4.3 We will determine, in our discretion, whether a Contribution breaches the Content Standards.

+

4.4 A Contribution must:

+

4.4.1 be accurate (where it states facts);

+

4.4.2 be genuinely held (where it states opinions); and

+

4.4.3 comply with the law applicable in England and Wales and in any country from which it is posted.

+

4.5 A Contribution must not:

+

4.5.1 contain misinformation that is likely to harm users, patients/service users, health and care workers, or the general public’s wellbeing, safety, trust and reputation, including the reputation of the NHS or any part of it. This could include false and misleading information relating to disease prevention and treatment, conspiracy theories, content that encourages discrimination, harassment or physical violence, content originating from misinformation campaigns, and content edited or manipulated in such a way as to constitute misinformation;

+

4.5.2 contain any content or link to any content:

+

4.5.2.1 which is created for advertising, promotional or other commercial purposes, including links, logos and business names;

+

4.5.2.2 which requires a subscription or payment to gain access to such content;

+

4.5.2.3 in which the user has a commercial interest;

+

4.5.2.4 which promotes a business name and/or logo;

+

4.5.2.5 which contains a link to an app via iOS or Google Play; or

+

4.5.2.6 which has as its purpose or effect the collection and sharing of personal data;

+

4.5.3 be irrelevant to the purpose or aims of the Platform or while addressing relevant subject matter, contain an irrelevant, unsuitable or inappropriate slant (for example relating to potentially controversial opinions or beliefs of any kind intended to influence others);

+

4.5.4 be defamatory of any person;

+

4.5.5 be obscene, offensive, hateful or inflammatory, or contain any profanity;

+

4.5.6 bully, insult, intimidate or humiliate;

+

4.5.7 encourage suicide, substance abuse, eating disorders or other acts of self-harm. Content related to self-harm for the purposes of therapy, education and the promotion of general wellbeing may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

+

4.5.8 feature sexual imagery purely intended to stimulate sexual arousal. Non-pornographic content relating to sexual health and related issues, surgical procedures and the results of surgical procedures, breastfeeding, therapy, education and the promotion of general wellbeing may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

+

4.5.9 include child sexual abuse material. Content relating to safeguarding which addresses the subject of child sexual abuse may be uploaded, but we reserve the right to make changes to the way in which it is accessed in order that users do not view it accidentally;

+

4.5.10 incite or glorify violence including content designed principally for the purposes of causing reactions of shock or disgust;

+

4.5.11 promote discrimination or discriminate in respect of the protected characteristics set out in the Equality Act 2010, being age, disability, gender reassignment, marriage and civil partnership, pregnancy and maternity, race, nationality, religion or belief, sex, and sexual orientation;

+

4.5.12 infringe any copyright, database right or trade mark of any other person;

+

4.5.13 be likely to deceive any person;

+

4.5.14 breach any legal duty owed to a third party, such as a contractual duty or a duty of confidence;

+

4.5.15 promote any illegal content or activity, including but not limited to the encouragement, promotion, justification, praise or provision of aid to dangerous persons or organisations, including extremists, terrorists and terrorist organisations and those engaged in any form of criminal activity;

+

4.5.16 be in contempt of court;

+

4.5.17 be threatening, abuse or invade another's privacy, or cause annoyance, inconvenience or needless anxiety;

+

4.5.18 be likely to harass, bully, shame, degrade, upset, embarrass, alarm or annoy any other person;

+

4.5.19 impersonate any person or misrepresent your identity or affiliation with any person;

+

4.5.20 advocate, promote, incite any party to commit, or assist any unlawful or criminal act such as (by way of example only) copyright infringement or computer misuse;

+

4.5.21 contain a statement which you know or believe, or have reasonable grounds for believing, that members of the public to whom the statement is, or is to be, published are likely to understand as a direct or indirect encouragement or other inducement to the commission, preparation or instigation of acts of terrorism;

+

4.5.22 contain harmful material;

+

4.5.23 give the impression that the Contribution emanates from us, if this is not the case; or

+

4.5.24 disclose any third party’s confidential information, identity, personally identifiable information or personal data (including data concerning health).

+

4.6 You acknowledge and accept that, when using the Platform and accessing the Content, some Content that has been uploaded by third parties may be factually inaccurate, or the topics addressed by the Content may be offensive, indecent, or objectionable in nature. We are not responsible (legally or otherwise) for any claim you may have in relation to the Content.

+

4.7 When producing Content to upload to the Platform, we encourage you to implement NICE guideline recommendations and ensure that sources of evidence are valid (for example, by peer review).

+

5 Metadata

+

When making any Contribution, you must where prompted include a sufficient description of the Content so that other users can understand the description, source, and age of the Content. For example, if Content has been quality assured, then the relevant information should be posted in the appropriate field. All metadata fields on the Platform must be completed appropriately before initiating upload. Including the correct information is important in order to help other users locate the Content (otherwise the Content may not appear in search results for others to select).

+

6 Updates

+

You must update each Contribution at least once every 3 (three) years, or update or remove it should it cease to be relevant or become outdated or revealed or generally perceived to be unsafe or otherwise unsuitable for inclusion on the Platform.

+

7 Accessibility

+

+ Where practicable, all Contributions should aim to meet the accessibility standards as described in our Accessibility Statement + https://learninghub.nhs.uk/Home/Accessibility and as set out in the AA Standard Web Content Accessibility Guidelines v2.1 found here: + https://www.w3.org/TR/WCAG21/. +

+

8 Rules about linking to the Platform

+

8.1 The Platform must not be framed on any other site.

+

8.2 You may directly link to any Content that is hosted on the Platform, however, please be aware that not all links will continue to be available indefinitely. We will use our best efforts to ensure that all links are valid at the time of creating the related Content but cannot be held responsible for any subsequent changes to the link address or related Content.

+

9 No text or data mining, or web scraping

+

9.1 You shall not conduct, facilitate, authorize or permit any text or data mining or web scraping in relation to the Platform or any services provided via, or in relation to, the Platform. This includes using (or permitting, authorizing or attempting the use of):

+

9.1.1 any "robot", "bot", "spider", "scraper" or other automated device, program, tool, algorithm, code, process or methodology to access, obtain, copy, monitor or republish any portion of the Platform or any data, Content, information or services accessed via the same; and/or

+

9.1.2 any automated analytical technique aimed at analyzing text and data in digital form to generate information which includes but is not limited to patterns, trends, and correlations.

+

9.2 The provisions in this paragraph should be treated as an express reservation of our rights in this regard, including for the purposes of Article 4(3) of Digital Copyright Directive ((EU) 2019/790).

+

9.3 This paragraph shall not apply insofar as (but only to the extent that) we are unable to exclude or limit text or data mining or web scraping activity by contract under the laws which are applicable to us.

+

10 Breach of this Acceptable Use Policy

+

Failure to comply with this Acceptable Use Policy constitutes a material breach of this Acceptable Use Policy upon which you are permitted to use the Platform and may result in our taking all or any of the following actions:

+

10.1 immediate, temporary, or permanent withdrawal of your right to use the Platform;

+

10.2 immediate, temporary, or permanent removal of any Contribution uploaded by you to the Platform;

+

10.3 issue of a warning to you;

+

10.4 legal proceedings against you for reimbursement of all costs on an indemnity basis (including, but not limited to, reasonable administrative and legal costs) resulting from the breach, and/or further legal action against you;

+

10.5 disclosure of such information to law enforcement authorities as we reasonably feel is necessary or as required by law; and/or

+

10.6 any other action we reasonably deem appropriate.

+

Moderation of Contributions

+

11.1 Course Manager means a person authorised by NHS England who is responsible for creating and managing courses and learning resources on the Learning Hub, including the moderation of learner's Contributions within social learning environments of an online course, such as discussion forums.

+

11.2 Course Managers shall be responsible for monitoring local forum activity and ensuring compliance of all Contributions with the Learning Hub’s Acceptable Use Policy. Inappropriate Contributions shall be addressed promptly and escalated where necessary to the Learning Hub, who will review the user’s access to the Platform and the relevant forum.

+

11.3 Course Managers shall also take responsibility for the following:

+

11.3.1 Clear Expectations: Set clear local forum rules within their course at the outset, compliantly with this Acceptable Use Policy, which includes expected behaviour, response times and moderation practices.

+

11.3.2 Inclusive Practice: Encourage participation from all learners/users and foster a respectful, inclusive environment that values diverse perspectives. This should involve reminding local forum users of the appropriate measures of this Acceptable Use Policy and potentially removing Contributions that infringe the rules of this Acceptable Use Policy including under paragraph 4.5 above.

+

11.3.3 Data Protection and Safety: Ensure that no sensitive or personal data i shared, requested or stored in local forums, including by promptly removing any inclusions or requests for such material and notifying NHS England promptly of any potential breaches by contacting NHS England’s Data Protection Officer team via england.dpo@nhs.net; and ensure that risks are actively managed and the local forums are maintained as a safe space for discussion.

+

11.4 All users must comply with this Acceptable Use Policy. Breaches may result in removal of Contributions and/or withdrawal or suspension of user access without notice.

+
+
+
+ @await Html.PartialAsync("~/Views/Shared/_PageReviewPartial.cshtml", new PageReviewModel { LastReviewedDate = new DateTime(2023, 6, 01), NextReviewDate = new DateTime(2026, 8, 16) }) +
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj index 50649cdb0..cecf1b22a 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj @@ -16,7 +16,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj index 2cd1e262f..a52fd6bf1 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj @@ -17,7 +17,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/Hierarchy/ICatalogueNodeVersionRepository.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/Hierarchy/ICatalogueNodeVersionRepository.cs index 846b83bdc..6e1dab9ce 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/Hierarchy/ICatalogueNodeVersionRepository.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/Hierarchy/ICatalogueNodeVersionRepository.cs @@ -55,6 +55,22 @@ public interface ICatalogueNodeVersionRepository : IGenericRepositoryThe task. Task UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel vm); + /// + /// The AddCategoryToCatalogueAsync. + /// + /// The userId. + /// The viewmodel. + /// + Task AddCategoryToCatalogueAsync(int userId, CatalogueViewModel vm); + + /// + /// The RemoveCategoryFromCatalogueAsync. + /// + /// The userId. + /// The viewmodel. + /// + Task RemoveCategoryFromCatalogueAsync(int userId, CatalogueViewModel vm); + /// /// The CreateCatalogueAsync. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/ICategoryRepository.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/ICategoryRepository.cs new file mode 100644 index 000000000..f10e6132c --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/ICategoryRepository.cs @@ -0,0 +1,20 @@ +namespace LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories +{ + using System.Linq; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Entities; + using LearningHub.Nhs.Models.Entities.Hierarchy; + + /// + /// The ProviderRepository interface. + /// + public interface ICategoryRepository + { + /// + /// The get by node version id async. + /// + /// The node version id. + /// The . + Task GetCategoryByCatalogueIdAsync(int nodeVersionId); + } +} diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs index f7b9320dc..1b8fe8783 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs @@ -505,10 +505,15 @@ public LearningHubDbContextOptions Options public virtual DbSet CatalogueNodeVersionProvider { get; set; } /// - /// Gets or sets the catalogue node version keyword.. + /// Gets or sets the catalogue node version keyword. /// public virtual DbSet CatalogueNodeVersionKeyword { get; set; } + /// + /// Gets or sets the catalogue node version category. + /// + public virtual DbSet CatalogueNodeVersionCategory { get; set; } + /// /// Gets or sets the Migration. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/ServiceMappings.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/ServiceMappings.cs index 2b2dad930..a571d177a 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/ServiceMappings.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/ServiceMappings.cs @@ -154,6 +154,7 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj index 56aa2d3f7..46722121a 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj @@ -24,7 +24,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Map/Hierarchy/CatalogueNodeVersionCategoryMap.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Map/Hierarchy/CatalogueNodeVersionCategoryMap.cs new file mode 100644 index 000000000..fdb9d94a3 --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Map/Hierarchy/CatalogueNodeVersionCategoryMap.cs @@ -0,0 +1,26 @@ +namespace LearningHub.Nhs.OpenApi.Repositories.Map.Hierarchy +{ + using LearningHub.Nhs.Models.Entities.Hierarchy; + using Microsoft.EntityFrameworkCore; + using Microsoft.EntityFrameworkCore.Metadata.Builders; + + /// + /// The CatalogueNodeVersionCategoryMap. + /// + public class CatalogueNodeVersionCategoryMap : BaseEntityMap + { + /// + /// The internal map. + /// + /// The modelBuilder. + protected override void InternalMap(EntityTypeBuilder modelBuilder) + { + modelBuilder.ToTable("CatalogueNodeVersionCategory", "hierarchy"); + + modelBuilder.Property(x => x.CatalogueNodeVersionId) + .IsRequired(); + modelBuilder.Property(x => x.CategoryId) + .IsRequired(); + } + } +} diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/CategoryRepository.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/CategoryRepository.cs new file mode 100644 index 000000000..6e10e7b71 --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/CategoryRepository.cs @@ -0,0 +1,46 @@ +namespace LearningHub.Nhs.OpenApi.Repositories.Repositories +{ + using System; + using System.Data; + using System.Linq; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Entities; + using LearningHub.Nhs.Models.Entities.Hierarchy; + using LearningHub.Nhs.Models.Entities.Resource; + using LearningHub.Nhs.OpenApi.Repositories.EntityFramework; + using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories; + using Microsoft.EntityFrameworkCore; + + /// + /// The category repository. + /// + public class CategoryRepository : GenericRepository, ICategoryRepository + { + /// + /// Initializes a new instance of the class. + /// + /// The db context. + /// The Timezone offset manager. + public CategoryRepository(LearningHubDbContext dbContext, ITimezoneOffsetManager tzOffsetManager) + : base(dbContext, tzOffsetManager) + { + } + + /// + /// The get by node version id async. + /// + /// The node version id. + /// The . + public async Task GetCategoryByCatalogueIdAsync(int nodeVersionId) + { + try + { + return await DbContext.CatalogueNodeVersionCategory.Where(n => n.CatalogueNodeVersionId == nodeVersionId && !n.Deleted).SingleOrDefaultAsync(); + } + catch (Exception ex) + { + return null; + } + } + } +} diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/Hierarchy/CatalogueNodeVersionRepository.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/Hierarchy/CatalogueNodeVersionRepository.cs index b8b7e93c7..3367b371f 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/Hierarchy/CatalogueNodeVersionRepository.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/Hierarchy/CatalogueNodeVersionRepository.cs @@ -216,6 +216,52 @@ public async Task UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel } } + /// + /// The AddCategoryToCatalogueAsync. + /// + /// The userId. + /// The catalogue view model. + /// The task. + public async Task AddCategoryToCatalogueAsync(int userId, CatalogueViewModel vm) + { + try + { + var param0 = new SqlParameter("@p0", SqlDbType.Int) { Value = userId }; + var param1 = new SqlParameter("@p1", SqlDbType.Int) { Value = vm.CatalogueNodeVersionId }; + var param2 = new SqlParameter("@p2", SqlDbType.Int) { Value = vm.SelectedCategoryId }; + var param3 = new SqlParameter("@p3", SqlDbType.Int) { Value = TimezoneOffsetManager.UserTimezoneOffset ?? (object)DBNull.Value }; + + await DbContext.Database.ExecuteSqlRawAsync("hierarchy.CatalogueNodeVersionCategoryCreate @p0, @p1, @p2, @p3", param0, param1, param2, param3); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + + /// + /// The RemoveCategoryFromCatalogueAsync. + /// + /// The userId. + /// The viewmodel. + /// + public async Task RemoveCategoryFromCatalogueAsync(int userId, CatalogueViewModel vm) + { + try + { + var param0 = new SqlParameter("@p0", SqlDbType.Int) { Value = userId }; + var param1 = new SqlParameter("@p1", SqlDbType.Int) { Value = vm.CatalogueNodeVersionId }; + var param2 = new SqlParameter("@p2", SqlDbType.Int) { Value = vm.SelectedCategoryId }; + var param3 = new SqlParameter("@p3", SqlDbType.Int) { Value = TimezoneOffsetManager.UserTimezoneOffset ?? (object)DBNull.Value }; + + await DbContext.Database.ExecuteSqlRawAsync("hierarchy.RemoveCatalogueCategory @p0, @p1, @p2, @p3", param0, param1, param2, param3); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + /// /// Get Catlogue by reference. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Startup.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Startup.cs index c5c9baef6..767d35d19 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Startup.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Startup.cs @@ -54,6 +54,7 @@ private static void AddRepositoryImplementations(this IServiceCollection service services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddTransient(); services.AddTransient(); diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj index 90ead8ca1..f6e92a8ce 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj @@ -17,7 +17,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs index af8ba8562..0f01277d1 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs @@ -149,6 +149,21 @@ public interface ICatalogueService /// The catalogue id. Task CreateCatalogueAsync(int userId, CatalogueViewModel catalogue); + /// + /// The AddCategoryToCatalogueAsync. + /// + /// The userid. + /// The catalogue. + /// + Task AddCategoryToCatalogueAsync(int userId, CatalogueViewModel catalogue); + + /// + /// The RemoveCategoryFromCatalogueAsync. + /// + /// The userId. + /// The catalogue. + /// The catalogue id. + Task RemoveCategoryFromCatalogueAsync(int userId, CatalogueViewModel catalogue); /// /// The UpdateCatalogueAsync. diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICategoryService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICategoryService.cs new file mode 100644 index 000000000..5c4a994a4 --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICategoryService.cs @@ -0,0 +1,19 @@ +namespace LearningHub.Nhs.OpenApi.Services.Interface.Services +{ + using System.Collections.Generic; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Entities.Hierarchy; + + /// + /// The Category Service interface. + /// + public interface ICategoryService + { + /// + /// Get category by node version id. + /// + /// node version id. + /// A representing the result of the asynchronous operation. + Task GetByCatalogueVersionIdAsync(int nodeVersionId); + } +} diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IMoodleApiService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IMoodleApiService.cs index f6aa5bc39..6dd7a4536 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IMoodleApiService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IMoodleApiService.cs @@ -1,4 +1,5 @@ -using LearningHub.Nhs.Models.Moodle.API; +using LearningHub.Nhs.Models.Moodle; +using LearningHub.Nhs.Models.Moodle.API; using LearningHub.Nhs.Models.MyLearning; using System.Collections.Generic; using System.Threading.Tasks; @@ -49,6 +50,12 @@ public interface IMoodleApiService /// List of MoodleCourseResponseModel. Task> GetInProgressEnrolledCoursesAsync(int userId); + /// + /// GetAllMoodleCategoriesAsync. + /// + /// List of MoodleCategory. + Task> GetAllMoodleCategoriesAsync(); + /// /// GetEnrolledCoursesAsync. /// @@ -65,5 +72,19 @@ public interface IMoodleApiService /// The page Number. /// A representing the result of the asynchronous operation. Task> GetUserCertificateAsync(int userId, string filterText = ""); + + /// + /// GetCoursesByCategoryIdAsync. + /// + /// The categoryId. + /// List of MoodleCoursesResponseModel. + Task GetCoursesByCategoryIdAsync(int categoryId); + + /// + /// GetSubCategoryByCategoryIdAsync. + /// + /// The categoryId. + /// List of MoodleSubCategoryResponseModel. + Task> GetSubCategoryByCategoryIdAsync(int categoryId); } } diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj index d473d9126..e2e064738 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj @@ -30,7 +30,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs index b5f934976..5edfe8cc4 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs @@ -56,6 +56,7 @@ public class CatalogueService : ICatalogueService private readonly FindwiseConfig findwiseConfig; private readonly INotificationSenderService notificationSenderService; private readonly ITimezoneOffsetManager timezoneOffsetManager; + private readonly ICategoryService categoryService; /// /// Initializes a new instance of the class. @@ -64,6 +65,7 @@ public class CatalogueService : ICatalogueService /// /// The . /// + /// /// /// /// @@ -77,9 +79,10 @@ public class CatalogueService : ICatalogueService /// /// /// - public CatalogueService(ICatalogueRepository catalogueRepository, INodeRepository nodeRepository, IUserUserGroupRepository userUserGroupRepository, IMapper mapper, IOptions findwiseConfig, IOptions learningHubConfig, ICatalogueNodeVersionRepository catalogueNodeVersionRepository, INodeResourceRepository nodeResourceRepository, IResourceVersionRepository resourceVersionRepository, IRoleUserGroupRepository roleUserGroupRepository, IProviderService providerService, ICatalogueAccessRequestRepository catalogueAccessRequestRepository, IUserRepository userRepository, IUserProfileRepository userProfileRepository, IEmailSenderService emailSenderService, IBookmarkRepository bookmarkRepository,INodeActivityRepository nodeActivityRepository, IFindwiseApiFacade findwiseApiFacade, INotificationSenderService notificationSenderService, ITimezoneOffsetManager timezoneOffsetManager) + public CatalogueService(ICatalogueRepository catalogueRepository, ICategoryService categoryService, INodeRepository nodeRepository, IUserUserGroupRepository userUserGroupRepository, IMapper mapper, IOptions findwiseConfig, IOptions learningHubConfig, ICatalogueNodeVersionRepository catalogueNodeVersionRepository, INodeResourceRepository nodeResourceRepository, IResourceVersionRepository resourceVersionRepository, IRoleUserGroupRepository roleUserGroupRepository, IProviderService providerService, ICatalogueAccessRequestRepository catalogueAccessRequestRepository, IUserRepository userRepository, IUserProfileRepository userProfileRepository, IEmailSenderService emailSenderService, IBookmarkRepository bookmarkRepository,INodeActivityRepository nodeActivityRepository, IFindwiseApiFacade findwiseApiFacade, INotificationSenderService notificationSenderService, ITimezoneOffsetManager timezoneOffsetManager) { this.catalogueRepository = catalogueRepository; + this.categoryService = categoryService; this.nodeRepository = nodeRepository; this.userUserGroupRepository = userUserGroupRepository; this.mapper = mapper; @@ -226,6 +229,7 @@ public async Task GetCatalogueAsync(int id) // Used by the admin screen to inform the admin user if they need to add a user group. vm.HasUserGroup = this.GetRoleUserGroupsForCatalogue(vm.NodeId).Any(); vm.Providers = await this.providerService.GetAllAsync(); + vm.SelectedCategoryId = await this.categoryService.GetByCatalogueVersionIdAsync(vm.CatalogueNodeVersionId); return vm; } @@ -591,6 +595,31 @@ public async Task CreateCatalogueAsync(int userId, }; } + /// + /// The AddCategoryToCatalogueAsync. + /// + /// The userId. + /// The catalogue. + /// The catalogue id. + public async Task AddCategoryToCatalogueAsync(int userId, CatalogueViewModel catalogue) + { + await this.catalogueNodeVersionRepository.AddCategoryToCatalogueAsync(userId, catalogue); + + return new LearningHubValidationResult(true); + } + + /// + /// The RemoveCategoryFromCatalogueAsync. + /// + /// The userId. + /// The catalogue. + /// The catalogue id. + public async Task RemoveCategoryFromCatalogueAsync(int userId, CatalogueViewModel catalogue) + { + await this.catalogueNodeVersionRepository.RemoveCategoryFromCatalogueAsync(userId, catalogue); + + return new LearningHubValidationResult(true); + } /// /// The IsUserLocalAdminAsync. @@ -651,9 +680,6 @@ private LearningHubValidationResult ValidateAddAsync(CatalogueViewModel model) }; } - - - /// /// Filter the items for resource version search. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CategoryService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CategoryService.cs new file mode 100644 index 000000000..e950a1d1f --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CategoryService.cs @@ -0,0 +1,45 @@ +namespace LearningHub.Nhs.OpenApi.Services.Services +{ + using System.Collections.Generic; + using System.Threading.Tasks; + using AutoMapper; + using LearningHub.Nhs.Models.Entities.Hierarchy; + using LearningHub.Nhs.Models.Provider; + using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories; + using LearningHub.Nhs.OpenApi.Services.Interface.Services; + using Microsoft.EntityFrameworkCore; + + /// + /// The provider service. + /// + public class CategoryService : ICategoryService + { + /// + /// The provider repository. + /// + private readonly ICategoryRepository categoryRepository; + + /// + /// mapper. + /// + private readonly IMapper mapper; + + /// + /// Initializes a new instance of the class. + /// + /// The category repository. + /// The mapper. + public CategoryService(ICategoryRepository categoryRepository, IMapper mapper) + { + this.categoryRepository = categoryRepository; + this.mapper = mapper; + } + + /// + public async Task GetByCatalogueVersionIdAsync(int nodeVersionId) + { + var category = await categoryRepository.GetCategoryByCatalogueIdAsync(nodeVersionId); + return category != null ? category.CategoryId : 0; + } + } +} \ No newline at end of file diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/MoodleApiService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/MoodleApiService.cs index 9ea97aaa8..9630ff24d 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/MoodleApiService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/MoodleApiService.cs @@ -1,5 +1,6 @@ namespace LearningHub.Nhs.OpenApi.Services.Services { + using LearningHub.Nhs.Models.Moodle; using LearningHub.Nhs.Models.Moodle.API; using LearningHub.Nhs.Models.MyLearning; using LearningHub.Nhs.Models.Report.ReportCreate; @@ -118,7 +119,7 @@ public async Task> GetRecentEnrolledCour int moodleUserId = await this.GetMoodleUserIdByUsernameAsync(userId); string statusFilter = string.Empty; ; - if ((requestModel.Incomplete && requestModel.Complete) || (!requestModel.Incomplete && !requestModel.Complete)) + if ((requestModel.Incomplete && requestModel.Complete) || (!requestModel.Incomplete && !requestModel.Complete)) { statusFilter = string.Empty; ; } @@ -156,6 +157,35 @@ public async Task> GetRecentEnrolledCour } } + /// + /// GetAllMoodleCategoriesAsync. + /// + /// A representing the result of the asynchronous operation. + public async Task> GetAllMoodleCategoriesAsync() + { + try + { + var parameters = new Dictionary + { + + }; + + var categories = await GetCallMoodleApiAsync>( + "core_course_get_categories", + parameters + ); + + if (categories == null || categories.Count == 0) + return new List(); + + return categories.ToList(); + } + catch (Exception ex) + { + return null; + } + } + /// /// GetEnrolledCoursesAsync. /// @@ -216,7 +246,7 @@ public async Task> GetInProgressEnrolled try { int moodleUserId = await this.GetMoodleUserIdByUsernameAsync(userId); - string statusFilter = "inprogress"; + string statusFilter = "inprogress"; var parameters = new Dictionary { @@ -248,7 +278,7 @@ public async Task> GetInProgressEnrolled /// Moodle user id. /// The page Number. /// A representing the result of the asynchronous operation. - public async Task> GetUserCertificateAsync(int userId, string filterText="") + public async Task> GetUserCertificateAsync(int userId, string filterText = "") { try { @@ -276,6 +306,67 @@ public async Task> GetUserCertificateAs } } + /// + /// GetSubCategoryByCategoryIdAsync. + /// + /// The categoryId. + /// + public async Task> GetSubCategoryByCategoryIdAsync(int categoryId) + { + try + { + var parameters = new Dictionary + { + { "criteria[0][key]", "id" }, + { "criteria[0][value]", categoryId.ToString() } + }; + // Fetch subcategory by category id + var subcategories = await GetCallMoodleApiAsync>( + "core_course_get_categories", + parameters + ); + + if (subcategories == null || subcategories.Count == 0) + return new List(); + + return subcategories.Where(sc => sc.Id != categoryId && sc.Parent == categoryId).ToList(); + } + catch (Exception ex) + { + return null; + } + } + + /// + /// GetCoursesByCategoryIdAsync. + /// + /// The categoryId. + /// + public async Task GetCoursesByCategoryIdAsync(int categoryId) + { + try + { + var parameters = new Dictionary + { + { "field", "category" }, + { "value", categoryId.ToString() } + }; + // Fetch courses by category id + var courses = await GetCallMoodleApiAsync( + "core_course_get_courses_by_field", + parameters + ); + + if (courses == null) + return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(courses)); + return courses; + } + catch (Exception ex) + { + return null; + } + } + /// /// GetEnrolledCoursesAsync. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs index f00f13253..87c94f64e 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs @@ -35,6 +35,7 @@ public static void AddServices(this IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj index ca313166f..35c780917 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/LearningHub.Nhs.OpenApi.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/Services/Services/CatalogueServiceTests.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/Services/Services/CatalogueServiceTests.cs index cfda30045..29e37935a 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Tests/Services/Services/CatalogueServiceTests.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Tests/Services/Services/CatalogueServiceTests.cs @@ -43,6 +43,7 @@ public class CatalogueServiceTests private readonly Mock> findwiseConfig; private readonly Mock notificationSenderService; private readonly Mock timezoneOffsetManager; + private readonly Mock categoryService; /// /// Initializes a new instance of the class. @@ -69,7 +70,8 @@ public CatalogueServiceTests() this.findwiseConfig = new Mock>(); this.notificationSenderService = new Mock(); this.timezoneOffsetManager = new Mock(); - this.catalogueService = new CatalogueService(this.catalogueRepository.Object, this.nodeRepository.Object, this.userUserGroupRepository.Object, this.mapper.Object, this.findwiseConfig.Object, this.learningHubConfig.Object, this.catalogueNodeVersionRepository.Object, this.nodeResourceRepository.Object, this.resourceVersionRepository.Object, this.roleUserGroupRepository.Object, this.providerService.Object, this.catalogueAccessRequestRepository.Object, this.userRepository.Object, this.userProfileRepository.Object, this.emailSenderService.Object, this.bookmarkRepository.Object, this.nodeActivityRepository.Object, this.findwiseApiFacade.Object,this.notificationSenderService.Object,this.timezoneOffsetManager.Object); + this.categoryService = new Mock(); + this.catalogueService = new CatalogueService(this.catalogueRepository.Object, this.categoryService.Object, this.nodeRepository.Object, this.userUserGroupRepository.Object, this.mapper.Object, this.findwiseConfig.Object, this.learningHubConfig.Object, this.catalogueNodeVersionRepository.Object, this.nodeResourceRepository.Object, this.resourceVersionRepository.Object, this.roleUserGroupRepository.Object, this.providerService.Object, this.catalogueAccessRequestRepository.Object, this.userRepository.Object, this.userProfileRepository.Object, this.emailSenderService.Object, this.bookmarkRepository.Object, this.nodeActivityRepository.Object, this.findwiseApiFacade.Object,this.notificationSenderService.Object,this.timezoneOffsetManager.Object); } private static IEnumerable CatalogueNodeVersionList => new List() diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs index 73d406e27..b59dd0aa0 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs @@ -166,6 +166,46 @@ public async Task CreateCatalogue([FromBody] CatalogueViewModel v } } + /// + /// The AddCategoryToCatalogue. + /// + /// The viewModel. + /// The actionResult. + [HttpPost] + [Route("AddCategoryToCatalogue")] + public async Task AddCategoryToCatalogue([FromBody] CatalogueViewModel viewModel) + { + try + { + var vr = await this.catalogueService.AddCategoryToCatalogueAsync(this.CurrentUserId.GetValueOrDefault(), viewModel); + return this.Ok(new ApiResponse(true, vr)); + } + catch (Exception ex) + { + return this.Ok(new ApiResponse(false, new LearningHubValidationResult(false, ex.Message))); + } + } + + /// + /// The RemoveCategoryFromCatalogue. + /// + /// The viewModel. + /// The actionResult. + [HttpPost] + [Route("RemoveCategoryFromCatalogue")] + public async Task RemoveCategoryFromCatalogue([FromBody] CatalogueViewModel viewModel) + { + try + { + var vr = await this.catalogueService.RemoveCategoryFromCatalogueAsync(this.CurrentUserId.GetValueOrDefault(), viewModel); + return this.Ok(new ApiResponse(true, vr)); + } + catch (Exception ex) + { + return this.Ok(new ApiResponse(false, new LearningHubValidationResult(false, ex.Message))); + } + } + /// /// Returns true if the catalogue is editable by the current user. /// diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CategoryController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CategoryController.cs new file mode 100644 index 000000000..cc4b65562 --- /dev/null +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CategoryController.cs @@ -0,0 +1,73 @@ +namespace LearningHub.NHS.OpenAPI.Controllers +{ + using System; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.Catalogue; + using LearningHub.Nhs.Models.Common; + using LearningHub.Nhs.Models.Validation; + using LearningHub.Nhs.OpenApi.Services.Interface.Services; + using Microsoft.AspNetCore.Authorization; + using Microsoft.AspNetCore.Mvc; + + /// + /// Catalogue controller. + /// + [Route("Category")] + [Authorize(Policy = "AuthorizeOrCallFromLH")] + [ApiController] + public class CategoryController : OpenApiControllerBase + { + private readonly ICategoryService categoryService; + private readonly IMoodleApiService moodleApiService; + + /// + /// Initializes a new instance of the class. + /// + /// The category service. + /// The moodleApi service. + public CategoryController(ICategoryService categoryService, IMoodleApiService moodleApiService) + { + this.categoryService = categoryService; + this.moodleApiService = moodleApiService; + } + + /// + /// The GetCatalogue. + /// + /// The catalogue node version id. + /// The catalogue. + [HttpGet] + [Route("GetCatalogueVersionCategory/{catalogueNodeVersionId}")] + public async Task GetCatalogueVersionCategory(int catalogueNodeVersionId) + { + var catalogueNodeVersionCategory = await this.categoryService.GetByCatalogueVersionIdAsync(catalogueNodeVersionId); + return this.Ok(catalogueNodeVersionCategory); + } + + /// + /// The GetCoursesByCategoryId. + /// + /// The category id. + /// The catalogue. + [HttpGet] + [Route("GetCoursesByCategoryId/{categoryId}")] + public async Task GetCoursesByCategoryId(int categoryId) + { + var courses = await this.moodleApiService.GetCoursesByCategoryIdAsync(categoryId); + return this.Ok(courses); + } + + /// + /// The GetSubCategoryByCategoryId. + /// + /// The category id. + /// The catalogue. + [HttpGet] + [Route("GetSubCategoryByCategoryId/{categoryId}")] + public async Task GetSubCategoryByCategoryId(int categoryId) + { + var subCategories = await this.moodleApiService.GetSubCategoryByCategoryIdAsync(categoryId); + return this.Ok(subCategories); + } + } +} diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/MoodleController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/MoodleController.cs index f2639d005..8ce20c2cb 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/MoodleController.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/MoodleController.cs @@ -66,5 +66,17 @@ public async Task GetEnrolledCoursesAsync(int? currentUserId, int return this.Ok(0); } } + + /// + /// GetAllMoodleCategoriesAsync. + /// + /// A representing the result of the asynchronous operation. + [HttpGet] + [Route("GetAllMoodleCategories")] + public async Task GetAllMoodleCategoriesAsync() + { + var entrolledCourses = await this.moodleService.GetAllMoodleCategoriesAsync(); + return this.Ok(entrolledCourses); + } } } diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj b/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj index 4d36a68dc..f23f74ba3 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj +++ b/OpenAPI/LearningHub.Nhs.OpenApi/LearningHub.NHS.OpenAPI.csproj @@ -19,7 +19,7 @@ - + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi.Services.Interface/LearningHub.Nhs.ReportApi.Services.Interface.csproj b/ReportAPI/LearningHub.Nhs.ReportApi.Services.Interface/LearningHub.Nhs.ReportApi.Services.Interface.csproj index f762d97bf..9925c85ea 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi.Services.Interface/LearningHub.Nhs.ReportApi.Services.Interface.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi.Services.Interface/LearningHub.Nhs.ReportApi.Services.Interface.csproj @@ -16,7 +16,7 @@ - + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi.Services.UnitTests/LearningHub.Nhs.ReportApi.Services.UnitTests.csproj b/ReportAPI/LearningHub.Nhs.ReportApi.Services.UnitTests/LearningHub.Nhs.ReportApi.Services.UnitTests.csproj index 13cd54f26..0948fa06c 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi.Services.UnitTests/LearningHub.Nhs.ReportApi.Services.UnitTests.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi.Services.UnitTests/LearningHub.Nhs.ReportApi.Services.UnitTests.csproj @@ -18,7 +18,7 @@ - + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi.Services/LearningHub.Nhs.ReportApi.Services.csproj b/ReportAPI/LearningHub.Nhs.ReportApi.Services/LearningHub.Nhs.ReportApi.Services.csproj index 589d77d9a..1e3c6f360 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi.Services/LearningHub.Nhs.ReportApi.Services.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi.Services/LearningHub.Nhs.ReportApi.Services.csproj @@ -19,7 +19,7 @@ - + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi.Shared/LearningHub.Nhs.ReportApi.Shared.csproj b/ReportAPI/LearningHub.Nhs.ReportApi.Shared/LearningHub.Nhs.ReportApi.Shared.csproj index 10cbd7a4e..2be568801 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi.Shared/LearningHub.Nhs.ReportApi.Shared.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi.Shared/LearningHub.Nhs.ReportApi.Shared.csproj @@ -17,7 +17,7 @@ - + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj b/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj index 12a684d1a..99ba74bda 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj @@ -20,7 +20,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj b/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj index 3f840e00b..8040a9f8d 100644 --- a/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj +++ b/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj @@ -29,7 +29,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.Api.Shared/LearningHub.Nhs.Api.Shared.csproj b/WebAPI/LearningHub.Nhs.Api.Shared/LearningHub.Nhs.Api.Shared.csproj index 6799cbedd..05dbc4e35 100644 --- a/WebAPI/LearningHub.Nhs.Api.Shared/LearningHub.Nhs.Api.Shared.csproj +++ b/WebAPI/LearningHub.Nhs.Api.Shared/LearningHub.Nhs.Api.Shared.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/WebAPI/LearningHub.Nhs.Api.UnitTests/LearningHub.Nhs.Api.UnitTests.csproj b/WebAPI/LearningHub.Nhs.Api.UnitTests/LearningHub.Nhs.Api.UnitTests.csproj index 5fea931a7..72f200f46 100644 --- a/WebAPI/LearningHub.Nhs.Api.UnitTests/LearningHub.Nhs.Api.UnitTests.csproj +++ b/WebAPI/LearningHub.Nhs.Api.UnitTests/LearningHub.Nhs.Api.UnitTests.csproj @@ -11,7 +11,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.Database/LearningHub.Nhs.Database.sqlproj b/WebAPI/LearningHub.Nhs.Database/LearningHub.Nhs.Database.sqlproj index eaa9ff17b..a88a4bcff 100644 --- a/WebAPI/LearningHub.Nhs.Database/LearningHub.Nhs.Database.sqlproj +++ b/WebAPI/LearningHub.Nhs.Database/LearningHub.Nhs.Database.sqlproj @@ -101,6 +101,8 @@ + + @@ -203,6 +205,10 @@ + + + + @@ -541,12 +547,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebAPI/LearningHub.Nhs.Database/Schemas/elfh.sql b/WebAPI/LearningHub.Nhs.Database/Schemas/elfh.sql new file mode 100644 index 000000000..09637bd31 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Schemas/elfh.sql @@ -0,0 +1,3 @@ +CREATE SCHEMA [elfh] + AUTHORIZATION [dbo]; +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-5864-Enable-CDC.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-5864-Enable-CDC.sql new file mode 100644 index 000000000..dd7b28b04 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-5864-Enable-CDC.sql @@ -0,0 +1,125 @@ +/* + TD-5864/TD-6220/TD-6366 + Enable the following tables for CDC / CT in the Learning Hub +*/ + + +-- Enable CDC on the database +EXEC sys.sp_cdc_enable_db; +GO + +-- STEP 2: Enable CDC on tables + +-- Table 1: UserUserGroup +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'UserUserGroup', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 2: UserGroup +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'UserGroup', + @role_name = NULL, + @supports_net_changes = 0; +GO +-- Table 3: UserProvider +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'UserProvider', + @role_name = NULL, + @supports_net_changes = 0; +GO +-- Table 4: UserGroupAttribute +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'UserGroupAttribute', + @role_name = NULL, + @supports_net_changes = 0; +GO +-- Table 5: Attribute +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'Attribute', + @role_name = NULL, + @supports_net_changes = 0; +GO +-- Table 6: AttributeType +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'AttributeType', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 7: NodeType +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'NodeType', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 8: CatalogueNodeVersionProvider +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'CatalogueNodeVersionProvider', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 9: CatalogueNodeVersionKeyword +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'CatalogueNodeVersionKeyword', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 10: Publication +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'Publication', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 11: PublicationLog +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'PublicationLog', + @role_name = NULL, + @supports_net_changes = 0; +GO +-- Table 12: NodePathNode +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'NodePathNode', + @role_name = NULL, + @supports_net_changes = 0; +GO + +-- Table 12: versionStatus +EXEC sys.sp_cdc_enable_table + @source_schema = N'hierarchy', + @source_name = N'versionStatus', + @role_name = NULL, + @supports_net_changes = 0; +GO + + + + + + + + + + + + + + + diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6109_Enable_CDC.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6109_Enable_CDC.sql index 0170b701a..a98f07fb4 100644 --- a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6109_Enable_CDC.sql +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6109_Enable_CDC.sql @@ -124,64 +124,35 @@ EXEC sys.sp_cdc_enable_table @role_name = NULL, @supports_net_changes = 0; GO --- Table 16: User -EXEC sys.sp_cdc_enable_table - @source_schema = N'hub', - @source_name = N'User', - @role_name = NULL, - @supports_net_changes = 0; -GO - --- Table 17: UserGroup -EXEC sys.sp_cdc_enable_table - @source_schema = N'hub', - @source_name = N'UserGroup', - @role_name = NULL, - @supports_net_changes = 0; -GO --- Table 18: UserProfile -EXEC sys.sp_cdc_enable_table - @source_schema = N'hub', - @source_name = N'UserProfile', - @role_name = NULL, - @supports_net_changes = 0; -GO --- Table 19: UserProfile -EXEC sys.sp_cdc_enable_table - @source_schema = N'hub', - @source_name = N'UserUserGroup', - @role_name = NULL, - @supports_net_changes = 0; -GO --- Table 20: AssessmentResourceVersion +-- Table 16: AssessmentResourceVersion EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'AssessmentResourceVersion', @role_name = NULL, @supports_net_changes = 0; GO --- Table 21: Resource +-- Table 17: Resource EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'Resource', @role_name = NULL, @supports_net_changes = 0; GO --- Table 22: ResourceReference +-- Table 18: ResourceReference EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceReference', @role_name = NULL, @supports_net_changes = 0; GO --- Table 23: ResourceType +-- Table 19: ResourceType EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceType', @role_name = NULL, @supports_net_changes = 0; GO --- Table 24: ResourceVersion +-- Table 20: ResourceVersion EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersion', @@ -189,7 +160,7 @@ EXEC sys.sp_cdc_enable_table @supports_net_changes = 0; GO --- Table 25: ResourceVersionEvent +-- Table 21: ResourceVersionEvent EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersionEvent', @@ -197,42 +168,42 @@ EXEC sys.sp_cdc_enable_table @supports_net_changes = 0; GO --- Table 26: ResourceVersionEventType +-- Table 22: ResourceVersionEventType EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersionEventType', @role_name = NULL, @supports_net_changes = 0; GO --- Table 27: VersionStatus +-- Table 23: VersionStatus EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'VersionStatus', @role_name = NULL, @supports_net_changes = 0; GO --- Table 28: VideoResourceVersion +-- Table 24: VideoResourceVersion EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'VideoResourceVersion', @role_name = NULL, @supports_net_changes = 0; GO --- Table 29: WebLinkResourceVersion +-- Table 25: WebLinkResourceVersion EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'WebLinkResourceVersion', @role_name = NULL, @supports_net_changes = 0; GO --- Table 30: ResourceAccessibility +-- Table 26: ResourceAccessibility EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceAccessibility', @role_name = NULL, @supports_net_changes = 0; GO --- Table 31: ResourceVersionAuthor +-- Table 27: ResourceVersionAuthor EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersionAuthor', @@ -240,7 +211,7 @@ EXEC sys.sp_cdc_enable_table @supports_net_changes = 0; GO --- Table 32: ResourceVersionKeyword +-- Table 28: ResourceVersionKeyword EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersionKeyword', @@ -248,14 +219,14 @@ EXEC sys.sp_cdc_enable_table @supports_net_changes = 0; GO --- Table 33: ResourceVersionRating +-- Table 29: ResourceVersionRating EXEC sys.sp_cdc_enable_table @source_schema = N'resources', @source_name = N'ResourceVersionRating', @role_name = NULL, @supports_net_changes = 0; GO --- Table 34: ScormActivityInteraction +-- Table 30: ScormActivityInteraction EXEC sys.sp_cdc_enable_table @source_schema = N'activity', @source_name = N'ScormActivityInteraction', @@ -263,7 +234,7 @@ EXEC sys.sp_cdc_enable_table @supports_net_changes = 0; GO --- Table 35: ScormActivityInteractionCorrectResponse +-- Table 31: ScormActivityInteractionCorrectResponse EXEC sys.sp_cdc_enable_table @source_schema = N'activity', @source_name = N'ScormActivityInteractionCorrectResponse', diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6148-ADFtableData.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6148-ADFtableData.sql new file mode 100644 index 000000000..e748cbf8a --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6148-ADFtableData.sql @@ -0,0 +1,45 @@ +INSERT INTO ADFSyncMetadata (SyncDirection, TableName, LastSyncTime) +VALUES +('ELFHtoLH', 'employmentReferenceTypeTBL', '1900-01-01'), +('ELFHtoLH', 'mergeUserTBL', '1900-01-01'), +('ELFHtoLH', 'userAdminLocationTBL', '1900-01-01'), +('ELFHtoLH', 'userEmploymentReferenceTBL', '1900-01-01'), +('ELFHtoLH', 'userEmploymentResponsibilityTBL', '1900-01-01'), +('ELFHtoLH', 'userHistoryAttributeTBL', '1900-01-01'), +('ELFHtoLH', 'userReportingUserTBL', '1900-01-01'), +('ELFHtoLH', 'emailTemplateTBL', '1900-01-01'), +('ELFHtoLH', 'userprofile', '1900-01-01'), +('ELFHtoLH', 'user', '1900-01-01'), +('ELFHtoLH', 'userRoleUpgradeTBL', '1900-01-01'), +('ELFHtoLH', 'userHistoryTBL', '1900-01-01'), +('ELFHtoLH', 'userHistoryTypeTBL', '1900-01-01'), +('ELFHtoLH', 'userPasswordValidationTokenTBL', '1900-01-01'), +('ELFHtoLH', 'userGroupTypeInputValidationTBL', '1900-01-01'), +('ELFHtoLH', 'userAttributeTBL', '1900-01-01'), +('ELFHtoLH', 'termsAndConditionsTBL', '1900-01-01'), +('ELFHtoLH', 'tenantUrlTBL', '1900-01-01'), +('ELFHtoLH', 'tenantTBL', '1900-01-01'), +('ELFHtoLH', 'tenantSmtpTBL', '1900-01-01'), +('ELFHtoLH', 'systemSettingTBL', '1900-01-01'), +('ELFHtoLH', 'loginWizardStageActivityTBL', '1900-01-01'), +('ELFHtoLH', 'loginWizardRuleTBL', '1900-01-01'), +('ELFHtoLH', 'loginWizardStageTBL', '1900-01-01'), +('ELFHtoLH', 'ipCountryLookupTBL', '1900-01-01'), +('ELFHtoLH', 'emailTemplateTypeTBL', '1900-01-01'), +('ELFHtoLH', 'attributeTBL', '1900-01-01'), +('ELFHtoLH', 'attributeTypeTBL', '1900-01-01'), +('ELFHtoLH', 'gdcRegisterTBL', '1900-01-01'), +('ELFHtoLH', 'gmclrmpTBL', '1900-01-01'), +('ELFHtoLH', 'regionTBL', '1900-01-01'), +('ELFHtoLH', 'userEmploymentTBL', '1900-01-01'), +('ELFHtoLH', 'locationTypeTBL', '1900-01-01'), +('ELFHtoLH', 'locationTBL', '1900-01-01'), +('ELFHtoLH', 'countryTBL', '1900-01-01'), +('ELFHtoLH', 'schoolTBL', '1900-01-01'), +('ELFHtoLH', 'deaneryTBL', '1900-01-01'), +('ELFHtoLH', 'gradeTBL', '1900-01-01'), +('ELFHtoLH', 'specialtyTBL', '1900-01-01'), +('ELFHtoLH', 'JobRoleTbl', '1900-01-01'), +('ELFHtoLH', 'userTermsAndConditionsTBL', '1900-01-01'), +('ELFHtoLH', 'medicalCouncilTBL', '1900-01-01'), +('ELFHtoLH', 'staffGroupTBL', '1900-01-01') diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6159-turn-on-cdc.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6159-turn-on-cdc.sql new file mode 100644 index 000000000..60d04fa46 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/TD-6159-turn-on-cdc.sql @@ -0,0 +1,135 @@ +-- Re-enable CDC + +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'User', + @role_name = NULL, + @supports_net_changes = 0; +GO + + +EXEC sys.sp_cdc_enable_table + @source_schema = N'hub', + @source_name = N'UserProfile', + @role_name = NULL, + @supports_net_changes = 0; +GO + + +-- Enable CDC for elfh tables + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'locationTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'locationTypeTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'countryTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userEmploymentTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'jobRoleTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'StaffGroupTbL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'specialtyTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'medicalCouncilTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userEmploymentReferenceTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'employmentReferenceTypeTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userAdminLocationTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'gradeTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userEmploymentResponsibilityTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'mergeUserTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userReportingUserTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + + +EXEC sys.sp_cdc_enable_table + @source_schema = N'elfh', + @source_name = N'userTermsAndConditionsTBL', + @role_name = NULL, + @supports_net_changes = 0; +GO + + + diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Pre-Deploy/Scripts/TD-6159-turn-off-cdc.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Pre-Deploy/Scripts/TD-6159-turn-off-cdc.sql new file mode 100644 index 000000000..47f6b2678 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Pre-Deploy/Scripts/TD-6159-turn-off-cdc.sql @@ -0,0 +1,13 @@ + +EXEC sys.sp_cdc_disable_table + @source_schema = N'hub', + @source_name = N'User', + @capture_instance = N'hub_User'; +GO + + +EXEC sys.sp_cdc_disable_table + @source_schema = N'hub', + @source_name = N'UserProfile', + @capture_instance = N'hub_UserProfile'; +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmailTemplate.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmailTemplate.sql new file mode 100644 index 000000000..92f822c7f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmailTemplate.sql @@ -0,0 +1,59 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeEmailTemplate] + @EmailTemplateList [dbo].[EmailTemplate] READONLY +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[emailTemplateTBL] ON; + MERGE [elfh].[emailTemplateTBL] AS TARGET + USING @EmailTemplateList AS SOURCE + ON TARGET.[emailTemplateId] = SOURCE.[emailTemplateId] + + WHEN MATCHED THEN + UPDATE SET + TARGET.[emailTemplateTypeId] = SOURCE.[emailTemplateTypeId], + TARGET.[programmeComponentId] = SOURCE.[programmeComponentId], + TARGET.[title] = SOURCE.[title], + TARGET.[subject] = SOURCE.[subject], + TARGET.[body] = SOURCE.[body], + TARGET.[deleted] = SOURCE.[deleted], + TARGET.[amendUserID] = SOURCE.[amendUserID], + TARGET.[amendDate] = SOURCE.[amendDate], + TARGET.[tenantId] = SOURCE.[tenantId] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [emailTemplateId], + [emailTemplateTypeId], + [programmeComponentId], + [title], + [subject], + [body], + [deleted], + [amendUserID], + [amendDate], + [tenantId] + ) + VALUES ( + SOURCE.[emailTemplateId], + SOURCE.[emailTemplateTypeId], + SOURCE.[programmeComponentId], + SOURCE.[title], + SOURCE.[subject], + SOURCE.[body], + SOURCE.[deleted], + SOURCE.[amendUserID], + SOURCE.[amendDate], + SOURCE.[tenantId] + ); + SET IDENTITY_INSERT [elfh].[emailTemplateTBL] OFF; +END; +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmploymentReferenceType.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmploymentReferenceType.sql new file mode 100644 index 000000000..03816a823 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeEmploymentReferenceType.sql @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeEmploymentReferenceType] + @EmploymentReferenceType dbo.EmploymentReferenceType READONLY +AS +BEGIN + SET NOCOUNT ON; + + + MERGE [ELFH].[employmentReferenceTypeTBL] AS target + USING @EmploymentReferenceType AS source + ON target.[EmploymentReferenceTypeId] = source.[EmploymentReferenceTypeId] + + WHEN MATCHED THEN + UPDATE SET + target.[Title] = source.[Title], + target.[RefAccess] = source.[RefAccess] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [EmploymentReferenceTypeId], + [Title], + [RefAccess] + ) + VALUES ( + source.[EmploymentReferenceTypeId], + source.[Title], + source.[RefAccess] + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeHubUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeHubUser.sql new file mode 100644 index 000000000..eeb1e5df8 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeHubUser.sql @@ -0,0 +1,72 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeHubUser] + @UserList [dbo].[UserType_Hub] READONLY +AS +BEGIN + SET NOCOUNT ON; + + ALTER TABLE [hub].[user] NOCHECK CONSTRAINT FK_userTBL_userEmploymentTBL; + ALTER TABLE [elfh].[userEmploymentTBL] NOCHECK CONSTRAINT FK_userEmploymentTBL_userTBL; + ALTER TABLE [hub].[User] NOCHECK CONSTRAINT ALL; + + MERGE [hub].[User] AS target + USING @UserList AS source + ON target.[Id] = source.[Id] + WHEN MATCHED THEN + UPDATE SET + target.[UserName] = source.[UserName], + target.[countryId] = source.[countryId], + target.[registrationCode] = source.[registrationCode], + target.[activeFromDate] = source.[activeFromDate], + target.[activeToDate] = source.[activeToDate], + target.[passwordHash] = source.[passwordHash], + target.[mustChangeNextLogin] = source.[mustChangeNextLogin], + target.[passwordLifeCounter] = source.[passwordLifeCounter], + target.[securityLifeCounter] = source.[securityLifeCounter], + target.[RemoteLoginKey] = source.[RemoteLoginKey], + target.[RemoteLoginGuid] = source.[RemoteLoginGuid], + target.[RemoteLoginStart] = source.[RemoteLoginStart], + target.[RestrictToSSO] = source.[RestrictToSSO], + target.[loginTimes] = source.[loginTimes], + target.[loginWizardInProgress] = source.[loginWizardInProgress], + target.[lastLoginWizardCompleted] = source.[lastLoginWizardCompleted], + target.[primaryUserEmploymentId] = source.[primaryUserEmploymentId], + target.[regionId] = source.[regionId], + target.[preferredTenantId] = source.[preferredTenantId], + target.[AmendUserId] = source.[AmendUserId], + target.[AmendDate] = source.[AmendDate], + target.[Deleted] = source.[Deleted] + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [Id], [UserName], [countryId], [registrationCode], + [activeFromDate], [activeToDate], [passwordHash], + [mustChangeNextLogin], [passwordLifeCounter], [securityLifeCounter], + [RemoteLoginKey], [RemoteLoginGuid], [RemoteLoginStart], + [RestrictToSSO], [loginTimes], [loginWizardInProgress], + [lastLoginWizardCompleted], [primaryUserEmploymentId], + [regionId], [preferredTenantId], [CreateUserId], + [CreateDate], [AmendUserId], [AmendDate], [Deleted] + ) + VALUES ( + source.[Id], source.[UserName], source.[countryId], source.[registrationCode], + source.[activeFromDate], source.[activeToDate], source.[passwordHash], + source.[mustChangeNextLogin], source.[passwordLifeCounter], source.[securityLifeCounter], + source.[RemoteLoginKey], source.[RemoteLoginGuid], source.[RemoteLoginStart], + source.[RestrictToSSO], source.[loginTimes], source.[loginWizardInProgress], + source.[lastLoginWizardCompleted], source.[primaryUserEmploymentId], + source.[regionId], source.[preferredTenantId],4, + source.[CreateDate], source.[AmendUserId], source.[AmendDate], source.[Deleted] + ); + ALTER TABLE [hub].[user] NOCHECK CONSTRAINT FK_userTBL_userEmploymentTBL; + ALTER TABLE [elfh].[userEmploymentTBL] NOCHECK CONSTRAINT FK_userEmploymentTBL_userTBL; + ALTER TABLE [hub].[User] CHECK CONSTRAINT ALL; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeMergeUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeMergeUser.sql new file mode 100644 index 000000000..f4b3dbe93 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeMergeUser.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeMergeUser] + @MergeUserList dbo.MergeUser READONLY +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[mergeUserTBL] ON; + + MERGE [elfh].[mergeUserTBL] AS target + USING @MergeUserList AS source + ON target.[mergeUserId] = source.[mergeUserId] + + WHEN MATCHED THEN + UPDATE SET + target.[fromUserId] = source.[fromUserId], + target.[intoUserId] = source.[intoUserId], + target.[amendUserId] = source.[amendUserId], + target.[createdDatetime] = source.[createdDatetime] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [mergeUserId], + [fromUserId], + [intoUserId], + [amendUserId], + [createdDatetime] + ) + VALUES ( + source.[mergeUserId], + source.[fromUserId], + source.[intoUserId], + source.[amendUserId], + source.[createdDatetime] + ); + + SET IDENTITY_INSERT [elfh].[mergeUserTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAdminLocation.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAdminLocation.sql new file mode 100644 index 000000000..28e48027f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAdminLocation.sql @@ -0,0 +1,50 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeUserAdminLocation] + @UserAdminLocationList dbo.UserAdminLocationType READONLY +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[userAdminLocationTBL] AS target + USING @UserAdminLocationList AS source + ON target.[userId] = source.[userId] + AND target.[adminLocationId] = source.[adminLocationId] -- composite key match + + WHEN MATCHED THEN + UPDATE SET + target.[deleted] = source.[deleted], + target.[amendUserId] = source.[amendUserId], + target.[amendDate] = source.[amendDate], + target.[createdUserId] = source.[createdUserId], + target.[createdDate] = source.[createdDate] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [userId], + [adminLocationId], + [deleted], + [amendUserId], + [amendDate], + [createdUserId], + [createdDate] + ) + VALUES ( + source.[userId], + source.[adminLocationId], + source.[deleted], + source.[amendUserId], + source.[amendDate], + source.[createdUserId], + source.[createdDate] + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAttribute.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAttribute.sql new file mode 100644 index 000000000..ebdf23815 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserAttribute.sql @@ -0,0 +1,62 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserAttribute] + @userAttributeList dbo.UserAttribute READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[userAttributeTBL] ON; + + MERGE [elfh].[userAttributeTBL] AS target + USING @userAttributeList AS source + ON target.userAttributeId = source.userAttributeId + + WHEN MATCHED THEN + UPDATE SET + userId = source.userId, + attributeId = source.attributeId, + intValue = source.intValue, + textValue = source.textValue, + booleanValue = source.booleanValue, + dateValue = source.dateValue, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + userAttributeId, + userId, + attributeId, + intValue, + textValue, + booleanValue, + dateValue, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.userAttributeId, + source.userId, + source.attributeId, + source.intValue, + source.textValue, + source.booleanValue, + source.dateValue, + source.deleted, + source.amendUserId, + source.amendDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userAttributeTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentReference.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentReference.sql new file mode 100644 index 000000000..5a5aa29a6 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentReference.sql @@ -0,0 +1,51 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeUserEmploymentReference] + @UserEmploymentReferenceList dbo.UserEmploymentReferenceType READONLY +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[userEmploymentReferenceTBL] ON; + MERGE [elfh].[userEmploymentReferenceTBL] AS target + USING @UserEmploymentReferenceList AS source + ON target.[userEmploymentReferenceId] = source.[userEmploymentReferenceId] + + WHEN MATCHED THEN + UPDATE SET + target.[employmentReferenceTypeId] = source.[employmentReferenceTypeId], + target.[userEmploymentId] = source.[userEmploymentId], + target.[referenceValue] = source.[referenceValue], + target.[deleted] = source.[deleted], + target.[amendUserId] = source.[amendUserId], + target.[amendDate] = source.[amendDate] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [userEmploymentReferenceId], + [employmentReferenceTypeId], + [userEmploymentId], + [referenceValue], + [deleted], + [amendUserId], + [amendDate] + ) + VALUES ( + source.[userEmploymentReferenceId], + source.[employmentReferenceTypeId], + source.[userEmploymentId], + source.[referenceValue], + source.[deleted], + source.[amendUserId], + source.[amendDate] + ); + SET IDENTITY_INSERT [elfh].[userEmploymentReferenceTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentResponsibility.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentResponsibility.sql new file mode 100644 index 000000000..ca257de1f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserEmploymentResponsibility.sql @@ -0,0 +1,45 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeUserEmploymentResponsibility] + @UserEmploymentResponsibilityList dbo.UserEmploymentResponsibilityType READONLY +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[userEmploymentResponsibilityTBL] ON; + MERGE [elfh].[userEmploymentResponsibilityTBL] AS target + USING @UserEmploymentResponsibilityList AS source + ON target.[userEmploymentResponsibilityId] = source.[userEmploymentResponsibilityId] + + WHEN MATCHED THEN + UPDATE SET + target.[userEmploymentId] = source.[userEmploymentId], + target.[additionalResponsibilityId] = source.[additionalResponsibilityId], + target.[deleted] = source.[deleted], + target.[amendUserId] = source.[amendUserId] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [userEmploymentResponsibilityId], + [userEmploymentId], + [additionalResponsibilityId], + [deleted], + [amendUserId] + ) + VALUES ( + source.[userEmploymentResponsibilityId], + source.[userEmploymentId], + source.[additionalResponsibilityId], + source.[deleted], + source.[amendUserId] + ); + SET IDENTITY_INSERT [elfh].[userEmploymentResponsibilityTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserGroupTypeInputValidation.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserGroupTypeInputValidation.sql new file mode 100644 index 000000000..9ffedb0b1 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserGroupTypeInputValidation.sql @@ -0,0 +1,67 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserGroupTypeInputValidation] + @userGroupTypeInputValidationList dbo.UserGroupTypeInputValidation READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if userGroupTypeInputValidationId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[userGroupTypeInputValidationTBL] ON; + + MERGE [elfh].[userGroupTypeInputValidationTBL] AS target + USING @userGroupTypeInputValidationList AS source + ON target.userGroupTypeInputValidationId = source.userGroupTypeInputValidationId + + WHEN MATCHED THEN + UPDATE SET + userGroupId = source.userGroupId, + userGroupTypePrefix = source.userGroupTypePrefix, + userGroupTypeId = source.userGroupTypeId, + validationTextValue = source.validationTextValue, + validationMethod = source.validationMethod, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate, + createdUserId = source.createdUserId, + createdDate = source.createdDate + + WHEN NOT MATCHED THEN + INSERT ( + userGroupTypeInputValidationId, + userGroupId, + userGroupTypePrefix, + userGroupTypeId, + validationTextValue, + validationMethod, + deleted, + amendUserId, + amendDate, + createdUserId, + createdDate + ) + VALUES ( + source.userGroupTypeInputValidationId, + source.userGroupId, + source.userGroupTypePrefix, + source.userGroupTypeId, + source.validationTextValue, + source.validationMethod, + source.deleted, + source.amendUserId, + source.amendDate, + source.createdUserId, + source.createdDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userGroupTypeInputValidationTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistory.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistory.sql new file mode 100644 index 000000000..7a53f6577 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistory.sql @@ -0,0 +1,49 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserHistory] + @userHistoryList dbo.UserHistory READONLY +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if userHistoryId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[userHistoryTBL] ON; + + MERGE [elfh].[userHistoryTBL] AS target + USING @userHistoryList AS source + ON target.[userHistoryId] = source.[userHistoryId] + + WHEN MATCHED THEN + UPDATE SET + [userHistoryTypeId] = source.[userHistoryTypeId], + [userId] = source.[userId], + [createdDate] = source.[createdDate], + [tenantId] = source.[tenantId] + + WHEN NOT MATCHED THEN + INSERT ( + [userHistoryId], + [userHistoryTypeId], + [userId], + [createdDate], + [tenantId] + ) + VALUES ( + source.[userHistoryId], + source.[userHistoryTypeId], + source.[userId], + source.[createdDate], + source.[tenantId] + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userHistoryTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryAttribute.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryAttribute.sql new file mode 100644 index 000000000..cc17b95fa --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryAttribute.sql @@ -0,0 +1,62 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeUserHistoryAttribute] + @UserHistoryAttributeList dbo.UserHistoryAttributeType READONLY +AS +BEGIN + SET NOCOUNT ON; + + ALTER TABLE [elfh].[userHistoryAttributeTBL] NOCHECK CONSTRAINT ALL; + SET IDENTITY_INSERT [elfh].[userHistoryAttributeTBL] ON; + MERGE [elfh].[userHistoryAttributeTBL] AS target + USING @UserHistoryAttributeList AS source + ON target.[userHistoryAttributeId] = source.[userHistoryAttributeId] + + WHEN MATCHED THEN + UPDATE SET + target.[userHistoryId] = source.[userHistoryId], + target.[attributeId] = source.[attributeId], + target.[intValue] = source.[intValue], + target.[textValue] = source.[textValue], + target.[booleanValue] = source.[booleanValue], + target.[dateValue] = source.[dateValue], + target.[deleted] = source.[deleted], + target.[amendUserId] = source.[amendUserId], + target.[amendDate] = source.[amendDate] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [userHistoryAttributeId], + [userHistoryId], + [attributeId], + [intValue], + [textValue], + [booleanValue], + [dateValue], + [deleted], + [amendUserId], + [amendDate] + ) + VALUES ( + source.[userHistoryAttributeId], + source.[userHistoryId], + source.[attributeId], + source.[intValue], + source.[textValue], + source.[booleanValue], + source.[dateValue], + source.[deleted], + source.[amendUserId], + source.[amendDate] + ); + SET IDENTITY_INSERT [elfh].[userHistoryAttributeTBL] OFF; + ALTER TABLE [elfh].[userHistoryAttributeTBL] CHECK CONSTRAINT ALL; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryType.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryType.sql new file mode 100644 index 000000000..f7fc0d735 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserHistoryType.sql @@ -0,0 +1,35 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserHistoryType] + @userHistoryTypeList dbo.UserHistoryType READONLY +AS +BEGIN + SET NOCOUNT ON; + + MERGE [ELFH].[userHistoryTypeTBL] AS target + USING @userHistoryTypeList AS source + ON target.UserHistoryTypeId = source.UserHistoryTypeId + + WHEN MATCHED THEN + UPDATE SET + [Description] = source.[Description] + + WHEN NOT MATCHED THEN + INSERT ( + [UserHistoryTypeId], + [Description] + ) + VALUES ( + source.[UserHistoryTypeId], + source.[Description] + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserPasswordValidationToke.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserPasswordValidationToke.sql new file mode 100644 index 000000000..d9c65fd6d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserPasswordValidationToke.sql @@ -0,0 +1,60 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserPasswordValidationToken] + @userPasswordValidationTokenList dbo.UserPasswordValidationToken READONLY +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if userPasswordValidationTokenId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[userPasswordValidationTokenTBL] ON; + MERGE [elfh].[userPasswordValidationTokenTBL] AS target + USING @userPasswordValidationTokenList AS source + ON target.userPasswordValidationTokenId = source.userPasswordValidationTokenId + + WHEN MATCHED THEN + UPDATE SET + hashedToken = source.hashedToken, + salt = source.salt, + [lookup] = source.[lookup], + expiry = source.expiry, + tenantId = source.tenantId, + userId = source.userId, + createdUserId = source.createdUserId, + createdDate = source.createdDate + + WHEN NOT MATCHED THEN + INSERT ( + userPasswordValidationTokenId, + hashedToken, + salt, + [lookup], + expiry, + tenantId, + userId, + createdUserId, + createdDate + ) + VALUES ( + source.userPasswordValidationTokenId, + source.hashedToken, + source.salt, + source.[lookup], + source.expiry, + source.tenantId, + source.userId, + source.createdUserId, + source.createdDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userPasswordValidationTokenTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserProfileData.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserProfileData.sql new file mode 100644 index 000000000..d1e51c702 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserProfileData.sql @@ -0,0 +1,68 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserProfileData] + @UserProfileLists [dbo].[UserProfileType] READONLY +AS +BEGIN + SET NOCOUNT ON; + + MERGE [hub].[UserProfile] AS target + USING @UserProfileLists AS source + ON target.[Id] = source.[Id] + + WHEN MATCHED THEN + UPDATE SET + target.[UserName] = source.[UserName], + target.[EmailAddress] = source.[EmailAddress], + target.[AltEmailAddress] = source.[AltEmailAddress], + target.[FirstName] = source.[FirstName], + target.[LastName] = source.[LastName], + target.[PreferredName] = source.[PreferredName], + target.[Active] = source.[Active], + target.[AmendUserId] = source.[AmendUserId], + target.[AmendDate] = source.[AmendDate], + target.[Deleted] = source.[Deleted] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [Id], + [UserName], + [EmailAddress], + [AltEmailAddress], + [FirstName], + [LastName], + [PreferredName], + [Active], + [CreateUserId], + [CreateDate], + [AmendUserId], + [AmendDate], + [Deleted] + ) + VALUES ( + source.[Id], + source.[UserName], + source.[EmailAddress], + source.[AltEmailAddress], + source.[FirstName], + source.[LastName], + source.[PreferredName], + source.[Active], + 4, + source.[CreateDate], + source.[AmendUserId], + source.[AmendDate], + source.[Deleted] + ); + + + +END; +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserReportingUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserReportingUser.sql new file mode 100644 index 000000000..e890b67cd --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserReportingUser.sql @@ -0,0 +1,52 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [AdfMergeUserReportingUser] + @UserReportingUserList dbo.UserReportingUserType READONLY +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[userReportingUserTBL] ON; + MERGE [elfh].[userReportingUserTBL] AS target + USING @UserReportingUserList AS source + ON target.[userReportingUserId] = source.[userReportingUserId] + + WHEN MATCHED THEN + UPDATE SET + target.[userId] = source.[userId], + target.[reportingUserId] = source.[reportingUserId], + target.[reportable] = source.[reportable], + target.[Deleted] = source.[Deleted], + target.[AmendUserID] = source.[AmendUserID], + target.[AmendDate] = source.[AmendDate] + + WHEN NOT MATCHED BY TARGET THEN + INSERT ( + [userReportingUserId], + [userId], + [reportingUserId], + [reportable], + [Deleted], + [AmendUserID], + [AmendDate] + ) + VALUES ( + source.[userReportingUserId], + source.[userId], + source.[reportingUserId], + source.[reportable], + source.[Deleted], + source.[AmendUserID], + source.[AmendDate] + ); + SET IDENTITY_INSERT [elfh].[userReportingUserTBL] OFF; + -- Optionally re-enable constraints +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserRoleUpgrade.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserRoleUpgrade.sql new file mode 100644 index 000000000..256cac018 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeUserRoleUpgrade.sql @@ -0,0 +1,64 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserRoleUpgrade] + @userRoleUpgradeList dbo.UserRoleUpgrade READONLY +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if userRoleUpgradeId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[userRoleUpgradeTBL] ON; + + MERGE [elfh].[userRoleUpgradeTBL] AS target + USING @userRoleUpgradeList AS source + ON target.[userRoleUpgradeId] = source.[userRoleUpgradeId] + + WHEN MATCHED THEN + UPDATE SET + [userId] = source.[userId], + [emailAddress] = source.[emailAddress], + [upgradeDate] = source.[upgradeDate], + [deleted] = source.[deleted], + [createUserId] = source.[createUserId], + [createDate] = source.[createDate], + [amendUserId] = source.[amendUserId], + [amendDate] = source.[amendDate], + [userHistoryTypeId] = source.[userHistoryTypeId] + + WHEN NOT MATCHED THEN + INSERT ( + [userRoleUpgradeId], + [userId], + [emailAddress], + [upgradeDate], + [deleted], + [createUserId], + [createDate], + [amendUserId], + [amendDate], + [userHistoryTypeId] + ) + VALUES ( + source.[userRoleUpgradeId], + source.[userId], + source.[emailAddress], + source.[upgradeDate], + source.[deleted], + source.[createUserId], + source.[createDate], + source.[amendUserId], + source.[amendDate], + source.[userHistoryTypeId] + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userRoleUpgradeTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattribute.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattribute.sql new file mode 100644 index 000000000..d6851b39d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattribute.sql @@ -0,0 +1,633 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE TYPE [dbo].[EmailTemplate] AS TABLE +( + [emailTemplateId] INT, + [emailTemplateTypeId] INT, + [programmeComponentId] INT, + [title] NVARCHAR(256), + [subject] NVARCHAR(256), + [body] ntext, + [deleted] BIT, + [amendUserID] INT, + [amendDate] DATETIMEOFFSET, + [tenantId] INT +); +GO +CREATE TYPE dbo.UserReportingUserType AS TABLE +( + [userReportingUserId] INT, + [userId] INT, + [reportingUserId] INT, + [reportable] BIT, + [Deleted] BIT, + [AmendUserID] INT, + [AmendDate] DATETIMEOFFSET +); +GO +CREATE TYPE UserHistoryAttributeType AS TABLE +( + [userHistoryAttributeId] INT, + [userHistoryId] INT, + [attributeId] INT, + [intValue] INT NULL, + [textValue] NVARCHAR(1000) NULL, + [booleanValue] BIT NULL, + [dateValue] DATETIMEOFFSET NULL, + [deleted] BIT, + [amendUserId] INT, + [amendDate] DATETIMEOFFSET +); +GO +CREATE TYPE UserEmploymentResponsibilityType AS TABLE +( + [userEmploymentResponsibilityId] INT, + [userEmploymentId] INT, + [additionalResponsibilityId] INT, + [deleted] BIT, + [amendUserId] INT +); +GO +CREATE TYPE UserEmploymentReferenceType AS TABLE +( + [userEmploymentReferenceId] INT, + [employmentReferenceTypeId] INT, + [userEmploymentId] INT, + [referenceValue] NVARCHAR(100), + [deleted] BIT, + [amendUserId] INT, + [amendDate] DATETIMEOFFSET +); +GO +CREATE TYPE dbo.UserAdminLocationType AS TABLE +( + [userId] INT, + [adminLocationId] INT, + [deleted] BIT, + [amendUserId] INT, + [amendDate] DATETIMEOFFSET, + [createdUserId] INT, + [createdDate] DATETIMEOFFSET +); +GO +CREATE TYPE dbo.MergeUser AS TABLE +( + [mergeUserId] INT, + [fromUserId] INT, + [intoUserId] INT, + [amendUserId] INT, + [createdDatetime] DATETIMEOFFSET +); +GO +CREATE TYPE dbo.EmploymentReferenceType AS TABLE +( + [EmploymentReferenceTypeId] INT, + [Title] NVARCHAR(255), + [RefAccess] NVARCHAR(255) +); +GO +CREATE TYPE [dbo].[UserProfileType] AS TABLE +( + [Id] INT , + [UserName] NVARCHAR(255) , + [EmailAddress] NVARCHAR(255) , + [AltEmailAddress] NVARCHAR(255) , + [FirstName] NVARCHAR(255) , + [LastName] NVARCHAR(255) , + [PreferredName] NVARCHAR(255) , + [Active] BIT , + [CreateDate] DATETIMEOFFSET, + [AmendUserId] INT , + [AmendDate] DATETIMEOFFSET, + [Deleted] BIT +); +GO +CREATE TYPE dbo.UserType_Hub AS TABLE +( + [Id] INT, + [UserName] NVARCHAR(250), + [countryId] INT, + [registrationCode] NVARCHAR(100), + [activeFromDate] DATETIMEOFFSET, + [activeToDate] DATETIMEOFFSET, + [passwordHash] NVARCHAR(500), + [mustChangeNextLogin] BIT, + [passwordLifeCounter] INT, + [securityLifeCounter] INT, + [RemoteLoginKey] NVARCHAR(250), + [RemoteLoginGuid] UNIQUEIDENTIFIER, + [RemoteLoginStart] DATETIMEOFFSET, + [RestrictToSSO] BIT, + [loginTimes] INT, + [loginWizardInProgress] BIT, + [lastLoginWizardCompleted] DATETIMEOFFSET, + [primaryUserEmploymentId] INT, + [regionId] INT, + [preferredTenantId] INT, + [CreateDate] DATETIMEOFFSET, + [AmendUserId] INT, + [AmendDate] DATETIMEOFFSET, + [Deleted] BIT +); +GO +CREATE TYPE dbo.UserTermsAndConditions AS TABLE +( + [userTermsAndConditionsId] INT, + [termsAndConditionsId] INT, + [userId] INT, + [acceptanceDate] DATETIMEOFFSET, + [deleted] BIT, + [amendUserID] INT, + [amendDate] DATETIMEOFFSET +); +GO +CREATE TYPE dbo.UserRoleUpgrade AS TABLE +( + [userRoleUpgradeId] INT, + [userId] INT, + [emailAddress] NVARCHAR(100), + [upgradeDate] DATETIMEOFFSET, + [deleted] BIT, + [createUserId] INT, + [createDate] DATETIMEOFFSET, + [amendUserId] INT, + [amendDate] DATETIMEOFFSET, + [userHistoryTypeId] INT +); +GO +CREATE TYPE dbo.UserHistory AS TABLE +( + [userHistoryId] INT, + [userHistoryTypeId] INT, + [userId] INT, + [createdDate] DATETIMEOFFSET, + [tenantId] INT +); +GO +CREATE TYPE dbo.UserHistoryType AS TABLE +( + UserHistoryTypeId INT, + [Description] NVARCHAR(100) +); +GO +CREATE TYPE dbo.UserPasswordValidationToken AS TABLE +( + userPasswordValidationTokenId INT, + hashedToken NVARCHAR(128), + salt NVARCHAR(128), + [lookup] NVARCHAR(128), + expiry DATETIMEOFFSET(7), + tenantId INT, + userId INT, + createdUserId INT, + createdDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.UserGroupTypeInputValidation AS TABLE +( + userGroupTypeInputValidationId INT, + userGroupId INT, + userGroupTypePrefix NVARCHAR(10), + userGroupTypeId INT, + validationTextValue NVARCHAR(1000), + validationMethod INT, + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7), + createdUserId INT, + createdDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.UserAttribute AS TABLE +( + userAttributeId INT, + userId INT, + attributeId INT, + intValue INT, + textValue NVARCHAR(255), + booleanValue BIT, + dateValue DATETIMEOFFSET(7), + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.TermsAndConditions AS TABLE +( + termsAndConditionsId INT, + createdDate DATETIMEOFFSET(7), + description NVARCHAR(512), + details ntext, + tenantId INT, + active BIT, + reportable BIT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.TenantUrl AS TABLE +( + tenantUrlId INT, + tenantId INT, + urlHostName NVARCHAR(128), + useHostForAuth BIT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Tenant AS TABLE +( + tenantId INT, + tenantCode NVARCHAR(100), + tenantName NVARCHAR(250), + tenantDescription NVARCHAR(1024), + showFullCatalogInfoMessageInd BIT, + catalogUrl NVARCHAR(500), + quickStartGuideUrl NVARCHAR(1024), + supportFormUrl NVARCHAR(500), + liveChatStatus NVARCHAR(50), + liveChatSnippet NVARCHAR(2048), + myElearningDefaultView NVARCHAR(100), + preLoginCatalogueDefaultView NVARCHAR(100), + postLoginCatalogueDefaultView NVARCHAR(100), + authSignInUrlRelative NVARCHAR(1024), + authSignOutUrlRelative NVARCHAR(500), + authSecret UNIQUEIDENTIFIER, + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.TenantSmtp AS TABLE +( + tenantId INT, + deliveryMethod NVARCHAR(128), + pickupDirectoryLocation NVARCHAR(256), + [from] NVARCHAR(256), + userName NVARCHAR(256), + [password] NVARCHAR(256), + enableSsl BIT, + host NVARCHAR(256), + port INT, + active BIT, + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.SystemSetting AS TABLE +( + systemSettingId INT, + systemSettingName NVARCHAR(50), + intValue INT, + textValue NVARCHAR(255), + booleanValue BIT, + dateValue DATETIMEOFFSET(7), + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.LoginWizardStageActivity AS TABLE +( + loginWizardStageActivityId INT, + loginWizardStageId INT, + userId INT, + activityDatetime DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.LoginWizardRule AS TABLE +( + loginWizardRuleId INT, + loginWizardStageId INT, + loginWizardRuleCategoryId INT, + description NVARCHAR(128), + reasonDisplayText NVARCHAR(1024), + activationPeriod INT, + required BIT, + active BIT, + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.LoginWizardStage AS TABLE +( + loginWizardStageId INT, + description NVARCHAR(128), + reasonDisplayText NVARCHAR(1024), + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.IPCountryLookup AS TABLE +( + fromIP NVARCHAR(50), + toIP NVARCHAR(50), + country NVARCHAR(100), + fromInt BIGINT, + toInt BIGINT +); +GO +CREATE TYPE dbo.EmailTemplateType AS TABLE +( + emailTemplateTypeId INT, + emailTemplateTypeName NVARCHAR(250), + availableTags NVARCHAR(MAX), + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Attribute AS TABLE +( + attributeId INT, + attributeTypeId INT, + attributeName NVARCHAR(250), + attributeAccess NVARCHAR(100), + attributeDescription NVARCHAR(500), + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.AttributeType AS TABLE +( + attributeTypeId INT, + attributeTypeName NVARCHAR(250), + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.GDCRegister AS TABLE +( + reg_number NVARCHAR(50), + Dentist bit, + Title NVARCHAR(50), + Surname NVARCHAR(200), + Forenames NVARCHAR(200), + honorifics NVARCHAR(200), + house_name NVARCHAR(200), + address_line1 NVARCHAR(200), + address_line2 NVARCHAR(200), + address_line3 NVARCHAR(200), + address_line4 NVARCHAR(200), + Town NVARCHAR(200), + County NVARCHAR(200), + PostCode NVARCHAR(50), + Country NVARCHAR(100), + regdate NVARCHAR(50), + qualifications NVARCHAR(1000), + dcp_titles NVARCHAR(500), + specialties NVARCHAR(500), + [condition] NVARCHAR(500), + suspension NVARCHAR(500), + dateProcessed DATETIMEOFFSET(7), + action NVARCHAR(50) +); +GO + +CREATE TYPE dbo.GMCLRMP AS TABLE +( + GMC_Ref_No NVARCHAR(50), + Surname NVARCHAR(200), + Given_Name NVARCHAR(200), + Year_Of_Qualification FLOAT, + GP_Register_Date NVARCHAR(100), + Registration_Status NVARCHAR(100), + Other_Names NVARCHAR(200), + dateProcessed DATETIME, + action NVARCHAR(50) +); +GO +CREATE TYPE dbo.Region AS TABLE +( + regionId INT, + regionName NVARCHAR(250), + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.UserEmployment AS TABLE +( + userEmploymentId INT, + userId INT, + jobRoleId INT, + specialtyId INT, + gradeId INT, + schoolId INT, + locationId INT, + medicalCouncilId INT, + medicalCouncilNo NVARCHAR(100), + startDate DATETIMEOFFSET(7), + endDate DATETIMEOFFSET(7), + deleted BIT, + archived BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Location AS TABLE +( + locationId INT, + locationCode NVARCHAR(50), + locationName NVARCHAR(250), + locationSubName NVARCHAR(250), + locationTypeId INT, + address1 NVARCHAR(250), + address2 NVARCHAR(250), + address3 NVARCHAR(250), + address4 NVARCHAR(250), + town NVARCHAR(250), + county NVARCHAR(250), + postCode NVARCHAR(50), + telephone NVARCHAR(50), + acute BIT, + ambulance BIT, + mental BIT, + care BIT, + mainHosp BIT, + nhsCode NVARCHAR(50), + parentId INT, + dataSource NVARCHAR(250), + active BIT, + importExclusion BIT, + depth INT, + lineage NVARCHAR(MAX), + created DATETIMEOFFSET(7), + updated DATETIMEOFFSET(7), + archivedDate DATETIMEOFFSET(7), + countryId INT, + iguId INT, + letbId INT, + ccgId INT, + healthServiceId INT, + healthBoardId INT, + primaryTrustId INT, + secondaryTrustId INT, + islandId INT, + otherNHSOrganisationId INT +); +GO +CREATE TYPE dbo.LocationType AS TABLE +( + locationTypeID INT, + locationType NVARCHAR(250), + countryId INT, + healthService NVARCHAR(250), + healthBoard NVARCHAR(250), + primaryTrust NVARCHAR(250), + secondaryTrust NVARCHAR(250) +); +GO +CREATE TYPE dbo.Country AS TABLE +( + countryId INT, + countryName NVARCHAR(250), + alpha2 NVARCHAR(10), + alpha3 NVARCHAR(10), + numeric NVARCHAR(10), + EUVatRate DECIMAL(10,4), + displayOrder INT, + deleted BIT, + amendUserId INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.School AS TABLE +( + schoolId INT, + deaneryId INT, + specialtyId INT, + schoolName NVARCHAR(250), + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Deanery AS TABLE +( + deaneryId INT, + deaneryName NVARCHAR(250), + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Grade AS TABLE +( + gradeId INT, + gradeName NVARCHAR(250), + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.Specialty AS TABLE +( + specialtyId INT, + specialtyName NVARCHAR(250), + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.JobRole AS TABLE +( + jobRoleId INT, + staffGroupId INT, + jobRoleName NVARCHAR(250), + medicalCouncilId INT, + displayOrder INT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.StaffGroup AS TABLE +( + staffGroupId INT, + staffGroupName NVARCHAR(250), + displayOrder INT, + internalUsersOnly BIT, + deleted BIT, + amendUserID INT, + amendDate DATETIMEOFFSET(7) +); +GO +CREATE TYPE dbo.MedicalCouncil AS TABLE +( + medicalCouncilId int, + medicalCouncilName nvarchar(50), + medicalCouncilCode nvarchar(50), + uploadPrefix nvarchar(3), + includeOnCerts bit , + deleted bit, + amendUserID int , + amendDate datetimeoffset(7) +); +GO +CREATE PROCEDURE [dbo].[AdfMergeattribute] + @attributeList dbo.Attribute READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[attributeTBL] ON; + + MERGE [elfh].[attributeTBL] AS target + USING @attributeList AS source + ON target.attributeId = source.attributeId + + WHEN MATCHED THEN + UPDATE SET + attributeTypeId = source.attributeTypeId, + attributeName = source.attributeName, + attributeAccess = source.attributeAccess, + attributeDescription = source.attributeDescription, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + attributeId, + attributeTypeId, + attributeName, + attributeAccess, + attributeDescription, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.attributeId, + source.attributeTypeId, + source.attributeName, + source.attributeAccess, + source.attributeDescription, + source.deleted, + source.amendUserId, + source.amendDate + ); + + SET IDENTITY_INSERT [elfh].[attributeTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattributeType.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattributeType.sql new file mode 100644 index 000000000..6b1930b57 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeattributeType.sql @@ -0,0 +1,45 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeattributeType] + @attributeTypeList dbo.AttributeType READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + + MERGE [elfh].[attributeTypeTBL] AS target + USING @attributeTypeList AS source + ON target.attributeTypeId = source.attributeTypeId + + WHEN MATCHED THEN + UPDATE SET + attributeTypeName = source.attributeTypeName, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + attributeTypeId, + attributeTypeName, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.attributeTypeId, + source.attributeTypeName, + source.deleted, + source.amendUserId, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergecountry.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergecountry.sql new file mode 100644 index 000000000..dbc50e13d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergecountry.sql @@ -0,0 +1,62 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +create PROCEDURE [dbo].[AdfMergecountry] + @countryList dbo.Country READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[countryTBL] ON; + + MERGE [elfh].[countryTBL] AS target + USING @countryList AS source + ON target.countryId = source.countryId + + WHEN MATCHED THEN + UPDATE SET + countryName = source.countryName, + alpha2 = source.alpha2, + alpha3 = source.alpha3, + numeric = source.numeric, + EUVatRate = source.EUVatRate, + displayOrder = source.displayOrder, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + countryId, + countryName, + alpha2, + alpha3, + numeric, + EUVatRate, + displayOrder, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.countryId, + source.countryName, + source.alpha2, + source.alpha3, + source.numeric, + source.EUVatRate, + source.displayOrder, + source.deleted, + source.amendUserId, + source.amendDate + ); + + SET IDENTITY_INSERT [elfh].[countryTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergedeanery.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergedeanery.sql new file mode 100644 index 000000000..6121f1941 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergedeanery.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergedeanery] + @deaneryList dbo.Deanery READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[deaneryTBL] ON; + MERGE [elfh].[deaneryTBL] AS target + USING @deaneryList AS source + ON target.deaneryId = source.deaneryId + + WHEN MATCHED THEN + UPDATE SET + deaneryName = source.deaneryName, + displayOrder = source.displayOrder, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + deaneryId, + deaneryName, + displayOrder, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.deaneryId, + source.deaneryName, + source.displayOrder, + source.deleted, + source.amendUserID, + source.amendDate + ); + SET IDENTITY_INSERT [elfh].[deaneryTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeemailTemplateType.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeemailTemplateType.sql new file mode 100644 index 000000000..b59c16fbd --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeemailTemplateType.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeemailTemplateType] + @emailTemplateTypeList dbo.EmailTemplateType READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[emailTemplateTypeTBL] AS target + USING @emailTemplateTypeList AS source + ON target.emailTemplateTypeId = source.emailTemplateTypeId + + WHEN MATCHED THEN + UPDATE SET + emailTemplateTypeName = source.emailTemplateTypeName, + availableTags = source.availableTags, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + emailTemplateTypeId, + emailTemplateTypeName, + availableTags, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.emailTemplateTypeId, + source.emailTemplateTypeName, + source.availableTags, + source.deleted, + source.amendUserID, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegdcRegister.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegdcRegister.sql new file mode 100644 index 000000000..e0878089a --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegdcRegister.sql @@ -0,0 +1,98 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergegdcRegister] + @gdcRegisterList dbo.GDCRegister READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [ELFH].[gdcRegisterTBL] AS target + USING @gdcRegisterList AS source + ON target.reg_number = source.reg_number + + WHEN MATCHED THEN + UPDATE SET + Dentist = source.Dentist, + Title = source.Title, + Surname = source.Surname, + Forenames = source.Forenames, + honorifics = source.honorifics, + house_name = source.house_name, + address_line1 = source.address_line1, + address_line2 = source.address_line2, + address_line3 = source.address_line3, + address_line4 = source.address_line4, + Town = source.Town, + County = source.County, + PostCode = source.PostCode, + Country = source.Country, + regdate = source.regdate, + qualifications = source.qualifications, + dcp_titles = source.dcp_titles, + specialties = source.specialties, + [condition] = source.[condition], + suspension = source.suspension, + dateProcessed = source.dateProcessed, + action = source.action + + WHEN NOT MATCHED THEN + INSERT ( + reg_number, + Dentist, + Title, + Surname, + Forenames, + honorifics, + house_name, + address_line1, + address_line2, + address_line3, + address_line4, + Town, + County, + PostCode, + Country, + regdate, + qualifications, + dcp_titles, + specialties, + [condition], + suspension, + dateProcessed, + action + ) + VALUES ( + source.reg_number, + source.Dentist, + source.Title, + source.Surname, + source.Forenames, + source.honorifics, + source.house_name, + source.address_line1, + source.address_line2, + source.address_line3, + source.address_line4, + source.Town, + source.County, + source.PostCode, + source.Country, + source.regdate, + source.qualifications, + source.dcp_titles, + source.specialties, + source.[condition], + source.suspension, + source.dateProcessed, + source.action + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegmclrmp.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegmclrmp.sql new file mode 100644 index 000000000..4f94ad397 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegmclrmp.sql @@ -0,0 +1,56 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergegmclrmp] + @gmclrmpList dbo.GMCLRMP READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[gmclrmpTBL] AS target + USING @gmclrmpList AS source + ON target.GMC_Ref_No = source.GMC_Ref_No + + WHEN MATCHED THEN + UPDATE SET + Surname = source.Surname, + Given_Name = source.Given_Name, + Year_Of_Qualification = source.Year_Of_Qualification, + GP_Register_Date = source.GP_Register_Date, + Registration_Status = source.Registration_Status, + Other_Names = source.Other_Names, + dateProcessed = source.dateProcessed, + action = source.action + + WHEN NOT MATCHED THEN + INSERT ( + GMC_Ref_No, + Surname, + Given_Name, + Year_Of_Qualification, + GP_Register_Date, + Registration_Status, + Other_Names, + dateProcessed, + action + ) + VALUES ( + source.GMC_Ref_No, + source.Surname, + source.Given_Name, + source.Year_Of_Qualification, + source.GP_Register_Date, + source.Registration_Status, + source.Other_Names, + source.dateProcessed, + source.action + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegrade.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegrade.sql new file mode 100644 index 000000000..8994639d9 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergegrade.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergegrade] + @gradeList dbo.Grade READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[gradeTBL] ON; + MERGE [elfh].[gradeTBL] AS target + USING @gradeList AS source + ON target.gradeId = source.gradeId + + WHEN MATCHED THEN + UPDATE SET + gradeName = source.gradeName + , displayOrder = source.displayOrder + , deleted = source.deleted + , amendUserID = source.amendUserID + , amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + gradeId + , gradeName + , displayOrder + , deleted + , amendUserID + , amendDate + ) + VALUES ( + source.gradeId + , source.gradeName + , source.displayOrder + , source.deleted + , source.amendUserID + , source.amendDate + ); + SET IDENTITY_INSERT [elfh].[gradeTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeipCountryLookup.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeipCountryLookup.sql new file mode 100644 index 000000000..bc982a2a8 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeipCountryLookup.sql @@ -0,0 +1,43 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeipCountryLookup] + @ipCountryLookupList dbo.IPCountryLookup READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[ipCountryLookupTBL] AS target + USING @ipCountryLookupList AS source + ON target.fromInt = source.fromInt AND target.toInt = source.toInt + + WHEN MATCHED THEN + UPDATE SET + fromIP = source.fromIP, + toIP = source.toIP, + country = source.country + + WHEN NOT MATCHED THEN + INSERT ( + fromIP, + toIP, + country, + fromInt, + toInt + ) + VALUES ( + source.fromIP, + source.toIP, + source.country, + source.fromInt, + source.toInt + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergejobRole.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergejobRole.sql new file mode 100644 index 000000000..8b36bf4e6 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergejobRole.sql @@ -0,0 +1,53 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergejobRole] + @jobRoleList dbo.JobRole READONLY -- table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[jobRoleTBL] ON; + MERGE [elfh].[jobRoleTBL] AS target + USING @jobRoleList AS source + ON target.jobRoleId = source.jobRoleId + + WHEN MATCHED THEN + UPDATE SET + staffGroupId = source.staffGroupId + , jobRoleName = source.jobRoleName + , medicalCouncilId = source.medicalCouncilId + , displayOrder = source.displayOrder + , deleted = source.deleted + , amendUserID = source.amendUserID + , amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + jobRoleId + , staffGroupId + , jobRoleName + , medicalCouncilId + , displayOrder + , deleted + , amendUserID + , amendDate + ) + VALUES ( + source.jobRoleId + , source.staffGroupId + , source.jobRoleName + , source.medicalCouncilId + , source.displayOrder + , source.deleted + , source.amendUserID + , source.amendDate + ); + SET IDENTITY_INSERT [elfh].[jobRoleTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocation.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocation.sql new file mode 100644 index 000000000..dda113cd5 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocation.sql @@ -0,0 +1,142 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergelocation] + @locationList dbo.Location READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + MERGE [elfh].[locationTBL] AS target + USING @locationList AS source + ON target.locationId = source.locationId + + WHEN MATCHED THEN + UPDATE SET + locationCode = source.locationCode, + locationName = source.locationName, + locationSubName = source.locationSubName, + locationTypeId = source.locationTypeId, + address1 = source.address1, + address2 = source.address2, + address3 = source.address3, + address4 = source.address4, + town = source.town, + county = source.county, + postCode = source.postCode, + telephone = source.telephone, + acute = source.acute, + ambulance = source.ambulance, + mental = source.mental, + care = source.care, + mainHosp = source.mainHosp, + nhsCode = source.nhsCode, + parentId = source.parentId, + dataSource = source.dataSource, + active = source.active, + importExclusion = source.importExclusion, + depth = source.depth, + lineage = source.lineage, + created = source.created, + updated = source.updated, + archivedDate = source.archivedDate, + countryId = source.countryId, + iguId = source.iguId, + letbId = source.letbId, + ccgId = source.ccgId, + healthServiceId = source.healthServiceId, + healthBoardId = source.healthBoardId, + primaryTrustId = source.primaryTrustId, + secondaryTrustId = source.secondaryTrustId, + islandId = source.islandId, + otherNHSOrganisationId = source.otherNHSOrganisationId + + WHEN NOT MATCHED THEN + INSERT ( + locationId, + locationCode, + locationName, + locationSubName, + locationTypeId, + address1, + address2, + address3, + address4, + town, + county, + postCode, + telephone, + acute, + ambulance, + mental, + care, + mainHosp, + nhsCode, + parentId, + dataSource, + active, + importExclusion, + depth, + lineage, + created, + updated, + archivedDate, + countryId, + iguId, + letbId, + ccgId, + healthServiceId, + healthBoardId, + primaryTrustId, + secondaryTrustId, + islandId, + otherNHSOrganisationId + ) + VALUES ( + source.locationId, + source.locationCode, + source.locationName, + source.locationSubName, + source.locationTypeId, + source.address1, + source.address2, + source.address3, + source.address4, + source.town, + source.county, + source.postCode, + source.telephone, + source.acute, + source.ambulance, + source.mental, + source.care, + source.mainHosp, + source.nhsCode, + source.parentId, + source.dataSource, + source.active, + source.importExclusion, + source.depth, + source.lineage, + source.created, + source.updated, + source.archivedDate, + source.countryId, + source.iguId, + source.letbId, + source.ccgId, + source.healthServiceId, + source.healthBoardId, + source.primaryTrustId, + source.secondaryTrustId, + source.islandId, + source.otherNHSOrganisationId + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocationType.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocationType.sql new file mode 100644 index 000000000..df660e586 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergelocationType.sql @@ -0,0 +1,55 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergelocationType] + @locationTypeList dbo.LocationType READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + + -- Enable explicit identity insert (if locationTypeID is an IDENTITY column) + SET IDENTITY_INSERT [elfh].[locationTypeTBL] ON; + + MERGE [elfh].[locationTypeTBL] AS target + USING @locationTypeList AS source + ON target.locationTypeID = source.locationTypeID + + WHEN MATCHED THEN + UPDATE SET + locationType = source.locationType, + countryId = source.countryId, + healthService = source.healthService, + healthBoard = source.healthBoard, + primaryTrust = source.primaryTrust, + secondaryTrust = source.secondaryTrust + + WHEN NOT MATCHED THEN + INSERT ( + locationTypeID, + locationType, + countryId, + healthService, + healthBoard, + primaryTrust, + secondaryTrust + ) + VALUES ( + source.locationTypeID, + source.locationType, + source.countryId, + source.healthService, + source.healthBoard, + source.primaryTrust, + source.secondaryTrust + ); + + -- Disable identity insert after operation + SET IDENTITY_INSERT [elfh].[locationTypeTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardRule.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardRule.sql new file mode 100644 index 000000000..53a4b8d44 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardRule.sql @@ -0,0 +1,60 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeloginWizardRule] + @loginWizardRuleList dbo.LoginWizardRule READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + MERGE [elfh].[loginWizardRuleTBL] AS target + USING @loginWizardRuleList AS source + ON target.loginWizardRuleId = source.loginWizardRuleId + + WHEN MATCHED THEN + UPDATE SET + loginWizardStageId = source.loginWizardStageId, + loginWizardRuleCategoryId = source.loginWizardRuleCategoryId, + description = source.description, + reasonDisplayText = source.reasonDisplayText, + activationPeriod = source.activationPeriod, + required = source.required, + active = source.active, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + loginWizardRuleId, + loginWizardStageId, + loginWizardRuleCategoryId, + description, + reasonDisplayText, + activationPeriod, + required, + active, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.loginWizardRuleId, + source.loginWizardStageId, + source.loginWizardRuleCategoryId, + source.description, + source.reasonDisplayText, + source.activationPeriod, + source.required, + source.active, + source.deleted, + source.amendUserId, + source.amendDate + ); +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStage.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStage.sql new file mode 100644 index 000000000..bcf50762b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStage.sql @@ -0,0 +1,46 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeloginWizardStage] + @loginWizardStageList dbo.LoginWizardStage READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + MERGE [elfh].[loginWizardStageTBL] AS target + USING @loginWizardStageList AS source + ON target.loginWizardStageId = source.loginWizardStageId + + WHEN MATCHED THEN + UPDATE SET + description = source.description, + reasonDisplayText = source.reasonDisplayText, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + loginWizardStageId, + description, + reasonDisplayText, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.loginWizardStageId, + source.description, + source.reasonDisplayText, + source.deleted, + source.amendUserId, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStageActivity.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStageActivity.sql new file mode 100644 index 000000000..ad1d56d86 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeloginWizardStageActivity.sql @@ -0,0 +1,43 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeloginWizardStageActivity] + @loginWizardStageActivityList dbo.LoginWizardStageActivity READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[loginWizardStageActivityTBL] ON; + MERGE [elfh].[loginWizardStageActivityTBL] AS target + USING @loginWizardStageActivityList AS source + ON target.loginWizardStageActivityId = source.loginWizardStageActivityId + + WHEN MATCHED THEN + UPDATE SET + loginWizardStageId = source.loginWizardStageId, + userId = source.userId, + activityDatetime = source.activityDatetime + + WHEN NOT MATCHED THEN + INSERT ( + loginWizardStageActivityId, + loginWizardStageId, + userId, + activityDatetime + ) + VALUES ( + source.loginWizardStageActivityId, + source.loginWizardStageId, + source.userId, + source.activityDatetime + ); + + SET IDENTITY_INSERT [elfh].[loginWizardStageActivityTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergemedicalCouncil.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergemedicalCouncil.sql new file mode 100644 index 000000000..4f2575378 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergemedicalCouncil.sql @@ -0,0 +1,50 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergemedicalCouncil] + @medicalCouncilList dbo.MedicalCouncil READONLY +AS +BEGIN + SET NOCOUNT ON; + MERGE [elfh].[medicalCouncilTBL] AS target + USING @medicalCouncilList AS source + ON target.medicalCouncilId = source.medicalCouncilId + WHEN MATCHED THEN + UPDATE SET + medicalCouncilName = source.medicalCouncilName + ,medicalCouncilCode = source.medicalCouncilCode + ,uploadPrefix = source.uploadPrefix + ,includeOnCerts = source.includeOnCerts + ,deleted = source.deleted + ,amendUserID = source.amendUserID + ,amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + medicalCouncilId + ,medicalCouncilName + ,medicalCouncilCode + ,uploadPrefix + ,includeOnCerts + ,deleted + ,amendUserID + ,amendDate + ) + VALUES ( + source.medicalCouncilId + ,source.medicalCouncilName + ,source.medicalCouncilCode + ,source.uploadPrefix + ,source.includeOnCerts + ,source.deleted + ,source.amendUserID + ,source.amendDate + ); +END +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeregion.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeregion.sql new file mode 100644 index 000000000..589f42112 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeregion.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeregion] + @regionList dbo.Region READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[regionTBL] AS target + USING @regionList AS source + ON target.regionId = source.regionId + + WHEN MATCHED THEN + UPDATE SET + regionName = source.regionName, + displayOrder = source.displayOrder, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + regionId, + regionName, + displayOrder, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.regionId, + source.regionName, + source.displayOrder, + source.deleted, + source.amendUserID, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeschool.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeschool.sql new file mode 100644 index 000000000..3e6cd502f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeschool.sql @@ -0,0 +1,53 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeschool] + @schoolList dbo.School READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[schoolTBL] ON; + MERGE [elfh].[schoolTBL] AS target + USING @schoolList AS source + ON target.schoolId = source.schoolId + + WHEN MATCHED THEN + UPDATE SET + deaneryId = source.deaneryId, + specialtyId = source.specialtyId, + schoolName = source.schoolName, + displayOrder = source.displayOrder, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + schoolId, + deaneryId, + specialtyId, + schoolName, + displayOrder, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.schoolId, + source.deaneryId, + source.specialtyId, + source.schoolName, + source.displayOrder, + source.deleted, + source.amendUserID, + source.amendDate + ); + SET IDENTITY_INSERT [elfh].[schoolTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergespecialty.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergespecialty.sql new file mode 100644 index 000000000..533476cdc --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergespecialty.sql @@ -0,0 +1,47 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergespecialty] + @specialtyList dbo.Specialty READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[specialtyTBL] ON; + MERGE [elfh].[specialtyTBL] AS target + USING @specialtyList AS source + ON target.specialtyId = source.specialtyId + + WHEN MATCHED THEN + UPDATE SET + specialtyName = source.specialtyName + , displayOrder = source.displayOrder + , deleted = source.deleted + , amendUserID = source.amendUserID + , amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + specialtyId + , specialtyName + , displayOrder + , deleted + , amendUserID + , amendDate + ) + VALUES ( + source.specialtyId + , source.specialtyName + , source.displayOrder + , source.deleted + , source.amendUserID + , source.amendDate + ); + SET IDENTITY_INSERT [elfh].[specialtyTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergestaffGroup.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergestaffGroup.sql new file mode 100644 index 000000000..d40f91c31 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergestaffGroup.sql @@ -0,0 +1,50 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergestaffGroup] + @staffGroupList dbo.StaffGroup READONLY -- your table type must exist +AS +BEGIN + SET NOCOUNT ON; + SET IDENTITY_INSERT [elfh].[staffGroupTBL] ON; + MERGE [elfh].[staffGroupTBL] AS target + USING @staffGroupList AS source + ON target.staffGroupId = source.staffGroupId + + WHEN MATCHED THEN + UPDATE SET + staffGroupName = source.staffGroupName + , displayOrder = source.displayOrder + , internalUsersOnly = source.internalUsersOnly + , deleted = source.deleted + , amendUserID = source.amendUserID + , amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + staffGroupId + , staffGroupName + , displayOrder + , internalUsersOnly + , deleted + , amendUserID + , amendDate + ) + VALUES ( + source.staffGroupId + , source.staffGroupName + , source.displayOrder + , source.internalUsersOnly + , source.deleted + , source.amendUserID + , source.amendDate + ); + SET IDENTITY_INSERT [elfh].[staffGroupTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergesystemSetting.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergesystemSetting.sql new file mode 100644 index 000000000..580e839fd --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergesystemSetting.sql @@ -0,0 +1,56 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergesystemSetting] + @systemSettingList dbo.SystemSetting READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [ELFH].[systemSettingTBL] AS target + USING @systemSettingList AS source + ON target.systemSettingId = source.systemSettingId + + WHEN MATCHED THEN + UPDATE SET + systemSettingName = source.systemSettingName, + intValue = source.intValue, + textValue = source.textValue, + booleanValue = source.booleanValue, + dateValue = source.dateValue, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + systemSettingId, + systemSettingName, + intValue, + textValue, + booleanValue, + dateValue, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.systemSettingId, + source.systemSettingName, + source.intValue, + source.textValue, + source.booleanValue, + source.dateValue, + source.deleted, + source.amendUserId, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantSmtp.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantSmtp.sql new file mode 100644 index 000000000..f6f44bc0e --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantSmtp.sql @@ -0,0 +1,68 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergetenantSmtp] + @tenantSmtpList dbo.TenantSmtp READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[tenantSmtpTBL] AS target + USING @tenantSmtpList AS source + ON target.tenantId = source.tenantId + + WHEN MATCHED THEN + UPDATE SET + deliveryMethod = source.deliveryMethod, + pickupDirectoryLocation = source.pickupDirectoryLocation, + [from] = source.[from], + userName = source.userName, + [password] = source.[password], + enableSsl = source.enableSsl, + host = source.host, + port = source.port, + active = source.active, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + tenantId, + deliveryMethod, + pickupDirectoryLocation, + [from], + userName, + [password], + enableSsl, + host, + port, + active, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.tenantId, + source.deliveryMethod, + source.pickupDirectoryLocation, + source.[from], + source.userName, + source.[password], + source.enableSsl, + source.host, + source.port, + source.active, + source.deleted, + source.amendUserId, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenants.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenants.sql new file mode 100644 index 000000000..4dc91fb59 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenants.sql @@ -0,0 +1,86 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergetenants] + @tenantList dbo.Tenant READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + MERGE [elfh].[tenantTBL] AS target + USING @tenantList AS source + ON target.tenantId = source.tenantId + + WHEN MATCHED THEN + UPDATE SET + tenantCode = source.tenantCode, + tenantName = source.tenantName, + tenantDescription = source.tenantDescription, + showFullCatalogInfoMessageInd = source.showFullCatalogInfoMessageInd, + catalogUrl = source.catalogUrl, + quickStartGuideUrl = source.quickStartGuideUrl, + supportFormUrl = source.supportFormUrl, + liveChatStatus = source.liveChatStatus, + liveChatSnippet = source.liveChatSnippet, + myElearningDefaultView = source.myElearningDefaultView, + preLoginCatalogueDefaultView = source.preLoginCatalogueDefaultView, + postLoginCatalogueDefaultView = source.postLoginCatalogueDefaultView, + authSignInUrlRelative = source.authSignInUrlRelative, + authSignOutUrlRelative = source.authSignOutUrlRelative, + authSecret = source.authSecret, + deleted = source.deleted, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + tenantId, + tenantCode, + tenantName, + tenantDescription, + showFullCatalogInfoMessageInd, + catalogUrl, + quickStartGuideUrl, + supportFormUrl, + liveChatStatus, + liveChatSnippet, + myElearningDefaultView, + preLoginCatalogueDefaultView, + postLoginCatalogueDefaultView, + authSignInUrlRelative, + authSignOutUrlRelative, + authSecret, + deleted, + amendUserId, + amendDate + ) + VALUES ( + source.tenantId, + source.tenantCode, + source.tenantName, + source.tenantDescription, + source.showFullCatalogInfoMessageInd, + source.catalogUrl, + source.quickStartGuideUrl, + source.supportFormUrl, + source.liveChatStatus, + source.liveChatSnippet, + source.myElearningDefaultView, + source.preLoginCatalogueDefaultView, + source.postLoginCatalogueDefaultView, + source.authSignInUrlRelative, + source.authSignOutUrlRelative, + source.authSecret, + source.deleted, + source.amendUserId, + source.amendDate + ); + +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantsUrl.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantsUrl.sql new file mode 100644 index 000000000..83408a426 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetenantsUrl.sql @@ -0,0 +1,55 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergetenantsUrl] + @tenantUrlList dbo.TenantUrl READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if tenantUrlId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[tenantUrlTBL] ON; + + MERGE [elfh].[tenantUrlTBL] AS target + USING @tenantUrlList AS source + ON target.tenantUrlId = source.tenantUrlId + + WHEN MATCHED THEN + UPDATE SET + tenantId = source.tenantId, + urlHostName = source.urlHostName, + useHostForAuth = source.useHostForAuth, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + tenantUrlId, + tenantId, + urlHostName, + useHostForAuth, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.tenantUrlId, + source.tenantId, + source.urlHostName, + source.useHostForAuth, + source.deleted, + source.amendUserID, + source.amendDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[tenantUrlTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetermsAndConditions.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetermsAndConditions.sql new file mode 100644 index 000000000..b01ba6b4a --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergetermsAndConditions.sql @@ -0,0 +1,64 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergetermsAndConditions] + @termsAndConditionsList dbo.TermsAndConditions READONLY -- Table-valued parameter +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if termsAndConditionsId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[termsAndConditionsTBL] ON; + + MERGE [elfh].[termsAndConditionsTBL] AS target + USING @termsAndConditionsList AS source + ON target.termsAndConditionsId = source.termsAndConditionsId + + WHEN MATCHED THEN + UPDATE SET + createdDate = source.createdDate, + description = source.description, + details = source.details, + tenantId = source.tenantId, + active = source.active, + reportable = source.reportable, + deleted = source.deleted, + amendUserID = source.amendUserID, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + termsAndConditionsId, + createdDate, + description, + details, + tenantId, + active, + reportable, + deleted, + amendUserID, + amendDate + ) + VALUES ( + source.termsAndConditionsId, + source.createdDate, + source.description, + source.details, + source.tenantId, + source.active, + source.reportable, + source.deleted, + source.amendUserID, + source.amendDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[termsAndConditionsTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserEmployment.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserEmployment.sql new file mode 100644 index 000000000..7e4dc75e7 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserEmployment.sql @@ -0,0 +1,77 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeuserEmployment] + @userEmploymentList dbo.UserEmployment READONLY -- Table-valued parameter type +AS +BEGIN + SET NOCOUNT ON; + + SET IDENTITY_INSERT [elfh].[userEmploymentTBL] ON; + MERGE [elfh].[userEmploymentTBL] AS target + USING @userEmploymentList AS source + ON target.userEmploymentId = source.userEmploymentId + + WHEN MATCHED THEN + UPDATE SET + userId = source.userId, + jobRoleId = source.jobRoleId, + specialtyId = source.specialtyId, + gradeId = source.gradeId, + schoolId = source.schoolId, + locationId = source.locationId, + medicalCouncilId = source.medicalCouncilId, + medicalCouncilNo = source.medicalCouncilNo, + startDate = source.startDate, + endDate = source.endDate, + deleted = source.deleted, + archived = source.archived, + amendUserId = source.amendUserId, + amendDate = source.amendDate + + WHEN NOT MATCHED THEN + INSERT ( + userEmploymentId, + userId, + jobRoleId, + specialtyId, + gradeId, + schoolId, + locationId, + medicalCouncilId, + medicalCouncilNo, + startDate, + endDate, + deleted, + archived, + amendUserId, + amendDate + ) + VALUES ( + source.userEmploymentId, + source.userId, + source.jobRoleId, + source.specialtyId, + source.gradeId, + source.schoolId, + source.locationId, + source.medicalCouncilId, + source.medicalCouncilNo, + source.startDate, + source.endDate, + source.deleted, + source.archived, + source.amendUserId, + source.amendDate + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userEmploymentTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserTermsAndConditions.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserTermsAndConditions.sql new file mode 100644 index 000000000..946e1bbb1 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/AdfMergeuserTermsAndConditions.sql @@ -0,0 +1,54 @@ +------------------------------------------------------------------------------- +-- Author Sarathlal +-- Created 04-11-2025 +-- Purpose ELFH-LH Data sync +-- +-- Modification History +-- +-- 04-11-2025 Sarathlal Initial Revision +------------------------------------------------------------------------------- +CREATE PROCEDURE [dbo].[AdfMergeUserTermsAndConditions] + @userTermsAndConditionsList dbo.UserTermsAndConditions READONLY +AS +BEGIN + SET NOCOUNT ON; + + -- Enable identity insert if userTermsAndConditionsId is an IDENTITY column + SET IDENTITY_INSERT [elfh].[userTermsAndConditionsTBL] ON; + MERGE [elfh].[userTermsAndConditionsTBL] AS target + USING @userTermsAndConditionsList AS source + ON target.[userTermsAndConditionsId] = source.[userTermsAndConditionsId] + + WHEN MATCHED THEN + UPDATE SET + [termsAndConditionsId] = source.[termsAndConditionsId], + [userId] = source.[userId], + [acceptanceDate] = source.[acceptanceDate], + [deleted] = source.[deleted], + [amendUserID] = source.[amendUserID], + [amendDate] = source.[amendDate] + + WHEN NOT MATCHED THEN + INSERT ( + [userTermsAndConditionsId], + [termsAndConditionsId], + [userId], + [acceptanceDate], + [deleted], + [amendUserID], + [amendDate] + ) + VALUES ( + source.[userTermsAndConditionsId], + source.[termsAndConditionsId], + source.[userId], + source.[acceptanceDate], + source.[deleted], + source.[amendUserID], + source.[amendDate] + ); + + -- Disable identity insert + SET IDENTITY_INSERT [elfh].[userTermsAndConditionsTBL] OFF; +END +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/proc_UpdateLastSyncTimeAdf.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/proc_UpdateLastSyncTimeAdf.sql new file mode 100644 index 000000000..c7896b6b2 Binary files /dev/null and b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Adf/proc_UpdateLastSyncTimeAdf.sql differ diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/GetUserByOpenAthensId.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/GetUserByOpenAthensId.sql new file mode 100644 index 000000000..bb0687719 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/GetUserByOpenAthensId.sql @@ -0,0 +1,23 @@ +----------------------------------------------------------------------------------------------- +-- Tobi Awe 31/10/2025 - Initial Version. +-- converted elfh efcore query to sp in LH database +------------------------------------------------------------------------------------------------ + +CREATE PROCEDURE elfh.proc_GetUserByOpenAthensId + @OpenAthensId NVARCHAR(255) +AS +BEGIN + SET NOCOUNT ON; + + SELECT + u.Id, + u.UserName, + up.FirstName, + up.LastName, + up.EmailAddress, + u.AmendDate AS LastUpdated + FROM hub.[user] u + INNER JOIN hub.userprofile up ON up.Id = u.Id + INNER JOIN elfh.userAttributeTBL ua ON ua.UserId = u.Id + WHERE ua.TextValue = @OpenAthensId AND u.deleted = 0 AND up.deleted = 0 AND ua.deleted = 0; +END diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/LinkEmploymentRecordToUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/LinkEmploymentRecordToUser.sql new file mode 100644 index 000000000..0f4f670ba --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/LinkEmploymentRecordToUser.sql @@ -0,0 +1,36 @@ +----------------------------------------------------------------------------------------------- +-- Mark Avey 11/06/2020 - Initial Version. +-- Update the UserTBL record with the primaryUserEmploymentId from userEmploymentTBL +------------------------------------------------------------------------------------------------ +CREATE PROCEDURE [elfh].[proc_LinkEmploymentRecordToUser] +( + @userId int +) +AS +BEGIN + BEGIN TRANSACTION + BEGIN TRY + SET NOCOUNT OFF + + UPDATE [hub].[User] + SET primaryUserEmploymentId = (SELECT userEmploymentId FROM [elfh].[userEmploymentTBL] WHERE userId = @userId) + WHERE Id = @userId + + END TRY + + BEGIN CATCH + SELECT + ERROR_NUMBER() AS ErrorNumber + ,ERROR_SEVERITY() AS ErrorSeverity + ,ERROR_STATE() AS ErrorState + ,ERROR_PROCEDURE() AS ErrorProcedure + ,ERROR_LINE() AS ErrorLine + ,ERROR_MESSAGE() AS ErrorMessage; + + IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION + END CATCH + + IF @@TRANCOUNT > 0 COMMIT TRANSACTION + + RETURN @@ERROR + END \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserDetailForAuthenticationByUserName.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserDetailForAuthenticationByUserName.sql new file mode 100644 index 000000000..70ecd918b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserDetailForAuthenticationByUserName.sql @@ -0,0 +1,49 @@ +------------------------------------------------------------------------- +-- Jignesh Jethwani 27 Sept 2023 - Initial version +-- Tobi Awe 24 Sept 2025 - swapped elfh user table to hub user table +-------------------------------------------------------------------------- +CREATE PROCEDURE [elfh].[proc_UserDetailForAuthenticationByUserName] +( + @userName varchar(100) +) +AS +BEGIN + SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED + SET NOCOUNT ON + DECLARE @Err int + DECLARE @false bit + SET @false = 0 + SELECT elfhuser.Id as Id, + elfhuser.userName, + ISNULL(elfhuser.passwordHash, '') AS 'passwordHash', + elfhuser.RestrictToSSO, + up.Active, + elfhuser.activeFromDate, + elfhuser.activeToDate, + elfhuser.passwordLifeCounter, + userAttribData.userAttributeId as OpenAthensUserAttributeId + FROM + [hub].[User] elfhuser + INNER JOIN hub.UserProfile up + ON elfhuser.Id = up.Id + OUTER APPLY + ( + SELECT + TOP 1 userAttrib.userAttributeId + FROM + elfh.userAttributeTBL userAttrib + INNER Join + elfh.attributeTBL attrib ON userAttrib.attributeId = attrib.attributeId AND lower(attrib.attributeName) = 'openathens_userid' AND userAttrib.deleted = 0 + WHERE + userAttrib.userId = elfhuser.Id + ) userAttribData + WHERE + elfhuser.userName = @userName + AND + elfhuser.deleted = 0 + AND + up.deleted = 0 + + SET @Err = @@Error + RETURN @Err +END \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryAttributeSave.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryAttributeSave.sql new file mode 100644 index 000000000..7ecb39048 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryAttributeSave.sql @@ -0,0 +1,89 @@ + +-------------------------------------------------------------------------- +-- Jignesh Jethwani 02-03-2018 Initial version +-- Jignesh Jethwani 02-10-2023 TD-2913, performance improvement, added no lock to select statement +-- Tobi Awe 24-09-2025 Updated table schema +-------------------------------------------------------------------------- +CREATE PROCEDURE [elfh].[proc_UserHistoryAttributeSave] +( + @userHistoryAttributeId int OUTPUT, + @userHistoryId int, + @attributeId int, + @intValue int, + @textValue nvarchar(255), + @booleanValue bit, + @dateValue datetimeoffset, + @deleted bit, + @amendUserId int, + @amendDate datetimeoffset +) +AS +BEGIN + DECLARE @currentIntValue int + DECLARE @currentTextValue nvarchar(255) + DECLARE @currentBooleanValue bit + DECLARE @currentDateValue datetimeoffset + SELECT + @userHistoryAttributeId = userHistoryAttributeId, + @currentIntValue = intValue, + @currentTextValue = textValue, + @currentBooleanValue = booleanValue, + @currentDateValue = dateValue + FROM + elfh.userHistoryAttributeTBL WITH (NOLOCK) + WHERE + userHistoryId = @userHistoryId + AND + attributeId = @attributeId + IF @userHistoryAttributeId IS NULL + BEGIN + IF @intValue IS NOT NULL + OR ISNULL(@textValue, '') != '' + OR @booleanValue IS NOT NULL + OR @dateValue IS NOT NULL + BEGIN + INSERT INTO elfh.userHistoryAttributeTBL(userHistoryId, + attributeId, + intValue, + textValue, + booleanValue, + dateValue, + deleted, + amendUserId, + amendDate) + SELECT + userHistoryId = @userHistoryId, + attributeId = @attributeId, + intValue = @intValue, + textValue = @textValue, + booleanValue = @booleanValue, + dateValue = @dateValue, + deleted = @deleted, + amendUserId = @amendUserId, + @amendDate + SELECT @userHistoryAttributeId = SCOPE_IDENTITY() + END + END + ELSE + BEGIN + -- Only update when an Attribute Value has changed + IF (@intValue != @currentIntValue + OR ISNULL(@textValue, '') != ISNULL(@currentTextValue,'') + OR @booleanValue != @currentBooleanValue + OR @dateValue != @currentDateValue) + BEGIN + UPDATE + elfh.userHistoryAttributeTBL + SET + intValue = @intValue, + textValue = @textValue, + booleanValue = @booleanValue, + dateValue = @dateValue, + deleted = @deleted, + amendUserId = @amendUserId, + amendDate = @amendDate + WHERE + userHistoryAttributeId = @userHistoryAttributeId + END + END +END diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryInsert.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryInsert.sql new file mode 100644 index 000000000..f972aa05b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryInsert.sql @@ -0,0 +1,143 @@ + +-------------------------------------------------------------------------- +-- Chris Bain 08 Aug 2014 - Initial Build +-- Killian Davies 12 Aug 2015 - Added userAgent info (for Login history event) +-- Chris Bain 18 Nov 2016 - Added tenant Id +-- Jignesh Jethwani 02 Mar 2018 - Save details to User History Attribute, add url referer +-------------------------------------------------------------------------- +CREATE PROCEDURE [elfh].[proc_UserHistoryInsert] + @userId int = 0, + @historyTypeId int, + @detailedInfo NVARCHAR(1000) = NULL, + @userAgent NVARCHAR(1000) = NULL, + @browserName NVARCHAR(1000) = NULL, + @browserVersion NVARCHAR(1000) = NULL, + @urlReferer NVARCHAR(1000) = NULL, + @loginIP NVARCHAR(50) = NULL, + @loginSuccessFul bit = NULL, + @tenantId INT, + @amendUserId INT, + @amendDate DATETIMEOFFSET = NULL +AS +BEGIN + + DECLARE @UserHistoryId int + DECLARE @detailInfoAttributeId int, @userAgentAttributeId int, @browserNameAttributeId int, @browserVersionAttributeId int, @urlRefererAttributeId int, @loginSuccessFulAttributeId int + SET @amendDate = CoalEsce(@amendDate,SysDateTimeOffset()) + + INSERT INTO userHistoryTBL (userId, userHistoryTypeId, tenantId,createdDate) + VALUES (@userId, @historyTypeId, @tenantId, @amendDate) + + + SET @UserHistoryId = CAST(SCOPE_IDENTITY() AS int) + + SELECT @detailInfoAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_DetailedInfo' AND deleted = 0 + SELECT @userAgentAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_UserAgent' AND deleted = 0 + SELECT @browserNameAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_BrowserName' AND deleted = 0 + SELECT @browserVersionAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_BrowserVersion' AND deleted = 0 + SELECT @urlRefererAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_UrlReferer' AND deleted = 0 + SELECT @loginSuccessFulAttributeId = attributeId FROM [elfh].[attributeTBL] WHERE [attributeName] = 'UserHistory_LoginSuccessful' AND deleted = 0 + + -- DetailedInfo + IF @detailInfoAttributeId > 0 AND @detailedInfo IS NOT NULL + BEGIN + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @detailInfoAttributeId, + NULL, + @detailedInfo, -- textValue, + NULL, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + END + + -- User Agent + IF @userAgentAttributeId > 0 AND @userAgent IS NOT NULL + BEGIN + + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @userAgentAttributeId, + NULL, -- intValue + @userAgent, -- textValue, + NULL, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + END + + -- Browser Name + IF @browserNameAttributeId > 0 AND @browserName IS NOT NULL + BEGIN + + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @browserNameAttributeId, + NULL, -- intValue + @browserName, -- textValue, + NULL, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + + END + + -- Browser Version + IF @browserVersionAttributeId > 0 AND @browserVersion IS NOT NULL + BEGIN + + + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @browserVersionAttributeId, + NULL, -- intValue + @browserVersion, + NULL, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + END + + + -- Url Referer + IF @urlRefererAttributeId > 0 AND @urlReferer IS NOT NULL + BEGIN + + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @urlRefererAttributeId, + NULL, -- intValue + @urlReferer, -- textValue, + NULL, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + + END + + + -- Login SuccessFul + IF @loginSuccessFulAttributeId > 0 AND @loginSuccessFul IS NOT NULL + BEGIN + + EXECUTE [elfh].[proc_UserHistoryAttributeSave] null, + @UserHistoryId, + @loginSuccessFulAttributeId, + NULL, -- intValue + @loginIP, -- textValue, + @loginSuccessFul, -- booleanValue, + NULL, -- dateValue, + 0, -- deleted + @amendUserId, + @amendDate + + END + + +END \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForLearningHubUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForLearningHubUser.sql new file mode 100644 index 000000000..7889a609b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForLearningHubUser.sql @@ -0,0 +1,50 @@ +-------------------------------------------------------------------------------- +-- Killian Davies 08-February-2021 Initial Revision - services LH user history +-------------------------------------------------------------------------------- +CREATE PROCEDURE [elfh].[proc_UserHistoryLoadForLearningHubUser] + @userId int, + @startPage int=1, + @PageSize float=10.0, + @TotalResults int output +AS + DECLARE @History Table(RowNumber int, userHistoryId int) + + DECLARE @ItemsReturned INT + DECLARE @StartRow INT + DECLARE @EndRow INT + SET @StartRow = ((@startPage - 1) * @PageSize) + SET @EndRow = (@startPage * @PageSize) + 1 + + INSERT INTO @History + SELECT + ROW_NUMBER() OVER( ORDER BY [userHistoryId] DESC) as RowNumber, + userHistoryId + FROM + userHistoryTBL + WHERE + userId = @userId + ORDER BY + createdDate DESC + + -- Determine the number of items in the search result set + SELECT + @TotalResults = Count(userHistoryId) + FROM + @History + + SELECT + uh.*, + uht.[Description], + ISNULL(t.tenantName,'Unknown') as tenantName + FROM userHistoryVW uh + INNER JOIN @History h ON h.userHistoryId = uh.userHistoryId + INNER JOIN userHistoryTypeTBL uht ON uht.UserHistoryTypeId = uh.userHistoryTypeId + LEFT JOIN tenantTBL t ON t.tenantId = uh.tenantId + WHERE + h.RowNumber > @StartRow + AND + h.RowNumber < @EndRow + ORDER BY + h.RowNumber ASC + +RETURN 0 diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForUser.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForUser.sql new file mode 100644 index 000000000..69e061a00 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Elfh/UserHistoryLoadForUser.sql @@ -0,0 +1,55 @@ +-------------------------------------------------------------------------------- +-- Jignesh Jethwani 05 Mar 2018 - Updated, moved userHistory to Attribute Table +-- Killian Davies 30 Oct 2019 - Perf improvement - modified to use table rather than view +-------------------------------------------------------------------------------- + +CREATE PROCEDURE [elfh].[proc_UserHistoryLoadForUser] + @userId int, + @startPage int=1, + @PageSize float=10.0, + @PagesReturned int output +AS + DECLARE @History Table(RowNumber int, userHistoryId int) + + DECLARE @ItemsReturned INT + DECLARE @StartRow INT + DECLARE @EndRow INT + SET @StartRow = ((@startPage - 1) * @PageSize) + SET @EndRow = (@startPage * @PageSize) + 1 + + INSERT INTO @History + SELECT + ROW_NUMBER() OVER( ORDER BY [userHistoryId] DESC) as RowNumber, + userHistoryId + FROM + userHistoryTBL + WHERE + userId = @userId + ORDER BY + createdDate DESC + + -- Determine the number of items in the search result set + SELECT + @ItemsReturned = Count(userHistoryId) + FROM + @History + + SET @PagesReturned = CEILING(@ItemsReturned / @PageSize); + + + SELECT + uh.*, + uht.[Description], + ISNULL(t.tenantName,'Unknown') as tenantName + FROM userHistoryVW uh + INNER JOIN @History h ON h.userHistoryId = uh.userHistoryId + INNER JOIN userHistoryTypeTBL uht ON uht.UserHistoryTypeId = uh.userHistoryTypeId + LEFT JOIN tenantTBL t ON t.tenantId = uh.tenantId + WHERE + h.RowNumber > @StartRow + AND + h.RowNumber < @EndRow + ORDER BY + h.RowNumber ASC + +RETURN 0 diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/CatalogueNodeVersionCategoryCreate.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/CatalogueNodeVersionCategoryCreate.sql new file mode 100644 index 000000000..cd0fa408f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/CatalogueNodeVersionCategoryCreate.sql @@ -0,0 +1,51 @@ +------------------------------------------------------------------------------- +-- Author SA +-- Created 14-10-2025 +-- Purpose Creates a Catalogue NodeVersion Category. +-- +-- Modification History +-- +-- 14-10-2025 SA Initial Revision. +------------------------------------------------------------------------------- +CREATE PROCEDURE [hierarchy].[CatalogueNodeVersionCategoryCreate] +( + @userId INT, + @CatalogueNodeVersionId INT, + @CategoryId INT, + @UserTimezoneOffset int = NULL +) + +AS +BEGIN + DECLARE @AmendDate datetimeoffset(7) = ISNULL(TODATETIMEOFFSET(DATEADD(mi, @UserTimezoneOffset, GETUTCDATE()), @UserTimezoneOffset), SYSDATETIMEOFFSET()) + IF EXISTS (SELECT 1 + FROM [hierarchy].[CatalogueNodeVersionCategory] + WHERE CatalogueNodeVersionId = @CatalogueNodeVersionId AND deleted =0 + ) + BEGIN + UPDATE [hierarchy].[CatalogueNodeVersionCategory] + SET + Deleted = 1, + AmendDate = @AmendDate, + AmendUserId = @UserId + WHERE + CatalogueNodeVersionId = @CatalogueNodeVersionId + END + + INSERT INTO [hierarchy].[CatalogueNodeVersionCategory] + ([CatalogueNodeVersionId] + ,[CategoryId] + ,[Deleted] + ,[CreateUserId] + ,[CreateDate] + ,[AmendUserId] + ,[AmendDate]) + VALUES + (@CatalogueNodeVersionId + ,@CategoryId + ,0 + ,@userId + ,@AmendDate + ,@userId + ,@AmendDate) +END \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/RemoveCatalogueCategory.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/RemoveCatalogueCategory.sql new file mode 100644 index 000000000..e699db010 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/RemoveCatalogueCategory.sql @@ -0,0 +1,34 @@ +------------------------------------------------------------------------------- +-- Author SA +-- Created 14-10-2025 +-- Purpose Removes a Catalogue NodeVersion Category. +-- +-- Modification History +-- +-- 05-11-2025 SA Initial Revision. +------------------------------------------------------------------------------- +CREATE PROCEDURE [hierarchy].[RemoveCatalogueCategory] +( + @userId INT, + @CatalogueNodeVersionId INT, + @CategoryId INT, + @UserTimezoneOffset int = NULL +) + +AS +BEGIN + DECLARE @AmendDate datetimeoffset(7) = ISNULL(TODATETIMEOFFSET(DATEADD(mi, @UserTimezoneOffset, GETUTCDATE()), @UserTimezoneOffset), SYSDATETIMEOFFSET()) + IF EXISTS (SELECT 1 + FROM [hierarchy].[CatalogueNodeVersionCategory] + WHERE CatalogueNodeVersionId = @CatalogueNodeVersionId AND deleted =0 + ) + BEGIN + UPDATE [hierarchy].[CatalogueNodeVersionCategory] + SET + Deleted = 1, + AmendDate = @AmendDate, + AmendUserId = @UserId + WHERE + CatalogueNodeVersionId = @CatalogueNodeVersionId + END +END \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Adf/ADFSyncMetadata.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Adf/ADFSyncMetadata.sql new file mode 100644 index 000000000..c39c5980b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Adf/ADFSyncMetadata.sql @@ -0,0 +1,7 @@ +CREATE TABLE ADFSyncMetadata ( + SyncDirection VARCHAR(50), -- e.g., 'ELFHtoLH' or 'LHtoELFH' + TableName VARCHAR(100), -- e.g., 'userTBL_Test', 'departmentTBL' + LastSyncTime DATETIME2, + PRIMARY KEY (SyncDirection, TableName) +); +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTBL.sql new file mode 100644 index 000000000..69fffa30b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTBL.sql @@ -0,0 +1,31 @@ +CREATE TABLE [elfh].[attributeTBL]( + [attributeId] [int] IDENTITY(1,1) NOT NULL, + [attributeTypeId] [int] NOT NULL, + [attributeName] [nvarchar](50) NOT NULL, + [attributeAccess] [tinyint] NOT NULL, + [attributeDescription] [nvarchar](400) NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_attributeTBL] PRIMARY KEY CLUSTERED +( + [attributeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[attributeTBL] ADD DEFAULT ((0)) FOR [attributeAccess] +GO + +ALTER TABLE [elfh].[attributeTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[attributeTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[attributeTBL] WITH CHECK ADD CONSTRAINT [FK_attributeTBL_attributeTypeId] FOREIGN KEY([attributeTypeId]) +REFERENCES [elfh].[attributeTypeTBL] ([attributeTypeId]) +GO + +ALTER TABLE [elfh].[attributeTBL] CHECK CONSTRAINT [FK_attributeTBL_attributeTypeId] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTypeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTypeTBL.sql new file mode 100644 index 000000000..39a87b055 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/AttributeTypeTBL.sql @@ -0,0 +1,18 @@ +CREATE TABLE [elfh].[attributeTypeTBL]( + [attributeTypeId] [int] NOT NULL, + [attributeTypeName] [nvarchar](50) NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_attributeTypeTBL] PRIMARY KEY CLUSTERED +( + [attributeTypeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[attributeTypeTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[attributeTypeTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/CountryTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/CountryTBL.sql new file mode 100644 index 000000000..2adf7cc35 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/CountryTBL.sql @@ -0,0 +1,24 @@ +CREATE TABLE [elfh].[countryTBL]( + [countryId] [int] IDENTITY(1,1) NOT NULL, + [countryName] [nvarchar](50) NULL, + [alpha2] [nvarchar](2) NULL, + [alpha3] [nvarchar](3) NULL, + [numeric] [nvarchar](3) NULL, + [EUVatRate] [float] NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_countryTBL] PRIMARY KEY CLUSTERED +( + [countryId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[countryTBL] ADD DEFAULT ((0)) FOR [EUVatRate] +GO + +ALTER TABLE [elfh].[countryTBL] ADD CONSTRAINT [DF_countryTBL_displayOrder] DEFAULT ((0)) FOR [displayOrder] +GO + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/DeaneryTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/DeaneryTBL.sql new file mode 100644 index 000000000..bc2f91bef --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/DeaneryTBL.sql @@ -0,0 +1,13 @@ +CREATE TABLE [elfh].[deaneryTBL]( + [deaneryId] [int] IDENTITY(1,1) NOT NULL, + [deaneryName] [nvarchar](50) NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_deaneryTBL] PRIMARY KEY CLUSTERED +( + [deaneryId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTBL.sql new file mode 100644 index 000000000..18210ed54 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTBL.sql @@ -0,0 +1,30 @@ +CREATE TABLE [elfh].[emailTemplateTBL]( + [emailTemplateId] [int] IDENTITY(1,1) NOT NULL, + [emailTemplateTypeId] [int] NOT NULL, + [programmeComponentId] [int] NOT NULL, + [title] [nvarchar](256) NULL, + [subject] [nvarchar](256) NOT NULL, + [body] [ntext] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + [tenantId] [int] NULL, + CONSTRAINT [PK_EmailTemplateTBL] PRIMARY KEY CLUSTERED +( + [emailTemplateId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [elfh].[emailTemplateTBL] ADD CONSTRAINT [DF_emailTemplateTBL_Deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[emailTemplateTBL] ADD CONSTRAINT [DF_EmailTemplate_AmendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[emailTemplateTBL] WITH CHECK ADD CONSTRAINT [FK_emailTemplateTBL_emailTemplateTypeTBL] FOREIGN KEY([emailTemplateTypeId]) +REFERENCES [elfh].[emailTemplateTypeTBL] ([emailTemplateTypeId]) +GO + +ALTER TABLE [elfh].[emailTemplateTBL] CHECK CONSTRAINT [FK_emailTemplateTBL_emailTemplateTypeTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTypeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTypeTBL.sql new file mode 100644 index 000000000..d3b4764b8 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmailTemplateTypeTBL.sql @@ -0,0 +1,19 @@ +CREATE TABLE [elfh].[emailTemplateTypeTBL]( + [emailTemplateTypeId] [int] NOT NULL, + [emailTemplateTypeName] [nvarchar](50) NOT NULL, + [availableTags] [nvarchar](255) NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_emailTemplateTypeTBL] PRIMARY KEY CLUSTERED +( + [emailTemplateTypeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[emailTemplateTypeTBL] ADD CONSTRAINT [DF_emailTemplateTypeTBL_Deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[emailTemplateTypeTBL] ADD CONSTRAINT [DF_emailTemplateTypeTBL_AmendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmploymentReferenceTypeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmploymentReferenceTypeTBL.sql new file mode 100644 index 000000000..be4a54abb --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/EmploymentReferenceTypeTBL.sql @@ -0,0 +1,13 @@ +CREATE TABLE [elfh].[employmentReferenceTypeTBL]( + [EmploymentReferenceTypeId] [int] NOT NULL, + [Title] [nvarchar](50) NOT NULL, + [RefAccess] [int] NOT NULL, + CONSTRAINT [PK_EmploymentReferenceType] PRIMARY KEY CLUSTERED +( + [EmploymentReferenceTypeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[employmentReferenceTypeTBL] ADD CONSTRAINT [DF_employmentReferenceTypeTBL_RefAccess] DEFAULT ((0)) FOR [RefAccess] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GdcRegister.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GdcRegister.sql new file mode 100644 index 000000000..560d58995 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GdcRegister.sql @@ -0,0 +1,36 @@ +CREATE TABLE [elfh].[gdcRegisterTBL]( + [reg_number] [nvarchar](50) NOT NULL, + [Dentist] [bit] NOT NULL, + [Title] [nvarchar](50) NULL, + [Surname] [nvarchar](255) NULL, + [Forenames] [nvarchar](255) NULL, + [honorifics] [nvarchar](50) NULL, + [house_name] [nvarchar](255) NULL, + [address_line1] [nvarchar](255) NULL, + [address_line2] [nvarchar](255) NULL, + [address_line3] [nvarchar](255) NULL, + [address_line4] [nvarchar](255) NULL, + [Town] [nvarchar](50) NULL, + [County] [nvarchar](50) NULL, + [PostCode] [nvarchar](50) NULL, + [Country] [nvarchar](50) NULL, + [regdate] [nvarchar](50) NULL, + [qualifications] [nvarchar](1000) NULL, + [dcp_titles] [nvarchar](100) NULL, + [specialties] [nvarchar](100) NULL, + [condition] [nvarchar](50) NULL, + [suspension] [nvarchar](50) NULL, + [dateProcessed] [datetimeoffset](7) NOT NULL, + [action] [nvarchar](1) NULL, + CONSTRAINT [PK_gdcRegisterTBL] PRIMARY KEY CLUSTERED +( + [reg_number] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[gdcRegisterTBL] ADD DEFAULT ((0)) FOR [Dentist] +GO + +ALTER TABLE [elfh].[gdcRegisterTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [dateProcessed] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GmcLrmp.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GmcLrmp.sql new file mode 100644 index 000000000..7d66d14c4 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GmcLrmp.sql @@ -0,0 +1,16 @@ +CREATE TABLE [elfh].[gmclrmpTBL]( + [GMC_Ref_No] [nvarchar](50) NOT NULL, + [Surname] [nvarchar](255) NULL, + [Given_Name] [nvarchar](255) NULL, + [Year_Of_Qualification] [float] NULL, + [GP_Register_Date] [nvarchar](255) NULL, + [Registration_Status] [nvarchar](255) NULL, + [Other_Names] [nvarchar](255) NULL, + [dateProcessed] [datetime] NULL, + [action] [nchar](1) NULL, + CONSTRAINT [PK_gmclrmpTBL] PRIMARY KEY CLUSTERED +( + [GMC_Ref_No] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GradeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GradeTBL.sql new file mode 100644 index 000000000..c9f7c47df --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/GradeTBL.sql @@ -0,0 +1,20 @@ +CREATE TABLE [elfh].[gradeTBL]( + [gradeId] [int] IDENTITY(1,1) NOT NULL, + [gradeName] [nvarchar](50) NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_gradeTBL] PRIMARY KEY CLUSTERED +( + [gradeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[gradeTBL] ADD CONSTRAINT [DF_gradeTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[gradeTBL] ADD CONSTRAINT [DF_gradeTBL_amendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/IpCountryLookupTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/IpCountryLookupTBL.sql new file mode 100644 index 000000000..d5bc7f13b --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/IpCountryLookupTBL.sql @@ -0,0 +1,8 @@ +CREATE TABLE [elfh].[ipCountryLookupTBL]( + [fromIP] [varchar](20) NOT NULL, + [toIP] [varchar](20) NOT NULL, + [country] [varchar](10) NOT NULL, + [fromInt] [bigint] NULL, + [toInt] [bigint] NULL +) ON [PRIMARY] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/JobRoleTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/JobRoleTBL.sql new file mode 100644 index 000000000..7bb035683 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/JobRoleTBL.sql @@ -0,0 +1,35 @@ +CREATE TABLE [elfh].[jobRoleTBL]( + [jobRoleId] [int] IDENTITY(1,1) NOT NULL, + [staffGroupId] [int] NULL, + [jobRoleName] [nvarchar](100) NOT NULL, + [medicalCouncilId] [int] NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_jobRoleTBL] PRIMARY KEY CLUSTERED +( + [jobRoleId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[jobRoleTBL] ADD CONSTRAINT [DF_jobRoleTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[jobRoleTBL] ADD CONSTRAINT [DF_jobRoleTBL_amendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[jobRoleTBL] WITH CHECK ADD CONSTRAINT [FK_jobRoleTBL_medicalCouncilTBL] FOREIGN KEY([medicalCouncilId]) +REFERENCES [elfh].[medicalCouncilTBL] ([medicalCouncilId]) +GO + +ALTER TABLE [elfh].[jobRoleTBL] CHECK CONSTRAINT [FK_jobRoleTBL_medicalCouncilTBL] +GO + +ALTER TABLE [elfh].[jobRoleTBL] WITH CHECK ADD CONSTRAINT [FK_jobRoleTBL_staffGroupTBL] FOREIGN KEY([staffGroupId]) +REFERENCES [elfh].[staffGroupTBL] ([staffGroupId]) +GO + +ALTER TABLE [elfh].[jobRoleTBL] CHECK CONSTRAINT [FK_jobRoleTBL_staffGroupTBL] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/Location.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/Location.sql new file mode 100644 index 000000000..54a0bac86 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/Location.sql @@ -0,0 +1,117 @@ + +CREATE TABLE [elfh].[locationTBL]( + [locationId] [int] NOT NULL, + [locationCode] [nvarchar](50) NOT NULL, + [locationName] [nvarchar](200) NOT NULL, + [locationSubName] [nvarchar](200) NULL, + [locationTypeId] [int] NOT NULL, + [address1] [nvarchar](100) NULL, + [address2] [nvarchar](100) NULL, + [address3] [nvarchar](100) NULL, + [address4] [nvarchar](100) NULL, + [town] [nvarchar](100) NULL, + [county] [nvarchar](100) NULL, + [postCode] [nvarchar](8) NULL, + [telephone] [nvarchar](50) NULL, + [acute] [bit] NOT NULL, + [ambulance] [bit] NOT NULL, + [mental] [bit] NOT NULL, + [care] [bit] NOT NULL, + [mainHosp] [bit] NOT NULL, + [nhsCode] [nvarchar](50) NULL, + [parentId] [int] NOT NULL, + [dataSource] [nvarchar](50) NOT NULL, + [active] [bit] NOT NULL, + [importExclusion] [bit] NOT NULL, + [depth] [int] NULL, + [lineage] [nvarchar](max) NULL, + [created] [datetimeoffset](7) NOT NULL, + [updated] [datetimeoffset](7) NOT NULL, + [archivedDate] [datetimeoffset](7) NULL, + [countryId] [int] NULL, + [iguId] [int] NOT NULL, + [letbId] [int] NOT NULL, + [ccgId] [int] NOT NULL, + [healthServiceId] [int] NOT NULL, + [healthBoardId] [int] NOT NULL, + [primaryTrustId] [int] NOT NULL, + [secondaryTrustId] [int] NOT NULL, + [islandId] [int] NOT NULL, + [otherNHSOrganisationId] [int] NOT NULL, + CONSTRAINT [PK_locationTBL] PRIMARY KEY CLUSTERED +( + [locationId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [locationTypeId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_Acute] DEFAULT ((0)) FOR [acute] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_Ambulance] DEFAULT ((0)) FOR [ambulance] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_Mental] DEFAULT ((0)) FOR [mental] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_Care] DEFAULT ((0)) FOR [care] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_MainHosp] DEFAULT ((0)) FOR [mainHosp] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_Active] DEFAULT ((1)) FOR [active] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_ImportExclusion] DEFAULT ((0)) FOR [importExclusion] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_created] DEFAULT (sysdatetimeoffset()) FOR [created] +GO + +ALTER TABLE [elfh].[locationTBL] ADD CONSTRAINT [DF_locationTBL_updated] DEFAULT (sysdatetimeoffset()) FOR [updated] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [iguId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [letbId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [ccgId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [healthServiceId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [healthBoardId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [primaryTrustId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [secondaryTrustId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [islandId] +GO + +ALTER TABLE [elfh].[locationTBL] ADD DEFAULT ((0)) FOR [otherNHSOrganisationId] +GO + +ALTER TABLE [elfh].[locationTBL] WITH CHECK ADD CONSTRAINT [FK_locationTBL_countryTBL] FOREIGN KEY([countryId]) +REFERENCES [elfh].[countryTBL] ([countryId]) +GO + +ALTER TABLE [elfh].[locationTBL] CHECK CONSTRAINT [FK_locationTBL_countryTBL] +GO + +ALTER TABLE [elfh].[locationTBL] WITH CHECK ADD CONSTRAINT [FK_locationTBL_locationTypeTBL] FOREIGN KEY([locationTypeId]) +REFERENCES [elfh].[locationTypeTBL] ([locationTypeID]) +GO + +ALTER TABLE [elfh].[locationTBL] CHECK CONSTRAINT [FK_locationTBL_locationTypeTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardRuleTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardRuleTBL.sql new file mode 100644 index 000000000..536df2f89 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardRuleTBL.sql @@ -0,0 +1,25 @@ +CREATE TABLE [elfh].[loginWizardRuleTBL]( + [loginWizardRuleId] [int] NOT NULL, + [loginWizardStageId] [int] NOT NULL, + [loginWizardRuleCategoryId] [int] NOT NULL, + [description] [nvarchar](128) NOT NULL, + [reasonDisplayText] [nvarchar](1024) NOT NULL, + [activationPeriod] [int] NULL, + [required] [bit] NOT NULL, + [active] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_loginWizardRule] PRIMARY KEY CLUSTERED +( + [loginWizardRuleId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[loginWizardRuleTBL] WITH CHECK ADD CONSTRAINT [FK_loginWizardRuleTBL_loginWizardStageTBL] FOREIGN KEY([loginWizardStageId]) +REFERENCES [elfh].[loginWizardStageTBL] ([loginWizardStageId]) +GO + +ALTER TABLE [elfh].[loginWizardRuleTBL] CHECK CONSTRAINT [FK_loginWizardRuleTBL_loginWizardStageTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardStageActivityTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardStageActivityTBL.sql new file mode 100644 index 000000000..5c8a60fc2 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/LoginWizardStageActivityTBL.sql @@ -0,0 +1,25 @@ +CREATE TABLE [elfh].[loginWizardStageActivityTBL]( + [loginWizardStageActivityId] [int] IDENTITY(1,1) NOT NULL, + [loginWizardStageId] [int] NOT NULL, + [userId] [int] NOT NULL, + [activityDatetime] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_loginWizardStageActivityTBL] PRIMARY KEY CLUSTERED +( + [loginWizardStageActivityId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[loginWizardStageActivityTBL] WITH CHECK ADD CONSTRAINT [FK_loginWizardStageActivityTBL_loginWizardStageTBL] FOREIGN KEY([loginWizardStageId]) +REFERENCES [elfh].[loginWizardStageTBL] ([loginWizardStageId]) +GO + +ALTER TABLE [elfh].[loginWizardStageActivityTBL] CHECK CONSTRAINT [FK_loginWizardStageActivityTBL_loginWizardStageTBL] +GO + +ALTER TABLE [elfh].[loginWizardStageActivityTBL] WITH CHECK ADD CONSTRAINT [FK_loginWizardStageActivityTBL_userTBL] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[loginWizardStageActivityTBL] CHECK CONSTRAINT [FK_loginWizardStageActivityTBL_userTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MedicalCouncilTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MedicalCouncilTBL.sql new file mode 100644 index 000000000..1eee676b8 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MedicalCouncilTBL.sql @@ -0,0 +1,24 @@ +CREATE TABLE [elfh].[medicalCouncilTBL]( + [medicalCouncilId] [int] NOT NULL, + [medicalCouncilName] [nvarchar](50) NOT NULL, + [medicalCouncilCode] [nvarchar](50) NOT NULL, + [uploadPrefix] [nvarchar](3) NOT NULL, + [includeOnCerts] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_medicalCouncilTBL] PRIMARY KEY CLUSTERED +( + [medicalCouncilId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[medicalCouncilTBL] ADD CONSTRAINT [DF_medicalCouncilTBL_includeOnCerts] DEFAULT ((0)) FOR [includeOnCerts] +GO + +ALTER TABLE [elfh].[medicalCouncilTBL] ADD CONSTRAINT [DF_medicalCouncilTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[medicalCouncilTBL] ADD CONSTRAINT [DF_medicalCouncilTBL_amendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MergeUserTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MergeUserTBL.sql new file mode 100644 index 000000000..510244acb --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/MergeUserTBL.sql @@ -0,0 +1,12 @@ +CREATE TABLE [elfh].[mergeUserTBL]( + [mergeUserId] [int] IDENTITY(1,1) NOT NULL, + [fromUserId] [int] NOT NULL, + [intoUserId] [int] NOT NULL, + [amendUserId] [int] NOT NULL, + [createdDatetime] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_mergeUserTBL] PRIMARY KEY CLUSTERED +( + [mergeUserId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/RegionTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/RegionTBL.sql new file mode 100644 index 000000000..e3de79cde --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/RegionTBL.sql @@ -0,0 +1,16 @@ +CREATE TABLE [elfh].[regionTBL]( + [regionId] [int] NOT NULL, + [regionName] [nvarchar](100) NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_regionTbl] PRIMARY KEY CLUSTERED +( + [regionId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[regionTBL] ADD CONSTRAINT [DF_regionTbl_deleted] DEFAULT ((0)) FOR [deleted] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SchoolTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SchoolTBL.sql new file mode 100644 index 000000000..b0ef70ea2 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SchoolTBL.sql @@ -0,0 +1,29 @@ +CREATE TABLE [elfh].[schoolTBL]( + [schoolId] [int] IDENTITY(1,1) NOT NULL, + [deaneryId] [int] NOT NULL, + [specialtyId] [int] NOT NULL, + [schoolName] [nvarchar](50) NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_schoolTBL] PRIMARY KEY CLUSTERED +( + [schoolId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[schoolTBL] WITH CHECK ADD CONSTRAINT [FK_schoolTBL_deaneryTBL] FOREIGN KEY([deaneryId]) +REFERENCES [elfh].[deaneryTBL] ([deaneryId]) +GO + +ALTER TABLE [elfh].[schoolTBL] CHECK CONSTRAINT [FK_schoolTBL_deaneryTBL] +GO + +ALTER TABLE [elfh].[schoolTBL] WITH CHECK ADD CONSTRAINT [FK_schoolTBL_specialtyTBL] FOREIGN KEY([specialtyId]) +REFERENCES [elfh].[specialtyTBL] ([specialtyId]) +GO + +ALTER TABLE [elfh].[schoolTBL] CHECK CONSTRAINT [FK_schoolTBL_specialtyTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SpecialtyTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SpecialtyTBL.sql new file mode 100644 index 000000000..dd2fcf677 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SpecialtyTBL.sql @@ -0,0 +1,19 @@ +CREATE TABLE [elfh].[specialtyTBL]( + [specialtyId] [int] IDENTITY(1,1) NOT NULL, + [specialtyName] [nvarchar](50) NOT NULL, + [displayOrder] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_specialtyTBL] PRIMARY KEY CLUSTERED +( + [specialtyId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[specialtyTBL] ADD CONSTRAINT [DF_specialty_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[specialtyTBL] ADD CONSTRAINT [DF_specialtyTBL_amendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/StaffGroupTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/StaffGroupTBL.sql new file mode 100644 index 000000000..e2ffb9bf0 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/StaffGroupTBL.sql @@ -0,0 +1,17 @@ +CREATE TABLE [elfh].[staffGroupTBL]( + [staffGroupId] [int] IDENTITY(1,1) NOT NULL, + [staffGroupName] [nvarchar](50) NOT NULL, + [displayOrder] [int] NOT NULL, + [internalUsersOnly] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_staffGroupTBL] PRIMARY KEY CLUSTERED +( + [staffGroupId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[staffGroupTBL] ADD CONSTRAINT [DF_staffGroupTBL_internalUsersOnly] DEFAULT ((0)) FOR [internalUsersOnly] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SystemSettingTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SystemSettingTBL.sql new file mode 100644 index 000000000..8ead0a47c --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/SystemSettingTBL.sql @@ -0,0 +1,24 @@ +CREATE TABLE [elfh].[systemSettingTBL]( + [systemSettingId] [int] NOT NULL, + [systemSettingName] [nvarchar](50) NOT NULL, + [intValue] [int] NULL, + [textValue] [nvarchar](255) NULL, + [booleanValue] [bit] NULL, + [dateValue] [datetimeoffset](7) NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_systemSettingsTBL] PRIMARY KEY CLUSTERED +( + [systemSettingId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[systemSettingTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[systemSettingTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantSmtpTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantSmtpTBL.sql new file mode 100644 index 000000000..390c1a123 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantSmtpTBL.sql @@ -0,0 +1,16 @@ +CREATE TABLE [elfh].[tenantSmtpTBL]( + [tenantId] [int] NOT NULL, + [deliveryMethod] [nvarchar](128) NOT NULL, + [pickupDirectoryLocation] [nvarchar](256) NULL, + [from] [nvarchar](256) NULL, + [userName] [nvarchar](256) NULL, + [password] [nvarchar](256) NULL, + [enableSsl] [bit] NULL, + [host] [nvarchar](256) NULL, + [port] [int] NULL, + [active] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL +) ON [PRIMARY] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantTBL.sql new file mode 100644 index 000000000..47fb44f17 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantTBL.sql @@ -0,0 +1,43 @@ +CREATE TABLE [elfh].[tenantTBL]( + [tenantId] [int] NOT NULL, + [tenantCode] [nvarchar](20) NOT NULL, + [tenantName] [nvarchar](64) NOT NULL, + [tenantDescription] [nvarchar](1024) NOT NULL, + [showFullCatalogInfoMessageInd] [bit] NOT NULL, + [catalogUrl] [nvarchar](256) NOT NULL, + [quickStartGuideUrl] [nvarchar](1024) NULL, + [supportFormUrl] [nvarchar](1024) NULL, + [liveChatStatus] [int] NOT NULL, + [liveChatSnippet] [nvarchar](2048) NULL, + [myElearningDefaultView] [int] NOT NULL, + [preLoginCatalogueDefaultView] [int] NOT NULL, + [postLoginCatalogueDefaultView] [int] NOT NULL, + [authSignInUrlRelative] [nvarchar](1024) NULL, + [authSignOutUrlRelative] [nvarchar](1024) NULL, + [authSecret] [uniqueidentifier] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_tenantTBL] PRIMARY KEY CLUSTERED +( + [tenantId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[tenantTBL] ADD DEFAULT ((0)) FOR [liveChatStatus] +GO + +ALTER TABLE [elfh].[tenantTBL] ADD DEFAULT ((0)) FOR [myElearningDefaultView] +GO + +ALTER TABLE [elfh].[tenantTBL] ADD DEFAULT ((0)) FOR [preLoginCatalogueDefaultView] +GO + +ALTER TABLE [elfh].[tenantTBL] ADD DEFAULT ((0)) FOR [postLoginCatalogueDefaultView] +GO + +ALTER TABLE [elfh].[tenantTBL] ADD DEFAULT (newid()) FOR [authSecret] +GO + + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantUrlTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantUrlTBL.sql new file mode 100644 index 000000000..f1698eafa --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TenantUrlTBL.sql @@ -0,0 +1,24 @@ +CREATE TABLE [elfh].[tenantUrlTBL]( + [tenantUrlId] [int] IDENTITY(1,1) NOT NULL, + [tenantId] [int] NOT NULL, + [urlHostName] [nvarchar](128) NOT NULL, + [useHostForAuth] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_tenantUrlTBL] PRIMARY KEY CLUSTERED +( + [tenantUrlId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[tenantUrlTBL] ADD DEFAULT ((0)) FOR [useHostForAuth] +GO + +ALTER TABLE [elfh].[tenantUrlTBL] WITH CHECK ADD CONSTRAINT [FK_tenantUrlTBL_tenantTBL] FOREIGN KEY([tenantId]) +REFERENCES [elfh].[tenantTBL] ([tenantId]) +GO + +ALTER TABLE [elfh].[tenantUrlTBL] CHECK CONSTRAINT [FK_tenantUrlTBL_tenantTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TermsAndConditionsTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TermsAndConditionsTBL.sql new file mode 100644 index 000000000..c2e581994 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/TermsAndConditionsTBL.sql @@ -0,0 +1,27 @@ +CREATE TABLE [elfh].[termsAndConditionsTBL]( + [termsAndConditionsId] [int] IDENTITY(1,1) NOT NULL, + [createdDate] [datetimeoffset](7) NOT NULL, + [description] [nvarchar](512) NOT NULL, + [details] [ntext] NOT NULL, + [tenantId] [int] NOT NULL, + [active] [bit] NOT NULL, + [reportable] [bit] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_termsAndConditions] PRIMARY KEY CLUSTERED +( + [termsAndConditionsId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [elfh].[termsAndConditionsTBL] ADD DEFAULT ((1)) FOR [reportable] +GO + +ALTER TABLE [elfh].[termsAndConditionsTBL] WITH CHECK ADD CONSTRAINT [FK_termsAndConditionsTBL_tenantTBL] FOREIGN KEY([tenantId]) +REFERENCES [elfh].[tenantTBL] ([tenantId]) +GO + +ALTER TABLE [elfh].[termsAndConditionsTBL] CHECK CONSTRAINT [FK_termsAndConditionsTBL_tenantTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAdminLocationTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAdminLocationTBL.sql new file mode 100644 index 000000000..4c88913e6 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAdminLocationTBL.sql @@ -0,0 +1,42 @@ + +CREATE TABLE [elfh].[userAdminLocationTBL]( + [userId] [int] NOT NULL, + [adminLocationId] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + [createdUserId] [int] NOT NULL, + [createdDate] [datetimeoffset](7) NOT NULL, +PRIMARY KEY CLUSTERED +( + [adminLocationId] ASC, + [userId] ASC, + [deleted] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [createdDate] +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] WITH CHECK ADD CONSTRAINT [FK_userAdminLocationTBL_locationTBL] FOREIGN KEY([adminLocationId]) +REFERENCES [elfh].[locationTBL] ([locationId]) +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] CHECK CONSTRAINT [FK_userAdminLocationTBL_locationTBL] +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] WITH CHECK ADD CONSTRAINT [FK_userAdminLocationTBL_userTBL] FOREIGN KEY([userId]) +REFERENCES [hub].[user] ([Id]) +GO + +ALTER TABLE [elfh].[userAdminLocationTBL] CHECK CONSTRAINT [FK_userAdminLocationTBL_userTBL] +GO + + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAttributeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAttributeTBL.sql new file mode 100644 index 000000000..bf9969af6 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserAttributeTBL.sql @@ -0,0 +1,37 @@ +CREATE TABLE [elfh].[userAttributeTBL]( + [userAttributeId] [int] IDENTITY(1,1) NOT NULL, + [userId] [int] NOT NULL, + [attributeId] [int] NOT NULL, + [intValue] [int] NULL, + [textValue] [nvarchar](255) NULL, + [booleanValue] [bit] NULL, + [dateValue] [datetimeoffset](7) NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userAttributeTBL] PRIMARY KEY CLUSTERED +( + [userAttributeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userAttributeTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userAttributeTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[userAttributeTBL] WITH CHECK ADD CONSTRAINT [FK_userAttributeTBL_attributeId] FOREIGN KEY([attributeId]) +REFERENCES [elfh].[attributeTBL] ([attributeId]) +GO + +ALTER TABLE [elfh].[userAttributeTBL] CHECK CONSTRAINT [FK_userAttributeTBL_attributeId] +GO + +ALTER TABLE [elfh].[userAttributeTBL] WITH CHECK ADD CONSTRAINT [FK_userAttributeTBL_userId] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userAttributeTBL] CHECK CONSTRAINT [FK_userAttributeTBL_userId] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentReferenceTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentReferenceTBL.sql new file mode 100644 index 000000000..66bc74d7f --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentReferenceTBL.sql @@ -0,0 +1,31 @@ +CREATE TABLE [elfh].[userEmploymentReferenceTBL]( + [userEmploymentReferenceId] [int] IDENTITY(1,1) NOT NULL, + [employmentReferenceTypeId] [int] NOT NULL, + [userEmploymentId] [int] NOT NULL, + [referenceValue] [nvarchar](100) NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userEmploymentReferenceTBL] PRIMARY KEY CLUSTERED +( + [userEmploymentReferenceId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userEmploymentReferenceTBL] ADD CONSTRAINT [DF_userEmploymentReferenceTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userEmploymentReferenceTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentReferenceTBL_employmentReferenceTypeTBL] FOREIGN KEY([employmentReferenceTypeId]) +REFERENCES [elfh].[employmentReferenceTypeTBL] ([EmploymentReferenceTypeId]) +GO + +ALTER TABLE [elfh].[userEmploymentReferenceTBL] CHECK CONSTRAINT [FK_userEmploymentReferenceTBL_employmentReferenceTypeTBL] +GO + +ALTER TABLE [elfh].[userEmploymentReferenceTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentReferenceTBL_userEmploymentTBL] FOREIGN KEY([userEmploymentId]) +REFERENCES [elfh].[userEmploymentTBL] ([userEmploymentId]) +GO + +ALTER TABLE [elfh].[userEmploymentReferenceTBL] CHECK CONSTRAINT [FK_userEmploymentReferenceTBL_userEmploymentTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentResponsibilityTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentResponsibilityTBL.sql new file mode 100644 index 000000000..546aead55 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentResponsibilityTBL.sql @@ -0,0 +1,15 @@ +CREATE TABLE [elfh].[userEmploymentResponsibilityTBL]( + [userEmploymentResponsibilityId] [int] IDENTITY(1,1) NOT NULL, + [userEmploymentId] [int] NOT NULL, + [additionalResponsibilityId] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, +PRIMARY KEY CLUSTERED +( + [userEmploymentResponsibilityId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userEmploymentResponsibilityTBL] ADD DEFAULT ((0)) FOR [deleted] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentTBL.sql new file mode 100644 index 000000000..f43db0eec --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserEmploymentTBL.sql @@ -0,0 +1,85 @@ + +CREATE TABLE [elfh].[userEmploymentTBL]( + [userEmploymentId] [int] IDENTITY(1,1) NOT NULL, + [userId] [int] NOT NULL, + [jobRoleId] [int] NULL, + [specialtyId] [int] NULL, + [gradeId] [int] NULL, + [schoolId] [int] NULL, + [locationId] [int] NOT NULL, + [medicalCouncilId] [int] NULL, + [medicalCouncilNo] [nvarchar](50) NULL, + [startDate] [datetimeoffset](7) NULL, + [endDate] [datetimeoffset](7) NULL, + [deleted] [bit] NOT NULL, + [archived] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userEmploymentTBL] PRIMARY KEY CLUSTERED +( + [userEmploymentId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] ADD CONSTRAINT [DF_userEmploymentTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] ADD CONSTRAINT [DF_userEmploymentTBL_archived] DEFAULT ((0)) FOR [archived] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_gradeTBL] FOREIGN KEY([gradeId]) +REFERENCES [elfh].[gradeTBL] ([gradeId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_gradeTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_jobRoleTBL] FOREIGN KEY([jobRoleId]) +REFERENCES [elfh].[jobRoleTBL] ([jobRoleId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_jobRoleTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_locationTBL] FOREIGN KEY([locationId]) +REFERENCES [elfh].[locationTBL] ([locationId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_locationTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_medicalCouncilTBL] FOREIGN KEY([medicalCouncilId]) +REFERENCES [elfh].[medicalCouncilTBL] ([medicalCouncilId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_medicalCouncilTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_schoolTBL] FOREIGN KEY([schoolId]) +REFERENCES [elfh].[schoolTBL] ([schoolId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_schoolTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_specialtyTBL] FOREIGN KEY([specialtyId]) +REFERENCES [elfh].[specialtyTBL] ([specialtyId]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_specialtyTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_userTBL] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_userTBL] +GO + +ALTER TABLE [elfh].[userEmploymentTBL] WITH CHECK ADD CONSTRAINT [FK_userEmploymentTBL_userTBL_AmendUser] FOREIGN KEY([amendUserId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userEmploymentTBL] CHECK CONSTRAINT [FK_userEmploymentTBL_userTBL_AmendUser] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserGroupTypeInputValidationTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserGroupTypeInputValidationTBL.sql new file mode 100644 index 000000000..dc2fd76dd --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserGroupTypeInputValidationTBL.sql @@ -0,0 +1,39 @@ +CREATE TABLE [elfh].[userGroupTypeInputValidationTBL]( + [userGroupTypeInputValidationId] [int] IDENTITY(1,1) NOT NULL, + [userGroupId] [int] NOT NULL, + [userGroupTypePrefix] [nvarchar](10) NOT NULL, + [userGroupTypeId] [int] NOT NULL, + [validationTextValue] [nvarchar](1000) NOT NULL, + [validationMethod] [int] NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + [createdUserId] [int] NOT NULL, + [createdDate] [datetimeoffset](7) NOT NULL, +PRIMARY KEY CLUSTERED +( + [userGroupTypeInputValidationId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], + CONSTRAINT [UQ_userGroupTypeInputValidationTBL_userGroupId_validationTextValue] UNIQUE NONCLUSTERED +( + [userGroupId] ASC, + [validationTextValue] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userGroupTypeInputValidationTBL] ADD DEFAULT (N'USR TYP:') FOR [userGroupTypePrefix] +GO + +ALTER TABLE [elfh].[userGroupTypeInputValidationTBL] ADD DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userGroupTypeInputValidationTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[userGroupTypeInputValidationTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [createdDate] +GO + +ALTER TABLE [elfh].[userGroupTypeInputValidationTBL] WITH CHECK ADD CONSTRAINT [FK_userGroupTypeInputValidationTBL_amendUserTBL] FOREIGN KEY([amendUserId]) +REFERENCES [hub].[User] ([Id]) +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryAttributeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryAttributeTBL.sql new file mode 100644 index 000000000..0ab661329 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryAttributeTBL.sql @@ -0,0 +1,39 @@ +CREATE TABLE [elfh].[userHistoryAttributeTBL]( + [userHistoryAttributeId] [int] IDENTITY(1,1) NOT NULL, + [userHistoryId] [int] NOT NULL, + [attributeId] [int] NOT NULL, + [intValue] [int] NULL, + [textValue] [nvarchar](1000) NULL, + [booleanValue] [bit] NULL, + [dateValue] [datetimeoffset](7) NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userHistoryAttributeTBL] PRIMARY KEY CLUSTERED +( + [userHistoryAttributeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] ADD CONSTRAINT [DF_userHistoryAttributeTBL_deleted] DEFAULT ((0)) FOR [deleted] +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] ADD CONSTRAINT [DF_userHistoryAttributeTBL_amendDate] DEFAULT (sysdatetimeoffset()) FOR [amendDate] +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] WITH CHECK ADD CONSTRAINT [FK_userHistoryAttributeTBL_attributeId] FOREIGN KEY([attributeId]) +REFERENCES [elfh].[attributeTBL] ([attributeId]) +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] CHECK CONSTRAINT [FK_userHistoryAttributeTBL_attributeId] +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] WITH CHECK ADD CONSTRAINT [FK_userHistoryAttributeTBL_userHistoryId] FOREIGN KEY([userHistoryId]) +REFERENCES [elfh].[userHistoryTBL] ([userHistoryId]) +GO + +ALTER TABLE [elfh].[userHistoryAttributeTBL] CHECK CONSTRAINT [FK_userHistoryAttributeTBL_userHistoryId] +GO + + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryTBL.sql new file mode 100644 index 000000000..12a25fc81 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserHistoryTBL.sql @@ -0,0 +1,25 @@ +CREATE TABLE [elfh].[userHistoryTBL]( + [userHistoryId] [int] IDENTITY(1,1) NOT NULL, + [userHistoryTypeId] [int] NOT NULL, + [userId] [int] NOT NULL, + [createdDate] [datetimeoffset](7) NOT NULL, + [tenantId] [int] NOT NULL, +PRIMARY KEY CLUSTERED +( + [userHistoryId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userHistoryTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [createdDate] +GO + +ALTER TABLE [elfh].[userHistoryTBL] ADD DEFAULT ((0)) FOR [tenantId] +GO + +ALTER TABLE [elfh].[userHistoryTBL] WITH CHECK ADD CONSTRAINT [FK_userHistoryTBL_userHistoryTypeTBL] FOREIGN KEY([userHistoryTypeId]) +REFERENCES [elfh].[userHistoryTypeTBL] ([UserHistoryTypeId]) +GO + +ALTER TABLE [elfh].[userHistoryTBL] CHECK CONSTRAINT [FK_userHistoryTBL_userHistoryTypeTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserPasswordValidationTokenTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserPasswordValidationTokenTBL.sql new file mode 100644 index 000000000..7beed21ce --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserPasswordValidationTokenTBL.sql @@ -0,0 +1,33 @@ +CREATE TABLE [elfh].[userPasswordValidationTokenTBL]( + [userPasswordValidationTokenId] [int] IDENTITY(1,1) NOT NULL, + [hashedToken] [nvarchar](128) NOT NULL, + [salt] [nvarchar](128) NOT NULL, + [lookup] [nvarchar](128) NOT NULL, + [expiry] [datetimeoffset](7) NOT NULL, + [tenantId] [int] NOT NULL, + [userId] [int] NOT NULL, + [createdUserId] [int] NOT NULL, + [createdDate] [datetimeoffset](7) NOT NULL, +PRIMARY KEY CLUSTERED +( + [userPasswordValidationTokenId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userPasswordValidationTokenTBL] ADD DEFAULT (sysdatetimeoffset()) FOR [createdDate] +GO + +ALTER TABLE [elfh].[userPasswordValidationTokenTBL] WITH CHECK ADD CONSTRAINT [FK_userPasswordValidationTokenTBL_tenantTBL] FOREIGN KEY([tenantId]) +REFERENCES [elfh].[tenantTBL] ([tenantId]) +GO + +ALTER TABLE [elfh].[userPasswordValidationTokenTBL] CHECK CONSTRAINT [FK_userPasswordValidationTokenTBL_tenantTBL] +GO + +ALTER TABLE [elfh].[userPasswordValidationTokenTBL] WITH CHECK ADD CONSTRAINT [FK_userPasswordValidationTokenTBL_userTBL] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userPasswordValidationTokenTBL] CHECK CONSTRAINT [FK_userPasswordValidationTokenTBL_userTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserReportingUserTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserReportingUserTBL.sql new file mode 100644 index 000000000..a96df3713 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserReportingUserTBL.sql @@ -0,0 +1,31 @@ +CREATE TABLE [elfh].[userReportingUserTBL]( + [userReportingUserId] [int] IDENTITY(1,1) NOT NULL, + [userId] [int] NOT NULL, + [reportingUserId] [int] NOT NULL, + [reportable] [bit] NOT NULL, + [Deleted] [bit] NOT NULL, + [AmendUserID] [int] NOT NULL, + [AmendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userReportingUser] PRIMARY KEY CLUSTERED +( + [userReportingUserId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userReportingUserTBL] ADD DEFAULT ((1)) FOR [reportable] +GO + +ALTER TABLE [elfh].[userReportingUserTBL] WITH CHECK ADD CONSTRAINT [FK_userReportingUser_reportingUser] FOREIGN KEY([reportingUserId]) +REFERENCES [hub].[user] ([Id]) +GO + +ALTER TABLE [elfh].[userReportingUserTBL] CHECK CONSTRAINT [FK_userReportingUser_reportingUser] +GO + +ALTER TABLE [elfh].[userReportingUserTBL] WITH CHECK ADD CONSTRAINT [FK_userReportingUser_user] FOREIGN KEY([userId]) +REFERENCES [hub].[user] ([Id]) +GO + +ALTER TABLE [elfh].[userReportingUserTBL] CHECK CONSTRAINT [FK_userReportingUser_user] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserRoleUpgradeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserRoleUpgradeTBL.sql new file mode 100644 index 000000000..c5f00d25d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserRoleUpgradeTBL.sql @@ -0,0 +1,35 @@ +CREATE TABLE [elfh].[userRoleUpgradeTBL]( + [userRoleUpgradeId] [int] IDENTITY(1,1) NOT NULL, + [userId] [int] NOT NULL, + [emailAddress] [nvarchar](100) NOT NULL, + [upgradeDate] [datetimeoffset](7) NULL, + [deleted] [bit] NOT NULL, + [createUserId] [int] NOT NULL, + [createDate] [datetimeoffset](7) NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + [userHistoryTypeId] [int] NOT NULL, + CONSTRAINT [PK_userRoleUpgrade] PRIMARY KEY CLUSTERED +( + [userRoleUpgradeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userRoleUpgradeTBL] ADD DEFAULT ((12)) FOR [userHistoryTypeId] +GO + +ALTER TABLE [elfh].[userRoleUpgradeTBL] WITH CHECK ADD CONSTRAINT [FK_userRoleUpgradeTBL_userHistoryTypeTBL] FOREIGN KEY([userHistoryTypeId]) +REFERENCES [elfh].[userHistoryTypeTBL] ([UserHistoryTypeId]) +GO + +ALTER TABLE [elfh].[userRoleUpgradeTBL] CHECK CONSTRAINT [FK_userRoleUpgradeTBL_userHistoryTypeTBL] +GO + +ALTER TABLE [elfh].[userRoleUpgradeTBL] WITH CHECK ADD CONSTRAINT [FK_userRoleUpgradeTbl_userTbl] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userRoleUpgradeTBL] CHECK CONSTRAINT [FK_userRoleUpgradeTbl_userTbl] +GO + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserTermsAndConditionsTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserTermsAndConditionsTBL.sql new file mode 100644 index 000000000..66e86902d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/UserTermsAndConditionsTBL.sql @@ -0,0 +1,28 @@ +CREATE TABLE [elfh].[userTermsAndConditionsTBL]( + [userTermsAndConditionsId] [int] IDENTITY(1,1) NOT NULL, + [termsAndConditionsId] [int] NOT NULL, + [userId] [int] NOT NULL, + [acceptanceDate] [datetimeoffset](7) NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserID] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_userTermsAndConditions] PRIMARY KEY CLUSTERED +( + [userTermsAndConditionsId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[userTermsAndConditionsTBL] WITH CHECK ADD CONSTRAINT [FK_userTermsAndConditionsTBL_portalUserTBL] FOREIGN KEY([userId]) +REFERENCES [hub].[User] ([Id]) +GO + +ALTER TABLE [elfh].[userTermsAndConditionsTBL] CHECK CONSTRAINT [FK_userTermsAndConditionsTBL_portalUserTBL] +GO + +ALTER TABLE [elfh].[userTermsAndConditionsTBL] WITH CHECK ADD CONSTRAINT [FK_userTermsAndConditionsTBL_termsAndConditionsTBL] FOREIGN KEY([termsAndConditionsId]) +REFERENCES [elfh].[termsAndConditionsTBL] ([termsAndConditionsId]) +GO + +ALTER TABLE [elfh].[userTermsAndConditionsTBL] CHECK CONSTRAINT [FK_userTermsAndConditionsTBL_termsAndConditionsTBL] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/locationTypeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/locationTypeTBL.sql new file mode 100644 index 000000000..cf10e09b5 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/locationTypeTBL.sql @@ -0,0 +1,34 @@ +CREATE TABLE [elfh].[locationTypeTBL]( + [locationTypeID] [int] IDENTITY(1,1) NOT NULL, + [locationType] [nvarchar](50) NOT NULL, + [countryId] [int] NULL, + [healthService] [bit] NOT NULL, + [healthBoard] [bit] NOT NULL, + [primaryTrust] [bit] NOT NULL, + [secondaryTrust] [bit] NOT NULL, + CONSTRAINT [PK_locationType] PRIMARY KEY CLUSTERED +( + [locationTypeID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [elfh].[locationTypeTBL] ADD DEFAULT ((0)) FOR [healthService] +GO + +ALTER TABLE [elfh].[locationTypeTBL] ADD DEFAULT ((0)) FOR [healthBoard] +GO + +ALTER TABLE [elfh].[locationTypeTBL] ADD DEFAULT ((0)) FOR [primaryTrust] +GO + +ALTER TABLE [elfh].[locationTypeTBL] ADD DEFAULT ((0)) FOR [secondaryTrust] +GO + +ALTER TABLE [elfh].[locationTypeTBL] WITH CHECK ADD CONSTRAINT [FK_locationTypeTBL_countryTBL] FOREIGN KEY([countryId]) +REFERENCES [elfh].[countryTBL] ([countryId]) +GO + +ALTER TABLE [elfh].[locationTypeTBL] CHECK CONSTRAINT [FK_locationTypeTBL_countryTBL] +GO + diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/loginWizardStageTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/loginWizardStageTBL.sql new file mode 100644 index 000000000..ae704a35d --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/loginWizardStageTBL.sql @@ -0,0 +1,13 @@ +CREATE TABLE [elfh].[loginWizardStageTBL]( + [loginWizardStageId] [int] NOT NULL, + [description] [nvarchar](128) NOT NULL, + [reasonDisplayText] [nvarchar](1024) NOT NULL, + [deleted] [bit] NOT NULL, + [amendUserId] [int] NOT NULL, + [amendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_loginWizardStageTBL] PRIMARY KEY CLUSTERED +( + [loginWizardStageId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY] +) ON [PRIMARY] +GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/userHistoryTypeTBL.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/userHistoryTypeTBL.sql new file mode 100644 index 000000000..95e58af92 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Elfh/userHistoryTypeTBL.sql @@ -0,0 +1,9 @@ +CREATE TABLE [elfh].[userHistoryTypeTBL]( + [UserHistoryTypeId] [int] NOT NULL, + [Description] [nvarchar](100) NOT NULL, +PRIMARY KEY CLUSTERED +( + [UserHistoryTypeId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Hierarchy/CatalogueNodeVersionCategory.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Hierarchy/CatalogueNodeVersionCategory.sql new file mode 100644 index 000000000..c3ddc4832 --- /dev/null +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Hierarchy/CatalogueNodeVersionCategory.sql @@ -0,0 +1,22 @@ +CREATE TABLE [hierarchy].[CatalogueNodeVersionCategory]( + [Id] [int] IDENTITY(1,1) NOT NULL, + [CatalogueNodeVersionId] [int] NOT NULL, + [CategoryId] [int] NOT NULL, + [Deleted] [bit] NOT NULL, + [CreateUserId] [int] NOT NULL, + [CreateDate] [datetimeoffset](7) NOT NULL, + [AmendUserId] [int] NOT NULL, + [AmendDate] [datetimeoffset](7) NOT NULL, + CONSTRAINT [PK_Hierarchy_CatalogueNodeVersionCategory] PRIMARY KEY CLUSTERED +( + [Id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] +) ON [PRIMARY] +GO + +ALTER TABLE [hierarchy].[CatalogueNodeVersionCategory] WITH CHECK ADD CONSTRAINT [FK_catalogueNodeVersionCategory_catalogueNodeVersion] FOREIGN KEY([CatalogueNodeVersionId]) +REFERENCES [hierarchy].[CatalogueNodeVersion] ([Id]) +GO + +ALTER TABLE [hierarchy].[CatalogueNodeVersionCategory] CHECK CONSTRAINT [FK_catalogueNodeVersionCategory_catalogueNodeVersion] +GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Hub/User.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Hub/User.sql index 20abd7d3c..3af869df7 100644 --- a/WebAPI/LearningHub.Nhs.Database/Tables/Hub/User.sql +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Hub/User.sql @@ -1,6 +1,24 @@ CREATE TABLE [hub].[User]( [Id] [int] NOT NULL, [UserName] [nvarchar](50) NOT NULL, + [countryId] [int] NULL, + [registrationCode] [nvarchar](50) NULL, + [activeFromDate] [datetimeoffset](7) NULL, + [activeToDate] [datetimeoffset](7) NULL, + [passwordHash] [nvarchar](255) NULL, + [mustChangeNextLogin] [bit] NULL, + [passwordLifeCounter] [int] NULL, + [securityLifeCounter] [int] NULL, + [RemoteLoginKey] [nvarchar](50) NULL, + [RemoteLoginGuid] [uniqueidentifier] NULL, + [RemoteLoginStart] [datetimeoffset](7) NULL, + [RestrictToSSO] [bit] NULL, + [loginTimes] [int] NULL, + [loginWizardInProgress] [bit] NULL, + [lastLoginWizardCompleted] [datetimeoffset](7) NULL, + [primaryUserEmploymentId] [int] NULL, + [regionId] [int] NULL, + [preferredTenantId] [int] NULL, [CreateUserId] [int] NOT NULL, [CreateDate] [datetimeoffset](7) NOT NULL, [AmendUserId] [int] NOT NULL, @@ -14,10 +32,6 @@ ), PERIOD FOR SYSTEM_TIME ([VersionStartTime], [VersionEndTime]) ) ON [PRIMARY] -WITH -( -SYSTEM_VERSIONING = ON ( HISTORY_TABLE = [hub].[UserHistory] ) -) GO ALTER TABLE [hub].[User] ADD DEFAULT (getutcdate()) FOR [VersionStartTime] @@ -26,6 +40,37 @@ GO ALTER TABLE [hub].[User] ADD DEFAULT (CONVERT([datetime2],'9999-12-31 23:59:59.9999999')) FOR [VersionEndTime] GO + +ALTER TABLE [hub].[User] ADD CONSTRAINT [DF_userTBL_passwordLifeCounter] DEFAULT ((0)) FOR [passwordLifeCounter] +GO + +ALTER TABLE [hub].[User] ADD CONSTRAINT [DF_userTBL_securityLifeCounter] DEFAULT ((0)) FOR [securityLifeCounter] +GO + +ALTER TABLE [hub].[User] ADD CONSTRAINT [DF_userTBL_RestrictToSSO] DEFAULT ((0)) FOR [RestrictToSSO] +GO + +ALTER TABLE [hub].[User] WITH CHECK ADD CONSTRAINT [FK_userTBL_countryTBL] FOREIGN KEY([countryId]) +REFERENCES [elfh].[countryTBL] ([countryId]) +GO + +ALTER TABLE [hub].[User] CHECK CONSTRAINT [FK_userTBL_countryTBL] +GO + +ALTER TABLE [hub].[User] WITH CHECK ADD CONSTRAINT [FK_userTBL_regionTBL] FOREIGN KEY([regionId]) +REFERENCES [elfh].[regionTBL] ([regionId]) +GO + +ALTER TABLE [hub].[User] CHECK CONSTRAINT [FK_userTBL_regionTBL] +GO + +ALTER TABLE [hub].[User] WITH CHECK ADD CONSTRAINT [FK_userTBL_userEmploymentTBL] FOREIGN KEY([primaryUserEmploymentId]) +REFERENCES [elfh].[userEmploymentTBL] ([userEmploymentId]) +GO + +ALTER TABLE [hub].[User] CHECK CONSTRAINT [FK_userTBL_userEmploymentTBL] +GO + CREATE INDEX idx_User_Deleted ON hub.[User] (Deleted) include (UserName) WITH (FILLFACTOR = 95); GO diff --git a/WebAPI/LearningHub.Nhs.Database/Tables/Hub/UserProfile.sql b/WebAPI/LearningHub.Nhs.Database/Tables/Hub/UserProfile.sql index 890cabfb7..61c95a2f5 100644 --- a/WebAPI/LearningHub.Nhs.Database/Tables/Hub/UserProfile.sql +++ b/WebAPI/LearningHub.Nhs.Database/Tables/Hub/UserProfile.sql @@ -2,8 +2,10 @@ [Id] [int] NOT NULL, [UserName] [nvarchar](50) NOT NULL, [EmailAddress] [nvarchar](100) NOT NULL, + [AltEmailAddress] [nvarchar](100) NULL, [FirstName] [nvarchar](50) NOT NULL, [LastName] [nvarchar](50) NOT NULL, + [PreferredName] [nvarchar](50) NULL, [Active] [bit] NOT NULL, [CreateUserId] [int] NOT NULL, [CreateDate] [datetimeoffset](7) NOT NULL, @@ -18,10 +20,6 @@ )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY], PERIOD FOR SYSTEM_TIME ([VersionStartTime], [VersionEndTime]) ) ON [PRIMARY] -WITH -( -SYSTEM_VERSIONING = ON ( HISTORY_TABLE = [hub].[UserProfileHistory] ) -) GO ALTER TABLE hub.[UserProfile] ADD DEFAULT (getutcdate()) FOR [VersionStartTime] diff --git a/WebAPI/LearningHub.Nhs.Repository.Interface/LearningHub.Nhs.Repository.Interface.csproj b/WebAPI/LearningHub.Nhs.Repository.Interface/LearningHub.Nhs.Repository.Interface.csproj index 0fd2d1571..337b1120d 100644 --- a/WebAPI/LearningHub.Nhs.Repository.Interface/LearningHub.Nhs.Repository.Interface.csproj +++ b/WebAPI/LearningHub.Nhs.Repository.Interface/LearningHub.Nhs.Repository.Interface.csproj @@ -10,7 +10,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.Repository/LearningHub.Nhs.Repository.csproj b/WebAPI/LearningHub.Nhs.Repository/LearningHub.Nhs.Repository.csproj index 25ed9f849..2a2cf49da 100644 --- a/WebAPI/LearningHub.Nhs.Repository/LearningHub.Nhs.Repository.csproj +++ b/WebAPI/LearningHub.Nhs.Repository/LearningHub.Nhs.Repository.csproj @@ -9,7 +9,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.Services.Interface/LearningHub.Nhs.Services.Interface.csproj b/WebAPI/LearningHub.Nhs.Services.Interface/LearningHub.Nhs.Services.Interface.csproj index d39f5a773..827bc8750 100644 --- a/WebAPI/LearningHub.Nhs.Services.Interface/LearningHub.Nhs.Services.Interface.csproj +++ b/WebAPI/LearningHub.Nhs.Services.Interface/LearningHub.Nhs.Services.Interface.csproj @@ -16,7 +16,7 @@ - + all diff --git a/WebAPI/LearningHub.Nhs.Services.UnitTests/LearningHub.Nhs.Services.UnitTests.csproj b/WebAPI/LearningHub.Nhs.Services.UnitTests/LearningHub.Nhs.Services.UnitTests.csproj index a3f1fc01e..658c2bc1b 100644 --- a/WebAPI/LearningHub.Nhs.Services.UnitTests/LearningHub.Nhs.Services.UnitTests.csproj +++ b/WebAPI/LearningHub.Nhs.Services.UnitTests/LearningHub.Nhs.Services.UnitTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/WebAPI/LearningHub.Nhs.Services/LearningHub.Nhs.Services.csproj b/WebAPI/LearningHub.Nhs.Services/LearningHub.Nhs.Services.csproj index 33a7331de..979ee394d 100644 --- a/WebAPI/LearningHub.Nhs.Services/LearningHub.Nhs.Services.csproj +++ b/WebAPI/LearningHub.Nhs.Services/LearningHub.Nhs.Services.csproj @@ -13,7 +13,7 @@ - + diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.ConsoleApp/LearningHub.Nhs.Migration.ConsoleApp.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.ConsoleApp/LearningHub.Nhs.Migration.ConsoleApp.csproj index 341aea0c7..1555adfe3 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.ConsoleApp/LearningHub.Nhs.Migration.ConsoleApp.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.ConsoleApp/LearningHub.Nhs.Migration.ConsoleApp.csproj @@ -25,7 +25,7 @@ - + all diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Interface/LearningHub.Nhs.Migration.Interface.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Interface/LearningHub.Nhs.Migration.Interface.csproj index 9b83e17aa..b03e83409 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Interface/LearningHub.Nhs.Migration.Interface.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Interface/LearningHub.Nhs.Migration.Interface.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Models/LearningHub.Nhs.Migration.Models.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Models/LearningHub.Nhs.Migration.Models.csproj index e02b10707..1d0a0e3e9 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Models/LearningHub.Nhs.Migration.Models.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Models/LearningHub.Nhs.Migration.Models.csproj @@ -10,7 +10,7 @@ - + all diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Repository/LearningHub.Nhs.Migration.Staging.Repository.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Repository/LearningHub.Nhs.Migration.Staging.Repository.csproj index e5cac2557..15b2ec905 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Repository/LearningHub.Nhs.Migration.Staging.Repository.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Repository/LearningHub.Nhs.Migration.Staging.Repository.csproj @@ -9,7 +9,7 @@ - + diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.UnitTests/LearningHub.Nhs.Migration.UnitTests.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.UnitTests/LearningHub.Nhs.Migration.UnitTests.csproj index 805897878..4d44dba23 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration.UnitTests/LearningHub.Nhs.Migration.UnitTests.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration.UnitTests/LearningHub.Nhs.Migration.UnitTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/WebAPI/MigrationTool/LearningHub.Nhs.Migration/LearningHub.Nhs.Migration.csproj b/WebAPI/MigrationTool/LearningHub.Nhs.Migration/LearningHub.Nhs.Migration.csproj index da7704d0b..094c39953 100644 --- a/WebAPI/MigrationTool/LearningHub.Nhs.Migration/LearningHub.Nhs.Migration.csproj +++ b/WebAPI/MigrationTool/LearningHub.Nhs.Migration/LearningHub.Nhs.Migration.csproj @@ -12,7 +12,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive