public void should_sync_new_patient() { var patient = new Patient(); patient.Firstname = "Frank1"; patient.Middlename = "L"; patient.Lastname = "Lampard1"; patient.Sex = 16; patient.Idtype = 40001; patient.Clientcode = "1"; patient.Dob = DateTime.Today.AddYears(-51); patient.Enrollmentdate = patient.Enrollmenttime = DateTime.Now; _patientService.Sync(patient, true); var savedPatient = _patientService.GetAll().FirstOrDefault(x => x.UuId == patient.UuId); Assert.That(savedPatient, Is.Not.Null); uuids.Add(savedPatient.UuId); Assert.That(savedPatient.Lastname, Is.EqualTo("Lampard1")); Assert.False(string.IsNullOrWhiteSpace(_createEmrPatientHandler.GetNotification())); Debug.Print(savedPatient.ToString()); Debug.Print(_createEmrPatientHandler.GetNotification()); _emrRepository = new EmrRepository(); var iqpatient = _emrRepository.GetPatient(savedPatient.UuId); Assert.NotNull(iqpatient); testIQPatientId = iqpatient.Id; Assert.That(iqpatient.FirstName, Is.EqualTo(patient.Firstname)); Assert.That(iqpatient.MiddleName, Is.EqualTo(patient.Middlename)); Assert.That(iqpatient.LastName, Is.EqualTo(patient.Lastname)); Assert.That(iqpatient.SyncId, Is.EqualTo(patient.UuId)); Debug.Print($"IQCare:{iqpatient.ToStringDetail()}"); }
public void should_Create_Patient() { testIQPatientId = -1; var patient = _testPatients.First(); Assert.NotNull(patient); IQLocation location = _emrRepository.GetLocation(locationId); Assert.NotNull(location); _createEmrPatientHandler.Handle(new PatientCreated(patient, location)); Debug.Print(_createEmrPatientHandler.GetNotification()); Assert.That(_createEmrPatientHandler.GetSqlActions(), Is.Not.Empty); //Debug.Print(_createEmrPatientHandler.GetSqlActionsBatch()); _emrRepository.CreatePatient(_createEmrPatientHandler.GetSqlActions(), patient.UuId); var iqpatient = _emrRepository.GetPatient(patient.UuId); Assert.NotNull(iqpatient); Assert.That(iqpatient.ClientCode, Is.EqualTo(patient.Clientcode)); testIQPatientId = iqpatient.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($"From Android:{patient}!"); Debug.Print(new string('-', 15)); Debug.Print($"New Patient:{iqpatient.ToStringDetail()}"); }