public int AddHivTestTracker(int personId, string facilityMflCode, string diagnosisMode, string providerName, string providerId, int ptnpk, DateTime resultDate, string testResult, string strategy, string testCategory) { try { using (UnitOfWork unitOfWork = new UnitOfWork(new PsmartContext())) { var hivTestResult = unitOfWork.HivTestTrackerRepository.FindBy(x => x.PersonId == personId && x.ResultDate == resultDate && x.Result == testResult && x.Strategy == testResult && x.MFLCode == facilityMflCode) .FirstOrDefault(); if (hivTestResult != null) { } else { var newHivTest = new HivTestTracker() { MFLCode = facilityMflCode, PersonId = personId, //hivtest.PersonId, ProviderName = providerName, ProviderId = providerId, Ptn_pk = ptnpk, ResultDate = resultDate, ResultCategory = testCategory, Result = testResult, Strategy = strategy }; if (!string.IsNullOrEmpty(diagnosisMode)) { newHivTest.DiagnosisMode = diagnosisMode; } unitOfWork.HivTestTrackerRepository.Add(newHivTest); _result = unitOfWork.Complete(); unitOfWork.Dispose(); } } return(_result); } catch (Exception e) { Console.WriteLine(e); throw new Exception(e.Message); } }
public int EditHivTestTracker(HivTestTracker hivTestTracker) { try { using (UnitOfWork unitOfWork = new UnitOfWork(new PsmartContext())) { unitOfWork.HivTestTrackerRepository.Update(hivTestTracker); _result = unitOfWork.Complete(); unitOfWork.Dispose(); return(_result); } } catch (Exception e) { Console.WriteLine(e); throw; } }
//private int result = 0; //public void TrackHIVTest(PatientLookup patient, List<DTO.PSmart.HIVTEST> hivTests) //{ // List<HivTestTracker> hivTracker = this.GetPersonsHivTests(patient.PersonId); // foreach (var hivtest in hivTests.Where(tx => !string.IsNullOrWhiteSpace(tx.RESULT))) // { // if (!hivTracker.Exists(xx => xx.PersonId == patient.PersonId // && xx.MFLCode == hivtest.FACILITY // && xx.Strategy == hivtest.STRATEGY // && xx.Result == hivtest.RESULT // && xx.ResultDate == DateTime.ParseExact(hivtest.DATE, "yyyyMMdd", CultureInfo.InvariantCulture) // && xx.ProviderName.Trim().ToLower() == xx.ProviderName.Trim().ToLower())) // { // DateTime resultDate = DateTime.ParseExact(hivtest.DATE, "yyyyMMdd", CultureInfo.InvariantCulture); // hivTestTrackerManager.AddHivTestTracker(patient.PersonId, hivtest.FACILITY, // hivtest.STRATEGY, hivtest.PROVIDER_DETAILS.NAME, hivtest.PROVIDER_DETAILS.ID, // Convert.ToInt32(patient.ptn_pk), resultDate, hivtest.RESULT, hivtest.STRATEGY, // hivtest.TYPE); // } // } //} //public int AddHivTestTracker(int personId, string facilityMflCode, string diagnosisMode, string providerName, string providerId, int ptnpk, DateTime resultDate, string testResult, string strategy, string testCategory) //{ // if (testResult != null) // { // result = hivTestTrackerManager.AddHivTestTracker(personId,facilityMflCode,diagnosisMode,providerName,providerId,ptnpk,resultDate,testResult,strategy,testCategory); // } // return result; //} //public List<HivTestTracker> GetPersonsHivTests(int personId) //{ // return hivTestTrackerManager.GetPersonHIVTest(personId); //} public int EditHivTestTracker(HivTestTracker hivTestTracker) { return(hivTestTrackerManager.EditHivTestTracker(hivTestTracker)); }