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.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
/**
* The UnbundleIdentifier class marshals the patient identifier to a client readable JSON format.
*
* @author Ian Meinert
*/
public class UnbundleIdentifier {
private List<IdentifierDt> identifiers;
/**
* The overloaded constructor accepting a list of {@link IdentifierDt}.
*
* @param identifiers list of {@link IdentifierDt}
*/
public UnbundleIdentifier(List<IdentifierDt> identifiers) {
this.identifiers = identifiers;
}
/**
* This method retrieves the identifiers, looking for a pattern which matches.
*
* @param text the record type
* @return string
*/
public String getIdentifier(String text) {
String value = new String();
for (IdentifierDt id : identifiers) {
if (!id.isEmpty() && id.getUse().equalsIgnoreCase("official")) {
CodeableConceptDt type = (CodeableConceptDt) id.getType();
if (type.getText().equalsIgnoreCase(text)) {
if ("USVHA".equalsIgnoreCase(id.getSystem())) {
Pattern pattern = Pattern.compile("^(\\d{3}-?\\d{2}-?\\d{4})$");
Matcher matcher = pattern.matcher(id.getValue());
if (matcher.find()) {
value = id.getValue();
break;
}
}
value = id.getValue();
break;
}
}
}
return value;
}
}