Add Room prescription database amangement

This commit is contained in:
Jacques Foucry 2022-03-07 18:19:35 +01:00
parent 3e38c7223c
commit a98601c8b0
3 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,13 @@
package net.foucry.pilldroid;
import android.arch.persistence.root.Database;
import android.arch.persistence.root.RoomDatabase;
import net.foucry.pilldroid.dao.MedicDAO;
import net.foucry.pilldroid.model.Medic;
@Database(entities = {Medic.class}, version = 1)
public abstract class PilldroidDatabase extends RoomDatabase {
public abstract MedicDAO getMedicDAO();
}

View file

@ -0,0 +1,32 @@
package net.foucry.pilldroid.dao;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Update;
import net.foucry.pilldroid.models.Medic;
import android.arch.persistence.room.Query;
import java.util.list;
@Dao
public interface MedicDAO {
@Insert
public void insert(Medic... medics);
@Upfdate
public void update(Medic... medics);
@Delete
public void delete(Medic medic);
}
@Query("SELECT * FROM medics")
public List<Medic> getMedics();
@Query("SELECT * FROM medics WHERE id = :id")
public Medic getMedicBy(Long id);
@Query("SELECT * FROM medics WHERE cip13 = :cip13")
public Medic getMedicByCIP13(String cip13);
@Query("SELECT count(*) FROM medics")
public int getMedicCount();

View file

@ -0,0 +1,22 @@
package net.foucry.pilldroid.models;
import android.arch.persitence.room.Entity;
import android.arch.persitence.room.PrimaryKey;
import android.support.annotation.NonNull;
@Entity(tableName = "medics")
public class medic {
@PrimaryKey
@NonNull private Long id;
private String cis;
private String cip13;
private String name;
private String administration_mode;
private String presentation;
private Long stock;
private Long take;
private Int warning;
private Int alert;
private Long last_update;
}