From e1d2c197cc2a7ecaa99c0b31602aa12c9659b987 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 16 Mar 2022 05:44:19 +0100 Subject: [PATCH] rename Medic in Prescription and refactor code --- .../foucry/pilldroid/DrugDetailActivity.java | 40 ++--- .../foucry/pilldroid/DrugDetailFragment.java | 32 ++-- .../foucry/pilldroid/DrugListActivity.java | 148 ++++++++++-------- ...atabase.java => PrescriptionDatabase.java} | 10 +- .../net/foucry/pilldroid/dao/MedicDAO.java | 34 ---- .../pilldroid/dao/PrescriptionsDAO.java | 34 ++++ .../models/{Medic.java => Prescription.java} | 8 +- .../android/en-US/changelogs/v0.100-beta.txt | 4 +- .../android/en-US/full_description.txt | 8 +- 9 files changed, 166 insertions(+), 152 deletions(-) rename app/src/main/java/net/foucry/pilldroid/{PilldroidDatabase.java => PrescriptionDatabase.java} (53%) delete mode 100644 app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java create mode 100644 app/src/main/java/net/foucry/pilldroid/dao/PrescriptionsDAO.java rename app/src/main/java/net/foucry/pilldroid/models/{Medic.java => Prescription.java} (94%) diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java index d5315ef..4426808 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailActivity.java @@ -15,8 +15,8 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; -import net.foucry.pilldroid.dao.MedicDAO; -import net.foucry.pilldroid.models.Medic; +import net.foucry.pilldroid.dao.PrescriptionsDAO; +import net.foucry.pilldroid.models.Prescription; import java.util.Date; @@ -30,7 +30,7 @@ public class DrugDetailActivity extends AppCompatActivity { private static final String TAG = DrugDetailActivity.class.getName(); - Medic aMedic; + Prescription aPrescription; @Override protected void onCreate(Bundle savedInstanceState) { @@ -38,8 +38,8 @@ public class DrugDetailActivity extends AppCompatActivity { Bundle bundle = getIntent().getExtras(); assert bundle != null; - aMedic = (Medic) bundle.get("medic"); - Log.d(TAG, "aMedic == " + aMedic); + aPrescription = (Prescription) bundle.get("medic"); + Log.d(TAG, "aPrescription == " + aPrescription); setContentView(R.layout.drug_detail_activity); Toolbar toolbar = findViewById(detail_toolbar); @@ -65,7 +65,7 @@ public class DrugDetailActivity extends AppCompatActivity { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(false); - actionBar.setTitle(aMedic.getName()); + actionBar.setTitle(aPrescription.getName()); } // savedInstanceState is non-null when there is fragment state @@ -81,7 +81,7 @@ public class DrugDetailActivity extends AppCompatActivity { // Create the detail fragment and add it to the activity // using a fragment transaction. Bundle arguments = new Bundle(); - arguments.putSerializable("medic", aMedic); + arguments.putSerializable("medic", aPrescription); DrugDetailFragment fragment = new DrugDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() @@ -109,11 +109,11 @@ public class DrugDetailActivity extends AppCompatActivity { private void getMDrugChanges() { Log.d(TAG, "Time to save new values"); - PilldroidDatabase prescriptions = null; + PrescriptionDatabase prescriptions = null; assert false; - MedicDAO medicDAO = prescriptions.getMedicDAO(); + PrescriptionsDAO prescriptionsDAO = prescriptions.getMedicDAO(); - Medic newMedic = medicDAO.getMedicByCIP13(aMedic.getCip13()); + Prescription newPrescription = prescriptionsDAO.getMedicByCIP13(aPrescription.getCip13()); View stockView; View takeView; @@ -136,18 +136,18 @@ public class DrugDetailActivity extends AppCompatActivity { TextView warningTextView = warningView.findViewById(R.id.value); String warningValue = warningTextView.getText().toString(); - newMedic.setStock(Float.parseFloat(stockValue)); - newMedic.setTake(Float.parseFloat(takeValue)); - newMedic.setWarning(Integer.parseInt(warningValue)); - newMedic.setAlert(Integer.parseInt(alertValue)); - newMedic.getDateEndOfStock(); + newPrescription.setStock(Float.parseFloat(stockValue)); + newPrescription.setTake(Float.parseFloat(takeValue)); + newPrescription.setWarning(Integer.parseInt(warningValue)); + newPrescription.setAlert(Integer.parseInt(alertValue)); + newPrescription.getDateEndOfStock(); - if (aMedic.equals(newMedic)) { - Log.d(TAG, "medic and newMedic are Equals"); + if (aPrescription.equals(newPrescription)) { + Log.d(TAG, "medic and newPrescription are Equals"); } else { - Log.d(TAG, "medic and newMedic are NOT Equals"); - newMedic.setLast_update(new Date().getTime()); - medicDAO.update(newMedic); + Log.d(TAG, "medic and newPrescription are NOT Equals"); + newPrescription.setLast_update(new Date().getTime()); + prescriptionsDAO.update(newPrescription); //dbHelper.updateDrug(newDrug); } } diff --git a/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java b/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java index 52169da..763746a 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugDetailFragment.java @@ -11,7 +11,7 @@ import androidx.fragment.app.Fragment; import com.google.android.material.appbar.CollapsingToolbarLayout; -import net.foucry.pilldroid.models.Medic; +import net.foucry.pilldroid.models.Prescription; /** * A fragment representing a single Drug detail screen. @@ -25,12 +25,12 @@ public class DrugDetailFragment extends Fragment { * The fragment argument representing the item ID that this fragment * represents. */ - public static final String ARG_ITEM_ID = "medic"; + public static final String ARG_ITEM_ID = "prescription"; /** * The dummy content this fragment is presenting. */ - private Medic medic; + private Prescription prescription; /** * Mandatory empty constructor for the fragment manager to instantiate the @@ -48,13 +48,13 @@ public class DrugDetailFragment extends Fragment { // Load the dummy content specified by the fragment // arguments. In a real-world scenario, use a Loader // to load content from a content provider. - medic = (Medic) getArguments().getSerializable(ARG_ITEM_ID); + prescription = (Prescription) getArguments().getSerializable(ARG_ITEM_ID); Activity activity = this.getActivity(); assert activity != null; CollapsingToolbarLayout appBarLayout = activity.findViewById(R.id.toolbar_layout); if (appBarLayout != null) { - appBarLayout.setTitle(medic.getName()); + appBarLayout.setTitle(prescription.getName()); } } } @@ -71,31 +71,31 @@ public class DrugDetailFragment extends Fragment { View alertView; // Show the dummy content as text in a TextView. - if (medic != null) { + if (prescription != null) { // Find each component of rootView nameView = detailView.findViewById(R.id.name_cell); TextView nameLabel = nameView.findViewById(R.id.label); TextView nameValue = nameView.findViewById(R.id.value); nameLabel.setText(R.string.drug_name_label); - nameValue.setText(medic.getName()); + nameValue.setText(prescription.getName()); presentationView = detailView.findViewById(R.id.presentation_cell); TextView presentationLabel = presentationView.findViewById(R.id.label); TextView presentationValue = presentationView.findViewById(R.id.value); presentationLabel.setText(R.string.drug_presentation_label); - presentationValue.setText(medic.getPresentation()); + presentationValue.setText(prescription.getPresentation()); adminModeView = detailView.findViewById(R.id.administration_cell); TextView adminModeLabel = adminModeView.findViewById(R.id.label); TextView adminModeValue = adminModeView.findViewById(R.id.value); adminModeLabel.setText(R.string.drug_administrationMode_label); - adminModeValue.setText(medic.getAdministration_mode()); + adminModeValue.setText(prescription.getAdministration_mode()); stockView = detailView.findViewById(R.id.stock_cell); TextView stockLibelle = (stockView.findViewById(R.id.label)); TextView stockValue = stockView.findViewById(R.id.value); stockLibelle.setText(R.string.drug_current_stock_label); - stockValue.setText(Utils.fmt(medic.getStock())); + stockValue.setText(Utils.fmt(prescription.getStock())); stockValue.setHint(R.string.drug_current_stock_label); stockValue.setSelectAllOnFocus(true); @@ -103,8 +103,8 @@ public class DrugDetailFragment extends Fragment { TextView takeLabel = takeView.findViewById(R.id.label); TextView takeValue = (takeView.findViewById(R.id.value)); takeLabel.setText(R.string.drug_take_label); - //takeValue.setText(Double.toString(medic.getTake())); - takeValue.setText(Utils.fmt(medic.getTake())); + //takeValue.setText(Double.toString(prescription.getTake())); + takeValue.setText(Utils.fmt(prescription.getTake())); takeValue.setHint(R.string.drug_take_label); takeValue.setSelectAllOnFocus(true); @@ -112,8 +112,8 @@ public class DrugDetailFragment extends Fragment { TextView warningLibelle = warningView.findViewById(R.id.label); TextView warningValue = warningView.findViewById(R.id.value); warningLibelle.setText(R.string.drug_warningThreshold_label); - //warningValue.setText(Integer.toString(medic.getWarnThreshold())); - warningValue.setText(Utils.fmt(medic.getWarning())); + //warningValue.setText(Integer.toString(prescription.getWarnThreshold())); + warningValue.setText(Utils.fmt(prescription.getWarning())); warningValue.setHint(R.string.drug_warningThreshold_label); warningValue.setSelectAllOnFocus(true); @@ -121,8 +121,8 @@ public class DrugDetailFragment extends Fragment { TextView alertLibelle = alertView.findViewById(R.id.label); TextView alertValue = alertView.findViewById(R.id.value); alertLibelle.setText(R.string.drug_alertThreshold_label); - //alertValue.setText(Integer.toString(medic.getAlertThreshold())); - alertValue.setText(Utils.fmt(medic.getAlert())); + //alertValue.setText(Integer.toString(prescription.getAlertThreshold())); + alertValue.setText(Utils.fmt(prescription.getAlert())); alertValue.setHint(R.string.drug_alertThreshold_label); alertValue.setSelectAllOnFocus(true); } diff --git a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java index 3faad62..b518cae 100644 --- a/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/DrugListActivity.java @@ -9,6 +9,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.text.Editable; @@ -36,8 +37,8 @@ import androidx.room.Room; import com.google.zxing.client.android.Intents; import com.journeyapps.barcodescanner.ScanOptions; -import net.foucry.pilldroid.dao.MedicDAO; -import net.foucry.pilldroid.models.Medic; +import net.foucry.pilldroid.dao.PrescriptionsDAO; +import net.foucry.pilldroid.models.Prescription; import java.text.SimpleDateFormat; import java.util.Date; @@ -63,10 +64,10 @@ public class DrugListActivity extends AppCompatActivity { private ActivityResultLauncher mBarcodeScannerLauncher; private static final String TAG = DrugListActivity.class.getName(); - public PilldroidDatabase prescriptions; - public PilldroidDatabase medications; + public PrescriptionDatabase prescriptions; + public PrescriptionDatabase medications; - private List medics; // used for prescriptions + private List prescriptionList; // used for prescriptions private SimpleItemRecyclerViewAdapter mAdapter; @@ -74,33 +75,46 @@ public class DrugListActivity extends AppCompatActivity { public void onStart() { super.onStart(); + if(BuildConfig.DEBUG) { + String manufacturer = Build.MANUFACTURER; + String model = Build.MODEL; + int version = Build.VERSION.SDK_INT; + String versionRelease = Build.VERSION.RELEASE; + + Log.e(TAG, "manufacturer " + manufacturer + + " \n model " + model + + " \n version " + version + + " \n versionRelease " + versionRelease + ); + } + medications = Room - .databaseBuilder(getApplicationContext(), PilldroidDatabase.class, "medications") + .databaseBuilder(getApplicationContext(), PrescriptionDatabase.class, "medications") .createFromAsset("drugs.db") .build(); // Manually migrate old database to room - MedicDAO medicDAO = prescriptions.getMedicDAO(); + PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); DBHelper dbHelper = new DBHelper(this); if (dbHelper.getCount() !=0) { List drugs=dbHelper.getAllDrugs(); for (int count=0; count < dbHelper.getCount(); count++) { Drug drug = drugs.get(count); - Medic medic = new Medic(); + Prescription prescription = new Prescription(); - if(medicDAO.getMedicByCIP13(drug.getCip13()) == null) { - medic.setName(drug.getName()); - medic.setCip13(drug.getCip13()); - medic.setCis(drug.getCis()); - medic.setPresentation(drug.getPresentation()); - medic.setAdministration_mode(drug.getAdministration_mode()); - medic.setStock((float) drug.getStock()); - medic.setTake((float) drug.getTake()); - medic.setWarning(drug.getWarnThreshold()); - medic.setAlert(drug.getAlertThreshold()); - medic.setLast_update(drug.getDateLastUpdate()); + if(prescriptionsDAO.getMedicByCIP13(drug.getCip13()) == null) { + prescription.setName(drug.getName()); + prescription.setCip13(drug.getCip13()); + prescription.setCis(drug.getCis()); + prescription.setPresentation(drug.getPresentation()); + prescription.setAdministration_mode(drug.getAdministration_mode()); + prescription.setStock((float) drug.getStock()); + prescription.setTake((float) drug.getTake()); + prescription.setWarning(drug.getWarnThreshold()); + prescription.setAlert(drug.getAlertThreshold()); + prescription.setLast_update(drug.getDateLastUpdate()); - medicDAO.insert(medic); + prescriptionsDAO.insert(prescription); } else { Log.i(TAG, "Already in the database"); @@ -132,7 +146,7 @@ public class DrugListActivity extends AppCompatActivity { // Create Room database prescriptions = Room - .databaseBuilder(getApplicationContext(), PilldroidDatabase.class, "prescriptions") + .databaseBuilder(getApplicationContext(), PrescriptionDatabase.class, "prescriptions") .allowMainThreadQueries() .build(); @@ -147,30 +161,30 @@ public class DrugListActivity extends AppCompatActivity { } if (DEMO) { - MedicDAO medicDAO = prescriptions.getMedicDAO(); + PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); - if (medicDAO.getMedicCount() == 0) { + if (prescriptionsDAO.getMedicCount() == 0) { final int min_stock = 5; final int max_stock = 50; final int min_take = 0; final int max_take = 3; for (int i = 1; i < 9; i++) { - Medic medic = new Medic(); - medic.setName("Medicament test " + i); - medic.setCip13("340093000001" + i); - medic.setCis("6000001" + i); - medic.setAdministration_mode("oral"); - medic.setPresentation("plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)"); - medic.setStock((float) intRandomExclusive(min_stock, max_stock)); - medic.setTake((float) intRandomExclusive(min_take, max_take)); - medic.setWarning(14); - medic.setAlert(7); - medic.setLast_update(UtilDate.dateAtNoon(new Date()).getTime()); + Prescription prescription = new Prescription(); + prescription.setName("Medicament test " + i); + prescription.setCip13("340093000001" + i); + prescription.setCis("6000001" + i); + prescription.setAdministration_mode("oral"); + prescription.setPresentation("plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)"); + prescription.setStock((float) intRandomExclusive(min_stock, max_stock)); + prescription.setTake((float) intRandomExclusive(min_take, max_take)); + prescription.setWarning(14); + prescription.setAlert(7); + prescription.setLast_update(UtilDate.dateAtNoon(new Date()).getTime()); - medicDAO.insert(medic); + prescriptionsDAO.insert(prescription); } - List prescriptions = medicDAO.getAllMedics(); + List prescriptions = prescriptionsDAO.getAllMedics(); System.out.println(prescriptions); Log.d(TAG, "prescriptions ==" + prescriptions); } @@ -225,8 +239,8 @@ public class DrugListActivity extends AppCompatActivity { } // Get Drug from database - MedicDAO medicationDAO = medications.getMedicDAO(); - final Medic scannedMedication = medicationDAO.getMedicByCIP13(cip13); + PrescriptionsDAO medicationDAO = medications.getMedicDAO(); // TODO + final Prescription scannedMedication = medicationDAO.getMedicByCIP13(cip13); // add Drug to prescription database askToAddInDB(scannedMedication); @@ -239,8 +253,8 @@ public class DrugListActivity extends AppCompatActivity { public void constructDrugsList() { - MedicDAO medicDAO = prescriptions.getMedicDAO(); - medics = medicDAO.getAllMedics(); + PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); + prescriptionList = prescriptionsDAO.getAllMedics(); View mRecyclerView = findViewById(R.id.drug_list); assert mRecyclerView != null; @@ -320,10 +334,10 @@ public class DrugListActivity extends AppCompatActivity { .setPositiveButton("OK", (dialog, id) -> { String cip13 = editText.getText().toString(); - MedicDAO medicationsDAO = medications.getMedicDAO(); - Medic aMedic = medicationsDAO.getMedicByCIP13(cip13); - //Medic aMedic = medications.getDrugByCIP13(cip13); - askToAddInDB(aMedic); + PrescriptionsDAO medicationsDAO = medications.getMedicDAO(); // TODO + Prescription aPrescription = medicationsDAO.getMedicByCIP13(cip13); + //Prescription aPrescription = medications.getDrugByCIP13(cip13); + askToAddInDB(aPrescription); }) .setNegativeButton("Cancel", (dialog, id) -> dialog.cancel()); @@ -354,14 +368,14 @@ public class DrugListActivity extends AppCompatActivity { * Ask if the drug found in the database should be include in the * user database * - * @param aMedic Medic- medication to be added + * @param aPrescription Prescription- medication to be added */ - private void askToAddInDB(Medic aMedic) { + private void askToAddInDB(Prescription aPrescription) { AlertDialog.Builder dlg = new AlertDialog.Builder(this); dlg.setTitle(getString(R.string.app_name)); - if (aMedic != null) { - String msg = aMedic.getName() + " " + getString(R.string.msgFound); + if (aPrescription != null) { + String msg = aPrescription.getName() + " " + getString(R.string.msgFound); dlg.setMessage(msg); dlg.setNegativeButton(getString(R.string.button_cancel), (dialog, which) -> { @@ -369,7 +383,7 @@ public class DrugListActivity extends AppCompatActivity { }); dlg.setPositiveButton(getString(R.string.button_ok), (dialog, which) -> { // Add Drug to DB then try to show it - addDrugToList(aMedic); + addDrugToList(aPrescription); }); } else { dlg.setMessage(getString(R.string.msgNotFound)); @@ -397,18 +411,18 @@ public class DrugListActivity extends AppCompatActivity { /** * Add New drug to the user database * - * @param aMedic Medic - medication to be added + * @param aPrescription Prescription - medication to be added */ @SuppressWarnings("deprecation") - private void addDrugToList(Medic aMedic) { - aMedic.getDateEndOfStock(); - mAdapter.addItem(aMedic); + private void addDrugToList(Prescription aPrescription) { + aPrescription.getDateEndOfStock(); + mAdapter.addItem(aPrescription); Log.d(TAG, "Call DrugDetailActivity"); Context context = this; Intent intent = new Intent(context, DrugDetailActivity.class); - intent.putExtra("medic", (Parcelable) aMedic); + intent.putExtra("medic", (Parcelable) aPrescription); startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); @@ -431,7 +445,7 @@ public class DrugListActivity extends AppCompatActivity { */ private void setupRecyclerView(@NonNull RecyclerView recyclerView) { recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getApplicationContext())); - mAdapter = new SimpleItemRecyclerViewAdapter(medics); + mAdapter = new SimpleItemRecyclerViewAdapter(prescriptionList); recyclerView.setAdapter(mAdapter); } @@ -441,19 +455,19 @@ public class DrugListActivity extends AppCompatActivity { public class SimpleItemRecyclerViewAdapter extends RecyclerView.Adapter { - private final List mValues; + private final List mValues; - SimpleItemRecyclerViewAdapter(List items) { + SimpleItemRecyclerViewAdapter(List items) { mValues = items; } - void addItem(Medic scannedMedic) { - MedicDAO medicDAO = prescriptions.getMedicDAO(); - if (medicDAO.getMedicByCIP13(scannedMedic.getCip13()) == null) { - mValues.add(scannedMedic); + void addItem(Prescription scannedPrescription) { + PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO(); + if (prescriptionsDAO.getMedicByCIP13(scannedPrescription.getCip13()) == null) { + mValues.add(scannedPrescription); //notifyDataSetChanged(); notifyItemInserted(mValues.size()); - medicDAO.insert(scannedMedic); + prescriptionsDAO.insert(scannedPrescription); } else { Toast.makeText(getApplicationContext(), "already in the database", Toast.LENGTH_LONG).show(); } @@ -494,10 +508,10 @@ public class DrugListActivity extends AppCompatActivity { holder.mView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Medic aMedic = mValues.get(position); + Prescription aPrescription = mValues.get(position); Context context = v.getContext(); Intent intent = new Intent(context, DrugDetailActivity.class); - intent.putExtra("medic", (Parcelable) aMedic); + intent.putExtra("medic", (Parcelable) aPrescription); startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); @@ -520,10 +534,10 @@ public class DrugListActivity extends AppCompatActivity { holder.mView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Medic medic = mValues.get(position); + Prescription prescription = mValues.get(position); Context context = v.getContext(); Intent intent = new Intent(context, DrugDetailActivity.class); - intent.putExtra("medic", medic); + intent.putExtra("prescription", prescription); startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE); overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); @@ -543,7 +557,7 @@ public class DrugListActivity extends AppCompatActivity { final TextView mContentView; final TextView mEndOfStock; final ImageView mIconView; - public Medic mItem; + public Prescription mItem; ViewHolder(View view) { super(view); diff --git a/app/src/main/java/net/foucry/pilldroid/PilldroidDatabase.java b/app/src/main/java/net/foucry/pilldroid/PrescriptionDatabase.java similarity index 53% rename from app/src/main/java/net/foucry/pilldroid/PilldroidDatabase.java rename to app/src/main/java/net/foucry/pilldroid/PrescriptionDatabase.java index 359f731..2ba6999 100644 --- a/app/src/main/java/net/foucry/pilldroid/PilldroidDatabase.java +++ b/app/src/main/java/net/foucry/pilldroid/PrescriptionDatabase.java @@ -4,18 +4,18 @@ import androidx.room.AutoMigration; import androidx.room.Database; import androidx.room.RoomDatabase; -import net.foucry.pilldroid.dao.MedicDAO; -import net.foucry.pilldroid.models.Medic; +import net.foucry.pilldroid.dao.PrescriptionsDAO; +import net.foucry.pilldroid.models.Prescription; @Database( version = 3, - entities = {Medic.class}, + entities = {Prescription.class}, autoMigrations = { @AutoMigration(from = 1, to = 2), @AutoMigration(from = 2, to = 3), } ) -public abstract class PilldroidDatabase extends RoomDatabase { - public abstract MedicDAO getMedicDAO(); +public abstract class PrescriptionDatabase extends RoomDatabase { + public abstract PrescriptionsDAO getPrescriptionsDAO(); } diff --git a/app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java b/app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java deleted file mode 100644 index 6b1fb0a..0000000 --- a/app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.foucry.pilldroid.dao; - -import androidx.room.Dao; -import androidx.room.Delete; -import androidx.room.Insert; -import androidx.room.Query; -import androidx.room.Update; - -import net.foucry.pilldroid.models.Medic; - -import java.util.List; - -@Dao -public interface MedicDAO { - @Insert - void insert(Medic... medics); - - @Update - void update(Medic... medics); - - @Delete - void delete(Medic medic); - - @Query("SELECT * FROM medics") - List getAllMedics(); - - @Query("SELECT * FROM medics WHERE cip13 = :cip13") - Medic getMedicByCIP13(String cip13); - - @Query("SELECT count(*) FROM medics") - int getMedicCount(); -} - - diff --git a/app/src/main/java/net/foucry/pilldroid/dao/PrescriptionsDAO.java b/app/src/main/java/net/foucry/pilldroid/dao/PrescriptionsDAO.java new file mode 100644 index 0000000..969ac4a --- /dev/null +++ b/app/src/main/java/net/foucry/pilldroid/dao/PrescriptionsDAO.java @@ -0,0 +1,34 @@ +package net.foucry.pilldroid.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; + +import net.foucry.pilldroid.models.Prescription; + +import java.util.List; + +@Dao +public interface PrescriptionsDAO { + @Insert + void insert(Prescription... prescriptions); + + @Update + void update(Prescription... prescriptions); + + @Delete + void delete(Prescription prescription); + + @Query("SELECT * FROM prescriptions") + List getAllMedics(); + + @Query("SELECT * FROM prescriptions WHERE cip13 = :cip13") + Prescription getMedicByCIP13(String cip13); + + @Query("SELECT count(*) FROM prescriptions") + int getMedicCount(); +} + + diff --git a/app/src/main/java/net/foucry/pilldroid/models/Medic.java b/app/src/main/java/net/foucry/pilldroid/models/Prescription.java similarity index 94% rename from app/src/main/java/net/foucry/pilldroid/models/Medic.java rename to app/src/main/java/net/foucry/pilldroid/models/Prescription.java index cb66220..6d23413 100644 --- a/app/src/main/java/net/foucry/pilldroid/models/Medic.java +++ b/app/src/main/java/net/foucry/pilldroid/models/Prescription.java @@ -10,16 +10,16 @@ import java.io.Serializable; import java.util.Calendar; import java.util.Date; -@Entity(tableName = "medics") -public class Medic implements Serializable { +@Entity(tableName = "prescriptions") +public class Prescription implements Serializable { @PrimaryKey @NonNull private String cis; private String cip13; private String name; private String administration_mode; private String presentation; - private Float stock; - private Float take; + private Float stock; + private Float take; private Integer warning; private Integer alert; private Long last_update; diff --git a/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt b/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt index fce252b..7e7f3a7 100644 --- a/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt +++ b/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt @@ -9,8 +9,8 @@ I made a lot a tests but there must stay some bugs. find the code. ## What is not implemented -- removing of a medic from the list; -- take medic reminder. It will be never been implemented (by me). +- removing of a prescription from the list; +- take prescription reminder. It will be never been implemented (by me). **ATTENTION**, Pilldroid does not manage creams, liquids (like insulin). diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt index 8c5bcde..2c04d56 100644 --- a/fastlane/metadata/android/en-US/full_description.txt +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -1,13 +1,13 @@ <<<<<<< HEAD -Pilldroid is a theoretical medics manager. It for French people +Pilldroid is a theoretical prescriptions manager. It for French people only. Why for french people only? -

Pilldroid use a medics databases that come from French government website, with -Pilldroid is a theoretical medics manager. It for French people +

Pilldroid use a prescriptions databases that come from French government website, with +Pilldroid is a theoretical prescriptions manager. It for French people only. -medics which are refund by french health care national insurance (Sécurité +prescriptions which are refund by french health care national insurance (Sécurité Sociale).

What is the Pilldroid's license?