您的位置:首页 > 数据库

挂号系统 V1.0(上)

2017-11-05 16:17 204 查看

我的医院挂号系统

很开心能够把粗糙的第一版写完,重写看了一遍Bmob的开发文档,很有收获。

我的数据库(javabean)

预约表的流水号、病人表的诊疗卡号都是自增的(从1开始),每次插入一条记录就增加1,再格式化为所要的格式

public class Appointment extends BmobObject {
private Doctor a_doctor;//  选择科室和医院
private Patient a_name;//       患者名字
private Integer a_queueno;//        挂号流水号
private String a_type;//        挂号类型
}


public class Patient extends BmobObject  implements Serializable {
private String p_address;
private String p_allergy;
private String p_birth;
private Integer p_card;
private String p_idcard;
private String p_name;
private String p_phone;
private boolean p_sex;
}


public class Doctor extends BmobObject implements Serializable {
private Department d_dcode;//   所在科室
private boolean d_isprofessor;    //是否为教授
//    private Hospital d_hosptial;  //所在医院 方便查询
private String d_name;    //医生名字
private String d_num;    //医生编号
private BmobFile d_photo;    //医生照片
private boolean d_sex;    //1男0女
private String d_specialty;    //专长
private Registrationtype d_registrationtype;    //为教授的挂号类型
private String d_titles;    //职称
private boolean is_visited;    //当天是否可以就诊
private Integer d_mcount;//上午挂的号
private Integer d_acount;//下午挂的号
private Integer d_nowacount;//上午已经挂的号
private Integer d_nowmcount;//下午已经挂的号
private String d_room;
}


public class Department extends BmobObject {
private BigDepartment d_bigdepartmentcode;    //所属大科编号
private String d_departmentCode;    //  科室编号
private String d_departmentname;    //  科室名
private Hospital d_hosptialnum;    //   所属医院编号
}


public class BigDepartment extends BmobObject {
private String bd_code;//   大科编号
private String bd_name;//   大科名字
private Hospital db_hosptialnum;//  所属医院编号
}


public class Hospital extends BmobObject {
private String h_dnum;//    科室总数
private Integer h_doctornum;//  医生总数
private String h_grade;//   医院级别
private String h_haddress;//    医院地址
private String h_hnum;//    医院编号
private BmobFile h_image;// 医院图片
private String h_importSpecialist;//    重点专科
private String h_mobilenum;//   医院电话
private String h_name;//    医院名称
}


也许会很复杂,但是这必不可少,分表就是在处理好逻辑 (谁应该有这个属性,谁没有,放在哪个表更合适) , 也是我们这个系统最基本的东西.

View





注册病人信息在前面已将其实现了 初诊和复诊的信息录入

查询医生挂号界
4000
面具体实现

我们会发现在展示医生个人信息的界面到挂号结束的界面都是一样的,所以我们可以复用,在进入医生个人信息传递一样的参数就可以了,比如传入医生的objectId , 或者患者的objectId。

在这上一篇初诊和复诊的信息录入中,我们在查询患者显示信息的方法中保存objectId信息,这样在每个界面都可以用到,并且挂号玩就把它clear().

//获得数据的objectId信息,保存到本地
String pid = patient.getObjectId();
SharedPreferences sp =  getSharedPreferences("patient",MODE_PRIVATE);
sp.edit().putString("pid",pid).commit();


(a)DoctorActivity: 输入医生名字,查询信息,并保存objectId信息,用intent传递字段的数据,其实传递序列化的对象也可以、或者使用轻量级的SharedPreferences保存也行。

还有使用handler更新UI,并发送Message把里面的doctor对象拿出来,不然在bmob异步任务中无法对全局变量赋值,会报空指针

public class DoctorActivity extends AppCompatActivity implements View.OnClickListener{

private Handler mHandler =  new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what){
case 1:
List<Doctor> list= (List<Doctor>) msg.obj;
for (Doctor doctor : list) {
name = doctor.getD_name();
d_num = doctor.getD_num();
specialty = doctor.getD_specialty();
titles = doctor.getD_titles();
Department department = doctor.getD_dcode();
departmentname = department.getD_departmentname();
d_acount = doctor.getD_acount();
d_mcount = doctor.getD_mcount();
d_nowacount = doctor.getD_nowacount();
d_nowmcount = doctor.getD_nowmcount();
Log.i("departmentname>>>>>>",departmentname+"");
}
break;
}

}
};
String d_num;
String name;
String specialty;
String titles;
String departmentname;
int d_acount;
int d_mcount;
int d_nowacount;
int d_nowmcount;
private EditText etDoctor;
private TextView tvDoctor;
private RoundImageView head;
private TextView tvname;
private TextView tvtitle;
private ImageLoader imageLoader;
private ImageView iv;
private LinearLayout ll;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
imageLoader=ImageLoader.getInstance();
setContentView(R.layout.activity_doctor);
initView();
}

