Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.med.pbm.ampl.fhir.unmarshall.dstu2.unbundle;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import ca.uhn.fhir.model.dstu2.composite.ContactPointDt;
import gov.va.med.pbm.ampl.model.Contact;
/**
* The UnbundleSignature class marshals a {@link Contact} resource to a client readable JSON format.
*
* @author Ian Meinert
*/
public class UnbundleContact {
private List<ca.uhn.fhir.model.dstu2.resource.Patient.Contact> contacts;
/**
* Default constructor.
*/
public UnbundleContact() {
// TODO Auto-generated constructor stub
}
/**
* Default constructor accepting a List of Contact.
*
* @param contacts List of Contact
*/
public UnbundleContact(List<ca.uhn.fhir.model.dstu2.resource.Patient.Contact> contacts) {
this.contacts = contacts;
}
/**
* Gets the contacts.
*
* @return {@link Contact}
*/
public Contact[] getContacts() {
List<Contact> contactList = new ArrayList<>();
for (ca.uhn.fhir.model.dstu2.resource.Patient.Contact contact : contacts) {
contactList.add(this.getContact(contact.getTelecom()));
}
return contactList.toArray(new Contact[contactList.size()]);
}
/**
* Gets the first first {@link Contact}.
*
* @return {@link Contact}
*/
public Contact getFirstContact() {
Contact[] contactArray = getContacts();
Contact contact = contactArray.length > 0 ? contactArray[0] : new Contact();
return contact;
}
/**
* Gets the contact based on values given by a list of {@link ContactPointDt}.
*
* @param contactPoints list of {@link ContactPointDt}
* @return {@link Contact}
*/
public Contact getContact(List<ContactPointDt> contactPoints) {
Contact c = new Contact();
for (ContactPointDt point : contactPoints) {
String value = point.getValue();
switch (point.getSystem().toLowerCase(Locale.ENGLISH)) {
case "phone":
switch (point.getUse().toLowerCase(Locale.ENGLISH)) {
case "home":
c.setHome(value);
break;
case "work":
c.setConfidential(value);
break;
case "temp":
c.setTemporary(value);
break;
case "mobile":
c.setMobile(value);
break;
default:
c.setPhone(value);
}
break;
case "fax":
c.setFax(value);
break;
case "email":
c.setEmail(value);
break;
case "pager":
c.setPager(value);
break;
default:
c.setOther(value);
}
}
return c;
}
}