org.hl7.fhir.r4.model.ContactPoint Java Examples

The following examples show how to use org.hl7.fhir.r4.model.ContactPoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IPatientPatientAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: ResourceUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
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());
  }
}
 
Example #3
Source File: NPMPackageGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private String url(List<ContactPoint> telecom) {
  for (ContactPoint cp : telecom) {
    if (cp.getSystem() == ContactPointSystem.URL)
      return cp.getValue();
  }
  return null;
}
 
Example #4
Source File: NPMPackageGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private String email(List<ContactPoint> telecom) {
  for (ContactPoint cp : telecom) {
    if (cp.getSystem() == ContactPointSystem.EMAIL)
      return cp.getValue();
  }
  return null;
}
 
Example #5
Source File: IPatientPatientAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
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());
		}
	}
}
 
Example #6
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #7
Source File: IPatientPatientAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
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);
}