Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component, Fragment } from 'react';
- import {
- View,
- TextInput,
- Text,
- Dimensions,
- FlatList,
- Alert,
- TouchableOpacity,
- Platform,
- StyleSheet
- } from 'react-native';
- import { SearchBar, Header, Input, Button, Image } from 'react-native-elements';
- import AsyncStorage from '@react-native-community/async-storage';
- import moment from "moment";
- // import Icon from 'react-native-vector-icons/dist/FontAwesome';
- // import Logo from '../assets/img/gundam.png';
- // import LoginLogo from '../assets/img/login-logo.png';
- // import LoginDoctor from '../assets/img/login-doctor.png';
- // import Ext from '../assets/img/Group5x.png';
- // import Stet from '../assets/img/stethoscope.png';
- // import Appoint from '../assets/img/browser.png';
- // import Que from '../assets/img/time-management.png';
- // import LeftHeaderLogin from '../components/leftHeaderLogin';
- // import { TextField } from 'react-native-material-textfield';
- // import { TextInputMask } from 'react-native-masked-text';
- // import CardQuota from '../components/cardQuota';
- // import Doctor from '../assets/img/doctor2.png';
- import Doctor from '../../../component/img/doctor2.png';
- import NoDoctor from '../../../component/img/no_doctor.png';
- import { SafeAreaView } from 'react-navigation';
- import { ScrollView } from 'react-native-gesture-handler';
- import LeftHeaderBack from '../../../component/header/leftHeaderBack';
- import CardDoctor from '../../../component/card/cardDoctor';
- import CardQuotaSelect from '../../../component/card/cardQuotaSelect';
- import Loader from '../../../global/loader';
- import { URL_SERVER_PHC } from '../../../global/settings';
- import base64 from 'react-native-base64';
- import { Peringatan, DateFormat, Exception, _1stColor} from '../../../global/dev';
- // import LeftHeaderBack from '../components/leftHeaderBack';
- // import CardDoctor from '../components/cardDoctor';
- // import CardQuotaSelect from '../components/cardQuotaSelect';
- const UkuranBaku = Dimensions.get('window').width;
- export default class getDokterJadwalList extends Component {
- constructor(props) {
- super(props);
- this.state = {
- // token: null,
- token: 'g4nUG',
- data: [],
- search: "",
- loading: false,
- HeightHeadVal: 122,
- PaddingTopVal: 70,
- HeightScreen: 712,
- coba: [],
- fromScreen: "",
- isLogedOn: false,
- fotoDokter: '',
- pasien_noPeserta_as: '',
- kodeAsuransi_as: '',
- norm_as: '',
- pasien_nama_as: '',
- tglLahir_as: '',
- pasien_alamat_as: '',
- namaAsuransi_as: '',
- pasien_email_as: '',
- pasien_phone_as: '',
- noAsuransi_as: '',
- appointmentType: 'byRS',
- test: '',
- tgl: '',
- tanggalPilih:'',
- };
- }
- componentDidMount = () => {
- this.checkState();
- };
- async checkState() {
- this.setState({
- loading: false
- })
- // const value = await AsyncStorage.getItem('ibs_jwt_token');
- // const value2 = await AsyncStorage.getItem('ibs_kd_cabang');
- // const value3 = await AsyncStorage.getItem('ibs_mplg_kode');
- // const value4 = await AsyncStorage.getItem('ibs_username');
- const pasien_noPeserta_as = await AsyncStorage.getItem('phc_pasien_noPeserta');
- const kodeAsuransi_as = await AsyncStorage.getItem('phc_kodeAsuransi');
- const norm_as = await AsyncStorage.getItem('phc_norm');
- const pasien_nama_as = await AsyncStorage.getItem('phc_pasien_nama');
- const tglLahir_as = await AsyncStorage.getItem('phc_tglLahir');
- const pasien_alamat_as = await AsyncStorage.getItem('phc_pasien_alamat');
- const namaAsuransi_as = await AsyncStorage.getItem('phc_namaAsuransi');
- const pasien_email_as = await AsyncStorage.getItem('phc_pasien_email');
- const pasien_phone_as = await AsyncStorage.getItem('phc_pasien_phone');
- const noAsuransi_as = await AsyncStorage.getItem('phc_noAsuransi');
- const isLogedOn = await AsyncStorage.getItem('phc_pasien_noPeserta') ? true : false;
- this.setState({
- isLogedOn: isLogedOn,
- pasien_noPeserta_as: pasien_noPeserta_as ? pasien_noPeserta_as : '-',
- kodeAsuransi_as: kodeAsuransi_as ? kodeAsuransi_as : '-',
- norm_as: norm_as ? norm_as : '-',
- pasien_nama_as: pasien_nama_as ? pasien_nama_as : '-',
- tglLahir_as: tglLahir_as ? tglLahir_as : '-',
- pasien_alamat_as: pasien_alamat_as ? pasien_alamat_as : '-',
- namaAsuransi_as: namaAsuransi_as ? namaAsuransi_as : '-',
- pasien_email_as: pasien_email_as ? pasien_email_as : '-',
- pasien_phone_as: pasien_phone_as ? pasien_phone_as : '-',
- noAsuransi_as: noAsuransi_as ? noAsuransi_as : '-',
- });
- if (this.state.token) {
- this.getData(moment().format('YYYY-MM-DD'))
- // this.getData('2019-09-10')
- }
- }
- getData = (setTanggal) => {
- // this.setState({ loading: true });
- // if (this.state.token != null) {
- if (this.state.kodePoli && this.state.kodeDokter) {
- let urlx = base64.decode(URL_SERVER_PHC) + 'ol_daftar_dokter_perjam.php?kddok=' + this.state.kodeDokter + '&kdklinik=' + this.state.kodePoli + '&tglberobat=' + setTanggal;
- return fetch(urlx, {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- },
- })
- .then((response) => response.json())
- .then((responseJson) => {
- // alert(JSON.stringify(responseJson))
- // this.setState({ data: responseJson.data });
- if (responseJson.data == 'null') {
- // alert('kosomng')
- Peringatan(responseJson.data[0]);
- this.props.navigation.goBack();
- } else {
- this.setState({ data: responseJson.data });
- }
- // console.error(this.state.data[0].TGL_PRAKTEK.date);
- // console.error(this.state.data[1].date);
- // console.error(this.state.data);
- this.setState({
- loading: false
- });
- })
- .catch((error) => {
- Exception('getData@getDokterJadwalList.js');
- this.setState({
- loading: false
- });
- });
- } else {
- this.setState({ loading: false });
- Peringatan('kode ' + (!this.state.kodePoli ? 'klinik' : 'dokter') + ' tidak ada');
- this.props.navigation.goBack();
- }
- }
- gotoAppointment1 = (a, b, kdp, ndp, c) => {
- // nyamm appoint
- let toScreen = '';
- // if (this.state.appointmentType == 'byRS') toScreen = 'PendaftaranRJOnline';
- // else if (this.state.appointmentType == 'byKlinik') toScreen = 'PendaftaranRJOnlineformKlinik';
- // else toScreen = 'PageAppointment1';
- toScreen = 'PageAppointment1';
- // end nyamm appoint
- this.props.navigation.navigate(toScreen, {
- kodeKlinik: this.state.kodeKlinik,
- namaKlinik: this.state.namaKlinik,
- kodePoli: this.state.kodePoli,
- namaPoli: this.state.namaPoli,
- kodeDokter: this.state.kodeDokter,
- namaDokter: this.state.namaDokter,
- tglPrakter: a.substring(0, 10),
- jamPrakter: b,
- kodeDokterPengganti: kdp,
- namaDokterPengganti: ndp,
- quota: c,
- // nyamm appoint
- appointmentType: this.state.appointmentType
- });
- }
- gotoAppointment2 = (a, b, kdp, ndp, c) => {
- let toScreen = '';
- // if (this.state.appointmentType == 'byRS') toScreen = 'PendaftaranRJOnline';
- // else if (this.state.appointmentType == 'byKlinik') toScreen = 'PendaftaranRJOnlineformKlinik';
- // else toScreen = 'PageAppointment1';
- toScreen = 'PageAppointment1';
- if (this.state.isLogedOn) {
- toScreen = 'PageAppointment2';
- this.props.navigation.navigate(toScreen, {
- kodeKlinik: this.state.kodeKlinik,
- namaKlinik: this.state.namaKlinik,
- kodeDokter: this.state.kodeDokter,
- namaDokter: this.state.namaDokter,
- namaPoli: this.state.namaPoli,
- kodePoli: this.state.kodePoli,
- tglPrakter: a.substring(0, 10),
- norm: this.state.norm_as.substring(0, 6),
- tglLahir: this.state.tglLahir_as,
- pasien_nama: this.state.pasien_nama_as,
- pasien_alamat: this.state.pasien_alamat_as,
- pasien_email: this.state.pasien_email_as,
- pasien_noKartu: this.state.noAsuransi_as,
- pasien_noPeserta: this.state.pasien_noPeserta_as,
- pasien_phone: this.state.pasien_phone_as,
- kodeAsuransi: this.state.kodeAsuransi_as,
- namaAsuransi: this.state.namaAsuransi_as,
- noAsuransi: this.state.noAsuransi_as,
- isValidPasien: true,
- jamPrakter: b,
- // nyamm appoint
- appointmentType: this.state.appointmentType
- });
- } else {
- this.gotoAppointment1();
- }
- }
- handleSettingsPress = (a, b, kdp, ndp, c) => {
- /////////////////////////////////////////////////////////
- if (this.state.isLogedOn) {
- Alert.alert(
- 'Notifikasi',
- 'Apakah anda mendaftar untuk diri sendiri .?',
- [
- // { text: 'cancel', onPress: () => '' },
- { text: 'orang lain', onPress: () => this.gotoAppointment1(a, b, kdp, ndp, c), },
- {
- text: 'saya sendiri',
- onPress: () => this.gotoAppointment2(a, b, kdp, ndp, c),
- style: 'cancel',
- },
- ],
- { cancelable: false },
- );
- } else {
- this.gotoAppointment1(a, b, kdp, ndp, c)
- }
- /////////////////////////////////////////////////////////
- };
- _renderItem = (item) => {
- let tglx = item;
- // console.error(tglx);
- // console.error('tglx');
- // this.state.data[0].TGL_PRAKTEK.date
- // console.error('itemx');
- // let tglPraktekDate = new Date(item.TGL_PRAKTEK.date.substring(0, 10));
- return (
- <TouchableOpacity id={item.KDDOK}
- onPress={item.KUOTA_JAM <= 0 || item.KUOTA_JAM == '0' || item.KUOTA_JAM == '' || item.KUOTA_JAM == null ? () => alert('kuota habis') : () => this.handleSettingsPress(
- JSON.stringify(this.state.tanggalPilih),
- item.JAM,
- // item.PENGGANTI.substring(0, 3), //kdp
- // item.PENGGANTI.substring(6), //ndp
- item.KUOTA_JAM
- )}
- underlayColor='#F5FCFF'
- >
- <CardQuotaSelect
- // Date(this.props.tglPrakter.substring(0, 10))
- // tgl={item.TGL_PRAKTEK ? DateFormat(tglPraktekDate.getDay(), 'DD') + ', ' + DateFormat(item.TGL_PRAKTEK.date.substring(0, 10), 'dd-mm-yyyy') : '-'}
- // tgl={item[0].TGL_PRAKTEK.date}
- tgl={item.JAM}
- doctor={item.KUOTA_JAM}
- spesialis={this.state.namaPoli}
- number={item.KUOTA_JAM} />
- {/* tgl={item.tgl}
- jam={item.jam}
- doctor={item.doctor}
- spesialis={item.spesialis}
- number={item.number} /> */}
- </TouchableOpacity>
- )
- }
- lihatSemua = () => {
- alert('lihat semua')
- }
- convertDay = (day) => {
- let a = '';
- if(day=='Sunday'){
- a = 'Min'
- } else if (day=='Monday'){
- a = 'Sen'
- } else if (day=='Tuesday'){
- a = 'Sel'
- } else if (day=='Wednesday'){
- a = 'Rab'
- } else if (day=='Thursday'){
- a = 'Kam'
- } else if (day=='Friday'){
- a = 'Jum'
- }
- else {
- a = 'Sab'
- }
- return a;
- }
- day = (name) => {
- let a = this.convertDay(moment().add(name, 'days').format('dddd'));
- return a;
- }
- date = (date) => {
- let a = moment().add(date, 'days').format('DD')
- return a;
- }
- getTgl = (tgl) => {
- let a = moment().add(tgl, 'days').format('YYYY-MM-DD')
- this.setState({
- tanggalPilih : a
- })
- this.getData(a);
- }
- render() {
- const { navigation } = this.props;
- this.state.fromScreen = navigation.getParam('Screen');
- this.state.kodeKlinik = navigation.getParam('kodeKlinik');
- this.state.namaKlinik = navigation.getParam('namaKlinik');
- this.state.kodePoli = navigation.getParam('kodePoli');
- this.state.namaPoli = navigation.getParam('namaPoli');
- this.state.kodeDokter = navigation.getParam('kodeDokter');
- this.state.namaDokter = navigation.getParam('namaDokter');
- this.state.fotoDokter = navigation.getParam('fotoDokter');
- this.state.kodeDokterPengganti = navigation.getParam('kodeDokterPengganti');
- this.state.namaDokterPengganti = navigation.getParam('dokterPengganti');
- // nyamm appoint
- this.state.appointmentType = navigation.getParam('appointmentType');
- // console.error(this.state.appointmentType)
- // console.error(this.state.fotoDokter)
- return (
- <SafeAreaView style={styles.container}>
- <Loader loading={this.state.loading} />
- <Header
- placement="left"
- leftComponent={<LeftHeaderBack title={'Pilih Jadwal'} onBack={() => this.props.navigation.goBack()} />}
- leftContainerStyle={{ width: Dimensions.get('window').width / 2 }}
- containerStyle={{
- flex: 0,
- backgroundColor: 'transparent',
- borderBottomWidth: 1,
- height: (0.185 * UkuranBaku),
- // height: 70,
- shadowColor: '#000',
- shadowOpacity: 0.1,
- justifyContent: 'center'
- //backfaceVisibility: 'hidden',
- }}
- style={{ opacity: 0.1 }}
- //backgroundColor={'transparent'}
- />
- <View style={styles.bottomContainer}>
- <CardDoctor
- // pic={NoDoctor}
- pic={this.state.fotoDokter}
- doctor={this.state.namaDokter}
- spesialis={this.state.namaPoli}
- // doctor={'Nur Rahmi, Dr.Sp.A'}
- // spesialis={'Spesialis Anak'}
- />
- <Text style={{ fontFamily: 'Montserrat-LightItalic', marginLeft: (0.045 * UkuranBaku), marginBottom: (0.0125 * UkuranBaku), fontSize: (0.045 * UkuranBaku), marginTop: (0.055 * UkuranBaku) }}>{this.state.namaKlinik}</Text>
- {/* <Text style={{ fontFamily: 'Montserrat-LightItalic', marginLeft: 10, marginBottom: 5, fontSize: 20, marginTop: 10 }}>RS PHC Surabaya</Text> */}
- </View>
- <View style={{flexDirection:'row', backgroundColor:_1stColor, height:50, justifyContent: 'center', width:'100%'}}>
- <Text style={styles.headerDate}>{moment().format('MMMM YYYY')}</Text>
- </View>
- <View style={{flexDirection:'row', backgroundColor:_1stColor, height:50, width:'100%'}}>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getData(moment().format('YYYY-MM-DD'))}
- // onPress={() => this.data()}
- >
- <Text style={styles.date}>{this.convertDay(moment(new Date()).format("dddd"))}</Text>
- <Text style={styles.date}>{moment(new Date()).format("DD")}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- // onPress={() => this.getData(moment().format('YYYY-MM-DD'))}
- onPress={() => this.getTgl(1)}
- >
- <Text style={styles.date}>{this.day(1)}</Text>
- <Text style={styles.date}>{this.date(1)}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getTgl(2)}
- >
- <Text style={styles.date}>{this.day(2)}</Text>
- <Text style={styles.date}>{this.date(2)}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getTgl(3)}
- >
- <Text style={styles.date}>{this.day(3)}</Text>
- <Text style={styles.date}>{this.date(3)}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getTgl(4)}
- >
- <Text style={styles.date}>{this.day(4)}</Text>
- <Text style={styles.date}>{this.date(4)}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getTgl(5)}
- >
- <Text style={styles.date}>{this.day(5)}</Text>
- <Text style={styles.date}>{this.date(5)}</Text>
- </TouchableOpacity>
- </View>
- <View style={{width:'14%'}}>
- <TouchableOpacity
- onPress={() => this.getTgl(6)}
- >
- <Text style={styles.date}>{this.day(6)}</Text>
- <Text style={styles.date}>{this.date(6)}</Text>
- </TouchableOpacity>
- </View>
- </View>
- <ScrollView style={{ width: '100%' }}>
- {/* {console.error(this.state.data)} */}
- <View>
- <FlatList
- // style={{
- // marginHorizontal: (0.0125 * UkuranBaku),
- // marginVertical: (0.125 * UkuranBaku),
- // }}
- // data={this.state.daÎta}
- //horizontal={true}
- data={this.state.data ? this.state.data : []}
- renderItem={({ item }) => this._renderItem(item)}
- keyExtractor={(item, index) => 'index' + index}
- />
- </View>
- </ScrollView>
- </SafeAreaView>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- //justifyContent: 'space-between',
- backgroundColor: '#fff',
- alignItems: 'center',
- width: '100%',
- },
- h0: {
- color: '#008F68',
- fontSize: 24,
- alignSelf: 'center'
- },
- h1: {
- color: '#008F68',
- fontSize: 40,
- },
- h2: {
- color: '#FAE042',
- fontSize: 18,
- marginTop: 8,
- },
- image: {
- width: 300,
- height: 260,
- justifyContent: 'center',
- },
- cardform: {
- borderRadius: 5,
- backgroundColor: '#F4F4F4',
- width: '95%',
- alignSelf: 'center'
- },
- logo: {
- flex: 1,
- maxHeight: 40,
- maxWidth: 40,
- alignSelf: 'center',
- marginLeft: 20,
- marginRight: 10
- },
- search: {
- borderWidth: 1,
- borderColor: '#bfc7ce',
- borderRadius: 5,
- backgroundColor: '#CAD1D7',
- //marginLeft: 10,
- //marginRight: 10,
- marginBottom: 10,
- flex: 1,
- width: '90%',
- alignSelf: 'center'
- },
- header: {
- maxHeight: 60,
- backgroundColor: '#fff',
- //flex: 1,
- width: '100%',
- margin: 0,
- flexDirection: 'row'
- },
- hr: {
- fontFamily: 'Montserrat-LightItalic',
- fontSize: (0.035 * UkuranBaku),
- color: '#4b4b7d',
- alignSelf: 'flex-start',
- marginTop: (0.025 * UkuranBaku),
- marginLeft: (0.025 * UkuranBaku),
- },
- headerDate: {
- fontFamily: 'Montserrat-LightItalic',
- fontSize: (0.090 * UkuranBaku),
- color: 'white',
- alignItems: 'center'
- },
- date: {
- fontFamily: 'Montserrat-LightItalic',
- fontSize: (0.035 * UkuranBaku),
- color: 'white',
- alignSelf: 'flex-start',
- },
- button: {
- flex: 1,
- width: 800,
- backgroundColor: '#008F68',
- color: '#008F68'
- },
- button2: {
- margin: 2,
- height: 100,
- width: 100,
- backgroundColor: '#000',
- borderRadius: 5
- },
- button3: {
- margin: 5,
- height: 90,
- width: 80,
- //backgroundColor: '#000',
- //borderWidth: 1,
- //borderColor: '#F4F4F4', //'#F4F4F4','#c6ced0'
- //borderRadius: 15
- },
- topContainer: {
- flex: 2,
- //margin: 0
- //justifyContent: 'center',
- //alignItems: 'center',
- },
- middleContainer: {
- //flex: 2,
- justifyContent: 'flex-start',
- //alignItems: 'center',
- //marginTop: 5,
- marginTop: 1,
- height: 240
- },
- bottomContainer: {
- justifyContent: 'flex-end',
- width: '100%',
- marginTop: (0.014 * UkuranBaku),
- // marginBottom: 50
- //padding: 10,
- },
- buttonContainer: {
- backgroundColor: '#008F68',
- borderRadius: 5,
- padding: 8,
- margin: 8,
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement