updated patient auditor to get patient name as a string from basehumannamedt

This commit is contained in:
lmds1 2014-12-03 13:21:23 -05:00
parent ed66ffebc9
commit df05f00b80
4 changed files with 46 additions and 7 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="hapi-fhir-structures-dstu/target/generated-sources/tinder"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -20,6 +20,9 @@ package ca.uhn.fhir.model.base.composite;
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -99,6 +102,28 @@ public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
public String getSuffixAsSingleString() {
return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(getSuffix());
}
/**
* Gets the value(s) for <b>text</b> (Text representation of the full name).
* creating it if it does
* not exist. Will not return <code>null</code>.
*
* <p>
* <b>Definition:</b>
* A full text representation of the name
* </p>
*/
public abstract StringDt getText() ;
/**
* Sets the value(s) for <b>text</b> (Text representation of the full name)
*
* <p>
* <b>Definition:</b>
* A full text representation of the name
* </p>
*/
public abstract BaseHumanNameDt setText(StringDt theValue);
@Override
public String toString() {
@ -108,4 +133,14 @@ public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
return b.toString();
}
public String getNameAsSingleString(){
List<StringDt> nameParts = new ArrayList<StringDt>();
nameParts.addAll(getPrefix());
nameParts.addAll(getGiven());
nameParts.addAll(getFamily());
nameParts.addAll(getSuffix());
if(nameParts.size() > 0) return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(nameParts);
else return getText().getValue();
}
}

View File

@ -51,7 +51,7 @@ public class PatientAuditor implements IResourceAuditor<Patient> {
@Override
public String getName() {
if(myPatient != null){
return "Patient: " + myPatient.getNameFirstRep().getText().getValue();
return "Patient: " + myPatient.getNameFirstRep().getNameAsSingleString();
}
return null;
}

View File

@ -158,7 +158,7 @@ public class AuditingInterceptorTest {
if("00001".equals(object.getIdentifier().getValue().getValue())){
assertEquals("Patient: PatientOne Test", object.getName().getValue());
}else if("00002".equals(object.getIdentifier().getValue().getValue())){
assertEquals("Patient: PatientTwo Test", object.getName().getValue());
assertEquals("Patient: Ms Laura Elizabeth MacDougall Sookraj B.Sc.", object.getName().getValue());
}else{
fail("Unexpected patient identifier being audited: " + object.getIdentifier().getValue().getValue());
}
@ -219,10 +219,14 @@ public class AuditingInterceptorTest {
patient.getIdentifier().get(0).setUse(IdentifierUseEnum.OFFICIAL);
patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns"));
patient.getIdentifier().get(0).setValue("00002");
patient.getName().add(new HumanNameDt());
patient.getName().get(0).addFamily("Test");
patient.getName().get(0).addGiven("PatientTwo");
patient.getName().get(0).setText("PatientTwo Test");
HumanNameDt name = new HumanNameDt();
name.addPrefix("Ms");
name.addGiven("Laura");
name.addGiven("Elizabeth");
name.addFamily("MacDougall");
name.addFamily("Sookraj");
name.addSuffix("B.Sc.");
patient.getName().add(name);
patient.getGender().setText("F");
patient.getId().setValue("2");
idToPatient.put("2", patient);
@ -279,7 +283,6 @@ public class AuditingInterceptorTest {
patient.addName();
patient.getName().get(0).addFamily("Test");
patient.getName().get(0).addGiven("PatientOne");
patient.getName().get(0).setText("PatientOne Test");
patient.getGender().setText("M");
patient.getId().setValue("1");
return patient;