Commit 1938a5fe authored by Krishna Reddy Tamatam's avatar Krishna Reddy Tamatam

To Production Move

parent 4682b717
...@@ -52,14 +52,64 @@ namespace FTP_Services.Services.Controllers ...@@ -52,14 +52,64 @@ namespace FTP_Services.Services.Controllers
} }
[HttpGet("GetSearchedPatients")] [HttpGet("GetSearchedPatients")]
public IActionResult GetSearchedPatients(string SearchText) public IActionResult GetSearchedPatients(string SearchText, int ProviderId, int LocationId, int DateType, string StartDate, string EndDate, int DischType)
{ {
log.Debug("GetSearchedPatients ==> "); log.Debug("GetSearchedPatients ==> ");
try try
{ {
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
// List<SearchPatients>? RequestsList = adapter.SearchedPatientsData(SearchText); // List<SearchPatients>? RequestsList = adapter.SearchedPatientsData(SearchText);
List<object>? RequestsList = adapter.SearchedPatientsData(SearchText); List<object>? RequestsList = adapter.SearchedPatientsData(SearchText, ProviderId, LocationId, DateType, StartDate, EndDate, DischType);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for search patients - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetAdmissionData")]
public IActionResult GetAdmissionData(int PatientID, int LocationID, int ProviderID, int DateType, string StartDate, string EndDate, int DischType)
{
log.Debug("GetAdmissionData ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetAdmissionData(PatientID, LocationID, ProviderID, DateType, StartDate, EndDate, DischType);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for Admissions - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("LoadPhysicians")]
public IActionResult GetLoadPhysicians(int LocationId)
{
log.Debug("LoadPhysicians ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GeLoadPhysicians(LocationId);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for Admissions - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetLocations")]
public IActionResult GetLocations(int LocationId, Boolean IsLoadAll)
{
log.Debug("GetLocations ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.LoadLocations(LocationId, IsLoadAll);
return Ok(RequestsList); return Ok(RequestsList);
} }
catch (Exception ex) catch (Exception ex)
...@@ -149,6 +199,40 @@ namespace FTP_Services.Services.Controllers ...@@ -149,6 +199,40 @@ namespace FTP_Services.Services.Controllers
return NotFound("No results"); return NotFound("No results");
} }
} }
[HttpGet("GetProcedures")]
public IActionResult GetProcedures()
{
log.Debug("GetProcedures ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetProcedures();
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for load documents - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("LoadDocumentTypes")]
public IActionResult LoadDocumentTypes()
{
log.Debug("LoadDocumentTypes ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.LoadDocumentTypes();
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for LoadDocumentTypes - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetConfigValues")] [HttpGet("GetConfigValues")]
public IActionResult GetConfigValues(int CompanyId) public IActionResult GetConfigValues(int CompanyId)
...@@ -159,7 +243,8 @@ namespace FTP_Services.Services.Controllers ...@@ -159,7 +243,8 @@ namespace FTP_Services.Services.Controllers
string DatabaseName = _appSettings.ConnectionString; string DatabaseName = _appSettings.ConnectionString;
_appSettings.ConnectionString = _appSettings.AdminConnectionString; _appSettings.ConnectionString = _appSettings.AdminConnectionString;
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<ConfigValues>? RequestsList = adapter.ConfigValues(CompanyId, DatabaseName); List<object>? RequestsList = adapter.ConfigValues(CompanyId, DatabaseName);
_appSettings.ConnectionString = DatabaseName;
return Ok(RequestsList); return Ok(RequestsList);
} }
catch (Exception ex) catch (Exception ex)
...@@ -187,13 +272,13 @@ namespace FTP_Services.Services.Controllers ...@@ -187,13 +272,13 @@ namespace FTP_Services.Services.Controllers
} }
[HttpGet("GetPatientDocuments")] [HttpGet("GetPatientDocuments")]
public IActionResult GetPatientDocuments(int SPatientID, int SDocID) public IActionResult GetPatientDocuments(int SPatientID, int SLocationID,int SAppointmentID,int SAdmissionID,int SDocID,string SDueFrom,string SDueTO)
{ {
log.Debug("GetPatientDocuments ==> "); log.Debug("GetPatientDocuments ==> ");
try try
{ {
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<PatientDocuments>? RequestsList = adapter.PatientDocuments(SPatientID, SDocID); List<object>? RequestsList = adapter.PatientDocuments(SPatientID, SLocationID,SAppointmentID,SAdmissionID,SDocID, SDueFrom, SDueTO);
return Ok(RequestsList); return Ok(RequestsList);
} }
catch (Exception ex) catch (Exception ex)
...@@ -203,21 +288,265 @@ namespace FTP_Services.Services.Controllers ...@@ -203,21 +288,265 @@ namespace FTP_Services.Services.Controllers
} }
} }
[HttpGet("GetPatientAdmissions")]
public IActionResult GetPatientAdmissions(int SPatientID)
{
log.Debug("GetPatientAdmissions ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<Admissions>? RequestsList = adapter.PatientAdmissions(SPatientID);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data for patient documents - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetAdmissionDischargeData")]
public IActionResult GetAdmissionDischargeData(int SndAdmissionID)
{
log.Debug("GetPatientAdmissions ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.AdmissionDischargeData(SndAdmissionID);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get GetAdmissionDischargeData - Error:" + ex.Message);
return NotFound("No results");
}
}
// [HttpPost("SavePatientDocument")]
// public int SavePatientDocument_bkp([FromBody] PatientDocumentDetailsModel model)
// {
// log.Debug("SavePatientDocument ==> ");
// int SavePT = 0;
// try
// {
// FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
// SavePT = adapter.SavePatientDocumentData(model);
// }
// catch (Exception ex)
// {
// log.Error("Fail to get data for save patient documents - Error:" + ex.Message);
// }
// return SavePT;
// }
[HttpPost("UpdateImageCategory")]
public int UpdateImageCategory(int sndPatDocId,int sndDocTypeId,int sndUserID)
{
int savedCount = 0;
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
savedCount = adapter.UpdateImageCategory(sndPatDocId,sndDocTypeId,sndUserID);
}
catch (Exception ex)
{
log.Error("UpdateImageCategory -> Failed to save documents - Error: " + ex.Message);
}
return savedCount;
}
[HttpPost("UpdateImageSortNo")]
public int UpdateImageSortNo ([FromBody] PatientImgDocSort PatImgDoc)
{
int savedCount = 0;
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
savedCount = adapter.UpdateImageSortNo(PatImgDoc);
}
catch (Exception ex)
{
log.Error("UpdateImageSortNo -> Failed to save documents - Error: " + ex.Message);
}
return savedCount;
}
[HttpPost("SavePatientDocument")] [HttpPost("SavePatientDocument")]
public int SavePatientDocument([FromBody] PatientDocumentDetailsModel model) public int SavePatientDocumentData([FromBody] List<PatientDocumentDetailsModel> models)
{
log.Debug("SaveMultiplePatientDocuments ==> Received " + models.Count + " records.");
int savedCount = 0;
try
{
if (models == null || models.Count == 0)
{
log.Warn("SaveMultiplePatientDocuments => No data received.");
return 0;
}
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
savedCount = adapter.SavePatientDocumentData(models);
}
catch (Exception ex)
{
log.Error("SaveMultiplePatientDocuments -> Failed to save documents - Error: " + ex.Message);
}
return savedCount;
}
[HttpPost("SaveAdmissionDischargeData")]
public IActionResult SaveAdmissionDischargeData([FromBody] List<AdmissionDischargeModel> models)
{
if (models == null || models.Count == 0)
{
log.Warn("SaveAdmissionDischargeData => No data received.");
return BadRequest("No data received.");
}
log.Debug("SaveAdmissionDischargeData ==> Received " + models.Count + " records.");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
int savedCount = adapter.SaveAdmissionDischargeData(models);
log.Info($"SaveAdmissionDischargeData => Successfully saved {savedCount} records.");
return Ok(savedCount);
}
catch (Exception ex)
{
log.Error("SaveAdmissionDischargeData -> Failed to save data - " + ex.Message);
return StatusCode(500, "Internal server error");
}
}
// [HttpPost("SaveAdmissionDischargeData")]
// public int SaveAdmissionDischargeData(int MRDId, int ProviderId, int DepartmentId, int AdmissionAge, string AdmissionDate,int AdmissionTypeId, string DischargeDate,
// int DischargeTypeId, string Cause, int UserId,string MRD_Wards, string MRD_ICDS, string MRD_Procedures)
// {
// log.Debug("SaveAdmissionDischargeData ==> Received request.");
// int savedCount = 0;
// try
// {
// FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
// savedCount = adapter.SaveAdmissionDischargeData(
// MRDId, ProviderId, DepartmentId, AdmissionAge, AdmissionDate,
// AdmissionTypeId, DischargeDate, DischargeTypeId, Cause, UserId,
// MRD_Wards, MRD_ICDS, MRD_Procedures);
// log.Info($"SaveAdmissionDischargeData => Successfully saved {savedCount} records.");
// }
// catch (Exception ex)
// {
// log.Error("SaveAdmissionDischargeData -> Failed to save data - " + ex.Message);
// }
// return savedCount;
// }
[HttpGet("GetUserLocations")]
public IActionResult GetUserLocations(string sndUserName)
{
log.Debug("GetLocations ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetUserLocations(sndUserName);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data GetUserLocations - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetDepartments")]
public IActionResult GetDepartments(int sndLocationId)
{
log.Debug("GetLocations ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetDepartments(sndLocationId);
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data GetDepartments - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetWards")]
public IActionResult GetWards(int sndLocationId)
{ {
log.Debug("SavePatientDocument ==> "); log.Debug("GetWards ==> ");
int SavePT = 0;
try try
{ {
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
SavePT = adapter.SavePatientDocumentData(model); List<object>? RequestsList = adapter.GetWards(sndLocationId);
return Ok(RequestsList);
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("Fail to get data for save patient documents - Error:" + ex.Message); log.Error("Fail to get data GetWards - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetAdmissionTypes")]
public IActionResult GetAdmissionTypes()
{
log.Debug("GetAdmissionTypes ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetAdmissionTypes();
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data GetAdmissionTypes - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("GetDischargeTypes")]
public IActionResult GetDischargeTypes()
{
log.Debug("GetDischargeTypes ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.GetDischargeTypes();
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data GetDischargeTypes - Error:" + ex.Message);
return NotFound("No results");
}
}
[HttpGet("LoadICD")]
public IActionResult LoadICD()
{
log.Debug("LoadICD ==> ");
try
{
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
List<object>? RequestsList = adapter.LoadICD();
return Ok(RequestsList);
}
catch (Exception ex)
{
log.Error("Fail to get data LoadICD - Error:" + ex.Message);
return NotFound("No results");
} }
return SavePT;
} }
// [HttpPost("DeletePatientDocument")] // [HttpPost("DeletePatientDocument")]
...@@ -238,14 +567,14 @@ namespace FTP_Services.Services.Controllers ...@@ -238,14 +567,14 @@ namespace FTP_Services.Services.Controllers
// } // }
[HttpPost("DeletePatientDocument")] [HttpPost("DeletePatientDocument")]
public string DeletePatientDocument(int DocumentID,int UserID) public string DeletePatientDocument(int DocumentID, int UserID)
{ {
log.Debug("DeletePatientDocument ==> "); log.Debug("DeletePatientDocument ==> ");
string DeletePT = ""; string DeletePT = "";
try try
{ {
FTPDataAdapter adapter = new FTPDataAdapter(_appSettings); FTPDataAdapter adapter = new FTPDataAdapter(_appSettings);
DeletePT = adapter.DeletePatientDocumentData(DocumentID,UserID); DeletePT = adapter.DeletePatientDocumentData(DocumentID, UserID);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -2,49 +2,41 @@ namespace FTP_Services.Core.Models ...@@ -2,49 +2,41 @@ namespace FTP_Services.Core.Models
{ {
public class PatientDocumentDetailsModel public class PatientDocumentDetailsModel
{ {
public string DocumentType { get; set; } public int DocumentType { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string DocumentName { get; set; } public string DocumentName { get; set; }
public int UploadedBy { get; set; } public int UploadedBy { get; set; }
public int PatientId { get; set; } public int PatientId { get; set; }
public string ContentType { get; set; } public string ContentType { get; set; }
public string Size { get; set; } public int Size { get; set; }
public string DocumentUrl { get; set; } public string DocumentUrl { get; set; }
public string ThumbnailUrl { get; set; } public string ThumbnailUrl { get; set; }
public int SplID { get; set; } public int SplID { get; set; }
public int PatDocId { get; set; } public int PatDocId { get; set; }
public string UploadedDate { get; set; } public string UploadedDate { get; set; }
public int AdmissionID { get; set; }
public int SortNo { get; set; }
public PatientDocumentDetailsModel() public PatientDocumentDetailsModel()
{ {
DocumentType = ""; DocumentType = 0;
Description = ""; Description = "";
DocumentName = ""; DocumentName = "";
UploadedBy = -1; UploadedBy = -1;
PatientId = -1; PatientId = -1;
ContentType = ""; ContentType = "";
Size = ""; Size = 0;
DocumentUrl = ""; DocumentUrl = "";
ThumbnailUrl = ""; ThumbnailUrl = "";
SplID = -1; SplID = -1;
PatDocId = 0; PatDocId = 0;
UploadedDate = ""; UploadedDate = "";
AdmissionID = 0;
SortNo =1;
} }
} }
// public class Login
// {
// public string ID { get; set; }
// public string Name { get; set; }
// public string Code { get; set; }
// public Login()
// {
// ID = "";
// Name = "";
// Code = "";
// }
// }
public class FileResponseModel public class FileResponseModel
{ {
...@@ -153,6 +145,12 @@ namespace FTP_Services.Core.Models ...@@ -153,6 +145,12 @@ namespace FTP_Services.Core.Models
public bool IsActive { get; set; } public bool IsActive { get; set; }
public int CompanyId { get; set; } public int CompanyId { get; set; }
public string DatabaseName { get; set; } public string DatabaseName { get; set; }
public string RemoteHost { get; set; }
public string RemoteUser { get; set; }
public string RemotePassword { get; set; }
public string RemotePort { get; set; }
public string ToolVersion { get; set; }
public ConfigValues() public ConfigValues()
{ {
...@@ -161,12 +159,17 @@ namespace FTP_Services.Core.Models ...@@ -161,12 +159,17 @@ namespace FTP_Services.Core.Models
RemotePath = ""; RemotePath = "";
CompanyName = ""; CompanyName = "";
FTPServiceURL = ""; FTPServiceURL = "";
DPI =100; DPI = 100;
PDFSizeLimit =20; PDFSizeLimit = 20;
DefaultDocType =""; DefaultDocType = "";
IsActive = true; IsActive = true;
CompanyId= 1; CompanyId = 1;
DatabaseName =""; DatabaseName = "";
RemoteHost = "";
RemoteUser = "";
RemotePassword = "";
RemotePort = "";
ToolVersion = "";
} }
} }
...@@ -191,6 +194,10 @@ namespace FTP_Services.Core.Models ...@@ -191,6 +194,10 @@ namespace FTP_Services.Core.Models
public int SplID { get; set; } public int SplID { get; set; }
public string ThumbnailUrl { get; set; } public string ThumbnailUrl { get; set; }
public bool IsExternal { get; set; } public bool IsExternal { get; set; }
public int AdmissionId { get; set; }
public string AdmissionNo { get; set; }
public string AdmissionDate { get; set; }
public PatientDocuments() public PatientDocuments()
...@@ -212,8 +219,22 @@ namespace FTP_Services.Core.Models ...@@ -212,8 +219,22 @@ namespace FTP_Services.Core.Models
FullName = ""; FullName = "";
DocumentUrl = ""; DocumentUrl = "";
SplID = -1; SplID = -1;
ThumbnailUrl =""; ThumbnailUrl = "";
IsExternal =false; IsExternal = false;
AdmissionId = -1;
AdmissionNo = "";
AdmissionDate = "";
}
}
public class Admissions
{
public int ID { get; set; }
public string AdmissionNo { get; set; }
public Admissions()
{
ID = -1;
AdmissionNo = "";
} }
} }
...@@ -226,4 +247,61 @@ namespace FTP_Services.Core.Models ...@@ -226,4 +247,61 @@ namespace FTP_Services.Core.Models
RecordCount = -1; RecordCount = -1;
} }
} }
public class AdmissionDischargeModel
{
public int MRDId { get; set; }
public int PatientId { get; set; }
public int AdmissionId { get; set; }
public int ProviderId { get; set; }
public int LocationId { get; set; }
public int DepartmentId { get; set; }
public int AdmissionAge { get; set; }
public DateTime? AdmissionDate { get; set; }
public int AdmissionTypeId { get; set; }
public DateTime? DischargeDate { get; set; }
//public int DischargeTypeId { get; set; }
public string DischargeType { get; set; }
public string Cause { get; set; }
public int UserId { get; set; }
public bool IsWardChanged { get; set; }
public bool IsICDChanged { get; set; }
public bool IsProcChanged { get; set; }
public List<WardModel> Wards { get; set; }
public List<ICDModel> ICDCodes { get; set; }
public List<ProcedureModel> Procedures { get; set; }
public string Diagnosis { get; set; }
public string MRD_OtherProcedures { get; set; }
}
// Supporting Models
public class WardModel
{
public int WardId { get; set; }
public DateTime WardDate { get; set; }
}
public class ICDModel
{
public string ICDCode { get; set; }
public string ICDDesc { get; set; }
}
public class ProcedureModel
{
public string ProcName { get; set; }
}
public class PatientImgDocSort
{
public int UserId { get; set; }
public List<PatientImgDocModel> PatientImgDoc { get; set; }
}
public class PatientImgDocModel
{
public int PatDocId { get; set; }
public int SortNo { get; set; }
}
} }
...@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Mvc; ...@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Npgsql; using Npgsql;
using PetaPoco; using PetaPoco;
...@@ -81,21 +82,253 @@ namespace FTP_Services.Services ...@@ -81,21 +82,253 @@ namespace FTP_Services.Services
// } // }
// } // }
public List<object>? SearchedPatientsData(string SearchText) public List<object>? GetUserLocations(string sndUserName)
{ {
List<object>? UserLocationsData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_GetUserLocations\"(@Parm_UserName)";
UserLocationsData = _repository.Fetch<object>(
sqlQuery,
new { Parm_UserName = sndUserName }
);
GC.Collect();
tx.Complete();
}
return UserLocationsData;
}
catch (Exception ex)
{
log.Error("GetAdmissionData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GetDepartments(int sndLocationId)
{
List<object>? DepartmentsData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_GetDepartments\"(@Parm_LocationId)";
DepartmentsData = _repository.Fetch<object>(
sqlQuery,
new { Parm_LocationId = sndLocationId }
);
GC.Collect();
tx.Complete();
}
return DepartmentsData;
}
catch (Exception ex)
{
log.Error("DepartmentsData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GetWards(int sndLocationId)
{
List<object>? WardsData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_GetWards\"(@Parm_LocationId)";
WardsData = _repository.Fetch<object>(
sqlQuery,
new { Parm_LocationId = sndLocationId }
);
GC.Collect();
tx.Complete();
}
return WardsData;
}
catch (Exception ex)
{
log.Error("GetWards->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GetAdmissionTypes()
{
List<object>? AdmissionTypesData = null;
try
{
using (var tx = _repository.GetTransaction())
{
AdmissionTypesData = _repository.Fetch<object>(
"SELECT * FROM \"SPScanTool_GetAdmissionTypes\"();"
);
// string sqlQuery =
// $"SELECT * FROM \"SPScanTool_GetAdmissionTypes\"()";
// AdmissionTypesData = _repository.Fetch<object>(
// sqlQuery
// );
GC.Collect();
tx.Complete();
}
return AdmissionTypesData;
}
catch (Exception ex)
{
log.Error("AdmissionTypesData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GetDischargeTypes()
{
List<object>? DischargeTypesData = null;
try
{
using (var tx = _repository.GetTransaction())
{
DischargeTypesData = _repository.Fetch<object>(
"SELECT * FROM \"SPScanTool_GetDischargeTypes\"();"
);
GC.Collect();
tx.Complete();
}
return DischargeTypesData;
}
catch (Exception ex)
{
log.Error("GetDischargeTypes->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? LoadICD()
{
List<object>? ICDData = null;
try
{
using (var tx = _repository.GetTransaction())
{
ICDData = _repository.Fetch<object>(
"SELECT * FROM \"SPScanTool_LoadICD\"();"
);
GC.Collect();
tx.Complete();
}
return ICDData;
}
catch (Exception ex)
{
log.Error("LoadICD->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? LoadDocumentTypes()
{
List<object>? DocumentTypesData = null;
try
{
using (var tx = _repository.GetTransaction())
{
DocumentTypesData = _repository.Fetch<object>(
"SELECT * FROM \"SPScanTool_LoadDocumentTypes\"();"
);
GC.Collect();
tx.Complete();
}
return DocumentTypesData;
}
catch (Exception ex)
{
log.Error("DocumentTypesData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GeLoadPhysicians(int sndLocationId)
{
List<object>? PhysiciansData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_LoadPhysicians\"(@Parm_LocationId)";
PhysiciansData = _repository.Fetch<object>(
sqlQuery,
new { Parm_LocationId = sndLocationId }
);
GC.Collect();
tx.Complete();
}
return PhysiciansData;
}
catch (Exception ex)
{
log.Error("GeLoadPhysicians->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? GetAdmissionData(int PatientID, int LocationID, int ProviderID, int DateType, string StartDate, string EndDate, int DischType)
{
List<object>? AdmissionData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_GetAdmissionData\"(@Parm_PatientId,@Parm_LocationId,@Parm_ProviderID,@Parm_DateType,@Parm_StartDate,@Parm_EndDate,@parm_DischType)";
AdmissionData = _repository.Fetch<object>(
sqlQuery,
new
{
Parm_PatientId = PatientID,
Parm_LocationId = LocationID,
Parm_ProviderID = ProviderID, // Notice the case change here
Parm_DateType = DateType,
Parm_StartDate = StartDate,
Parm_EndDate = EndDate,
parm_DischType = DischType
}
);
GC.Collect();
tx.Complete();
}
return AdmissionData;
}
catch (Exception ex)
{
log.Error("GetAdmissionData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<object>? SearchedPatientsData(string SearchText, int ProviderId, int LocationId, int DateType, string StartDate, string EndDate, int DischType)
{
List<object>? SearchPatientsData = null; List<object>? SearchPatientsData = null;
try try
{ {
using (var tx = _repository.GetTransaction()) using (var tx = _repository.GetTransaction())
{ {
string searchTextParam = string.IsNullOrEmpty(SearchText) string searchTextParam = string.IsNullOrEmpty(SearchText)
? "%" ? "''"
: SearchText.Replace("'", "''"); : SearchText.Replace("'", "''");
string sqlQuery = string sqlQuery =
$"SELECT * FROM \"SPScanTool_GetSearchedPatients\"(@Parm_SearchText)"; $"SELECT * FROM \"SPScanTool_GetSearchedPatients\"(@Parm_SearchText,@parm_ProviderId,@parm_LocationId,@parm_DateType,@parm_StartDate,@parm_EndDate,@parm_DischType )";
SearchPatientsData = _repository.Fetch<object>( SearchPatientsData = _repository.Fetch<object>(
sqlQuery, sqlQuery,
new { Parm_SearchText = searchTextParam } new { Parm_SearchText = SearchText, parm_ProviderId = ProviderId, parm_LocationId = LocationId, parm_DateType = DateType, parm_StartDate = StartDate, parm_EndDate = EndDate, parm_DischType = DischType }
); );
GC.Collect(); GC.Collect();
tx.Complete(); tx.Complete();
...@@ -109,6 +342,32 @@ namespace FTP_Services.Services ...@@ -109,6 +342,32 @@ namespace FTP_Services.Services
} }
} }
public List<object>? LoadLocations(int LocationId, Boolean IsLoadAll)
{
List<object>? LoadLocationsData = null;
try
{
using (var tx = _repository.GetTransaction())
{
string sqlQuery =
$"SELECT * FROM \"SPScanTool_LoadLocations\"(@Parm_LocationId,@Parm_LoadAll)";
LoadLocationsData = _repository.Fetch<object>(
sqlQuery,
new { Parm_LocationId = LocationId, Parm_LoadAll = IsLoadAll }
);
GC.Collect();
tx.Complete();
}
return LoadLocationsData;
}
catch (Exception ex)
{
log.Error("LoadLocationsData->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<DocumentCategories>? DocumentCategories() public List<DocumentCategories>? DocumentCategories()
{ {
List<DocumentCategories>? DocumentCategoriesData = null; List<DocumentCategories>? DocumentCategoriesData = null;
...@@ -130,6 +389,27 @@ namespace FTP_Services.Services ...@@ -130,6 +389,27 @@ namespace FTP_Services.Services
return null; return null;
} }
} }
public List<object>? GetProcedures()
{
List<object>? GetProceduresData = null;
try
{
using (var tx = _repository.GetTransaction())
{
GetProceduresData = _repository.Fetch<object>(
"SELECT * FROM \"SPScanTool_GetProcedures\"()"
);
GC.Collect();
tx.Complete();
}
return GetProceduresData;
}
catch (Exception ex)
{
log.Error("GetProcedures ->Failed to get info from db - " + ex.Message);
return null;
}
}
// public List<ConfigValues>? ConfigValues(int CompanyId) // public List<ConfigValues>? ConfigValues(int CompanyId)
// { // {
// List<ConfigValues>? ConfigValuesData = null; // List<ConfigValues>? ConfigValuesData = null;
...@@ -173,17 +453,17 @@ namespace FTP_Services.Services ...@@ -173,17 +453,17 @@ namespace FTP_Services.Services
// Return a default message if not found // Return a default message if not found
return "Database name not found!"; return "Database name not found!";
} }
public List<ConfigValues>? ConfigValues(int CompanyId, string StrConnection) public List<object>? ConfigValues(int CompanyId, string StrConnection)
{ {
string DatabaseName = GetDatabaseNameFromConnectionString(StrConnection); string DatabaseName = GetDatabaseNameFromConnectionString(StrConnection);
List<ConfigValues>? ConfigValuesData = null; List<object>? ConfigValuesData = null;
try try
{ {
using (var tx = _repository.GetTransaction()) using (var tx = _repository.GetTransaction())
{ {
ConfigValuesData = _repository.Fetch<ConfigValues>( ConfigValuesData = _repository.Fetch<object>(
"SELECT '" + DatabaseName + "' AS \"DatabaseName\", * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId "SELECT '" + DatabaseName + "' AS \"DatabaseName\", * FROM \"SPScanTool_GetScanConfigByCompanyId\"(@0)", CompanyId
); );
...@@ -223,77 +503,296 @@ namespace FTP_Services.Services ...@@ -223,77 +503,296 @@ namespace FTP_Services.Services
} }
} }
public List<PatientDocuments>? PatientDocuments(int SPatientID, int SDocID) public List<object>? PatientDocuments(int SPatientID, int SLocationID,int SAppointmentID, int SAdmissionID, int SDocID, string? SDueFrom, string? SDueTO)
{ {
List<PatientDocuments>? PatientDocumentsData = null; List<object>? PatientDocumentsData = null;
try try
{ {
using (var tx = _repository.GetTransaction()) using (var tx = _repository.GetTransaction())
{ {
PatientDocumentsData = _repository.Fetch<PatientDocuments>( string dueFromSql = string.IsNullOrWhiteSpace(SDueFrom) ? "NULL" : $"'{SDueFrom}'";
"SELECT * FROM \"SPScanTool_GetPatientDocuments\"(" string dueToSql = string.IsNullOrWhiteSpace(SDueTO) ? "NULL" : $"'{SDueTO}'";
string sql = $@"
SELECT * FROM ""SPScanTool_GetPatientDocuments""(
{SPatientID},
{SLocationID},
{SAppointmentID},
{SAdmissionID},
{SDocID},
{dueFromSql},
{dueToSql}
);";
PatientDocumentsData = _repository.Fetch<object>(sql);
GC.Collect();
tx.Complete();
}
return PatientDocumentsData;
}
catch (Exception ex)
{
log.Error("PatientDocuments->Failed to get info from db - " + ex.Message);
return null;
}
}
public List<Admissions>? PatientAdmissions(int SPatientID)
{
List<Admissions>? PatientAdmissions = null;
try
{
using (var tx = _repository.GetTransaction())
{
PatientAdmissions = _repository.Fetch<Admissions>(
"SELECT * FROM \"SPScanTool_LoadAdmissions\"("
+ SPatientID.ToString() + SPatientID.ToString()
+ ","
+ SDocID.ToString()
+ ");" + ");"
); );
GC.Collect(); GC.Collect();
tx.Complete(); tx.Complete();
} }
return PatientDocumentsData; return PatientAdmissions;
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("PatientDocuments->Failed to get info from db - " + ex.Message); log.Error("PatientAdmissions->Failed to get info from db - " + ex.Message);
return null; return null;
} }
} }
public int SavePatientDocumentData(PatientDocumentDetailsModel SndPatDocRec) public List<object>? AdmissionDischargeData(int SndAdmissionId)
{ {
int _save = 0; List<object>? AdmissionDischargeData = null;
try try
{ {
using (var tx = _repository.GetTransaction()) using (var tx = _repository.GetTransaction())
{ {
string SQLStr =
"SELECT * FROM \"SPScanTool_SavePatientDocument\"(" string sqlQuery =
+ SndPatDocRec.PatDocId $"SELECT * FROM \"SPScanTool_GetAdmissionDischargeData\"(@Parm_AdmissionId)";
+ ",'" AdmissionDischargeData = _repository.Fetch<object>(
+ SndPatDocRec.UploadedDate sqlQuery,
+ "'," new { Parm_AdmissionId = SndAdmissionId }
+ SndPatDocRec.PatientId );
+ ",'"
+ SndPatDocRec.UploadedBy
+ "','"
+ SndPatDocRec.DocumentName
+ "','"
+ SndPatDocRec.DocumentType
+ "','"
+ SndPatDocRec.ContentType
+ "',"
+ SndPatDocRec.Size
+ ",'"
+ SndPatDocRec.Description
+ "','"
+ SndPatDocRec.DocumentUrl
+ "','"
+ SndPatDocRec.ThumbnailUrl
+ "',"
+ SndPatDocRec.SplID
+ ")";
_save = _repository.Single<int>(SQLStr);
GC.Collect(); GC.Collect();
tx.Complete(); tx.Complete();
} }
return AdmissionDischargeData;
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("SavePatientDocumentData->Failed to get info from db - " + ex.Message); log.Error("AdmissionDischargeData->Failed to get info from db - " + ex.Message);
return null;
}
} }
return _save; public int SaveAdmissionDischargeData(List<AdmissionDischargeModel> models)
{
int savedCount = 0;
try
{
using (var tx = _repository.GetTransaction())
{
string SQLStr = "SELECT public.\"SPScanTool_SaveAdmissionDischargeData\"(@MRDId, @PatientId, @AdmissionId, @ProviderId, " +
"@LocationId, @DepartmentId, @AdmissionAge, @AdmissionDate, @AdmissionTypeId, @DischargeDate, " +
"@DischargeType, @Cause, @UserId, @IsWardChanged, @IsICDChanged, @IsProcChanged, " +
"@Wards::jsonb, @ICDCodes::jsonb, @Procedures::jsonb, @MRD_Diagnosis,@MRD_OtherProcedures)"; // Explicitly cast JSON to jsonb @MRD_Diagnosis::jsonb
foreach (var model in models)
{
var parameters = new
{
MRDId = model.MRDId,
PatientId = model.PatientId,
AdmissionId = model.AdmissionId,
ProviderId = model.ProviderId,
LocationId = model.LocationId,
DepartmentId = model.DepartmentId,
AdmissionAge = model.AdmissionAge,
AdmissionDate = model.AdmissionDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? (object)DBNull.Value, // Null safety
AdmissionTypeId = model.AdmissionTypeId,
DischargeDate = model.DischargeDate?.ToString("yyyy-MM-dd HH:mm:ss") ?? (object)DBNull.Value, // Null safety
//DischargeTypeId = model.DischargeTypeId,
DischargeType = model.DischargeType,
Cause = string.IsNullOrEmpty(model.Cause) ? (object)DBNull.Value : model.Cause, // Handle null
UserId = model.UserId,
IsWardChanged = model.IsWardChanged,
IsICDChanged = model.IsICDChanged,
IsProcChanged = model.IsProcChanged,
Wards = model.Wards != null ? JsonConvert.SerializeObject(model.Wards) : (object)DBNull.Value, // Convert to JSON string
ICDCodes = model.ICDCodes != null ? JsonConvert.SerializeObject(model.ICDCodes) : (object)DBNull.Value,
Procedures = model.Procedures != null ? JsonConvert.SerializeObject(model.Procedures) : (object)DBNull.Value,
MRD_Diagnosis = string.IsNullOrEmpty(model.Diagnosis) ? (object)DBNull.Value : model.Diagnosis.ToString(),
MRD_OtherProcedures = string.IsNullOrEmpty(model.MRD_OtherProcedures) ? (object)DBNull.Value : model.MRD_OtherProcedures.ToString(),
};
savedCount += _repository.Single<int>(SQLStr, parameters);
} }
tx.Complete();
}
}
catch (Npgsql.PostgresException pgEx)
{
log.Error($"PostgreSQL Error in SaveAdmissionDischargeData -> Code: {pgEx.SqlState}, Message: {pgEx.Message}", pgEx);
}
catch (Exception ex)
{
log.Error($"SaveAdmissionDischargeData -> Failed to execute query - Error: {ex.Message}", ex);
}
return savedCount;
}
public int SavePatientDocumentData(List<PatientDocumentDetailsModel> patientDocs)
{
int savedCount = 0;
try
{
using (var tx = _repository.GetTransaction())
{
foreach (var doc in patientDocs)
{
string SQLStr = "SELECT * FROM \"SPScanTool_SavePatientDocument\"(@PatDocId, @UploadedDate, @PatientId, @UploadedBy, " +
"@DocumentName, @DocumentType, @ContentType, @Size, @Description, @DocumentUrl, @ThumbnailUrl,@SortNo, @SplID, @AdmissionID)";
var parameters = new
{
PatDocId = doc.PatDocId,
UploadedDate = doc.UploadedDate, // Ensure valid date format if needed
PatientId = doc.PatientId,
UploadedBy = doc.UploadedBy,
DocumentName = doc.DocumentName,
DocumentType = doc.DocumentType,
ContentType = doc.ContentType,
Size = doc.Size, // Ensure string is handled correctly
Description = doc.Description,
DocumentUrl = doc.DocumentUrl,
ThumbnailUrl = doc.ThumbnailUrl,
SortNo = doc.SortNo,
SplID = doc.SplID,
AdmissionID = doc.AdmissionID
};
_repository.Single<int>(SQLStr, parameters);
savedCount++;
}
tx.Complete();
}
}
catch (Exception ex)
{
log.Error("SaveMultiplePatientDocuments -> Failed to save records - Error: " + ex.Message);
}
return savedCount;
}
public int UpdateImageCategory(int sndPatDocId, int sndDocTypeId, int sndUserID)
{
int savedCount = 0;
try
{
using (var tx = _repository.GetTransaction())
{
string SQLStr = "SELECT * FROM \"SPScanTool_UpdateImageCategory\"(@PatDocId, @DocTypeId, @UserID)";
var parameters = new
{
PatDocId = sndPatDocId,
DocTypeId = sndDocTypeId, // Ensure valid date format if needed
UserID = sndUserID
};
_repository.Single<int>(SQLStr, parameters);
savedCount++;
tx.Complete();
}
}
catch (Exception ex)
{
log.Error("UpdateImageCategory -> Failed to save records - Error: " + ex.Message);
}
return savedCount;
}
public int UpdateImageSortNo(PatientImgDocSort model)
{
int savedCount = 0;
try
{
using (var tx = _repository.GetTransaction())
{
string SQLStr = "SELECT * FROM public.\"SPScanTool_UpdateImageSortNo\"(@Parm_SortData::jsonb)";
var parameters = new
{
Parm_SortData = model != null
? JsonConvert.SerializeObject(model)
: "[]"
};
_repository.Single<int>(SQLStr, parameters);
savedCount++;
tx.Complete();
}
}
catch (Exception ex)
{
log.Error("UpdateImageSortNo -> Failed to save records - Error: " + ex.Message);
}
return savedCount;
}
// public int SavePatientDocumentData_bkp(PatientDocumentDetailsModel SndPatDocRec)
// {
// int _save = 0;
// try
// {
// using (var tx = _repository.GetTransaction())
// {
// string SQLStr =
// "SELECT * FROM \"SPScanTool_SavePatientDocument\"("
// + SndPatDocRec.PatDocId
// + ",'"
// + SndPatDocRec.UploadedDate
// + "',"
// + SndPatDocRec.PatientId
// + ","
// + SndPatDocRec.UploadedBy
// + ",'"
// + SndPatDocRec.DocumentName
// + "','"
// + SndPatDocRec.DocumentType
// + "','"
// + SndPatDocRec.ContentType
// + "',"
// + SndPatDocRec.Size
// + ",'"
// + SndPatDocRec.Description
// + "','"
// + SndPatDocRec.DocumentUrl
// + "','"
// + SndPatDocRec.ThumbnailUrl
// + "',"
// + SndPatDocRec.SplID
// + ","
// + SndPatDocRec.AdmissionID
// + ")";
// _save = _repository.Single<int>(SQLStr);
// GC.Collect();
// tx.Complete();
// }
// }
// catch (Exception ex)
// {
// log.Error("SavePatientDocumentData->Failed to get info from db - " + ex.Message);
// }
// return _save;
// }
// public int DeletePatientDocumentData(int SndPatDocRecID) // public int DeletePatientDocumentData(int SndPatDocRecID)
// { // {
// int _Delete = 0; // int _Delete = 0;
...@@ -317,7 +816,7 @@ namespace FTP_Services.Services ...@@ -317,7 +816,7 @@ namespace FTP_Services.Services
// return _Delete; // return _Delete;
// } // }
public string DeletePatientDocumentData(int SndPatDocRecID,int SndUserID) public string DeletePatientDocumentData(int SndPatDocRecID, int SndUserID)
{ {
string result = string.Empty; string result = string.Empty;
try try
...@@ -326,7 +825,7 @@ namespace FTP_Services.Services ...@@ -326,7 +825,7 @@ namespace FTP_Services.Services
{ {
string SQLStr = string SQLStr =
"SELECT * FROM \"SPScanTool_DeletePatientDocument\"(" "SELECT * FROM \"SPScanTool_DeletePatientDocument\"("
+ SndPatDocRecID +','+ SndUserID + SndPatDocRecID + ',' + SndUserID
+ ");"; + ");";
result = _repository.Single<string>(SQLStr); result = _repository.Single<string>(SQLStr);
......
{ {
"AppSettings": { "AppSettings": {
"Secret": "A78E-F7FA-B0FD-DAA45BB866CD-AA73D560-DACC-978C-4A9B-9924-5DE7E33F0040-GCD00", "Secret": "A78E-F7FA-B0FD-DAA45BB866CD-AA73D560-DACC-978C-4A9B-9924-5DE7E33F0040-GCD00",
"ConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000", "ConnectionString": "SERVER=192.168.7.207;PORT=5432;UID=ff4dbuser;PWD=dbuser4ff123!;Database=fernandez_test_20250409_dev;Timeout=1000",
"AdminConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000", "AdminConnectionString": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=CareaxesAdmin;Timeout=1000",
"ConnectionString1": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000",
"AdminConnectionString1": "SERVER=10.11.12.106;PORT=5432;UID=himsdbuser;PWD=dbuser@hims123!;database=fernandez_20241125;Timeout=1000",
"FTPConfiguration": { "FTPConfiguration": {
"Username": "admin", "Username": "admin",
"Password": "Fmh@xp@rt01", "Password": "Fmh@xp@rt01",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment