onaled777
asked on
Conflicting setter definitions for property Exception
I get the following error whenever I attempt to return an object from my controller
The Controller code is as shown below:
The FhirConverter code is as shown below
The Fhir object is created as follows:
Can you see any reason why when the controller method, when accessed via Swagger, throws this error
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"active\": ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params) vs ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params)
Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"active\": ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params) vs ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params)"}}
DEBUG: org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
DEBUG: org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
DEBUG: org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
The Controller code is as shown below:
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/fhir/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(tags = "Fhir Patients Information", httpMethod = "GET", value = "Get Fhir Patient Information", notes = "Get Fhir Patient Information.")
public FhirPatient getFhirPatientInfo(@PathVariable("id") long id) throws Exception {
Patient patient = patientDAO.findPatientById(123708L);
FhirPatient fhirPatient = FhirConverter.transformPatientToFhirPatient(patient);
return fhirPatient;
}
The FhirConverter code is as shown below
public static FhirPatient getFhirPatientFromPatient(Patient patient){
FhirPatient fhirPatient = new FhirPatient();
// Add an MRN (a patient identifier)
IdentifierDt id = fhirPatient.addIdentifier();
id.setValue(patient.getPatientId().toString());
id.setUse(IdentifierUseEnum.OFFICIAL);
// Add a name
HumanNameDt name = fhirPatient.addName();
name.setUse(NameUseEnum.OFFICIAL);
name.addFamily(patient.getLastName());
name.addGiven(patient.getFirstName()).addGiven(patient.getMiddleName());
}
The Fhir object is created as follows:
package com.entity.fhir;
import java.util.Date;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.primitive.BooleanDt;
public class FhirPatient extends Patient implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer pcpId;
private Date dateOfBirth;
private Integer maritialStatus;
private Integer officeId;
private Integer practiceId;
public Integer getPcpId() {
return this.pcpId;
}
public void setPcpId(Integer pcpId) {
this.pcpId = pcpId;
}
public Date getDateOfBirth() {
return this.dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public Integer getMaritialStatus() {
return this.maritialStatus;
}
public void setMaritialStatus(Integer maritialStatus) {
this.maritialStatus = maritialStatus;
}
public Integer getOfficeId() {
return officeId;
}
public void setOfficeId(Integer officeId) {
this.officeId = officeId;
}
public Integer getPracticeId() {
return practiceId;
}
public void setPracticeId(Integer practiceId) {
this.practiceId = practiceId;
}
}
Can you see any reason why when the controller method, when accessed via Swagger, throws this error
Please also post the patient class.
ASKER
The Patient Class can be found here:
http://hapifhir.io/apidocs-dstu2/ca/uhn/fhir/model/dstu2/resource/Patient.html
I have tried putting @JsonIgnore around some of the inherited methods, but that only leads to another field with a similar error. I am not sure if that is the right approach.
http://hapifhir.io/apidocs-dstu2/ca/uhn/fhir/model/dstu2/resource/Patient.html
I have tried putting @JsonIgnore around some of the inherited methods, but that only leads to another field with a similar error. I am not sure if that is the right approach.
can you supply the source?
ASKER
@JsonIgnore
public Boolean getActive(){
return this.active;
}
@JsonIgnore
public void setActive(Boolean active){
this.active = active;
}
@JsonIgnore
public String getGender(){
return this.gender;
}
@JsonIgnore
public Patient setGender(String gender){
return null;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.