mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Merge branch 'bugfix/Fix_add_medic' into develop
This commit is contained in:
commit
033c29b564
20 changed files with 383 additions and 303 deletions
|
@ -116,7 +116,7 @@ dependencies {
|
|||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 3,
|
||||
"identityHash": "ed6d0a13273d73ba9fcec1f374251efa",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "medics",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cis` TEXT NOT NULL, `cip13` TEXT, `name` TEXT, `administration_mode` TEXT, `presentation` TEXT, `stock` REAL, `take` REAL, `warning` INTEGER, `alert` INTEGER, `last_update` INTEGER, PRIMARY KEY(`cis`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "cis",
|
||||
"columnName": "cis",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "cip13",
|
||||
"columnName": "cip13",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "administration_mode",
|
||||
"columnName": "administration_mode",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "presentation",
|
||||
"columnName": "presentation",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "stock",
|
||||
"columnName": "stock",
|
||||
"affinity": "REAL",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "take",
|
||||
"columnName": "take",
|
||||
"affinity": "REAL",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "warning",
|
||||
"columnName": "warning",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "alert",
|
||||
"columnName": "alert",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "last_update",
|
||||
"columnName": "last_update",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"cis"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ed6d0a13273d73ba9fcec1f374251efa')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -2,17 +2,23 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "5ac4c79044120e5fa2716c6a89eff9bf",
|
||||
"identityHash": "96dc5c4ccb337047e323d613eb86bdd1",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "medics",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cis` TEXT NOT NULL, `cip13` TEXT, `name` TEXT, `administration_mode` TEXT, `presentation` TEXT, `stock` INTEGER, `take` INTEGER, `warning` INTEGER, `alert` INTEGER, `last_update` INTEGER, PRIMARY KEY(`cis`))",
|
||||
"tableName": "drugs",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER NOT NULL, `cis` TEXT, `cip13` TEXT, `cip7` TEXT, `administration_mode` TEXT, `name` TEXT, `presentation` TEXT, `label_group` TEXT, `generic_type` INTEGER, PRIMARY KEY(`_id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "_id",
|
||||
"columnName": "_id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "cis",
|
||||
"columnName": "cis",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "cip13",
|
||||
|
@ -21,8 +27,8 @@
|
|||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"fieldPath": "cip7",
|
||||
"columnName": "cip7",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
|
@ -32,6 +38,12 @@
|
|||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "presentation",
|
||||
"columnName": "presentation",
|
||||
|
@ -39,39 +51,21 @@
|
|||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "stock",
|
||||
"columnName": "stock",
|
||||
"affinity": "INTEGER",
|
||||
"fieldPath": "label_group",
|
||||
"columnName": "label_group",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "take",
|
||||
"columnName": "take",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "warning",
|
||||
"columnName": "warning",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "alert",
|
||||
"columnName": "alert",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "last_update",
|
||||
"columnName": "last_update",
|
||||
"fieldPath": "generic_type",
|
||||
"columnName": "generic_type",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"cis"
|
||||
"_id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
|
@ -82,7 +76,7 @@
|
|||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5ac4c79044120e5fa2716c6a89eff9bf')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '96dc5c4ccb337047e323d613eb86bdd1')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 2,
|
||||
"identityHash": "ed6d0a13273d73ba9fcec1f374251efa",
|
||||
"version": 1,
|
||||
"identityHash": "46c4983931eaf7414e25dfd9e1a55e0f",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "medics",
|
||||
"tableName": "prescriptions",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cis` TEXT NOT NULL, `cip13` TEXT, `name` TEXT, `administration_mode` TEXT, `presentation` TEXT, `stock` REAL, `take` REAL, `warning` INTEGER, `alert` INTEGER, `last_update` INTEGER, PRIMARY KEY(`cis`))",
|
||||
"fields": [
|
||||
{
|
||||
|
@ -82,7 +82,7 @@
|
|||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ed6d0a13273d73ba9fcec1f374251efa')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '46c4983931eaf7414e25dfd9e1a55e0f')"
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -41,7 +41,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
private static final String TAG = DBHelper.class.getName();
|
||||
|
||||
private static final String[] COLUMS = {KEY_ID, KEY_CIS,KEY_CIP13, KEY_NAME, KEY_ADMIN, KEY_PRES, KEY_STOCK, KEY_TAKE,
|
||||
private static final String[] COLUMNS = {KEY_ID, KEY_CIS,KEY_CIP13, KEY_NAME, KEY_ADMIN, KEY_PRES, KEY_STOCK, KEY_TAKE,
|
||||
KEY_THRESHOLD_WARN, KEY_THRESHOLD_ALERT, KEY_LAST_UPDATE};
|
||||
|
||||
DBHelper(Context context) {
|
||||
|
@ -114,7 +114,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
// Insert
|
||||
db.insert(TABLE_DRUG, // table
|
||||
null, // colunms list not needed
|
||||
null, // columns list not needed
|
||||
values); // key/value
|
||||
|
||||
// Close database
|
||||
|
@ -132,7 +132,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
// Build query
|
||||
Cursor cursor = db.query(TABLE_DRUG, // Which table
|
||||
COLUMS, // column names
|
||||
COLUMNS, // column names
|
||||
" id = ?", // selections
|
||||
new String[] { String.valueOf(id) }, // selections args
|
||||
null, // group by
|
||||
|
@ -173,7 +173,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param cip13 drug id in French nomemclature
|
||||
* @param cip13 drug id in French nomenclature
|
||||
* @return the drug object found in DB or null
|
||||
*/
|
||||
public Drug getDrugByCIP13(String cip13) {
|
||||
|
@ -182,7 +182,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
// Build query
|
||||
Cursor cursor = db.query(TABLE_DRUG, // Which table
|
||||
COLUMS, // column names
|
||||
COLUMNS, // column names
|
||||
" cip13 = ?", // selections
|
||||
new String[]{String.valueOf(cip13)}, // selections args
|
||||
null, // group by
|
||||
|
|
|
@ -15,8 +15,9 @@ 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.databases.PrescriptionDatabase;
|
||||
import net.foucry.pilldroid.models.Prescription;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -30,7 +31,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 +39,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("prescription");
|
||||
Log.d(TAG, "aPrescription == " + aPrescription);
|
||||
|
||||
setContentView(R.layout.drug_detail_activity);
|
||||
Toolbar toolbar = findViewById(detail_toolbar);
|
||||
|
@ -65,7 +66,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 +82,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("prescription", aPrescription);
|
||||
DrugDetailFragment fragment = new DrugDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
|
@ -109,11 +110,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.getPrescriptionsDAO();
|
||||
|
||||
Medic newMedic = medicDAO.getMedicByCIP13(aMedic.getCip13());
|
||||
Prescription newPrescription = prescriptionsDAO.getMedicByCIP13(aPrescription.getCip13());
|
||||
|
||||
View stockView;
|
||||
View takeView;
|
||||
|
@ -136,18 +137,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ 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;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
|
@ -33,11 +33,16 @@ import androidx.appcompat.widget.Toolbar;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.room.Room;
|
||||
|
||||
import com.google.zxing.client.android.BuildConfig;
|
||||
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.MedicinesDAO;
|
||||
import net.foucry.pilldroid.dao.PrescriptionsDAO;
|
||||
import net.foucry.pilldroid.databases.MedicineDatabase;
|
||||
import net.foucry.pilldroid.databases.PrescriptionDatabase;
|
||||
import net.foucry.pilldroid.models.Medicine;
|
||||
import net.foucry.pilldroid.models.Prescription;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
@ -63,10 +68,10 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
private ActivityResultLauncher<ScanOptions> mBarcodeScannerLauncher;
|
||||
private static final String TAG = DrugListActivity.class.getName();
|
||||
|
||||
public PilldroidDatabase prescriptions;
|
||||
public PilldroidDatabase medications;
|
||||
public PrescriptionDatabase prescriptions;
|
||||
public MedicineDatabase medicines;
|
||||
|
||||
private List<Medic> medics; // used for prescriptions
|
||||
private List<Prescription> prescriptionList; // used for prescriptions
|
||||
|
||||
private SimpleItemRecyclerViewAdapter mAdapter;
|
||||
|
||||
|
@ -74,33 +79,47 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
medications = Room
|
||||
.databaseBuilder(getApplicationContext(), PilldroidDatabase.class, "medications")
|
||||
if(net.foucry.pilldroid.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
|
||||
);
|
||||
}
|
||||
|
||||
medicines = Room
|
||||
.databaseBuilder(getApplicationContext(), MedicineDatabase.class, "medicines")
|
||||
.createFromAsset("drugs.db")
|
||||
.allowMainThreadQueries()
|
||||
.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<Drug> 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");
|
||||
|
@ -115,9 +134,11 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
nm.cancelAll();
|
||||
}
|
||||
|
||||
// start tutorial
|
||||
Log.i(TAG, "Launch tutorial");
|
||||
startActivity(new Intent(this, WelcomeActivity.class));
|
||||
// start tutorial (only in non debug mode
|
||||
if(!net.foucry.pilldroid.BuildConfig.DEBUG) {
|
||||
Log.i(TAG, "Launch tutorial");
|
||||
startActivity(new Intent(this, WelcomeActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,7 +153,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 +168,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<Medic> prescriptions = medicDAO.getAllMedics();
|
||||
List<Prescription> prescriptions = prescriptionsDAO.getAllMedics();
|
||||
System.out.println(prescriptions);
|
||||
Log.d(TAG, "prescriptions ==" + prescriptions);
|
||||
}
|
||||
|
@ -225,11 +246,11 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
// Get Drug from database
|
||||
MedicDAO medicationDAO = medications.getMedicDAO();
|
||||
final Medic scannedMedication = medicationDAO.getMedicByCIP13(cip13);
|
||||
MedicinesDAO medicinesDAO = medicines.getMedicinesDAO();
|
||||
final Medicine scannedMedicine = medicinesDAO.getMedicineByCIP13(cip13);
|
||||
|
||||
// add Drug to prescription database
|
||||
askToAddInDB(scannedMedication);
|
||||
askToAddInDB(scannedMedicine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +260,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 +341,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);
|
||||
MedicinesDAO medicineDAO = medicines.getMedicinesDAO();
|
||||
Medicine aMedicine = medicineDAO.getMedicineByCIP13(cip13);
|
||||
//Prescription aPrescription = medications.getDrugByCIP13(cip13);
|
||||
askToAddInDB(aMedicine);
|
||||
})
|
||||
.setNegativeButton("Cancel",
|
||||
(dialog, id) -> dialog.cancel());
|
||||
|
@ -354,14 +375,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 aMedicine Prescription- medication to be added
|
||||
*/
|
||||
private void askToAddInDB(Medic aMedic) {
|
||||
private void askToAddInDB(Medicine aMedicine) {
|
||||
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 (aMedicine != null) {
|
||||
String msg = aMedicine.getName() + " " + getString(R.string.msgFound);
|
||||
|
||||
dlg.setMessage(msg);
|
||||
dlg.setNegativeButton(getString(R.string.button_cancel), (dialog, which) -> {
|
||||
|
@ -369,7 +390,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(Utils.medicine2prescription(aMedicine));
|
||||
});
|
||||
} else {
|
||||
dlg.setMessage(getString(R.string.msgNotFound));
|
||||
|
@ -397,18 +418,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("prescription", aPrescription);
|
||||
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
|
@ -431,7 +452,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 +462,19 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
public class SimpleItemRecyclerViewAdapter extends
|
||||
RecyclerView.Adapter<SimpleItemRecyclerViewAdapter.ViewHolder> {
|
||||
|
||||
private final List<Medic> mValues;
|
||||
private final List<Prescription> mValues;
|
||||
|
||||
SimpleItemRecyclerViewAdapter(List<Medic> items) {
|
||||
SimpleItemRecyclerViewAdapter(List<Prescription> 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 +515,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("prescription", aPrescription);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
|
||||
|
@ -520,10 +541,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 +564,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);
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package net.foucry.pilldroid;
|
||||
|
||||
import androidx.room.AutoMigration;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import net.foucry.pilldroid.dao.MedicDAO;
|
||||
import net.foucry.pilldroid.models.Medic;
|
||||
|
||||
@Database(
|
||||
version = 3,
|
||||
entities = {Medic.class},
|
||||
autoMigrations = {
|
||||
@AutoMigration(from = 1, to = 2),
|
||||
@AutoMigration(from = 2, to = 3),
|
||||
}
|
||||
)
|
||||
|
||||
public abstract class PilldroidDatabase extends RoomDatabase {
|
||||
public abstract MedicDAO getMedicDAO();
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
package net.foucry.pilldroid;
|
||||
|
||||
import androidx.room.Database;
|
||||
|
||||
import net.foucry.pilldroid.models.Medicine;
|
||||
import net.foucry.pilldroid.models.Prescription;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -24,4 +30,21 @@ public class Utils {
|
|||
else
|
||||
return String.format("%s",d);
|
||||
}
|
||||
|
||||
public static Prescription medicine2prescription(Medicine aMedicine) {
|
||||
Prescription aPrescription = new Prescription();
|
||||
|
||||
aPrescription.setName(aMedicine.getName());
|
||||
aPrescription.setCis(aMedicine.getCis());
|
||||
aPrescription.setCip13(aMedicine.getCip13());
|
||||
aPrescription.setPresentation(aMedicine.getPresentation());
|
||||
aPrescription.setAdministration_mode(aMedicine.getAdministration_mode());
|
||||
aPrescription.setStock(0F);
|
||||
aPrescription.setAlert(7);
|
||||
aPrescription.setTake(0F);
|
||||
aPrescription.setWarning(14);
|
||||
aPrescription.setLast_update(UtilDate.dateAtNoon(new Date()).getTime());
|
||||
|
||||
return aPrescription;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Medic> getAllMedics();
|
||||
|
||||
@Query("SELECT * FROM medics WHERE cip13 = :cip13")
|
||||
Medic getMedicByCIP13(String cip13);
|
||||
|
||||
@Query("SELECT count(*) FROM medics")
|
||||
int getMedicCount();
|
||||
}
|
||||
|
||||
|
20
app/src/main/java/net/foucry/pilldroid/dao/MedicinesDAO.java
Normal file
20
app/src/main/java/net/foucry/pilldroid/dao/MedicinesDAO.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package net.foucry.pilldroid.dao;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Query;
|
||||
|
||||
import net.foucry.pilldroid.models.Medicine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface MedicinesDAO {
|
||||
@Query("SELECT * FROM drugs")
|
||||
List<Medicine> getAllMedicines();
|
||||
|
||||
@Query("SELECT * FROM drugs WHERE cip13 = :cip13")
|
||||
Medicine getMedicineByCIP13(String cip13);
|
||||
|
||||
@Query("SELECT count(*) FROM drugs")
|
||||
int getMedicineCount();
|
||||
}
|
|
@ -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<Prescription> getAllMedics();
|
||||
|
||||
@Query("SELECT * FROM prescriptions WHERE cip13 = :cip13")
|
||||
Prescription getMedicByCIP13(String cip13);
|
||||
|
||||
@Query("SELECT count(*) FROM prescriptions")
|
||||
int getMedicCount();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package net.foucry.pilldroid.databases;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import net.foucry.pilldroid.dao.MedicinesDAO;
|
||||
import net.foucry.pilldroid.models.Medicine;
|
||||
|
||||
@Database(
|
||||
version = 1,
|
||||
entities = {Medicine.class}
|
||||
)
|
||||
|
||||
public abstract class MedicineDatabase extends RoomDatabase {
|
||||
public abstract MedicinesDAO getMedicinesDAO();
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package net.foucry.pilldroid.databases;
|
||||
|
||||
import androidx.room.AutoMigration;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import net.foucry.pilldroid.dao.PrescriptionsDAO;
|
||||
import net.foucry.pilldroid.models.Prescription;
|
||||
|
||||
@Database(
|
||||
version = 1,
|
||||
entities = {Prescription.class}
|
||||
)
|
||||
|
||||
public abstract class PrescriptionDatabase extends RoomDatabase {
|
||||
public abstract PrescriptionsDAO getPrescriptionsDAO();
|
||||
}
|
97
app/src/main/java/net/foucry/pilldroid/models/Medicine.java
Normal file
97
app/src/main/java/net/foucry/pilldroid/models/Medicine.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
package net.foucry.pilldroid.models;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "drugs")
|
||||
public class Medicine {
|
||||
@PrimaryKey
|
||||
@NonNull private Integer _id;
|
||||
private String cis;
|
||||
private String cip13;
|
||||
private String cip7;
|
||||
private String administration_mode;
|
||||
private String name;
|
||||
private String presentation;
|
||||
private String label_group;
|
||||
private Integer generic_type;
|
||||
|
||||
public Medicine(@NonNull String cis) {
|
||||
this.cis = cis;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getCis() {
|
||||
return cis;
|
||||
}
|
||||
|
||||
public void setCis(@NonNull String cis) {
|
||||
this.cis = cis;
|
||||
}
|
||||
|
||||
public String getCip13() {
|
||||
return cip13;
|
||||
}
|
||||
|
||||
public void setCip13(String cip13) {
|
||||
this.cip13 = cip13;
|
||||
}
|
||||
|
||||
public String getCip7() {
|
||||
return cip7;
|
||||
}
|
||||
|
||||
public void setCip7(String cip7) {
|
||||
this.cip7 = cip7;
|
||||
}
|
||||
|
||||
public String getAdministration_mode() {
|
||||
return administration_mode;
|
||||
}
|
||||
|
||||
public void setAdministration_mode(String administration_mode) {
|
||||
this.administration_mode = administration_mode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPresentation() {
|
||||
return presentation;
|
||||
}
|
||||
|
||||
public void setPresentation(String presentation) {
|
||||
this.presentation = presentation;
|
||||
}
|
||||
|
||||
public String getLabel_group() {
|
||||
return label_group;
|
||||
}
|
||||
|
||||
public void setLabel_group(String label_group) {
|
||||
this.label_group = label_group;
|
||||
}
|
||||
|
||||
public Integer getGeneric_type() {
|
||||
return generic_type;
|
||||
}
|
||||
|
||||
public void setGeneric_type(Integer generic_type) {
|
||||
this.generic_type = generic_type;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Integer get_id() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void set_id(@NonNull Integer _id) {
|
||||
this._id = _id;
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -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).
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<<<<<<< HEAD
|
||||
<strong>Pilldroid</strong> is a theoretical medics manager. It for French people
|
||||
<strong>Pilldroid</strong> is a theoretical prescriptions manager. It for French people
|
||||
only.
|
||||
|
||||
<strong>Why for french people only?</strong>
|
||||
<p>Pilldroid use a medics databases that come from French government website, with
|
||||
<strong>Pilldroid</strong> is a theoretical medics manager. It for French people
|
||||
<p>Pilldroid use a prescriptions databases that come from French government website, with
|
||||
<strong>Pilldroid</strong> 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).</p>
|
||||
|
||||
<strong>What is the Pilldroid's license?</strong>
|
||||
|
|
Loading…
Reference in a new issue