【发布时间】:2016-09-26 17:40:51
【问题描述】:
当您从药房获得处方时,会有一个与药物相关的开始日期。药物也有一个预定的频率,告诉您何时服用。频率有相当常见的模式。您可以每 4 小时服用一次。您可以每天服用一次。您可以在用餐时或临睡前服用。您也可以使用 PRN 或“根据需要”。许多药物也有停止作用。您可能需要服药 7 天。您可能需要服用一定数量的剂量。您也可以在余生中服药。假设您必须实施一个系统来告诉护士患者何时应该接受药物治疗。您将如何为处理开始日期、结束日期和频率的药物时间表建模?
我已经完成了基本设计..但我坚持实施计划功能(通知护士用药频率的通知功能)
我的解决方案是
频率等级
package patientmedicine;
公开课频率{
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;
}
}
医学类
package patientmedicine;
导入 java.util.List;
公开课医学{
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;
}
}
患者分类
package patientmedicine;
导入 java.util.List;
公共类患者{
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;
}
}
程序类
package patientmedicine;
导入 java.util.ArrayList; 导入 java.util.List;
导入patientmedicine.Frequency.PartoftheDay;
公开课程序{ // 私有列表 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());
}
}
}
}
}
【问题讨论】:
-
对不起,我的错误。移除 JS
-
您介意编辑您的问题并更清楚地说明您遇到的问题吗?你想达到什么目的?你是如何尝试做到这一点的?你卡在哪一部分了?
-
我已经实现了服用患者药物和频率的类..但我坚持实施计划功能(通知护士患者每天必须服用的药物频率的通知功能)跨度>
-
所以您正在寻找一种方法来在某个患者需要服药时通知护士?
-
是的,这就是我要找的
标签: java list design-patterns notifications frequency