private void initView() {
etDoctor = (EditText)findViewById(R.id.etdoctor);
tvDoctor = (TextView) findViewById(R.id.btndoctor);
tvname = (TextView) findViewById(R.id.tv_d_name);
tvtitle = (TextView) findViewById(R.id.tv_d_title);
head = (RoundImageView) findViewById(R.id.iv_d_photo);
iv = (ImageView)findViewById(R.id.doctor_iv_detail);
ll = (LinearLayout) findViewById(R.id.ll_doctor);
tvDoctor.setOnClickListener(this);
iv.setOnClickListener(this);

}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btndoctor:
String doctor = etDoctor.getText().toString();
findDoctor(doctor);
break;
case R.id.doctor_iv_detail:
Intent intent = new Intent(DoctorActivity.this,DoctorDetailActivity.class);
intent.putExtra("dname",name);
intent.putExtra("dspecialty",specialty);
intent.putExtra("dtitles",titles);
intent.putExtra("ddepartmentname",departmentname);
intent.putExtra("dnum",d_num);
intent.putExtra("dacount",d_acount);
intent.putExtra("dmcount",d_mcount);
intent.putExtra("dnowacount",d_nowacount);
intent.putExtra("dnowmcount",d_nowmcount);
startActivity(intent);
}

}

/**
* 查询医生并更新UI界面
* @param dname
*/
public void findDoctor(String dname){

BmobQuery<Doctor> query = new BmobQuery<Doctor>();
query.addWhereEqualTo("d_name",dname);
query.include("d_dcode");
//        query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);
//执行查询方法
query.findObjects(new FindListener<Doctor>() {
@Override
public void done(List<Doctor> object, BmobException e) {
if(e==null){

Message message = mHandler.obtainMessage();
message.what = 1;
//以消息为载体
message.obj = object;//这里的list就是查询出list
//向handler发送消息
mHandler.sendMessage(message);

for (final Doctor doctor : object) {
//获得playerName的信息
final String name = doctor.getD_name();
final String specialty = doctor.getD_specialty();
final String titles = doctor.getD_titles();

//下载医生的头像,以医生的名字命名的文件
BmobFile bmobfile = doctor.getD_photo();
//允许设置下载文件的存储路径,默认下载文件的目录为:context.getApplicationContext().getCacheDir()+"/bmob/"
final File saveFile = new File(Environment.getExternalStorageDirectory(), name +".jpg");
if(!saveFile.exists()){
bmobfile.download(saveFile, new DownloadFileListener() {
@Override
public void onStart() {
}
@Override
public void done(String savePath,BmobException e) {
if(e==null){
Log.i("bmob","下载进度cg");
}else{
Log.i("bmob","下载进度sb");
}
}
@Override
public void onProgress(Integer value, long newworkSpeed) {
Log.i("bmob","下载进度:"+value+","+newworkSpeed);
}
});
}

//获得数据的objectId信息
String pid = doctor.getObjectId();
SharedPreferences sp =  getSharedPreferences("patient",MODE_PRIVATE);
sp.edit().putString("pdid",pid).commit();
//获得createdAt数据创建时间(注意是:createdAt,不是createAt)
doctor.getCreatedAt();

mHandler.post(new Runnable() {
@Override
public void run() {
tvname.setText(name);
tvname.setTextColor(Color.RED);
tvtitle.setText(titles);
tvtitle.setTextColor(Color.RED);
ll.setBackgroundResource(R.color.orange02);

if(saveFile.exists()){
String path = Environment.getExternalStorageDirectory() + "/"+name +".jpg";
Bitmap bitmap = BitmapFactory.decodeFile(path);
head.setImageBitmap(bitmap);
}

}
});
}
}else{
Log.i("bmob","失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}
}


使用Bmob的下载图片的方法,以后可以用缓存改进。

(b)DoctorDetailActivity :查看医生信息,跳转到支付界面以及查看挂号情况,医生要求时可以加一个号

使用Bmob原子计数器来保证原子性的修改某一数值字段的值。

注意:原子计数器只能对应用于Web后台的Number类型的字段,即JavaBeans数据对象中的Integer对象类型(不要用int类型)。

public class DoctorDetailActivity extends AppCompatActivity implements View.OnClickListener{

private RoundImageView head;
private TextView detailname;
private TextView detailtitles;
private TextView detailspecial;
private TextView detaildepartment;
private TextView dacount;
private TextView dacountClick;
private TextView dmcount;
private TextView dnowacount;
private TextView dnowmcount;
private TextView dmcountClick;
private ImageView mbtn;
private ImageView abtn;

String dnum;
Handler mHandler = new Handler();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doctor_detail);
initView();
initData();
}

private void initData() {

Intent intent = getIntent();
dnum = intent.getStringExtra("dnum");
String name = intent.getStringExtra("dname");
String specialty = intent.getStringExtra("dspecialty");
String titles = intent.getStringExtra("dtitles");
String departmentname = intent.getStr
13c21
ingExtra("ddepartmentname");
int a = intent.getIntExtra("dacount",0);
int m = intent.getIntExtra("dmcount",0);
int na = intent.getIntExtra("dnowacount",0);
int nm = intent.getIntExtra("dnowmcount",0);

detailname.setText(name);
detailtitles.setText(titles);
detailspecial.setText(specialty);
detaildepartment.setText(departmentname);
detaildepartment.setTextColor(Color.parseColor("#b48c5a"));
String path = Environment.getExternalStorageDirectory() + "/"+name +".jpg";
Bitmap bitmap = BitmapFactory.decodeFile(path);
head.setImageBitmap(bitmap);
dacount.setText(a+"");
dnowacount.setText(na+"");
dmcount.setText(m+"");
dnowmcount.setText(nm+"");
}

private void initView() {
detailname = (TextView) findViewById(R.id.detail_name);
detailtitles = (TextView) findViewById(R.id.detail_titles);
detailspecial = (TextView) findViewById(R.id.detail_special);
detaildepartment = (TextView) findViewById(R.id.detail_department);
dacount = (TextView) findViewById(R.id.afternoon_hao);
dnowacount = (TextView) findViewById(R.id.now_afternoon_hao);
dacountClick = (TextView) findViewById(R.id.afternoon_config);
dacountClick.setOnClickListener(this);
dmcount = (TextView) findViewById(R.id.morning_hao);
dnowmcount = (TextView) findViewById(R.id.now_morning_hao);
dmcountClick = (TextView) findViewById(R.id.morning_config);
dmcountClick.setOnClickListener(this);
head = (RoundImageView) findViewById(R.id.detail_head);
mbtn = (ImageView)findViewById(R.id.madd);
mbtn.setOnClickListener(this);
abtn = (ImageView)findViewById(R.id.aadd);
abtn.setOnClickListener(this);
}

@Override
public void onClick(View v) {
SharedPreferences sp =  getSharedPreferences("patient",MODE_PRIVATE);
switch (v.getId()){
case R.id.afternoon_config:
Intent intent = new Intent(DoctorDetailActivity.this,Pay2Activity.class);
sp.edit().putBoolean("pam",false).commit();
startActivity(intent);
break;
case R.id.morning_config:
Intent intent2 = new Intent(DoctorDetailActivity.this,PayActivity.class);
sp.edit().putBoolean("pam",true).commit();
startActivity(intent2);
break;
case R.id.madd:
addMorning();
findDoctor();
break;
case R.id.aadd:
addAfternoon();
findDoctor();
break;
}
}

private void addMorning() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");
Doctor doctor = new Doctor();
doctor.increment("d_mcount",1); // 分数递增1
doctor.update(pdid, new UpdateListener() {
@Override
public void done(BmobException e) {
if(e==null){
Log.i("bmob加号","更新成功");
}else{
Log.i("bmob更新挂号","更新失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}
private void addAfternoon() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");
Doctor doctor = new Doctor();
doctor.increment("d_acount",1); // 分数递增1
doctor.update(pdid, new UpdateListener() {
@Override
public void done(BmobException e) {
if(e==null){
Log.i("bmob更新挂号","更新成功");
}else{
Log.i("bmob加号","更新失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}

public void findDoctor() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");

BmobQuery<Doctor> query = new BmobQuery<Doctor>();
query.include("d_dcode");
//执行查询方法
query.getObject(pdid,new QueryListener<Doctor>() {
@Override
public void done(Doctor doctor, BmobException e) {

if (e == null) {

final int ma = doctor.getD_mcount();
final int aa = doctor.getD_acount();
mHandler.post(new Runnable() {
@Override
public void run() {
dacount.setText(aa + "");
dmcount.setText(ma + "");
}
});
} else {
Log.i("bmob", "失败:" + e.getMessage() + "," + e.getErrorCode());
}
}
});
}
}


(c)PayActivity :选择号别、费别等等、显示找补,在这里查询patient、doctor的信息,传递序列化对象给下个Activity,支付完成表示挂号成功,把医生的剩余号数减1、已挂加1,在Appointment表中插入一条记录,产生流水号

拿到objectid去查表

SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pid= pref.getString("pid","");


public class PayActivity extends AppCompatActivity implements View.OnClickListener{

private RadioGroup rg01;
private RadioGroup rg02;
private RadioGroup rg03;
private RadioGroup rg04;
private RadioGroup rg05;
private Button button;

private double money;
private TextView tvmoney;
private EditText etmoney;
private TextView getmoney;
private TextView tv_pname;
private TextView rmoney;
private Button dayin;

Patient patient=new Patient();
Doctor doctor=new Doctor();

//要传递的数据,传递对象也可以,不过得序列化对象
Handler mhanler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what){

case 1:
patient = (Patient)msg.obj;

break;
case 2:
doctor = (Doctor) msg.obj;
break;
}
}
};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pay);
initView();
}

private void initView() {

rg01 = (RadioGroup)findViewById(R.id.rg_01);
rg02 = (RadioGroup)findViewById(R.id.rg_02);
rg03 = (RadioGroup)findViewById(R.id.rg_03);
rg04 = (RadioGroup)findViewById(R.id.rg_04);
rg05 = (RadioGroup)findViewById(R.id.rg_05);
tvmoney = (TextView)findViewById(R.id.money);
rmoney = (TextView)findViewById(R.id.returnmoney);
getmoney = (TextView)findViewById(R.id.getmoney);
tv_pname = (TextView)findViewById(R.id.tv_pname);
getmoney.setOnClickListener(this);
button = (Button)findViewById(R.id.btn_yes);
dayin = (Button)findViewById(R.id.btn_dayin);
dayin.setOnClickListener(this);
etmoney = (EditText)findViewById(R.id.et_money);
button.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_yes:
money = pay() + pay02() + pay03();
tvmoney.setText(money+"");
findPatient();
findDoctor();
break;
case R.id.getmoney:
double getM = Double.parseDouble(etmoney.getText().toString());
String rm = (getM - money) + "";
rmoney.setText(rm);
break;
case R.id.btn_dayin:
//                findAppoint();
addAppoint();
updateMorning();
Intent intent = new Intent(PayActivity.this,AppointActivity.class);
intent.putExtra("patient", patient);
intent.putExtra("doctor", doctor);
startActivity(intent);
}
}

public double pay(){

RadioButton rb21 = (RadioButton) rg02.getChildAt(0);
if (rb21.isChecked()) {
return 3.0;
}
RadioButton rb22 = (RadioButton) rg02.getChildAt(1);
if (rb22.isChecked()) {
return 5.0;
}

RadioButton rb23 = (RadioButton) rg02.getChildAt(2);
if (rb23.isChecked()) {
return 5.0;
}
RadioButton rb24 = (RadioButton) rg02.getChildAt(3);
if (rb24.isChecked()) {
return 5.0;
}
return 3.0;
}

public double pay02(){
RadioButton rb31 = (RadioButton) rg03.getChildAt(0);
if (rb31.isChecked()) {
return 1.0;
}
RadioButton rb32 = (RadioButton) rg03.getChildAt(1);
if (rb32.isChecked()) {
return 0.0;
}
return 1.0;
}
public double pay03(){
RadioButton rb51 = (RadioButton) rg05.getChildAt(0);
if (rb51.isChecked()) {
return 2.0;
}
RadioButton rb52 = (RadioButton) rg05.getChildAt(1);
if (rb52.isChecked()) {
return 3.0;
}
RadioButton rb53 = (RadioButton) rg05.getChildAt(2);
if (rb53.isChecked()) {
return 10.0;
}
return 2.0;
}
public String selectHaobie(){
//设置患者的性别
RadioButton rb21 = (RadioButton) rg02.getChildAt(0);
if (rb21.isChecked()) {
return "普通";
}
RadioButton rb22 = (RadioButton) rg02.getChildAt(1);
if (rb22.isChecked()) {
return "主任医师";
}

RadioButton rb23 = (RadioButton) rg02.getChildAt(2);
if (rb23.isChecked()) {
return "教授";
}
RadioButton rb24 = (RadioButton) rg02.getChildAt(3);
if (rb23.isChecked()) {
return "副教授";
}
return "普通";
}
public void findPatient() {

SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pid= pref.getString("pid","");
BmobQuery<Patient> query = new BmobQuery<Patient>();
//执行查询方法
query.getObject(pid,new QueryListener<Patient>() {
@Override
public void done(Patient patient, BmobException e) {

if (e == null) {
final String name = patient.getP_name();
//添加挂号类别
Message message = mhanler.obtainMessage();
message.what = 1;
//以消息为载体
message.obj = patient;
//向handler发送消息
mhanler.sendMessage(message);

mhanler.post(new Runnable() {
@Override
public void run() {
tv_pname.setText(name);

}
});

} else {
Log.i("bmob", "失败:" + e.getMessage() + "," + e.getErrorCode());
}
}
});
}

public void findDoctor() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");

BmobQuery<Doctor> query = new BmobQuery<Doctor>();
query.include("d_dcode");
//执行查询方法
query.getObject(pdid,new QueryListener<Doctor>() {
@Override
public void done(Doctor doctor, BmobException e) {

if (e == null) {
Message message = mhanler.obtainMessage();
message.what = 2;
//以消息为载体
message.obj = doctor;
//向handler发送消息
mhanler.sendMessage(message);

} else {
Log.i("bmob", "失败:" + e.getMessage() + "," + e.getErrorCode());
}
}
});
}

private void addAppoint(){
Appointment appointment = new Appointment();
appointment.setA_name(patient);
String haobie = selectHaobie();
appointment.setA_type(haobie);
appointment.setA_doctor(doctor);
appointment.save(new SaveListener<String>() {

@Override
public void done(String objectId, BmobException e) {
if(e==null){
Toast.makeText(PayActivity.this, "挂号成功", Toast.LENGTH_SHORT).show();
}else{
Log.i("bmob","失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}
private void updateMorning() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");
Doctor doctor = new Doctor();
doctor.increment("d_mcount",-1); // 分数递增1
doctor.increment("d_nowmcount",1); // 分数递增1
doctor.update(pdid, new UpdateListener() {
@Override
public void done(BmobException e) {
if(e==null){
Log.i("bmob更新挂号","更新成功");
}else{
Log.i("bmob更新挂号","更新失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}
}


(d)AppointActivity : 显示电子病历,获取前面得到的序列化对象,查询对应的字段

public class AppointActivity extends AppCompatActivity implements View.OnClickListener{

private TextView aq;
private TextView an;
private TextView as;
private TextView ah;
private TextView ad;
private TextView ak;
private TextView ac;
private TextView aa;
private TextView a;
private TextView name;
private Button yes;

private String type;
private int queue;
private String create;
private String myname;
private boolean mysex;
private String dname;
private String droom;
private String ddepartment;
private String myallergy;
Handler mhanler = new Handler();

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appoint);
initView();

initData();

}

private void initData() {
Intent intent = getIntent();
Patient patient = (Patient)intent.getSerializableExtra("patient");
Doctor doctor = (Doctor)intent.getSerializableExtra("doctor");

myname = patient.getP_name();
mysex = patient.isP_sex();
myallergy = patient.getP_allergy();
dname = doctor.getD_name();
Department department = doctor.getD_dcode();
ddepartment = department.getD_departmentname();
droom = doctor.getD_room();
//只能显示上午的挂号排队号情况,应该加两个字段证明
// 你是挂上午的号还是挂下午的
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
boolean ism= pref.getBoolean("pam",true);
if(ism){
int nowcount = doctor.getD_nowmcount() + 1;
final String now = String.format("%02d",nowcount);
a.setText(now);
name.setText("排队号(上午):");
}else{
int nowcount = doctor.getD_acount() + 1;
final String now = String.format("%02d",nowcount);
a.setText(now);
name.setText("排队号(下午):");
}

an.setText(myname);
if(mysex){
as.setText("男");
}else{
as.setText("女");
}

ad.setText(dname);
ak.setText(ddepartment);
ac.setText(droom);
aa.setText(myallergy);

BmobQuery<Appointment> query = new BmobQuery<Appointment>();
query.addWhereEqualTo("a_name",patient);
//执行查询方法
query.findObjects(new FindListener<Appointment>() {
@Override
public void done(List<Appointment> object, BmobException e) {
if(e==null){

for (Appointment appointment : object) {

type = appointment.getA_type();
queue = appointment.getA_queueno();
final String myqueue = String.format("%04d",queue);
create = appointment.getCreatedAt();
final String date = DateUtil.getWantDate(create, "yyyyMMdd");

mhanler.post(new Runnable() {
@Override
public void run() {
aq.setText(myqueue+date);
ah.setText(type);
}
});
}
}else{
Log.i("bmob","失败:"+e.getMessage()+","+e.getErrorCode());
}
}
});
}

private void initView() {

aq = (TextView)findViewById(R.id.a_queue);
an = (TextView)findViewById(R.id.a_name);
as = (TextView)findViewById(R.id.a_sex);
ah = (TextView)findViewById(R.id.a_haobie);
ad = (TextView)findViewById(R.id.a_yisheng);
ak = (TextView)findViewById(R.id.a_keshi);
ac = (TextView)findViewById(R.id.a_keshihao);
aa = (TextView)findViewById(R.id.a_guomin);
a = (TextView)findViewById(nowcount);
name = (TextView)findViewById(R.id.nowcountname);
yes = (Button)findViewById(R.id.yes);
yes.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch (R.id.yes){
case R.id.yes:
Intent intent = new Intent(AppointActivity.this,FinishActivity.class);
startActivity(intent);
break;
}
}

public void clear(){
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
if(pref!=null){
pref.edit().clear().commit();
}
}
}


(e)FinishActivity : 清除缓存文件SharedPreferences,显示医生挂号情况,返回初诊复诊界面

public class FinishActivity extends AppCompatActivity implements View.OnClickListener{

Handler mhanler = new Handler();
private TextView fn;
private TextView ft;
private TextView fd;
private TextView fm;
private TextView fa;
private Button finish;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_finish);
initView();
findDoctor();
}

private void initView() {
fn = (TextView)findViewById(R.id.finish_name);
ft = (TextView)findViewById(R.id.finish_titles);
fd = (TextView)findViewById(R.id.finish_keshi);
fm = (TextView)findViewById(R.id.finish_morning_hao);
fa = (TextView)findViewById(R.id.finish_afternoon_hao);
finish = (Button)findViewById(R.id.finish);
finish.setOnClickListener(this);
}

public void findDoctor() {
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
String pdid= pref.getString("pdid","");

BmobQuery<Doctor> query = new BmobQuery<Doctor>();
query.include("d_dcode");
//执行查询方法
query.getObject(pdid,new QueryListener<Doctor>() {
@Override
public void done(Doctor doctor, BmobException e) {

if (e == null) {

final String dname = doctor.getD_name();
final int dnm = doctor.getD_nowmcount();
final int dna = doctor.getD_nowacount();
final String dtitles = doctor.getD_titles();
Department department = doctor.getD_dcode();
final String ddepartment = department.getD_departmentname();
mhanler.post(new Runnable() {
@Override
public void run() {
fn.setText(dname);
ft.setText(dtitles);
fd.setText(ddepartment);
fa.setText(dna + "");
fm.setText(dnm + "");
}
});

} else {
Log.i("bmob", "失败:" + e.getMessage() + "," + e.getErrorCode());
}
}
});
}
public void clear(){
SharedPreferences pref = getSharedPreferences("patient",MODE_PRIVATE);
if(pref!=null){
pref.edit().clear().commit();
}
}

@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.finish:
clear();
Intent intent = new Intent(FinishActivity.this,SelectActivity.class);
startActivity(intent);
break;
}
}
}


好了,完整的医生挂号流程就完成了,接下来就写查询科室挂号,很简单,就是DoctorDetailActivity所要的参数,拿到传给它就可以了,试试做做看。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数据库