Skip to content
Snippets Groups Projects
Commit 1ae88091 authored by Robiel Elias Redie's avatar Robiel Elias Redie
Browse files

Merge branch 'development' into 'main'

Development

See merge request !2
parents f6436da5 c09c9240
No related branches found
No related tags found
1 merge request!2Development
Pipeline #127213 passed
<?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
...@@ -16,6 +16,11 @@ public class Akte { ...@@ -16,6 +16,11 @@ public class Akte {
this.isActive = isActive; this.isActive = isActive;
} }
// new constructor for the search button
public Akte ( String _Patientname){
this._Patientname=_Patientname;
}
public Akte() { public Akte() {
......
...@@ -139,4 +139,52 @@ public class DatabaseHelper extends SQLiteOpenHelper { ...@@ -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;
}
} }
...@@ -8,18 +8,20 @@ import android.widget.ArrayAdapter; ...@@ -8,18 +8,20 @@ import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Switch;
import android.widget.Toast; import android.widget.Toast;
public class PatientenSuche extends AppCompatActivity { public class PatientenSuche extends AppCompatActivity {
Button btn_search, btn_viewAll; EditText pname,vname,rname;
EditText Pname; Button vbutton,sbutton;
ListView rv_patientList; Switch swPatient;
ListView listings;
ArrayAdapter patientArrayAdapter; ArrayAdapter patientArrayAdapter;
DatabaseHelper databaseHelper; DatabaseHelper databaseHelper;
Akte akte; Akte akte;
@Override @Override
...@@ -27,48 +29,61 @@ public class PatientenSuche extends AppCompatActivity { ...@@ -27,48 +29,61 @@ public class PatientenSuche extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patienten_suche); setContentView(R.layout.activity_patienten_suche);
btn_search=findViewById(R.id.searchbtn); pname=findViewById(R.id.pname);
btn_viewAll=findViewById(R.id.viewbtn); // 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 @Override
public void onClick(View view) { 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); 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) {
} databaseHelper= new DatabaseHelper(PatientenSuche.this);
} patientArrayAdapter= new ArrayAdapter<Akte>(PatientenSuche.this, android.R.layout.simple_list_item_1,databaseHelper.getEveryone());
listings.setAdapter(patientArrayAdapter);
/*
next steps to do
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
...@@ -7,51 +7,47 @@ ...@@ -7,51 +7,47 @@
tools:context=".PatientenSuche"> tools:context=".PatientenSuche">
<EditText <EditText
android:id="@+id/patSuche" android:id="@+id/pname"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="56dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:ems="10" android:ems="10"
android:hint="PatientenName" android:hint="PatientName"
android:inputType="textPersonName" android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<Button <Button
android:id="@+id/searchbtn" android:id="@+id/vbutton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:layout_marginEnd="60dp" android:text="ViewAll"
android:text="Search" app:layout_constraintEnd_toStartOf="@+id/sbutton"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/patSuche" /> app:layout_constraintTop_toBottomOf="@+id/pname" />
<Button <Button
android:id="@+id/viewbtn" android:id="@+id/sbutton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:text="View All" android:text="Search"
app:layout_constraintEnd_toStartOf="@+id/searchbtn" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.275" app:layout_constraintStart_toEndOf="@id/vbutton"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/pname" />
app:layout_constraintTop_toBottomOf="@+id/patSuche"
app:layout_constraintStart_toEndOf="@id/searchbtn"/>
<ListView <ListView
android:id="@+id/plist"
android:layout_width="409dp" android:layout_width="409dp"
android:layout_height="516dp" android:layout_height="479dp"
android:layout_marginStart="8dp"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/viewbtn" /> app:layout_constraintTop_toBottomOf="@+id/vbutton" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment