diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 19d433d383f1fe422a8986f4ee14f29cd0619a0d..0000000000000000000000000000000000000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="deploymentTargetDropDown"> - <runningDeviceTargetSelectedWithDropDown> - <Target> - <type value="RUNNING_DEVICE_TARGET" /> - <deviceKey> - <Key> - <type value="VIRTUAL_DEVICE_PATH" /> - <value value="C:\Users\robie\.android\avd\Pixel_2_API_28.avd" /> - </Key> - </deviceKey> - </Target> - </runningDeviceTargetSelectedWithDropDown> - <timeTargetWasSelectedWithDropDown value="2022-12-31T23:17:06.169086700Z" /> - </component> -</project> \ No newline at end of file diff --git a/app/src/main/java/com/example/firstintent/Akte.java b/app/src/main/java/com/example/firstintent/Akte.java index 32aead74bca8fbbe3996a0dabefe5020eb04ec8f..27297ec9a088a4f9622d008903038b51157fb775 100644 --- a/app/src/main/java/com/example/firstintent/Akte.java +++ b/app/src/main/java/com/example/firstintent/Akte.java @@ -16,6 +16,11 @@ public class Akte { this.isActive = isActive; } + // new constructor for the search button + public Akte ( String _Patientname){ + + this._Patientname=_Patientname; + } public Akte() { diff --git a/app/src/main/java/com/example/firstintent/DatabaseHelper.java b/app/src/main/java/com/example/firstintent/DatabaseHelper.java index 42ea6ea27b815b8540798ca537a7fba97b8ad12e..b63f1418c72ee4783f62d6abaa9bf7c846743e84 100644 --- a/app/src/main/java/com/example/firstintent/DatabaseHelper.java +++ b/app/src/main/java/com/example/firstintent/DatabaseHelper.java @@ -139,4 +139,52 @@ public class DatabaseHelper extends SQLiteOpenHelper { } + public List<Akte> search (Akte akte){ + List<Akte> returnList = new ArrayList<>(); + + // get Data from the database + + String queryString = "SELECT * FROM " + PATIENT_TABLE + + " WHERE " + COLUMN_PATIENT_NAME + + "=\"" + akte.get_Patientname() + "\";"; + + SQLiteDatabase db = this.getReadableDatabase(); + Cursor cursor = db.rawQuery(queryString, null); + if (cursor.moveToFirst()) { + // loop through the results and create a new patient object and put them into the return list + + do { + int patientID = cursor.getInt(0); + String PatientName = cursor.getString(1); + int VersicherungsNumber = cursor.getInt(2); + int roomNumber = cursor.getInt(3); + boolean activePatients = cursor.getInt(4) == 1 ? true : false; + + akte = new Akte(patientID, VersicherungsNumber, PatientName, roomNumber, activePatients); + + returnList.add(akte); + + } + while (cursor.moveToNext()); + + } + + else { + // If there are no results from the database then we will not add anything to the list + + + + } + + cursor.close(); + db.close(); + return returnList; + + } + + + + + + } diff --git a/app/src/main/java/com/example/firstintent/PatientenSuche.java b/app/src/main/java/com/example/firstintent/PatientenSuche.java index 524a4abf69a8044ac8e99cef704ae85539377695..594edc62db2d6f8e6005b558d036ba6c4aff1791 100644 --- a/app/src/main/java/com/example/firstintent/PatientenSuche.java +++ b/app/src/main/java/com/example/firstintent/PatientenSuche.java @@ -8,18 +8,20 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; +import android.widget.Switch; import android.widget.Toast; - public class PatientenSuche extends AppCompatActivity { - Button btn_search, btn_viewAll; - EditText Pname; - ListView rv_patientList; + EditText pname,vname,rname; + Button vbutton,sbutton; + Switch swPatient; + ListView listings; + + ArrayAdapter patientArrayAdapter; DatabaseHelper databaseHelper; - Akte akte; @Override @@ -27,48 +29,61 @@ public class PatientenSuche extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_patienten_suche); - btn_search=findViewById(R.id.searchbtn); - btn_viewAll=findViewById(R.id.viewbtn); + pname=findViewById(R.id.pname); + // vname=findViewById(R.id.Vnumber); + // rname=findViewById(R.id.editTextTextPersonName5); + vbutton=findViewById(R.id.vbutton); + sbutton=findViewById(R.id.sbutton); + // swPatient=findViewById(R.id.switch2); + listings=findViewById(R.id.plist); - btn_viewAll.setOnClickListener(new View.OnClickListener() { + // impementazion for searching patients from the list.This function calls the search method from the database class + sbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - try{ + try { + + // akte = new Akte(-1, Integer.parseInt(vname.getText().toString()), pname.getText().toString(), Integer.parseInt(rname.getText().toString()), swPatient.isChecked()); + akte =new Akte(pname.getText().toString()); databaseHelper= new DatabaseHelper(PatientenSuche.this); - patientArrayAdapter= new ArrayAdapter<Akte>(PatientenSuche.this, android.R.layout.simple_list_item_1,databaseHelper.getEveryone()); + // databaseHelper.search(akte); + // commmented the next line toast message out because it keep printing ebven when it can not find a patient from the database + // Toast.makeText(PatientenSuche.this,"successfully searching patient", Toast.LENGTH_SHORT).show(); + patientArrayAdapter= new ArrayAdapter<Akte>(PatientenSuche.this, android.R.layout.simple_list_item_1,databaseHelper.search(akte)); + listings.setAdapter(patientArrayAdapter); - rv_patientList.setAdapter(patientArrayAdapter); - } - catch (Exception e){ - Toast.makeText(PatientenSuche.this,"failed to print", Toast.LENGTH_SHORT).show(); } + catch(Exception e){ + Toast.makeText(PatientenSuche.this,"Error searching patient", Toast.LENGTH_SHORT).show(); + + } } }); + // implementation for viewing all the patients + vbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { - } -} - - - -/* -next steps to do + databaseHelper= new DatabaseHelper(PatientenSuche.this); + patientArrayAdapter= new ArrayAdapter<Akte>(PatientenSuche.this, android.R.layout.simple_list_item_1,databaseHelper.getEveryone()); + listings.setAdapter(patientArrayAdapter); -delete the whole patientensuche interface and set it up new by copying exactly from patient entlassen -it should lool like the patient entlassen exactly -The only thing you should change is the second button to search instead of delete + } + }); - */ \ No newline at end of file + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_patienten_suche.xml b/app/src/main/res/layout/activity_patienten_suche.xml index c039ddc42f893b37291f49ed0dec73a4ce130d09..17e0fd8a901daea5eb61f333d6cdffba0534c07f 100644 --- a/app/src/main/res/layout/activity_patienten_suche.xml +++ b/app/src/main/res/layout/activity_patienten_suche.xml @@ -7,51 +7,47 @@ tools:context=".PatientenSuche"> <EditText - android:id="@+id/patSuche" + android:id="@+id/pname" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" - android:layout_marginTop="56dp" + android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:ems="10" - android:hint="PatientenName" + android:hint="PatientName" android:inputType="textPersonName" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button - android:id="@+id/searchbtn" + android:id="@+id/vbutton" android:layout_width="wrap_content" - android:layout_height="0dp" + android:layout_height="wrap_content" android:layout_marginTop="64dp" - android:layout_marginEnd="60dp" - android:text="Search" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@+id/patSuche" /> + android:text="ViewAll" + app:layout_constraintEnd_toStartOf="@+id/sbutton" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/pname" /> <Button - android:id="@+id/viewbtn" + android:id="@+id/sbutton" android:layout_width="wrap_content" - android:layout_height="0dp" + android:layout_height="wrap_content" android:layout_marginTop="64dp" - android:text="View All" - app:layout_constraintEnd_toStartOf="@+id/searchbtn" - app:layout_constraintHorizontal_bias="0.275" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/patSuche" - app:layout_constraintStart_toEndOf="@id/searchbtn"/> + android:text="Search" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/vbutton" + app:layout_constraintTop_toBottomOf="@+id/pname" /> <ListView + android:id="@+id/plist" android:layout_width="409dp" - android:layout_height="516dp" - android:layout_marginStart="8dp" + android:layout_height="479dp" android:layout_marginTop="64dp" - android:layout_marginEnd="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/viewbtn" /> + app:layout_constraintTop_toBottomOf="@+id/vbutton" /> </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file