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

The following examples show how to use org.hl7.fhir.dstu3.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: IEEE11073Convertor.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException {
  ConceptMap cm = new ConceptMap();
  cm.setId("loinc-mdc");
  cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc");
  cm.setVersion("[todo]");
  cm.setName("LoincMdcCrossMap");
  cm.setTitle("Cross Map between LOINC and MDC");
  cm.setStatus(PublicationStatus.DRAFT);
  cm.setExperimental(true);
  cm.setDateElement(new DateTimeType());
  cm.setPublisher("HL7, Inc");
  ContactDetail cd = cm.addContact();
  cd.setName("LOINC + IEEE");
  ContactPoint cp = cd.addTelecom();
  cp.setSystem(ContactPointSystem.URL);
  cp.setValue("http://loinc.org");
  cm.setDescription("A Cross Map between the LOINC and MDC Code systems");
  cm.setPurpose("To implementers map between medical device codes and LOINC codes");
  cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use");
  cm.setSource(new UriType("http://loinc.org/vs"));
  cm.setTarget(new UriType(MDC_ALL_VALUES));
  ConceptMapGroupComponent g = cm.addGroup();
  g.setSource("urn:iso:std:iso:11073:10101");
  g.setTarget("http://loinc.org");

  CSVReader csv = new CSVReader(new FileInputStream(src));
  csv.readHeaders();
  while (csv.line()) {
    SourceElementComponent e = g.addElement();
    e.setCode(csv.cell("IEEE_CF_CODE10"));
    e.setDisplay(csv.cell("IEEE_DESCRIPTION"));
    TargetElementComponent t = e.addTarget();
    t.setEquivalence(ConceptMapEquivalence.EQUIVALENT);
    t.setCode(csv.cell("LOINC_NUM"));
    t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
  }
  new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-"+cm.getId()+".xml")), cm);
  System.out.println("Done");
  return cm;
}
 
Example #2
Source File: Example02_EnumeratedTypes.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] theArgs) {

      Patient pat = new Patient();

      pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");

      // Enumerated types are provided for many coded elements
      ContactPoint contact = pat.addTelecom();
      contact.setUse(ContactPoint.ContactPointUse.HOME);
      contact.setSystem(ContactPoint.ContactPointSystem.PHONE);
      contact.setValue("1 (416) 340-4800");

      pat.setGender(Enumerations.AdministrativeGender.MALE);
   }
 
Example #3
Source File: OrganizationResourceProvider.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * The "@Read" annotation indicates that this method supports the read operation. It takes one argument, the Resource type being returned.
 * 
 * @param theId
 *            The read operation takes one parameter, which must be of type IdDt and must be annotated with the "@Read.IdParam" annotation.
 * @return Returns a resource matching this identifier, or null if none exists.
 */
@Read()
public MyOrganization getResourceById(@IdParam IdType theId) {
	
	/*
	 * We only support one organization, so the follwing
	 * exception causes an HTTP 404 response if the 
	 * ID of "1" isn't used.
	 */
	if (!"1".equals(theId.getValue())) {
		throw new ResourceNotFoundException(theId);
	}
	
	MyOrganization retVal = new MyOrganization();
	retVal.setId("1");
	retVal.addIdentifier().setSystem("urn:example:orgs").setValue("FooOrganization");
	retVal.addAddress().addLine("123 Fake Street").setCity("Toronto");
	retVal.addTelecom().setUse(ContactPointUse.WORK).setValue("1-888-123-4567");
	
	// Populate the first, primitive extension
	retVal.setBillingCode(new CodeType("00102-1"));
	
	// The second extension is repeatable and takes a block type
	MyOrganization.EmergencyContact contact = new MyOrganization.EmergencyContact();
	contact.setActive(new BooleanType(true));
	contact.setContact(new ContactPoint());
	retVal.getEmergencyContact().add(contact);
	
	return retVal;
}
 
Example #4
Source File: Example02_EnumeratedTypes.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] theArgs) {

      Patient pat = new Patient();

      pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");

      // Enumerated types are provided for many coded elements
      ContactPoint contact = pat.addTelecom();
      contact.setUse(ContactPoint.ContactPointUse.HOME);
      contact.setSystem(ContactPoint.ContactPointSystem.PHONE);
      contact.setValue("1 (416) 340-4800");

      pat.setGender(Enumerations.AdministrativeGender.MALE);
   }
 
