HumanNameDt nextHumanName = (HumanNameDt) nextObject; allNames.addAll(nextHumanName.getFamily()); allNames.addAll(nextHumanName.getGiven()); for (StringDt nextName : allNames) { addSearchTerm(theEntity, retVal, nextSpName, nextName.getValue());
/** * Adds a given new value for <b>given</b> () * * <p> * <b>Definition:</b> * Given name * </p> * @param theValue The given to add (must not be <code>null</code>) */ public HumanNameDt addGiven(StringDt theValue) { if (theValue == null) { throw new NullPointerException("theValue must not be null"); } getGiven().add(theValue); return this; }
/** * Adds and returns a new value for <b>given</b> () * * <p> * <b>Definition:</b> * Given name * </p> */ public StringDt addGiven() { StringDt newType = new StringDt(); getGiven().add(newType); return newType; }
@Override public String toString(HumanNameDt name) { StringBuilder sb = new StringBuilder(); append(sb, name.getPrefix()); append(sb, name.getFamily()); sb.append(","); append(sb, name.getGiven()); append(sb, name.getSuffix()); return sb.toString(); }
@Override public String serialize(HumanNameDt value) { return getComponent(value.getFamily(), 0) + NAME_DELIM + getComponent(value.getGiven(), 0) + NAME_DELIM + getComponent(value.getGiven(), 1) + NAME_DELIM + getComponent(value.getSuffix(), 0) + NAME_DELIM + getComponent(value.getPrefix(), 0) + NAME_DELIM + getComponent(value.getSuffix(), 1) + NAME_DELIM + value.getUse(); }
@Override public void buildQuery(PractitionerSearchCriteria criteria, IQuery<Bundle> query) { super.buildQuery(criteria, query); if (criteria.getDEA() != null) { query.where(Practitioner.IDENTIFIER.exactly().identifier(criteria.getDEA())); } if (criteria.getSSN() != null) { query.where(Practitioner.IDENTIFIER.exactly().identifier(criteria.getSSN())); } if (criteria.getGender() != null) { query.where(Practitioner.GENDER.exactly().code(criteria.getGender())); } if (criteria.getName() != null) { HumanNameDt name = criteria.getName(); if (!name.getFamily().isEmpty()) { query.where(Practitioner.FAMILY.matches().values(FhirUtil.toStringList(name.getFamily()))); } if (!name.getGiven().isEmpty()) { query.where(Practitioner.GIVEN.matches().values(FhirUtil.toStringList(name.getGiven()))); } } }
@Test public void test() { NameSerializer ns = new NameSerializer(); HumanNameDt name = new HumanNameDt(); name.addFamily("Martin"); name.addGiven("Douglas"); name.addGiven("Kent"); name.addPrefix("Dr."); name.addSuffix("M.D."); name.getUseElement().setValueAsEnum(NameUseEnum.OFFICIAL); String s = ns.serialize(name); System.out.println(s); HumanNameDt name2 = ns.deserialize(s); assertEquals(name.getFamily(), name2.getFamily()); assertEquals(name.getGiven(), name2.getGiven()); assertEquals(name.getPrefix(), name2.getPrefix()); assertEquals(name.getSuffix(), name2.getSuffix()); assertEquals(name.getUse(), name2.getUse()); }