/** * The contents of this file are subject to the OpenMRS Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://license.openmrs.org * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) OpenMRS, LLC. All Rights Reserved. */ package org.openmrs.web.dwr; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.Patient; import org.openmrs.PatientIdentifier; public class PatientListItem extends PersonListItem { protected final Log log = LogFactory.getLog(getClass()); private Integer patientId; private String identifier = ""; private Boolean identifierCheckDigit = false; private String identifierTypeName = ""; private String otherIdentifiers = ""; public PatientListItem() { } public PatientListItem(Patient patient) { super(patient); if (patient != null) { patientId = patient.getPatientId(); // get patient's identifiers boolean first = true; for (PatientIdentifier pi : patient.getIdentifiers()) { if (first) { identifier = pi.getIdentifier(); identifierCheckDigit = pi.getIdentifierType().hasCheckDigit(); first = false; } else { if (!"".equals(otherIdentifiers)) otherIdentifiers += ","; otherIdentifiers += " " + pi.getIdentifier(); } } } } public boolean equals(Object obj) { if (obj instanceof PatientListItem) { PatientListItem pi = (PatientListItem) obj; if (pi.getPatientId() == null || patientId == null) return false; return pi.getPatientId().equals(patientId); } return false; } public int hashCode() { if (patientId == null) return super.hashCode(); return patientId.hashCode(); } public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } public String getOtherIdentifiers() { return otherIdentifiers; } public void setOtherIdentifiers(String otherIdentifiers) { this.otherIdentifiers = otherIdentifiers; } public Integer getPatientId() { return patientId; } public void setPatientId(Integer patientId) { this.patientId = patientId; } /** * @return Returns the identifierIdentifierCheckdigit. */ public Boolean getIdentifierCheckDigit() { return identifierCheckDigit; } /** * @param identifierIdentifierCheckdigit The identifierIdentifierCheckdigit to set. */ public void setIdentifierCheckDigit(Boolean identifierCheckDigit) { this.identifierCheckDigit = identifierCheckDigit; } /** * @param identifierTypeName the identifierTypeName to set */ public void setIdentifierTypeName(String identifierTypeName) { this.identifierTypeName = identifierTypeName; } /** * @return the identifierTypeName */ public String getIdentifierTypeName() { return identifierTypeName; } }