Пример #1
0
    def test_pembelian_create(self):
        param_subsidi_obat = ParameterSubsidiObatFactory.create(
            kategori_pasien='Mahasiswa')
        new_pasien = PasienFactory.create(kategori='Mahasiswa')
        new_pembelian = PembelianResepFactory.create(pasien=new_pasien)
        data = new_pembelian.serialize()
        data['pasien'] = data['pasien']['no_pasien']
        data['waktu_pembelian'] = datetime.datetime.now()
        for i in range(len(data['obat'])):
            data['obat'][i]['obat'] = data['obat'][i]['obat']['kode']

        response = Request().post('/main/apotek/resep/',
                                  data,
                                  **self.auth_headers,
                                  content_type='application/json')
        self.assertEqual(response.status_code, 200)

        saved_pembelian = PembelianResep.objects.first()
        saved_pembelian = saved_pembelian.serialize()
        saved_pembelian.pop('id')
        saved_pembelian.pop('obat')
        new_pembelian = new_pembelian.serialize()
        new_pembelian.pop('obat')
        new_pembelian.pop('id')
        self.assertEqual(saved_pembelian, new_pembelian)
Пример #2
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)
Пример #3
0
    def test_list_pembelian_without_search_parameter(self):
        PembelianResepFactory.create_batch(20)

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

        expected_list = GetModelList(PembelianResep).call()
        fetched_list = json.loads(response.content)['pembelian']

        for i in range(len(expected_list)):
            self.assertEqual(fetched_list[i], expected_list[i].serialize())
Пример #4
0
    def test_pembelian_get(self):
        new_pembelian = PembelianResepFactory.create()

        response = Request().get(
            '/main/apotek/resep/{}/'.format(new_pembelian.id),
            **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        fetched_pembelian = json.loads(response.content)['pembelian']
        expected_pembelian = new_pembelian.serialize()
        self.assertEqual(fetched_pembelian, expected_pembelian)
Пример #5
0
    def test_list_kunjungan_without_search_parameter(self):
        KunjunganFactory.create_batch(20)

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

        expected_list = GetModelList(Kunjungan).call()
        fetched_list = json.loads(response.content)['kunjungan']

        for i in range(len(expected_list)):
            self.assertEqual(fetched_list[i], expected_list[i].serialize())
Пример #6
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)
Пример #7
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)
Пример #8
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())
Пример #9
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'])
Пример #10
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'])
Пример #11
0
    def test_kunjungan_get(self):
        new_kunjungan = KunjunganFactory.create()
        new_tindakan = TindakanKunjunganFactory.create(kunjungan=new_kunjungan)
        new_diagnosis = DiagnosisKunjunganFactory.create(
            kunjungan=new_kunjungan)

        response = Request().get(
            '/main/klinik/kunjungan/{}/'.format(new_kunjungan.kode),
            **self.auth_headers)
        self.assertEqual(response.status_code, 200)

        fetched_kunjungan = json.loads(response.content)['kunjungan']
        expected_kunjungan = new_kunjungan.serialize()
        self.assertEqual(fetched_kunjungan['id'], expected_kunjungan['id'])
        self.assertEqual(len(fetched_kunjungan['tindakan']),
                         len(expected_kunjungan['tindakan']))
        self.assertEqual(len(fetched_kunjungan['diagnosis']),
                         len(expected_kunjungan['diagnosis']))
Пример #12
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)