Пример #1
0
        public void should_sync_existing_patient()
        {
            var patient = _patientService.GetAll().FirstOrDefault(x => x.Lastname.ToLower() == "TerryXy".ToLower());

            Assert.That(patient, Is.Not.Null);
            patient.Lastname = "Terry";
            _patientService.Sync(patient, true);

            var savedPatient = _patientService.GetAll().FirstOrDefault(x => x.Lastname == patient.Lastname);

            Assert.That(savedPatient, Is.Not.Null);
            Assert.That(savedPatient.Firstname, Is.EqualTo(patient.Firstname));

            Assert.False(string.IsNullOrWhiteSpace(_createEmrPatientHandler.GetNotification()));
            Debug.Print(savedPatient.ToString());
            Debug.Print(_createEmrPatientHandler.GetNotification());

            var iqpatient = _emrRepository.GetPatient(savedPatient.UuId);

            Assert.NotNull(iqpatient);
            testIQPatientId = iqpatient.Id;
            Assert.That(iqpatient.FirstName, Is.EqualTo(savedPatient.Firstname));
            Assert.That(iqpatient.MiddleName, Is.EqualTo(savedPatient.Middlename));
            Assert.That(iqpatient.LastName, Is.EqualTo(savedPatient.Lastname));
            Assert.That(iqpatient.SyncId, Is.EqualTo(savedPatient.UuId));
            Debug.Print($"IQCare:{iqpatient.ToStringDetail()}");
        }
Пример #2
0
        public void should_GetPatient()
        {
            var module = _emrRepository.GetPatient(5);

            Assert.NotNull(module);
            Debug.Print($"{module.ToStringDetail()}");
        }
Пример #3
0
        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()}");
        }
Пример #4
0
        public void should_Post()
        {
            // Arrange
            Assert.That(_patientWithEncounter, Is.Not.Null);
            var controller = new PatientController(_patientService);

            // Act
            controller.Post(PateintDTO.Create(_patientWithEncounter));

            // Assert
            _uow            = new UnitOfWork(new SyncContext());
            _patientService = new PatientService(_uow, new EmrRepository(), _createEmrPatientHandler, _createEmrEncounterHandler);
            var newPatient = _patientService.GetAll().FirstOrDefault(x => x.UuId == _patientWithEncounter.UuId);

            Assert.NotNull(newPatient);
            Assert.AreEqual(_patientWithEncounter.Lastname, newPatient.Lastname);
            Debug.Print(newPatient.ToString());
            var iqpatient = _emrRepository.GetPatient(newPatient.UuId);

            Assert.NotNull(iqpatient);
            testIQPatientId = iqpatient.Id;
            Assert.That(iqpatient.FirstName, Is.EqualTo(_patientWithEncounter.Firstname));
            Assert.That(iqpatient.MiddleName, Is.EqualTo(_patientWithEncounter.Middlename));
            Assert.That(iqpatient.LastName, Is.EqualTo(_patientWithEncounter.Lastname));
            Assert.That(iqpatient.SyncId, Is.EqualTo(_patientWithEncounter.UuId));
            Debug.Print($"IQCare:{iqpatient.ToStringDetail()}");
        }
Пример #5
0
        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()}");
        }