use of org.hl7.fhir.r4.model.Group in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7FinancialInsuranceTest method testForDataBleedFromPatientToOrganization.
@Test
// Ensure that Patient data does not bleed into Organizations created for the Patient's insurance
void testForDataBleedFromPatientToOrganization() throws IOException {
String hl7message = "MSH|^~\\&|TEST|TEST|||20220101120000||ADT^A01^ADT_A01|1234|P|2.6\n" + // PID.12 Used for district calculation
"PID|1|103456|MR12345678^^^^MR||DOE^JANE^|||F|||19 Raymond St^Route3^Albany^NY^56321^USA^P|12||||||||||||||||||||||||||\n" + // PD1.4 Used for org creation to check for bleed of districts
"PD1|||Mayo|123456^Walt^^^^Dr||||||||||||||||||\n" + // IN1 Broadly populated to create organization
"IN1|1|GLOBAL|7776664|Blue Cross Blue Shield|456 Blue Cross Lane||||Blue|987123|IBM||||||NON||||||||||||20210322145350|Dr Disney|S|GOOD|200|12|B6543|H789456|||17|||1|M|123 IBM way|True|NONE|B|NO|J321456|M|20210322145605|London|YES\n" + // IN2 Broadly populated to create organizations
"IN2|A23456|222001111|IBM 1345|EMPLOYEED|E|N23497234|R3294809|S234234|Army|U439823|SGT SCHULTZ|Army|Fort Wayne|USA|E1... E9|ACT|20300402145954|N|N|N|Yes|Grey Duck|Goose|T34941341232|D123123123|C435435345|2|SPR|2ANC|1234.00|O|A0|USA|EN|F|F|Y|N|COG|Stanley|DUTCH|N|M|20170322150208||Software Engineer|8|P|Mr Blue|1-555-333-4444|SURGERY|Jim Stanley|1-555-222-3333|FIRST|20170202150409|20210322150400|3|1-222-333-4444|GLOBAL|GROUP|B14456789|OTH|1-444-777-8888|1-444-555-3333|NONE|N|Y|N|GVH 123456|CDP 98765|2106-3|9\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
// From PID
assertThat(patients).hasSize(1);
Patient patient = (Patient) patients.get(0);
assertThat(patient.getAddressFirstRep().getDistrict()).hasToString("12");
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
// From Payor created by IN1
assertThat(organizations).hasSize(3);
Organization org = (Organization) organizations.get(0);
assertThat(org.getAddressFirstRep().hasDistrict()).isFalse();
org = (Organization) organizations.get(1);
assertThat(org.hasAddress()).isFalse();
org = (Organization) organizations.get(2);
assertThat(org.hasAddress()).isFalse();
List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
// From IN1 segment
assertThat(coverages).hasSize(1);
Coverage coverage = (Coverage) coverages.get(0);
// Confirm Coverage Identifiers
assertThat(coverage.getIdentifier()).hasSize(6);
// Coverage Identifiers deep check in testBasicInsuranceCoverageFields
// Because the relationship is NON, no subscriber is created
assertThat(coverage.hasSubscriber()).isFalse();
// Expect no RelatedPerson because IN1.17 is NON
List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
// No related person should be created because IN1.17 was an unknown code
assertThat(relatedPersons).isEmpty();
// Confirm there are no unaccounted for resources
// Expected: Coverage, Organization (3), Patient, Practitioner
assertThat(e).hasSize(6);
}
use of org.hl7.fhir.r4.model.Group in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ORUMessageTest method test_oru_with_multiple_reports.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void test_oru_with_multiple_reports() throws IOException {
String hl7message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|112^Final Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3068^JOHN^Paul^J|\r" + "OBX|1|ST|TS-F-01-007^Endocrine Disorders 7^L||obs report||||||F\r" + "OBX|2|ST|TS-F-01-008^Endocrine Disorders 8^L||ECHOCARDIOGRAPHIC REPORT||||||F\r" + "OBR|1||98^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|113^Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3065^Mahoney^Paul^J|\r" + "OBX|1|CWE|625-4^Bacteria identified in Stool by Culture^LN^^^^2.33^^result1|1|27268008^Salmonella^SCT^^^^20090731^^Salmonella species|||A^A^HL70078^^^^2.5|||P|||20120301|||^^^^^^^^Bacterial Culture||201203140957||||||\r" + "OBX|2|ST|TS-F-01-002^Endocrine Disorders^L||ECHOCARDIOGRAPHIC REPORT Group 2||||||F\r";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Verify that the right resources are being created
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(obsResource).hasSize(4);
List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practitionerResource).hasSize(2);
List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
assertThat(diagnosticReport).hasSize(2);
List<Resource> servReqResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
assertThat(servReqResource).hasSize(2);
// Expecting only the above resources, no extras!
assertThat(e).hasSize(11);
// /////////////////////////////////////////
// Now confirm content of the FIRST diagnosticReport because we don't have separate tests for DiagnosticReport
// /////////////////////////////////////////
DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
// Verify status from OBR.25
assertThat(diag.getStatus().toCode()).isEqualTo("final");
// Verify category from OBR.24
assertThat(diag.getCategory()).isEmpty();
// Verify code from OBR.4
assertThat(diag.hasCode()).isTrue();
List<Coding> codings = diag.getCode().getCoding();
assertThat(codings).hasSize(1);
Coding coding = codings.get(0);
assertThat(coding.hasDisplay()).isTrue();
assertThat(coding.getDisplay()).hasToString("Final Echocardiogram Report");
assertThat(coding.hasCode()).isTrue();
assertThat(coding.getCode()).hasToString("112");
assertThat(coding.hasSystem()).isFalse();
// Verify encounter reference
assertThat(diag.getEncounter().isEmpty()).isTrue();
// Verify subject reference
assertThat(diag.getSubject().isEmpty()).isFalse();
// Verify effectiveDateTime from OBR.7 and OBR.8
// This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
assertThat(diag.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
// Verify issued from OBR.22
assertThat(diag.getIssued()).isNull();
// Verify resultsInterpreter from OBR.32
assertThat(diag.getResultsInterpreter()).hasSize(1);
// Verify basedOn is ref to the ServiceRequest created for ORC or OBR
assertThat(diag.getBasedOn()).hasSize(1);
assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
// Verify specimen reference
assertThat(diag.getSpecimen()).isEmpty();
// Verify result reference
List<Reference> obsRef = diag.getResult();
assertThat(obsRef).hasSize(2);
assertThat(obsRef.get(0).isEmpty()).isFalse();
// Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not of type TX.
List<Attachment> attachments = diag.getPresentedForm();
Assertions.assertEquals(0, attachments.size(), "Unexpected number of attachments");
// /////////////////////////////////////////
// Now confirm content of the SECOND diagnosticReport because we don't have separate tests for DiagnosticReport
// /////////////////////////////////////////
DiagnosticReport diag2 = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
// Verify status from OBR.25
assertThat(diag2.getStatus().toCode()).isEqualTo("final");
// Verify category from OBR.24
assertThat(diag2.getCategory()).isEmpty();
// Verify code from OBR.4
assertThat(diag2.hasCode()).isTrue();
List<Coding> codings2 = diag2.getCode().getCoding();
assertThat(codings2).hasSize(1);
Coding coding2 = codings.get(0);
assertThat(coding2.hasDisplay()).isTrue();
assertThat(coding2.getDisplay()).hasToString("Final Echocardiogram Report");
assertThat(coding2.hasCode()).isTrue();
assertThat(coding2.getCode()).hasToString("112");
assertThat(coding2.hasSystem()).isFalse();
// Verify encounter reference
assertThat(diag2.getEncounter().isEmpty()).isTrue();
// Verify subject reference
assertThat(diag2.getSubject().isEmpty()).isFalse();
// Verify effectiveDateTime from OBR.7 and OBR.8
// This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
assertThat(diag2.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
// Verify issued from OBR.22
assertThat(diag2.getIssued()).isNull();
// Verify resultsInterpreter from OBR.32
assertThat(diag2.getResultsInterpreter()).hasSize(1);
// Verify basedOn is ref to the ServiceRequest created for ORC or OBR
assertThat(diag.getBasedOn()).hasSize(1);
assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
// Verify specimen reference
assertThat(diag2.getSpecimen()).isEmpty();
// Verify result reference
List<Reference> obsRef2 = diag2.getResult();
assertThat(obsRef2).hasSize(2);
assertThat(obsRef2.get(0).isEmpty()).isFalse();
// Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not type TX.
List<Attachment> attachments2 = diag2.getPresentedForm();
Assertions.assertEquals(0, attachments2.size(), "Unexpected number of attachments");
// //////////////////////////////////
for (Resource res : obsResource) {
// Verify encounter reference is not set
Observation obs = (Observation) res;
assertThat(obs.getEncounter().isEmpty()).isTrue();
// Verify subject reference to Patient exists
Base subject = ResourceUtils.getValue(obs, "subject");
assertThat(ResourceUtils.getValueAsString(subject, "reference").substring(0, 8)).isEqualTo("Patient/");
}
}
use of org.hl7.fhir.r4.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 org.hl7.fhir.r4.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 org.hl7.fhir.r4.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);
}
Aggregations