예제 #1
0
    def test_kunjungan_create(self):
        diagnosis = DiagnosisFactory.create()
        new_diagnosis = DiagnosisKunjunganFactory.build_batch(
            random.randint(0, 3), diagnosis=diagnosis)
        tindakan = TindakanFactory.create()
        subsidi_tindakan = ParameterSubsidiTindakanFactory.create(
            tindakan=tindakan, kategori_pasien='Mahasiswa')
        new_tindakan = TindakanKunjunganFactory.build_batch(random.randint(
            0, 3),
                                                            tindakan=tindakan)

        new_pasien = MahasiswaFactory.create()
        new_pasien.init_subsidi()
        new_dokter = DokterFactory.create()
        new_kunjungan = KunjunganFactory.build(pasien=new_pasien,
                                               dokter=new_dokter)

        data = {
            'kunjungan': new_kunjungan.serialize(),
        }

        data['kunjungan']['pasien'] = data['kunjungan']['pasien']['no_pasien']
        data['kunjungan']['klinik'] = data['kunjungan']['klinik']['kode']
        data['kunjungan']['dokter'] = data['kunjungan']['dokter']['kode']

        response = Request().post('/main/klinik/kunjungan/',
                                  data,
                                  **self.auth_headers,
                                  content_type='application/json')
        self.assertEqual(response.status_code, 200)
        ''' Test if pasien created '''
        saved_kunjungan = Kunjungan.objects.first()
        self.assertEqual(saved_kunjungan.pasien.no_pasien,
                         new_kunjungan.pasien.no_pasien)
예제 #2
0
    def test_list_pasien_with_search_parameter(self):
        pasien_list = MahasiswaFactory.create_batch(15, golongan_darah='O')
        noise = MahasiswaFactory.create_batch(10, golongan_darah='AB')

        response = Request().get('/main/pasien/?golongan_darah=O', **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        search_dict = {'golongan_darah' : 'O'}
        expected_list = GetModelList(Pasien, search_dict=search_dict).call()
        fetched_list = json.loads(response.content)['pasien']

        for i in range(len(expected_list)):
            self.assertEqual(fetched_list[i]['id'], expected_list[i].id)
            self.assertEqual(fetched_list[i]['no_pasien'], expected_list[i].no_pasien)
            self.assertEqual(fetched_list[i]['kategori'], expected_list[i].kategori)
            self.assertEqual(fetched_list[i]['nama'], expected_list[i].nama)
예제 #3
0
    def test_list_pasien_without_search_parameter(self):
        pasien_list = MahasiswaFactory.create_batch(20)

        response = Request().get('/main/pasien/', **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        expected_list = GetModelList(Pasien).call()
        fetched_list = json.loads(response.content)['pasien']

        for i in range(len(expected_list)):
            self.assertEqual(fetched_list[i]['id'], expected_list[i].id)
            self.assertEqual(fetched_list[i]['no_pasien'], expected_list[i].no_pasien)
            self.assertEqual(fetched_list[i]['kategori'], expected_list[i].kategori)
            self.assertEqual(fetched_list[i]['nama'], expected_list[i].nama)
예제 #4
0
    def test_list_kunjungan_with_search_parameter(self):
        new_pasien = MahasiswaFactory.create()
        kunjungan_list = KunjunganFactory.create_batch(15, pasien=new_pasien)
        noise = KunjunganFactory.create_batch(15)

        response = Request().get(
            '/main/klinik/kunjungan/?pasien__nama={}'.format(new_pasien.nama),
            **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        search_dict = {'pasien__nama': new_pasien.nama}
        expected_list = GetModelList(Kunjungan, search_dict=search_dict).call()
        fetched_list = json.loads(response.content)['kunjungan']

        for i in range(len(expected_list)):
            self.assertEqual(fetched_list[i], expected_list[i].serialize())
예제 #5
0
    def test_pasien_get(self):
        new_pasien = MahasiswaFactory.create()
        
        response = Request().get(
            '/main/pasien/{}/'.format(new_pasien.no_pasien), **self.auth_headers
        )
        self.assertEqual(response.status_code, 200)

        fetched_pasien = json.loads(response.content)['pasien']
        self.assertEqual(fetched_pasien['no_pasien'], new_pasien.no_pasien)
        self.assertEqual(fetched_pasien['kategori'], new_pasien.kategori)
        self.assertEqual(
            fetched_pasien['nomor_kartu_identitas'],
            new_pasien.nomor_kartu_identitas
        )
        self.assertEqual(fetched_pasien['no_hp'], new_pasien.no_hp)
        self.assertTrue(fetched_pasien['subsidi'])
예제 #6
0
    def test_pasien_update(self):
        pasien = MahasiswaFactory.create()
        update_params = {
            'no_telepon' : '123',
            'no_hp' : '456',
            'alamat' : 'jalan ganesha',
            'kota' : 'Surakarta'
        }
        url = '/main/pasien/{}/'.format(pasien.no_pasien)

        response = Request().patch(url, data=json.dumps(update_params), **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        pasien.refresh_from_db()
        self.assertEqual(pasien.no_telepon, update_params['no_telepon'])
        self.assertEqual(pasien.no_hp, update_params['no_hp'])
        self.assertEqual(pasien.alamat, update_params['alamat'])
        self.assertEqual(pasien.kota, update_params['kota'])
예제 #7
0
    def test_pasien_create(self):
        ParameterSubsidiKunjunganFactory.create(kategori_pasien='Mahasiswa')
        ParameterSubsidiObatFactory.create(kategori_pasien='Mahasiswa')
        ParameterSubsidiTindakanFactory.create(kategori_pasien='Mahasiswa')
        new_pasien = MahasiswaFactory.build()
        data = new_pasien.serialize()

        response = Request().post(
            '/main/pasien/', data, **self.auth_headers, content_type='application/json'
        )
        self.assertEqual(response.status_code, 200)
        
        ''' Test if pasien created '''
        saved_pasien = Pasien.objects.first()
        self.assertEqual(saved_pasien.nama, new_pasien.nama)
        self.assertEqual(
            saved_pasien.nomor_kartu_identitas,
            new_pasien.nomor_kartu_identitas
        )
        self.assertEqual(saved_pasien.kategori, new_pasien.kategori)
        self.assertTrue(saved_pasien.subsidi_kunjungan_set)
        self.assertTrue(saved_pasien.subsidi_obat_set)
        self.assertTrue(saved_pasien.subsidi_tindakan_set)