public void should_sync_new_Encounter() { var encounters = new List <Encounter>(); var patient = _testEncounters.First().Patient; var encounter = _testEncounters.First(); encounters.Add(encounter); _encounterService.Sync(encounters, patient); _uow = new UnitOfWork(new SyncContext()); _patientService = new PatientService(_uow, _emrRepository, _createEmrPatientHandler, _createEmrEncounterHandler); _encounterService = _patientService.EncounterService; var savedEncounter = _encounterService.GetAll().First(x => x.UuId == encounter.UuId); Assert.That(savedEncounter, Is.Not.Null); Debug.Print(savedEncounter.ToString()); foreach (var obs in savedEncounter.Observations) { Debug.Print($" >.{obs.ToString()}"); } Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [ord_Visit] where Ptn_Pk in ({_iqPatient.Id}) AND VisitType=219"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [DTL_FBCUSTOMFIELD_KNH_HTC_Form] where Ptn_Pk in ({_iqPatient.Id})"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [dtl_fb_MARPsHTC] where Ptn_Pk in ({_iqPatient.Id})"), Is.EqualTo(2)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [dtl_fb_DisabilityHTC] where Ptn_Pk in ({_iqPatient.Id})"), Is.EqualTo(3)); Assert.That(_emrRepository.ExecuteQueryStringResult($"select remarks from [DTL_FBCUSTOMFIELD_KNH_HTC_Form] where Ptn_Pk in ({_iqPatient.Id})"), Is.StringContaining("No remark")); }
public void should_decrypt_session() { string sql = $@" {Utility.GetSqlDecrptyion()} select top 1 (convert(varchar(50),decryptbykey(firstname))) from mst_Patient"; string patientFirstName = _emrRepository.ExecuteQueryStringResult(sql); Assert.False(string.IsNullOrWhiteSpace(patientFirstName)); Debug.Print(patientFirstName); }
public void should_sync_new_patient_with_encounters() { testIQPatientId = -1; var patient = _testEncounters.First().Patient; Assert.NotNull(patient); Assert.That(patient, Is.Not.Null); Assert.That(patient.Encounters, Is.Not.Empty); _patientService.Sync(patient, false); var savedPatient = _patientService.GetAll().FirstOrDefault(x => x.Lastname == patient.Lastname); Assert.That(savedPatient, Is.Not.Null); Debug.Print(savedPatient.ToString()); Assert.That(savedPatient.Encounters, Is.Not.Empty); foreach (var e in savedPatient.Encounters) { Debug.Print($" >.{e.ToString()}"); foreach (var o in e.Observations) { Debug.Print($" >>.{o}"); } } Assert.False(string.IsNullOrWhiteSpace(_createEmrPatientHandler.GetNotification())); Debug.Print(_createEmrPatientHandler.GetNotification()); var iqpatient = _emrRepository.GetPatient(savedPatient.UuId); Assert.NotNull(iqpatient); testIQPatientId = iqpatient.Id; Debug.Print($"IQCare:{iqpatient.ToStringDetail()}"); Assert.That(_createEmrEncounterHandler.GetSqlActions(), Is.Not.Empty); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [ord_Visit] where Ptn_Pk in ({testIQPatientId}) AND VisitType=219"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [DTL_FBCUSTOMFIELD_KNH_HTC_Form] where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [dtl_fb_MARPsHTC] where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(2)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [dtl_fb_DisabilityHTC] where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(3)); Assert.That(_emrRepository.ExecuteQueryStringResult($"select remarks from [DTL_FBCUSTOMFIELD_KNH_HTC_Form] where Ptn_Pk in ({testIQPatientId})"), Is.StringContaining("No remark")); }
public void should_Update_Patient() { testIQPatientId = -1; var patient = _testPatients.First(); Assert.NotNull(patient); IQLocation location = _emrRepository.GetLocation(locationId); Assert.NotNull(location); _createEmrPatientHandler.Handle(new PatientCreated(patient, location)); _emrRepository.CreatePatient(_createEmrPatientHandler.GetSqlActions(), patient.UuId); var iqpatient = _emrRepository.GetPatient(patient.UuId); Assert.NotNull(iqpatient); Debug.Print($"From Android:{patient}!"); Assert.That(iqpatient.ClientCode, Is.EqualTo(patient.Clientcode)); testIQPatientId = iqpatient.Id; ///// patient.Lastname = "Kimani"; patient.Clientcode = "KKK"; _uow = new UnitOfWork(new SyncContext()); _uow.PatientRepository.Update(patient); _uow.Commit(); _uow = new UnitOfWork(new SyncContext()); var updatedPatient = _uow.PatientRepository.FindById(patient.Id); Assert.NotNull(updatedPatient); Assert.AreEqual(updatedPatient.UuId, patient.UuId); Assert.AreEqual("Kimani", updatedPatient.Lastname); Assert.AreEqual("KKK", updatedPatient.Clientcode); _createEmrPatientHandler.Handle(new PatientCreated(updatedPatient, location)); _emrRepository.CreatePatient(_createEmrPatientHandler.GetSqlActions(), updatedPatient.UuId); _emrRepository = new EmrRepository(); var iqpatientUpdated = _emrRepository.GetPatient(updatedPatient.UuId); Assert.NotNull(iqpatientUpdated); Assert.That(iqpatientUpdated.ClientCode, Is.EqualTo(updatedPatient.Clientcode)); Assert.That(iqpatientUpdated.LastName, Is.EqualTo(updatedPatient.Lastname)); Assert.AreEqual(testIQPatientId, iqpatientUpdated.Id); Assert.True(testIQPatientId > -1); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [mst_Patient] where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [DTL_FBCUSTOMFIELD_Patient_Registration] where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQueryStringResult($"SELECT IQNumber FROM mst_Patient WHERE Ptn_Pk = {testIQPatientId}"), Is.StringContaining("IQ-")); foreach (var t in _factory.GetIQTables()) { Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from {t} where Ptn_Pk in ({testIQPatientId})"), Is.EqualTo(1)); } Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [ord_Visit] where Ptn_Pk in ({testIQPatientId}) AND VisitType=12"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [ord_Visit] where Ptn_Pk in ({testIQPatientId}) AND VisitType=115"), Is.EqualTo(1)); Assert.That(_emrRepository.ExecuteQuery($"select count(Ptn_Pk) from [lnk_patientprogramstart] where Ptn_Pk in ({testIQPatientId}) AND ModuleID=5"), Is.EqualTo(1)); Debug.Print($"Udated to:{updatedPatient}!"); Debug.Print(new string('-', 15)); Debug.Print($"New Patient:{iqpatientUpdated.ToStringDetail()}"); }