Example #5
Source File: LocationEntityToFHIRLocationTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Test
public void testTransformLocationEntity(){

    LocationEntity locationEntity = new LocationEntityBuilder()
            .setName("Example Location")
            .addAddress("20 High Street", "Holmfirth", null,
                    "Halifax", "West Yorkshire", "HX1 2TT")
            .addHomePhone("0113240998")
            .build();

    Location location = transformer.transform(locationEntity);

    // Check that the Name has been populated
    assertThat(location, not(nullValue()));
    assertThat(location.getName(), equalTo("Example Location"));

    // Check that the Address has been populated
    Address address = location.getAddress();
    assertThat(address, not(nullValue()));
    assertThat(address.getLine().get(0).getValue(), equalTo("20 High Street"));
    assertThat(address.getLine().get(1).getValue(), equalTo("Holmfirth"));
    assertThat(address.getLine().size(),equalTo(2));
   // assertThat(address.getLine().get(3), nullValue());
    assertThat(address.getDistrict(), equalTo("West Yorkshire"));
    assertThat(address.getCity(), equalTo("Halifax"));
    assertThat(address.getPostalCode(), equalTo("HX1 2TT"));

    // Check that the Telephone Number has been populated
    assertThat(location.getTelecom(), not(nullValue()));
    assertThat(location.getTelecom().size(), equalTo(1));
    ContactPoint phoneNumber = location.getTelecom().get(0);
    assertThat(phoneNumber.getValue(), equalTo("0113240998"));
    assertThat(phoneNumber.getUse().getDisplay(), equalTo("Home"));
}
 
Example #6
Source File: LocationEntityBuilder.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
public LocationEntityBuilder addHomePhone(String phoneNumber) {
    LocationTelecom telecom = new LocationTelecom();
    telecom.setTelecomUse(ContactPoint.ContactPointUse.HOME);
    telecom.setValue(phoneNumber);
    telecoms.add(telecom);
    return this;
}
 
Example #7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addTelecom(XhtmlNode p, ContactPoint c) {
  if (c.getSystem() == ContactPointSystem.PHONE) {
    p.tx("Phone: "+c.getValue());
  } else if (c.getSystem() == ContactPointSystem.FAX) {
    p.tx("Fax: "+c.getValue());
  } else if (c.getSystem() == ContactPointSystem.EMAIL) {
    p.ah( "mailto:"+c.getValue()).addText(c.getValue());
  } else if (c.getSystem() == ContactPointSystem.URL) {
    if (c.getValue().length() > 30)
      p.ah(c.getValue()).addText(c.getValue().substring(0, 30)+"...");
    else
      p.ah(c.getValue()).addText(c.getValue());
  }
}
 
Example #8
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static String displayContactPoint(ContactPoint contact) {
  StringBuilder s = new StringBuilder();
  s.append(describeSystem(contact.getSystem()));
  if (Utilities.noString(contact.getValue()))
    s.append("-unknown-");
  else
    s.append(contact.getValue());
  if (contact.hasUse())
    s.append("("+contact.getUse().toString()+")");
  return s.toString();
}
 
Example #9
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 #10
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected void addToContactList(List<ContactPoint> list, ContactPoint c) throws Exception {
	for (ContactPoint item : list) {
		if (Comparison.matches(item, c, null))
			Comparison.merge(item, c);
	}
	list.add(c);
}
 
Example #11
Source File: Convert.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public ContactPoint makeContactFromTEL(Element e) throws Exception {
if (e == null)
	return null;
if (e.hasAttribute("nullFlavor"))
	return null;
 ContactPoint c = new ContactPoint();
	String use = e.getAttribute("use");
 if (use != null) {
 	if (use.equals("H") || use.equals("HP") || use.equals("HV"))
 		c.setUse(ContactPointUse.HOME);
 	else if (use.equals("WP") || use.equals("DIR") || use.equals("PUB"))
 		c.setUse(ContactPointUse.WORK);
 	else if (use.equals("TMP"))
 		c.setUse(ContactPointUse.TEMP);
 	else if (use.equals("BAD"))
 		c.setUse(ContactPointUse.OLD);
 }
 if (e.getAttribute("value") != null) {
 	String[] url = e.getAttribute("value").split(":");
 	if (url.length == 1) {
 		c.setValue(url[0].trim());
 		c.setSystem(ContactPointSystem.PHONE);
 	} else {
 		if (url[0].equals("tel"))
 			c.setSystem(ContactPointSystem.PHONE);
 		else if (url[0].equals("mailto"))
 			c.setSystem(ContactPointSystem.EMAIL);
 		else if (e.getAttribute("value").contains(":"))
 			c.setSystem(ContactPointSystem.OTHER);
 		else 
 			c.setSystem(ContactPointSystem.PHONE);
 		c.setValue(url[1].trim());
 	}
 }
 return c;
 
}
 
