Java源码示例:org.hl7.fhir.r4.model.ContactPoint
示例1
private void mapRelatedContacts(IPatient source, Patient target) {
List<ContactComponent> contacts = new ArrayList<>();
IPerson legalGuardian = source.getLegalGuardian();
if (legalGuardian != null) {
ContactComponent _legalGuardian = new ContactComponent();
CodeableConcept addCoding = new CodeableConcept().addCoding(new Coding().setCode("N"));
_legalGuardian.setRelationship(Collections.singletonList(addCoding));
_legalGuardian.setId(legalGuardian.getId());
List<HumanName> humanNames = contactHelper.getHumanNames(legalGuardian);
_legalGuardian.setName((!humanNames.isEmpty()) ? humanNames.get(0) : null);
List<Address> addresses = contactHelper.getAddresses(legalGuardian);
_legalGuardian.setAddress((!addresses.isEmpty()) ? addresses.get(0) : null);
AdministrativeGender gender = contactHelper.getGender(legalGuardian.getGender());
_legalGuardian.setGender(gender);
List<ContactPoint> contactPoints = contactHelper.getContactPoints(legalGuardian);
_legalGuardian.setTelecom(contactPoints);
contacts.add(_legalGuardian);
}
target.setContact(contacts);
}
示例2
public static void renderContactPoint(StringBuilder b, ContactPoint cp) {
if (cp != null && !cp.isEmpty()) {
if (cp.getSystem() == ContactPointSystem.EMAIL)
b.append("<a href=\"mailto:"+cp.getValue()+"\">"+cp.getValue()+"</a>");
else if (cp.getSystem() == ContactPointSystem.FAX)
b.append("Fax: "+cp.getValue());
else if (cp.getSystem() == ContactPointSystem.OTHER)
b.append("<a href=\""+cp.getValue()+"\">"+cp.getValue()+"</a>");
else
b.append(cp.getValue());
}
}
示例3
private String url(List<ContactPoint> telecom) {
for (ContactPoint cp : telecom) {
if (cp.getSystem() == ContactPointSystem.URL)
return cp.getValue();
}
return null;
}
示例4
private String email(List<ContactPoint> telecom) {
for (ContactPoint cp : telecom) {
if (cp.getSystem() == ContactPointSystem.EMAIL)
return cp.getValue();
}
return null;
}
示例5
private void mapAddressTelecom(Patient source, IPatient target) {
List<Address> addresses = source.getAddress();
for (Address address : addresses) {
if (AddressUse.HOME.equals(address.getUse())) {
target.setCity(address.getCity());
target.setZip(address.getPostalCode());
if (!address.getLine().isEmpty()) {
target.setStreet(address.getLine().get(0).asStringValue());
}
Country country = null;
try {
country = Country.valueOf(address.getCountry());
} catch (IllegalArgumentException | NullPointerException e) {
// ignore
}
target.setCountry(country);
}
}
List<ContactPoint> telecoms = source.getTelecom();
for (ContactPoint contactPoint : telecoms) {
if (ContactPointSystem.PHONE.equals(contactPoint.getSystem())) {
if (ContactPointUse.MOBILE.equals(contactPoint.getUse())) {
target.setMobile(contactPoint.getValue());
} else if (1 == contactPoint.getRank()) {
target.setPhone1(contactPoint.getValue());
} else if (2 == contactPoint.getRank()) {
target.setPhone2(contactPoint.getValue());
}
} else if (ContactPointSystem.EMAIL.equals(contactPoint.getSystem())) {
target.setEmail(contactPoint.getValue());
} else if (ContactPointSystem.FAX.equals(contactPoint.getSystem())) {
target.setFax(contactPoint.getValue());
}
}
}
示例6
private PropertyWithType createProfile(StructureMap map, List<StructureDefinition> profiles, PropertyWithType prop, String sliceName, Base ctxt) throws FHIRException {
if (prop.getBaseProperty().getDefinition().getPath().contains("."))
throw new DefinitionException("Unable to process entry point");
String type = prop.getBaseProperty().getDefinition().getPath();
String suffix = "";
if (ids.containsKey(type)) {
int id = ids.get(type);
id++;
ids.put(type, id);
suffix = "-"+Integer.toString(id);
} else
ids.put(type, 0);
StructureDefinition profile = new StructureDefinition();
profiles.add(profile);
profile.setDerivation(TypeDerivationRule.CONSTRAINT);
profile.setType(type);
profile.setBaseDefinition(prop.getBaseProperty().getStructure().getUrl());
profile.setName("Profile for "+profile.getType()+" for "+sliceName);
profile.setUrl(map.getUrl().replace("StructureMap", "StructureDefinition")+"-"+profile.getType()+suffix);
ctxt.setUserData("profile", profile.getUrl()); // then we can easily assign this profile url for validation later when we actually transform
profile.setId(map.getId()+"-"+profile.getType()+suffix);
profile.setStatus(map.getStatus());
profile.setExperimental(map.getExperimental());
profile.setDescription("Generated automatically from the mapping by the Java Reference Implementation");
for (ContactDetail c : map.getContact()) {
ContactDetail p = profile.addContact();
p.setName(c.getName());
for (ContactPoint cc : c.getTelecom())
p.addTelecom(cc);
}
profile.setDate(map.getDate());
profile.setCopyright(map.getCopyright());
profile.setFhirVersion(FHIRVersion.fromCode(Constants.VERSION));
profile.setKind(prop.getBaseProperty().getStructure().getKind());
profile.setAbstract(false);
ElementDefinition ed = profile.getDifferential().addElement();
ed.setPath(profile.getType());
prop.profileProperty = new Property(worker, ed, profile);
return prop;
}
示例7
private void mapAddressTelecom(IPatient source, Patient target) {
List<Address> addresses = contactHelper.getAddresses(source);
target.setAddress(addresses);
List<ContactPoint> contactPoints = contactHelper.getContactPoints(source);
target.setTelecom(contactPoints);
}