public org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.instance.model.HumanName src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); copyElement(src, tgt); tgt.setUse(convertNameUse(src.getUse())); tgt.setText(src.getText()); for (org.hl7.fhir.instance.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; }
public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); copyElement(src, tgt); tgt.setUse(convertNameUse(src.getUse())); if (src.hasText()) tgt.setText(src.getText()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; }
@Override public HumanName deserialize(String value) { String pcs[] = value.split("\\" + NAME_DELIM); HumanName result = new HumanName(); int i = 0; if ((value = getComponent(pcs, i++)) != null) { result.setFamily(value); } if ((value = getComponent(pcs, i++)) != null) { result.addGiven(value); } if ((value = getComponent(pcs, i++)) != null) { result.addGiven(value); } if ((value = getComponent(pcs, i++)) != null) { result.addSuffix(value); } if ((value = getComponent(pcs, i++)) != null) { result.addPrefix(value); } if ((value = getComponent(pcs, i++)) != null) { result.addSuffix(value); } if ((value = getComponent(pcs, i++)) != null) { result.getUseElement().setValueAsString(value.toLowerCase()); } return result; }
public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); copyElement(src, tgt); tgt.setUse(convertNameUse(src.getUse())); if (src.hasText()) tgt.setText(src.getText()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; }
public org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.instance.model.HumanName src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); copyElement(src, tgt); tgt.setUse(convertNameUse(src.getUse())); tgt.setText(src.getText()); for (org.hl7.fhir.instance.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.instance.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; }
@Test public void test() { NameSerializer ns = new NameSerializer(); HumanName name = new HumanName(); name.setFamily("Martin"); name.addGiven("Douglas"); name.addGiven("Kent"); name.addPrefix("Dr."); name.addSuffix("M.D."); name.getUseElement().setValue(NameUse.OFFICIAL); String s = ns.serialize(name); System.out.println(s); HumanName name2 = ns.deserialize(s); assertEquals(name.getFamily(), name2.getFamily()); assertListEquals(name.getGiven(), name2.getGiven()); assertListEquals(name.getPrefix(), name2.getPrefix()); assertListEquals(name.getSuffix(), name2.getSuffix()); assertEquals(name.getUse(), name2.getUse()); }