Let discuss here about any issues, challenges, requirement etc. regarding PViMS customization and implementation in Bangladesh.
Dear Shaun,
Thank you for your yesterday’s wonderful orientation, it helps us a lot to expedite our development. We are having issues when trying to clone the source code from the development branch. Please see the attachment and let us know what should we do. Looking forward to hearing back from you.
Thanks,
Rasel
Dear Julhas,
I am glad the orientation last week was useful, I hope I can continue being of assistance.
With regards to the issues noted, MediatR package references all point to the correct version. I am not 100% sure what is causing this issue. I will provide additional feedback this morning, I would like to do a new clone of the dev branch to see if I get the same issue.
Will provide feedback this morning.
Many thanks
Shaun
Dear Julhas,
The compile error is due to PViMS.Core referencing an older version of the MediatR library. This is due to an uncommitted change on my side.
Please can you pull down the latest set of changes from the development branch and the codebase should then compile on your side.
Thanks Julhas
Shaun
Thanks Shaun. Let us try.
Julhas
Dear Shaun,
The project is now error-free.
But when I run the API project the database is created but there is only one table.
I am sending you the screenshot.
Can you please give me any suggestions?
Morning,
May I please suggest the following:
- Please check if the seedData property in the API appsettings.json file, is set to true
- Please check if the __EFMigrationsHistory table has any data in it
- Please could you email me the latest log file (should exist in the log folder of the API project)
Many thanks
Dear Shaun,
Step 1 seed data property is true
Step 2 there is no data in migration table
Step 3, Error log
[11:14:24 ERR] An error occurred while migrating the database used on context PVIMSDbContext
System.AggregateException: One or more errors occurred. (Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling ‘Dispose’ on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: ‘PVIMSDbContext’.)
—> System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling ‘Dispose’ on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: ‘PVIMSDbContext’.
at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
at Microsoft.EntityFrameworkCore.DbContext.get_Database()
at PVIMS.API.Infrastructure.PVIMSContextSeed.<>c__DisplayClass0_0.<b__0>d.MoveNext() in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 35
— End of stack trace from previous location —
at Polly.AsyncPolicy.<>c__DisplayClass40_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates
1 shouldRetryResultPredicates, Func5 onRetryAsync, Int32 permittedRetryCount, IEnumerable
1 sleepDurationsEnumerable, Func4 sleepDurationProvider, Boolean continueOnCapturedContext) at Polly.AsyncPolicy.ExecuteAsync(Func
3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
at PVIMS.API.Infrastructure.PVIMSContextSeed.SeedAsync(PVIMSDbContext context, IWebHostEnvironment env, IOptions1 settings, ILogger
1 logger) in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 26
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millise
[13:37:50 ERR] An exception occurred while iterating over the results of a query for context type ‘PVIMS.Infrastructure.PVIMSDbContext’.
Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name ‘User’.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable
1.Enumerator.InitializeReader(Enumerator enumerator)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.<>c.<MoveNext>b__19_0(DbContext _, Enumerator enumerator) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass31_0
2.b__0(DbContext context, TState state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func3 operation, Func
3 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func
3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() ClientConnectionId:5e1248fb-dc93-423a-afec-ee69963b4de4 Error Number:208,State:1,Class:16 Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'User'. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData() at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource
1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.InitializeReader(Enumerator enumerator) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable
1.Enumerator.<>c.b__19_0(DbContext _, Enumerator enumerator)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass31_02.<Execute>b__0(DbContext context, TState state) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func
3 operation, Func3 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.Execute[TState,TResult](TState state, Func
3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable
1.Enumerator.MoveNext()
ClientConnectionId:5e1248fb-dc93-423a-afec-ee69963b4de4
Error Number:208,State:1,Class:16
[13:38:11 WRN] [PVIMSContextSeed] Exception SqlException with message Invalid object name ‘User’. detected on attempt 1 of 3
Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name ‘User’.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable
1.Enumerator.InitializeReader(Enumerator enumerator)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.<>c.<MoveNext>b__19_0(DbContext _, Enumerator enumerator) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass31_0
2.b__0(DbContext context, TState state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func3 operation, Func
3 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func
3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable
1 source, Boolean& found)
at lambda_method556(Closure , QueryContext )
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Any[TSource](IQueryable1 source, Expression
1 predicate)
at PVIMS.API.Infrastructure.PVIMSContextSeed.PrepareUsers(PVIMSDbContext context) in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 76
at PVIMS.API.Infrastructure.PVIMSContextSeed.<>c__DisplayClass0_0.<b__0>d.MoveNext() in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 37
— End of stack trace from previous location —
at Polly.AsyncPolicy.<>c__DisplayClass40_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates
1 shouldRetryResultPredicates, Func5 onRetryAsync, Int32 permittedRetryCount, IEnumerable
1 sleepDurationsEnumerable, Func4 sleepDurationProvider, Boolean continueOnCapturedContext) ClientConnectionId:5e1248fb-dc93-423a-afec-ee69963b4de4 Error Number:208,State:1,Class:16 [13:38:25 ERR] An error occurred while migrating the database used on context PVIMSDbContext System.AggregateException: One or more errors occurred. (Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'PVIMSDbContext'.) ---> System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'PVIMSDbContext'. at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed() at Microsoft.EntityFrameworkCore.DbContext.get_Database() at PVIMS.API.Infrastructure.PVIMSContextSeed.<>c__DisplayClass0_0.<<SeedAsync>b__0>d.MoveNext() in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 35 --- End of stack trace from previous location --- at Polly.AsyncPolicy.<>c__DisplayClass40_0.<<ImplementationAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func
3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates1 shouldRetryResultPredicates, Func
5 onRetryAsync, Int32 permittedRetryCount, IEnumerable1 sleepDurationsEnumerable, Func
4 sleepDurationProvider, Boolean continueOnCapturedContext)
at Polly.AsyncPolicy.ExecuteAsync(Func3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext) at PVIMS.API.Infrastructure.PVIMSContextSeed.SeedAsync(PVIMSDbContext context, IWebHostEnvironment env, IOptions
1 settings, ILogger`1 logger) in D:\5.Professional\PVIMS-DEV\PViMS-2\src\Service\PViMS.API\Infrastructure\PVIMSContextSeed.cs:line 26
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millise
@jbrsoft Please can you fetch latest changes from development branch. Db context migrations assembly has been modified to reflect location of new migrations folder.
If you fetch and rebuild, database will build and be seeded normally.
API start up was searching for database migrations in API project, which is no longer the location for migrations
Dear Shaun,
Now code and DB are built and created successfully.
If any issue occurs I will communicate with you.
Now I just only run dbo.Datapack.Spontaneous.sql right?
Thanks
Shafkat
Hi Shafkat,
Running dbo.Datapack.Spontaneous.sql on the database will create a baseline spontaneous report, accessible from the public widget on the site landing page. So you are certainly able to use the script to generate this dataset and it does make sense that this is your next step.
However, you may want to copy this script first and prepare an example Yellow Card vaccination dataset that you can work from.
Please let me know if I can assist further.
Thanks
Shaun
Dear Shaun,
Thanks for your support.
I will let you know if I face any issues when developing.
Thanks
Shafkat
Hello Shaun,
When i call public report from the front end getting this error in the console
can you help me out with this?
also, share with me the credential of the staff login.
Hello Shaun,
When I run the SQL scripts for spontaneous reports i got some errors.
I am sharing the screenshot.
Please provide me with the updated scripts that we can test.
There is some column missing in the scripts.
Please provide us with error-free scripts of spontaneous scripts.
Hi,
Please may I request that actual error messages are pasted as text into the forum, and only use screenshots when requested. It is useful to have the error message searchable in case other users of PViMS run into similar issues.
With regards to the error noted, the cannot insert the value NULL into column 'System’ is received because Entity Framework is not creating this column with a default value. Behaviour on database creation has changed between EF 4.6 and EF Core 6.0 and as we have recently migrated to EF 6.0 as it is under LTS, we are picking up teething issues on the creation of the database.
I have pushed a fix to the development branch ( entity migrations changed to include default values on dataset bit fi… · MSH/PViMS-2@6890d75 (github.com)) that ensures these tables have default values on these columns. Please fetch latest changes and build and seed the database again. Once this is done you should be able to execute the script dbo.Datapack.Spontaneous.sql successfully.
Thanks very much for sharing details of the issue with us.
Hello Shaun,
I hope you are well.
Que 1, When creating yellow from the dataset and create an instance of yellow form from which we can see the data for the report view.
Que 2, Should we work on the dataset controller for creation?
Que 3, There is some hardcoded condition why do you need it in the dataset controller?
Thanks
Shafkat
Hi Shafkat,
I will try and address each of your questions as best I can:
Que 1, When creating yellow from the dataset and create an instance of yellow form from which we can see the data for the report view.
I need a bit more clarification here:
If you are referring to how you can access this report from your reporting layer, this is where I was referring to the creation of a denormalised read-only MetaDatasetInstance table with a flat structure that can be queried for reporting purposes.
If you are referring to having the ability to view the report through an existing function in PViMS, you would access the report from within the analytical portal → Spontaneous → Reports. All spontaneous reports are reflected here so that causality and terminology may take place on the report
Que 2, Should we work on the dataset controller for creation?
As discussed in our last meeting, the CreatedDatasetInstance endpoint can be used as is to generate a new record in DatasetInstance. This should work as is for the new Yellow Card report. However, there is some hardcoding that may affect the generation of a new work flow instance in ReportInstance. As we suggested in the meeting, for now, you can edit the name of the hardcoded field.
Specifically, I am referring to this hardcoding in the Dataset Controller:
var patientIdentifier = datasetInstance.GetInstanceValue("Initials");
if (String.IsNullOrWhiteSpace(patientIdentifier))
{
patientIdentifier = datasetInstance.GetInstanceValue("Identification Number");
}
var sourceIdentifier = datasetInstance.GetInstanceValue("Description of reaction");
await _workflowService.CreateWorkFlowInstanceAsync("New Spontaneous Surveilliance Report", datasetInstance.DatasetInstanceGuid, patientIdentifier, sourceIdentifier, "PUBLIC");
// Prepare medications
List<ReportInstanceMedicationListItem> medications = new List<ReportInstanceMedicationListItem>();
var sourceProductElement = _datasetElementRepository.Get(u => u.ElementName == "Product Information");
var destinationProductElement = _datasetElementRepository.Get(u => u.ElementName == "Medicinal Products");
var sourceContexts = datasetInstance.GetInstanceSubValuesContext("Product Information");
Please edit the hardcoded fields as needed
Que 3, There is some hardcoded condition why do you need it in the dataset controller?
I think this is addressed in the previous point.
Please let me know if you would like to discuss further.
Thanks
Shaun
Dear Shaun,
Can you please help me where is the analytical portal → Spontaneous → Reports
I didn’t find any menu in the admin panel.
if we create multiple entries we can get all the records in the report which we already save from the yellow card right?
There is no analytical portal
Que 2,
Also i am facing an error in WorkFlowService.cs file
var userName = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
var currentUser = await _userRepository.GetAsync(u => u.UserName == userName);
if (currentUser == null)
{
throw new KeyNotFoundException($"Unable to locate current user");
}
object reference not set to an instance of an object
current user not found.
Waiting for your prompt reply.