use of ca.uhn.hl7v2.model.Group in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7DataExtractor method getAllStructures.
public ParsingResult<Structure> getAllStructures(String group, int groupRep, String segment) {
LOGGER.debug("Fetching segment: {} {} {} ", group, groupRep, segment);
try {
ParsingResult<Structure> parsingResult = null;
Preconditions.checkArgument(StringUtils.isNotBlank(group), "group cannot be null or empty");
Preconditions.checkArgument(StringUtils.isNotBlank(segment), SEGMENT_CANNOT_BE_NULL_OR_EMPTY);
Preconditions.checkArgument(groupRep >= 0, "groupRep should be greater than or equal to 0");
Structure groupStr = message.get(group, groupRep);
if (groupStr instanceof Group) {
Group gp = (Group) groupStr;
Structure[] s = gp.getAll(segment);
List<Structure> list = Lists.newArrayList(s);
list.removeIf(isEmpty());
parsingResult = new Hl7ParsingStructureResult(Lists.newArrayList(list));
} else {
parsingResult = new Hl7ParsingStructureResult(new ArrayList<>());
}
return parsingResult;
} catch (HL7Exception | IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
String spec = group + " " + groupRep + " " + segment;
LOGGER.debug("Cannot extract value for {} ", spec, e);
LOGGER.warn("Cannot extract value for {} ", spec);
return new Hl7ParsingStructureResult(new ArrayList<>());
}
}
use of ca.uhn.hl7v2.model.Group in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7DataExtractor method getAllStructures.
public ParsingResult<Structure> getAllStructures(Structure struct, String segment) {
LOGGER.debug("Fetching segment: {} {} ", struct, segment);
try {
ParsingResult<Structure> parsingResult = null;
Preconditions.checkArgument(struct != null, "struct cannot be null ");
Preconditions.checkArgument(StringUtils.isNotBlank(segment), SEGMENT_CANNOT_BE_NULL_OR_EMPTY);
if (struct instanceof Group) {
Group gp = (Group) struct;
Structure[] s = gp.getAll(segment);
List<Structure> list = Lists.newArrayList(s);
list.removeIf(isEmpty());
parsingResult = new Hl7ParsingStructureResult(list);
} else {
parsingResult = new Hl7ParsingStructureResult(new ArrayList<>());
}
return parsingResult;
} catch (HL7Exception | IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
LOGGER.debug("Cannot extract value for Structure {} Segment {} ", struct, segment, e);
LOGGER.warn("Cannot extract value for Structure {} Segment {} ", struct, segment);
return new Hl7ParsingStructureResult(new ArrayList<>());
}
}
use of ca.uhn.hl7v2.model.Group in project manifoldcf by apache.
the class ConfluenceClient method getUserAuthorities.
/**
* @param username
* @return
* @throws Exception
*/
public ConfluenceUser getUserAuthorities(final String username) throws Exception {
final List<String> authorities = Lists.<String>newArrayList();
final List<Group> groups = getUserGroups(username);
groups.forEach(group -> {
authorities.add("group-" + group.getName());
});
final User user = getConfluenceUser(username);
authorities.add("user-" + user.getUserKey());
final List<Space> spaces = getSpaces();
for (final Space space : spaces) {
final List<String> permissions = getSpacePermissionsForUser(space, username);
if (permissions.contains(VIEW_PERMISSION)) {
authorities.add("space-" + space.getKey());
}
}
return new ConfluenceUser(username, authorities);
}
use of ca.uhn.hl7v2.model.Group in project manifoldcf by apache.
the class ConfluenceClient method getUserGroups.
private List<Group> getUserGroups(final String username) throws Exception {
long lastStart = 0;
final long defaultSize = 50;
final List<Group> groups = new ArrayList<Group>();
if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
final String groupsDesc = "groups of user " + username;
Logging.connectors.debug(new MessageFormat("Starting from {0} and size {1} for {2}", Locale.ROOT).format(new Object[] { lastStart, defaultSize, groupsDesc }));
}
Boolean isLast = true;
do {
final ConfluenceResponse<Group> response = getUserGroups((int) lastStart, (int) defaultSize, username);
int count = 0;
for (final Group group : response.getResults()) {
groups.add(group);
count++;
}
lastStart += count;
isLast = response.isLast();
if (Logging.connectors != null && Logging.connectors.isDebugEnabled()) {
Logging.connectors.debug(new MessageFormat("New start {0} and size {1}", Locale.ROOT).format(new Object[] { lastStart, defaultSize }));
}
} while (!isLast);
return groups;
}
use of ca.uhn.hl7v2.model.Group in project cqf-ruler by DBCG.
the class ParameterUser method getPatientListFromGroup.
// TODO: replace this with version from the evaluator?
default List<Patient> getPatientListFromGroup(String subjectGroupId) {
List<Patient> patientList = new ArrayList<>();
Group group = read(newId(subjectGroupId));
if (group == null) {
throw new IllegalArgumentException("Could not find Group: " + subjectGroupId);
}
group.getMember().forEach(member -> {
Reference reference = member.getEntity();
if (reference.getReferenceElement().getResourceType().equals("Patient")) {
Patient patient = ensurePatient(reference.getReference());
patientList.add(patient);
} else if (reference.getReferenceElement().getResourceType().equals("Group")) {
patientList.addAll(getPatientListFromGroup(reference.getReference()));
} else {
ourLog.info("Group member was not a Patient or a Group, so skipping. \n{}", reference.getReference());
}
});
return patientList;
}
Aggregations