Example #12
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void renderContactPoint(ContactPoint contact, XhtmlNode x) {
  x.addText(displayContactPoint(contact));
}
 
Example #13
Source File: BaseContactPoint.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public ContactPoint.ContactPointSystem getSystem() {
    return this.system;
}
 
Example #14
Source File: BaseContactPoint.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setSystem(ContactPoint.ContactPointSystem systemEntity) {
    this.system = systemEntity;
}
 
Example #15
Source File: ResourceUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private static DataElement showDECHeader(StringBuilder b, Bundle bundle) {
  DataElement meta = new DataElement();
  DataElement prototype = (DataElement) bundle.getEntry().get(0).getResource();
  meta.setPublisher(prototype.getPublisher());
  meta.getContact().addAll(prototype.getContact());
  meta.setStatus(prototype.getStatus());
  meta.setDate(prototype.getDate());
  meta.addElement().getType().addAll(prototype.getElement().get(0).getType());

  for (BundleEntryComponent e : bundle.getEntry()) {
    DataElement de = (DataElement) e.getResource();
    if (!Base.compareDeep(de.getPublisherElement(), meta.getPublisherElement(), false))
      meta.setPublisherElement(null);
    if (!Base.compareDeep(de.getContact(), meta.getContact(), false))
      meta.getContact().clear();
    if (!Base.compareDeep(de.getStatusElement(), meta.getStatusElement(), false))
      meta.setStatusElement(null);
    if (!Base.compareDeep(de.getDateElement(), meta.getDateElement(), false))
      meta.setDateElement(null);
    if (!Base.compareDeep(de.getElement().get(0).getType(), meta.getElement().get(0).getType(), false))
      meta.getElement().get(0).getType().clear();
  }
  if (meta.hasPublisher() || meta.hasContact() || meta.hasStatus() || meta.hasDate() /* || meta.hasType() */) {
    b.append("<table class=\"grid\">\r\n"); 
    if (meta.hasPublisher())
      b.append("<tr><td>Publisher:</td><td>"+meta.getPublisher()+"</td></tr>\r\n");
    if (meta.hasContact()) {
      b.append("<tr><td>Contacts:</td><td>");
      boolean firsti = true;
      for (ContactDetail c : meta.getContact()) {
        if (firsti)
          firsti = false;
        else
          b.append("<br/>");
        if (c.hasName())
          b.append(Utilities.escapeXml(c.getName())+": ");
        boolean first = true;
        for (ContactPoint cp : c.getTelecom()) {
          if (first)
            first = false;
          else
            b.append(", ");
          renderContactPoint(b, cp);
        }
      }
      b.append("</td></tr>\r\n");
    }
    if (meta.hasStatus())
      b.append("<tr><td>Status:</td><td>"+meta.getStatus().toString()+"</td></tr>\r\n");
    if (meta.hasDate())
      b.append("<tr><td>Date:</td><td>"+meta.getDateElement().asStringValue()+"</td></tr>\r\n");
    if (meta.getElement().get(0).hasType())
      b.append("<tr><td>Type:</td><td>"+renderType(meta.getElement().get(0).getType())+"</td></tr>\r\n");
    b.append("</table>\r\n"); 
  }  
  return meta;
}
 
Example #16
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 DefinitionException {
  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(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 #17
Source File: MyOrganization.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setContact(ContactPoint theContact) {
   myContact = theContact;
}
 
Example #18
Source File: BaseContactPoint.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
public void setTelecomUse(ContactPoint.ContactPointUse use) { this.telecomUse = use; } 
Example #19
Source File: BaseContactPoint.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
public ContactPoint.ContactPointUse getTelecomUse() { 	return this.telecomUse; }