jeudi 29 septembre 2016

Notify nurse about the frequency of a medicine the patient must take

When you get a prescription from a pharmacy, there is a start date associated with the medication. Medications also have a scheduled frequency that tells you when to take the doses. There are fairly common patterns for the frequencies. You can take them every 4 hours. You can take them once a day. You can take them with meals or just before bed. You can also take them PRN or "as needed." Many medications also have a stop. You may need to take the medication for 7 days. You may need to take a certain number of doses. You may also take the medication for the rest of your life. Assume you have to implement a system to tell nurses when a patient should receive medications. How would you model a schedule for a medication that handles start dates, end dates, and frequencies?

I have done basic design ..but I'm stuck with implementing the schedule functionality (notification functionality that notifies the nurse bout medicine frequency )

The solution i have is

Frequency Class

    package patientmedicine;

public class Frequency {

public PartoftheDay part;
public enum PartoftheDay
{
    Morning,
    Afternoon,
    Evening,
    Night
}

public Frequency( PartoftheDay part ) {
    this.part = part;

} 

public PartoftheDay getPart() {
    return part;
}
public void setPart(PartoftheDay part) {
    this.part = part;
}

}

Medicine Class

    package patientmedicine;

import java.util.List;

public class Medicine {

private String name;
private String disease;
private String composition;
private String details;
private List<Frequency> frequencyList;



public List<Frequency> getFrequencyList() {
    return frequencyList;
}

public void setFrequencyList(List<Frequency> frequencyList) {
    this.frequencyList = frequencyList;
}

public String getName() {
    return name;
}

public Medicine(String name, String composition, String details) {
    this.name = name;
    this.setComposition(composition);
    this.setDetails(details);

}

public void setName(String name) {
    this.name = name;
}
public String getDisease() {
    return disease;
}
public void setDisease(String disease) {
    this.disease = disease;
}

/**
 * @return the composition
 */
public String getComposition() {
    return composition;
}

/**
 * @param composition the composition to set
 */
public void setComposition(String composition) {
    this.composition = composition;
}

/**
 * @return the details
 */
public String getDetails() {
    return details;
}

/**
 * @param details the details to set
 */
public void setDetails(String details) {
    this.details = details;
}

}

Patient class

    package patientmedicine;

import java.util.List;

public class Patient {

private String name;
private String disease;
private List<Medicine> medicineList;



public Patient(String name, String disease) {
    this.setName(name);
    this.setDisease(disease);

}



public List<Medicine> getMedicineList() {
    return medicineList;
}



public void setMedicineList(List<Medicine> medicineList) {
    this.medicineList = medicineList;
}



/**
 * @return the name
 */
public String getName() {
    return name;
}

/**
 * @param name the name to set
 */
public void setName(String name) {
    this.name = name;
}

/**
 * @return the disease
 */
public String getDisease() {
    return disease;
}

/**
 * @param disease the disease to set
 */
public void setDisease(String disease) {
    this.disease = disease;
}

}

Program Class

    package patientmedicine;

import java.util.ArrayList; import java.util.List;

import patientmedicine.Frequency.PartoftheDay;

public class Program { // private List patientList;

public static void main(String[] args) {

    List<Frequency> freque1 = new ArrayList<Frequency>();
    freque1.add(new Frequency(PartoftheDay.Morning));
    freque1.add(new Frequency(PartoftheDay.Evening));

    // List<Medicine> medicine = new ArrayList<Medicine>();
    Medicine med1 = new Medicine("Paracetemol", "38g", "For fever");
    med1.setFrequencyList(freque1);

    List<Frequency> freque2 = new ArrayList<Frequency>();
    freque2.add(new Frequency(PartoftheDay.Morning));
    freque2.add(new Frequency(PartoftheDay.Evening));

    Medicine med2 = new Medicine("Ibuprofen", "38g", "For body pains");
    med2.setFrequencyList(freque2);

    List<Medicine> medicineList = new ArrayList<Medicine>();
    medicineList.add(med1);
    medicineList.add(med2);

    Patient patient1 = new Patient("Deepthi", "For body pains");
    patient1.setMedicineList(medicineList);

    List<Patient> patientList = new ArrayList<Patient>();
    patientList.add(patient1);

    for (Patient patientt : patientList) {
        System.out.println(patientt.getDisease());
        System.out.println(patientt.getName());

        for (Medicine medi : patientt.getMedicineList()) {

            System.out.println(medi.getDetails() + medi.getComposition()
                    + medi.getName());

            for (Frequency freq : medi.getFrequencyList()) {
                System.out.println(freq.getPart());
            }

        }

    }

}

}

Aucun commentaire:

Enregistrer un commentaire