|
@@ -7,6 +7,7 @@ using Vinno.IUS.Common.Log;
|
|
|
using Vinno.vCloud.Common.FIS.Helper;
|
|
|
using Vinno.vCloud.Common.Vid2;
|
|
|
using Vinno.vCloud.FIS.CrossPlatform.Common.Helper;
|
|
|
+using Vinno.vCloud.FIS.CrossPlatform.Common.SQLite;
|
|
|
using Vinno.vCloud.Protocol.Infrastructures;
|
|
|
using WingInterfaceLibrary.DTO.Comment;
|
|
|
using WingInterfaceLibrary.DTO.Measure;
|
|
@@ -29,6 +30,7 @@ namespace Vinno.vCloud.Common.FIS.Remedicals
|
|
|
private const string BreastImageLocation = "BreastImageLocation";
|
|
|
private const string LiverImageLocation = "LiverImageLocation";
|
|
|
private const string ThyroidImageLocation = "ThyroidImageLocation";
|
|
|
+ private Action<ExamRecordCache> _updateExamRecordCache;
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <summary>
|
|
@@ -135,8 +137,10 @@ namespace Vinno.vCloud.Common.FIS.Remedicals
|
|
|
/// </summary>
|
|
|
public ScanImageDTO CommentResults { get; }
|
|
|
|
|
|
+ public bool CanRecreateExamRecord { get; }
|
|
|
+
|
|
|
public vCloudScanDataV2(IvCloudExamRecord record, string id, string vidFilePath,
|
|
|
- VidType dataType, string description, PatientScanInfo patientInfo, UploadStatus status, IRemedicalService remedicalService, IStorageService storageService, string token, MeasuredResultsDTO measuredResults = null, ScanImageDTO commentResults = null)
|
|
|
+ VidType dataType, string description, PatientScanInfo patientInfo, UploadStatus status, IRemedicalService remedicalService, IStorageService storageService, string token, Action<ExamRecordCache> updateExamRecordCache, MeasuredResultsDTO measuredResults = null, ScanImageDTO commentResults = null, bool canModifyExamRecordId = false)
|
|
|
{
|
|
|
_status = status;
|
|
|
_token = token;
|
|
@@ -151,6 +155,8 @@ namespace Vinno.vCloud.Common.FIS.Remedicals
|
|
|
PatientInfo = patientInfo;
|
|
|
MeasuredResults = measuredResults;
|
|
|
CommentResults = commentResults;
|
|
|
+ CanRecreateExamRecord = canModifyExamRecordId;
|
|
|
+ _updateExamRecordCache = updateExamRecordCache;
|
|
|
//Generate files.
|
|
|
VidFilePath = GetVidFilePath(_status);
|
|
|
if (string.Compare(VidFilePath, vidFilePath, StringComparison.OrdinalIgnoreCase) != 0)
|
|
@@ -401,13 +407,44 @@ namespace Vinno.vCloud.Common.FIS.Remedicals
|
|
|
{
|
|
|
if (result.ErrorCode == 4002)
|
|
|
{
|
|
|
- Status = UploadStatus.FailBecauseExamIsFinished;
|
|
|
- Save();
|
|
|
- return;
|
|
|
+ if (!CanRecreateExamRecord)
|
|
|
+ {
|
|
|
+ Status = UploadStatus.FailBecauseExamIsFinished;
|
|
|
+ Save();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (CreateExamRecord(string.Empty, out var newExamRecordId))
|
|
|
+ {
|
|
|
+ ExamRecordId = newExamRecordId;
|
|
|
+ uploadExamDataRequest.ExamCode = ExamRecordId;
|
|
|
+ var examRecordCache = new ExamRecordCache(ExamId, newExamRecordId, WorkOrderId);
|
|
|
+ _updateExamRecordCache(examRecordCache);
|
|
|
+ result = JsonRpcHelper.UploadExamData(_remedicalService, uploadExamDataRequest);
|
|
|
+ if (result == null)
|
|
|
+ {
|
|
|
+ throw new InvalidDataException($"JsonRPCHelper UploadExamData Result is null");
|
|
|
+ }
|
|
|
+ else if (result.IsSuccess)
|
|
|
+ {
|
|
|
+ Status = UploadStatus.Uploaded;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new InvalidDataException($"JsonRPCHelper UploadExamData Fail,Error Code is {result.ErrorCode}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new InvalidDataException($"JsonRPCHelper UploadExamData Fail:FailBecauseExamIsFinished and ReCreateExamRecord Result is false");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else if (result.ErrorCode == 4015)
|
|
|
{
|
|
|
- if (CreateExamRecord())
|
|
|
+ if (CreateExamRecord(ExamRecordId, out var newExamRecordId) && ExamRecordId == newExamRecordId)
|
|
|
{
|
|
|
result = JsonRpcHelper.UploadExamData(_remedicalService, uploadExamDataRequest);
|
|
|
if (result == null)
|
|
@@ -498,23 +535,25 @@ namespace Vinno.vCloud.Common.FIS.Remedicals
|
|
|
/// <param name="workOrderId">The workerId</param>
|
|
|
/// <param name="patientInfo">The patient basic info for creating the exam record.</param>
|
|
|
/// <returns><see cref="T:Vinno.vCloud.Terminal.Remedicals.IvCloudExamRecord" /></returns>
|
|
|
- public bool CreateExamRecord()
|
|
|
+ public bool CreateExamRecord(string examRecordId, out string newExamRecordId)
|
|
|
{
|
|
|
var createExaminfoRequest = new CreateExaminfoRequest
|
|
|
{
|
|
|
Token = _token,
|
|
|
PatientType = vCloudServerConfig.Instance.PatientType.ToString(),
|
|
|
- ExamRecordCode = ExamRecordId,
|
|
|
+ ExamRecordCode = examRecordId,
|
|
|
PatientInfo = DTOConverter.RenderPatientInfo(PatientInfo),
|
|
|
PatientScanInfoList = DTOConverter.RenderPatientScanInfo(PatientInfo),
|
|
|
};
|
|
|
CreateExaminfoResult result = JsonRpcHelper.CreateExamInfo(_remedicalService, createExaminfoRequest);
|
|
|
- if (result == null || result.ExamCode != ExamRecordId)
|
|
|
+ if (result == null || string.IsNullOrEmpty(result.ExamCode))
|
|
|
{
|
|
|
+ newExamRecordId = string.Empty;
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ newExamRecordId = result.ExamCode;
|
|
|
return true;
|
|
|
}
|
|
|
}
|