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>中?

最佳答案

这是您可以在上面完成的一些小更改(一定要更改返回类型):

public Map<String, PatientMapObject> getPatients(String sendingApplication,String sendingFacility) {
    // TODO Auto-generated method stub
    Map<String, PatientMapObject> patientMap = null;
    List<PatientInfo> patientList = null;
    patientMap = new HashMap<String, PatientMapObject>();
    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("Male");

            patientList.add(patient);
        }

        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());

        PatientMapObject pmo = new PatientMapObject();
        pmo.setPatientList(patientList);
        pmo.setPDate(date);

        patientMap.put("PATIENTLIST", pmo);
        return patientMap;
    }catch(Exception ase){

        throw new RuntimeException("internalServerError");
    }
}

class PatientMapObject{


    private List<PatientInfo> patientList;
    private String pdate;

    public void setPDate(String pdate) {
        this.pdate = pdate;
    }

    public void setPatientList(List<PatientInfo> patientList) {
        this.patientList = patientList;
    }

    //getters
}

10-04 12:34