gpt4 book ai didi

java - 如何在 Java 中将 Map 添加到 Map>

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:38:59 24 4
gpt4 key购买 nike

public Map<String, List<PatientInfo>> getPatients(String sendingApplication,String sendingFacility) {
// TODO Auto-generated method stub
Map<String, List<PatientInfo>> patientMap = null;
List<PatientInfo> patientList = null;
patientMap = new HashMap<String, List<PatientInfo>>();
patientList = new ArrayList<PatientInfo>();
try {
PatientInfoDAO patientInfoDAO = new PatientInfoDAOImpl();
ItemCollection<QueryOutcome> items = patientInfoDAO.getPatients(sendingApplication, sendingFacility);

for(Item item : items){
PatientInfo patient = new PatientInfo();
patient.setAdministrativeSex(item.getString(""));
patient.setFamilyName(item.getString("FAMILYNAME"));
patient.setGivenName(item.getString("GIVENNAME"));
patient.setAdmitDateOrTime(item.getString("GENDER"));
patient.setAssignedPatientLocationBuilding(item.getString("USERNAME"));
patient.setAssignedPatientLocationFloor(item.getString("PASSWORD"));
patient.setAssignedPatientLocationPersonLocationType(item.getString("USERROLE"));
patient.setAssignedPatientLocationRoom(item.getString("USERSTATUS"));
patient.setAsssignedPatientLocationBed(item.getString("EMAIL"));
patient.setAttendingDoctor(item.getString("EMROPERATOR"));
patient.setClientId(item.getString("clientId"));
patient.setDateOrTimeOfMessage(item.getString("dateOrTimeOfMessage"));
patient.setDischargeDateOrTime(item.getString("dischargeDateOrTime"));
patient.setDob(item.getString("dob"));
patient.setEventOccuredTime(item.getString("eventOccuredTime"));
patient.setImageUrl(item.getString("imageUrl"));
patient.setLastModifiedOn(item.getString("lastModifiedOn"));
patient.setMessageControlId(item.getString("messageControlId"));
patient.setNrPatientId(item.getString("nrPatientId"));
patient.setPatientId(item.getString("patientId"));
patient.setPatientStatus(item.getString("patientStatus"));
patient.setPriorPatientLocationBed(item.getString("priorPatientLocationBed"));
patient.setPriorPatientLocationBuilding(item.getString("priorPatientLocationBuilding"));
patient.setPriorPatientLocationFloor(item.getString("priorPatientLocationFloor"));
patient.setPriorPatientLocationPersonLocationType(item.getString("priorPatientLocationPersonLocationType"));
patient.setPriorPatientLocationPointOfCare(item.getString("priorPatientLocationPointOfCare"));
patient.setPriorPatientLocationRoom(item.getString("priorPatientLocationRoom"));
patient.setReceivingFacility(item.getString("receivingFacility"));
patient.setRecevingApplication(item.getString("recevingApplication"));
patient.setSendingApplicaation(item.getString("sendingApplicaation"));
patient.setSendingFacility(item.getString("sendingFacility"));

patientList.add(patient);
}

String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
patientMap.put("PATIENTLIST", patientList);
patientMap.put("LASTKEY", date);


return patientMap;

}catch(AmazonServiceException ase){

throw new RuntimeException("internalServerError");
}catch(AmazonClientException ase){

throw new RuntimeException("internalServerError");
}
}

在这种情况下,我无法将日期字符串添加到 map 中>?

最佳答案

您正在尝试将字符串放置在 map 需要列表的位置。

代替:

patientMap.put("PATIENTLIST", patientList);
patientMap.put("LASTKEY", date);

地点:

patientMap.put(date, patientList);

使用以日期字符串为键、以患者列表为值的 map ,您可以快速获取给定日期的患者列表。


如果您想使用映射以字符串形式保存日期和对象列表,那么您必须将这些字符串转换回它们的原始日期或患者对象列表。

如果这确实是您想要的,我建议您查看java 对象序列化和反序列化

关于java - 如何在 Java 中将 Map<String, string> 添加到 Map<String, List<Object>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47766851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com