我想对从fhir数据库中获得的列表进行排序。它基本上是一个要求它的数组列表,我在Java源代码中看不到数据本身
试图用html对其进行排序,但没有起作用。 我还尝试了Collections类的sort()方法。 然后,使用reverse()方法反转数组列表。
ArrayList<sample.jersey.db.Patient> list = new ArrayList<sample.jersey.db.Patient>();
for (Entry e : response.getEntry()) {
Patient p = (Patient) e.getResource();
sample.jersey.db.Patient pat = new sample.jersey.db.Patient();
pat.setId(p.getId().getIdPartAsLong());
pat.setName(p.getNameFirstRep().getNameAsSingleString());
try {
pat.setBirthdate(p.getBirthDate().toString());
}
catch (NullPointerException ex){
pat.setBirthdate("missing");
}
list.add(pat);
patientRepository.save(pat);
logger.info(p.toString() + ": " + e.getFullUrl());
logger.info("Name: " + p.getNameFirstRep().getNameAsSingleString());
//logger.info("Birthdate: " + p.getBirthDate().toString());
}
model.addAttribute("p_repo", serverBase);
model.addAttribute("p_info", infoBase);
model.addAttribute("p_number", response.getEntry().size());
model.addAttribute("patientList", list);
if (response.getTotal() == null)
model.addAttribute("p_total", "Not Available");
else
model.addAttribute("p_total", response.getTotal());
FhirContext ctx = FhirContext.forDstu2();
String serverBase = "http://hapi.fhir.org/baseDstu2";
String infoBase = "https://fhirtest.uhn.ca/resource?serverId=hapi_dev&pretty=true&resource=Patient";
serverId=hapi_dev&pretty=true&resource=Patient
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
ca.uhn.fhir.model.dstu2.resource.Bundle response = client.search().forResource(Patient.class)
// .where(Patient.BIRTHDATE.beforeOrEquals().day("2017-01-01"))
// .and(Patient.CAREPROVIDER.hasChainedProperty(Organization.NAME.matches().value("Health")))
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();
public class Patient {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private Date date;
private String birthdate;
public Patient() {
}
public Patient(String name) {
this.name = name;
this.date = new Date();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Override
public String toString() {
return "Patient{" +
"id=" + id +
", name='" + name + '\'' +
", date=" + date +
'}';
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
}
到目前为止,当我再次检查该网站时,基本上没有任何改变