From dcff425d9e592ecef1d9d2e30890dc29cc71b7b8 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 16 Mar 2022 17:08:13 +0100 Subject: [PATCH] add convert method between Medicine and Prescription --- .../main/java/net/foucry/pilldroid/Utils.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/net/foucry/pilldroid/Utils.java b/app/src/main/java/net/foucry/pilldroid/Utils.java index 647d793..0d8c037 100644 --- a/app/src/main/java/net/foucry/pilldroid/Utils.java +++ b/app/src/main/java/net/foucry/pilldroid/Utils.java @@ -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; + } }