-
Notifications
You must be signed in to change notification settings - Fork 10
DicomAssociation Controller #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
055edd5
dicom association controller.
lillie-dae 2522e57
Merge branch 'develop' of https://github.com/Project-MONAI/monai-depl…
lillie-dae 3b72aa5
added docs
lillie-dae c6c4c01
moved class to own folder
lillie-dae 442f4c9
added headers
lillie-dae 2a8bb5d
repository tests
lillie-dae 1bcb32b
code comment changes
lillie-dae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!-- | ||
~ Copyright 2021-2023 MONAI Consortium | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
# DICOM Association information | ||
|
||
The `/dai' endpoint is for retrieving a list of information regarding dicom | ||
associations. | ||
|
||
## GET /dai/ | ||
|
||
#### Query Parameters | ||
|
||
| Name | Type | Description | | ||
|------------|----------|---------------------------------------------| | ||
| startTime | DateTime | (Optional) Start date to query from. | | ||
| endTime | DateTime | (Optional) End date to query from. | | ||
| pageNumber | Number | (Optional) Page number to query.(default 0) | | ||
| pageSize | Number | (Optional) Page size of query. | | ||
|
||
Max & Defaults for PageSize can be set in appSettings. | ||
|
||
```json | ||
"endpointSettings": { | ||
"defaultPageSize": number, | ||
"maxPageSize": number | ||
} | ||
``` | ||
|
||
Endpoint returns a paged result for example | ||
|
||
```json | ||
{ | ||
"PageNumber": 1, | ||
"PageSize": 10, | ||
"FirstPage": "/payload?pageNumber=1&pageSize=10", | ||
"LastPage": "/payload?pageNumber=1&pageSize=10", | ||
"TotalPages": 1, | ||
"TotalRecords": 3, | ||
"NextPage": null, | ||
"PreviousPage": null, | ||
"Data": [...] | ||
"Succeeded": true, | ||
"Errors": null, | ||
"Message": null | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021-2023 MONAI Consortium | ||
* Copyright 2019-2021 NVIDIA Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Monai.Deploy.InformaticsGateway.Configuration | ||
{ | ||
public class EndpointSettings | ||
{ | ||
[ConfigurationKeyName("defaultPageSize")] | ||
public int DefaultPageSize { get; set; } = 10; | ||
|
||
[ConfigurationKeyName("maxPageSize")] | ||
public int MaxPageSize { get; set; } = 10; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/Database/MongoDB/Repositories/MongoDBRepositoryBase.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2021-2023 MONAI Consortium | ||
* Copyright 2019-2021 NVIDIA Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System.Linq.Expressions; | ||
using MongoDB.Driver; | ||
|
||
namespace Monai.Deploy.InformaticsGateway.Database.MongoDB.Repositories | ||
{ | ||
public abstract class MongoDBRepositoryBase | ||
{ | ||
/// <summary> | ||
/// Get All T that match filters provided. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="collection">Collection to run against.</param> | ||
/// <param name="filterFunction">Filter function you can filter on properties of T.</param> | ||
/// <param name="sortFunction">Function used to sort data.</param> | ||
/// <param name="skip">Items to skip.</param> | ||
/// <param name="limit">Items to limit results by.</param> | ||
/// <returns></returns> | ||
protected static async Task<IList<T>> GetAllAsync<T>(IMongoCollection<T> collection, | ||
Expression<Func<T, bool>>? filterFunction, | ||
SortDefinition<T> sortFunction, | ||
int? skip = null, | ||
int? limit = null) | ||
{ | ||
return await collection | ||
.Find(filterFunction) | ||
.Skip(skip) | ||
.Limit(limit) | ||
.Sort(sortFunction) | ||
.ToListAsync().ConfigureAwait(false); | ||
} | ||
|
||
protected static async Task<IList<T>> GetAllAsync<T>(IMongoCollection<T> collection, | ||
FilterDefinition<T> filterFunction, | ||
SortDefinition<T> sortFunction, | ||
int? skip = null, | ||
int? limit = null) | ||
{ | ||
var result = await collection | ||
.Find(filterFunction) | ||
.Skip(skip) | ||
.Limit(limit) | ||
.Sort(sortFunction) | ||
.ToListAsync().ConfigureAwait(false); | ||
return result; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/InformaticsGateway/Services/Common/Pagination/PagedResponse.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright 2021-2023 MONAI Consortium | ||
* Copyright 2019-2021 NVIDIA Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using Monai.Deploy.InformaticsGateway.Services.UriService; | ||
|
||
namespace Monai.Deploy.InformaticsGateway.Services.Common.Pagination | ||
{ | ||
/// <summary> | ||
/// Paged Response for use with pagination's. | ||
/// </summary> | ||
/// <typeparam name="T">Type of response.</typeparam> | ||
public class PagedResponse<T> : Response<T> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PagedResponse{T}"/> class. | ||
/// </summary> | ||
/// <param name="data">Response Data.</param> | ||
/// <param name="pageNumber">Page number.</param> | ||
/// <param name="pageSize">Page size.</param> | ||
public PagedResponse(T data, int pageNumber, int pageSize) | ||
{ | ||
PageNumber = pageNumber; | ||
PageSize = pageSize; | ||
Data = data; | ||
Message = null; | ||
Succeeded = true; | ||
Errors = null; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets PageNumber. | ||
/// </summary> | ||
public int PageNumber { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets PageSize. | ||
/// </summary> | ||
public int PageSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets FirstPage. | ||
/// </summary> | ||
public string? FirstPage { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets LastPage. | ||
/// </summary> | ||
public string? LastPage { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets TotalPages. | ||
/// </summary> | ||
public int TotalPages { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets TotalRecords. | ||
/// </summary> | ||
public long TotalRecords { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets NextPage. | ||
/// </summary> | ||
public string? NextPage { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets previousPage. | ||
/// </summary> | ||
public string? PreviousPage { get; set; } | ||
|
||
public void SetUp(PaginationFilter validFilter, long totalRecords, IUriService uriService, string route) | ||
{ | ||
var totalPages = (double)totalRecords / PageSize; | ||
var roundedTotalPages = Convert.ToInt32(Math.Ceiling(totalPages)); | ||
|
||
var pageNumber = validFilter.PageNumber ?? 0; | ||
NextPage = | ||
pageNumber >= 1 && pageNumber < roundedTotalPages | ||
? uriService.GetPageUriString(new PaginationFilter(pageNumber + 1, PageSize), route) | ||
: null; | ||
|
||
PreviousPage = | ||
pageNumber - 1 >= 1 && pageNumber <= roundedTotalPages | ||
? uriService.GetPageUriString(new PaginationFilter(pageNumber - 1, PageSize), route) | ||
: null; | ||
|
||
FirstPage = uriService.GetPageUriString(new PaginationFilter(1, PageSize), route); | ||
LastPage = uriService.GetPageUriString(new PaginationFilter(roundedTotalPages, PageSize), route); | ||
TotalPages = roundedTotalPages; | ||
TotalRecords = totalRecords; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.