Skip navigation links

Package oracle.hsgbu.hdr.hl7.query

Contains the query component classes used to build a RIM-based query in CTB.

See: Description

Package oracle.hsgbu.hdr.hl7.query Description

Contains the query component classes used to build a RIM-based query in CTB.

Classes in this package are divided into two types:

The user can use the QueryComponentFactory to create Fetch objects.  The fetch creation methods can either be used with no arguments or with appropriate criteria to create a fetch with a pre-assigned criteria object.  The user may also specify version and merge characteristics for applicable RIM objects. 

The user can use the QueryComponentFactory to create or join Criteria objects.  The user can join criteria objects to make more specific (AND) or more general (OR) query criteria.

Special Notes

The following are code examples to show basic and more complex query creation:

(1a) Find all current, active encounters

    // Retrieve the services and factories needed for this example.
    RimService rimService = serviceLocator.getRimService();
    ActFactory actFactory = ActFactory.getInstance();
    QueryComponentFactory queryComponentFactory = QueryComponentFactory.getInstance();

    // Construct an ActAttributeCriteria, setting the ClassCode == ENC, 
    // StatusCode == ACTIVE and setting the current version flag to true 
    ActAttributeCriteria actAttrCriteria = queryComponentFactory.newActAttributeCriteria();
    actAttrCriteria.setClassCode(SearchOperator.EQUALS, ActClass.ENC);
    actAttrCriteria.setStatusCode(SearchOperator.EQUALS, ActStatus.ACTIVE);
    actAttrCriteria.setCurrentVersion(true);
    
    // Construct an ActFetch with the specified criteria
    ActFetch actFetch = queryComponentFactory.newActFetch(actAttrCriteria);

    // Create a query act with the top level fetch, attach it to a 
    // Control Act and submit the ControlAct to the RimService. 
    QueryAct queryAct = actFactory.newQueryAct(actFetch);
    ControlAct queryControlAct = actFactory.newControlActEvent(null, null);
    queryControlAct.addOBActRelationship(ActRelationshipType.SUBJ, queryAct);
    ControlAct queryResult = rimService.submit(queryControlAct);

 

(1b) Find all current, active encounters in which the current logged-in user (Id=1234) is the attending practitioner - also retrieve the instance identifiers, the subject of the encounter(s), including his/her name, and the scoping entities of these encounters

    // Retrieve the services and factories needed for this example.
    RimService rimService = serviceLocator.getRimService();
    ActFactory actFactory = ActFactory.getInstance();
    QueryComponentFactory queryComponentFactory = QueryComponentFactory.getInstance();
    DataTypeFactory dataTypeFactory = DataTypeFactory.getInstance();

    
    // Construct an ActAttributeCriteria, setting the ClassCode == ENC,
    // StatusCode == ACTIVE and setting the current version flag to true
    ActAttributeCriteria actAttrCriteria = queryComponentFactory.newActAttributeCriteria();
    actAttrCriteria.setClassCode(SearchOperator.EQUALS, ActClass.ENC);
    actAttrCriteria.setStatusCode(SearchOperator.EQUALS, ActStatus.ACTIVE);
    actAttrCriteria.setCurrentVersion(true);
    
    
    // Create the attending practitioner criteria and attach it to the ActCriteria
    ParticipationAttributeCriteria participationCriteria = queryComponentFactory.newParticipationAttributeCriteria();
    participationCriteria.setTypeCode(SearchOperator.EQUALS, ParticipationType.ATND);
    actAttrCriteria.setParticipationCriteria(participationCriteria, QueryComponentFactory.VERSION_DEPENDENT);

    
    // Create the role criteria, set the ID attribute and attach it to the ParticipationCriteria
    RoleAttributeCriteria roleCriteria = queryComponentFactory.newRoleAttributeCriteria();
    UID uidVal = dataTypeFactory.newUID("1234");
    II roleId = dataTypeFactory.newII(uidVal, null, null, null);
    roleCriteria.setId(SetSearchOperator.ANY, new II[] { roleId });
    participationCriteria.setRoleCriteria(roleCriteria, QueryComponentFactory.VERSION_DEPENDENT);


    // Construct an ActFetch with the specified criteria and make IDs for retrieval.
    ActFetch actFetch = queryComponentFactory.newActFetch(actAttrCriteria);
    actFetch.retrieveId(true);

    // Create the participation fetch and attached criteria and attach to the Act Fetch.
    ParticipationAttributeCriteria subjParticipationCriteria = queryComponentFactory
        .newParticipationAttributeCriteria();
    subjParticipationCriteria.setTypeCode(SearchOperator.EQUALS, ParticipationType.SBJ);
    ParticipationFetch participationFetch = queryComponentFactory.newParticipationFetch(subjParticipationCriteria);
    actFetch.addParticipationFetch(participationFetch);

    // Create a Role Fetch with no criteria and attach it to the Participation fetch. 
    RoleFetch roleFetch = queryComponentFactory.newRoleFetch();
    participationFetch.addRoleFetch(roleFetch);
    
    // Create the player/scoper entity fetch and mark Name and ID for retrieval.
    // Note that as we want to get the same attributes for both the player and 
    // scoper, we will use the same EntityFetch.
    EntityFetch entityFetch = queryComponentFactory.newEntityFetch();
    entityFetch.retrieveName(true);
    entityFetch.retrieveId(true);
    roleFetch.addPlayerEntityFetch(entityFetch);
    roleFetch.addScoperEntityFetch(entityFetch);

    // Create a query act with the top level fetch, attach it to a
    // Control Act and submit the ControlAct to the RimService.
    QueryAct queryAct = actFactory.newQueryAct(actFetch);
    ControlAct queryControlAct = actFactory.newControlActEvent(null, null);
    queryControlAct.addOBActRelationship(ActRelationshipType.SUBJ, queryAct);
    ControlAct queryResult = rimService.submit(queryControlAct);

 


 

(2) Find all persons with "John" in any part of his name - also retrieve all played and scoped roles for these persons

    // Retrieve the services and factories needed for this example.
    RimService rimService = serviceLocator.getRimService();
    ActFactory actFactory = ActFactory.getInstance();
    QueryComponentFactory queryComponentFactory = QueryComponentFactory.getInstance();
    DataTypeFactory dataTypeFactory = DataTypeFactory.getInstance();
    
    // Create a Name Part Criteria attached to a Name Criteria attaches to an entity Criteria
    ENXPAttributeCriteria namePartCriteria =queryComponentFactory.newENXPAttributeCriteria();
    namePartCriteria.setST(SearchOperator.EQUALS,dataTypeFactory.newST("John"));
    ENAttributeCriteria nameCriteria = queryComponentFactory.newENAttributeCriteria();
    nameCriteria.setENXPCriteria(namePartCriteria);
    EntityAttributeCriteria entityCriteria = queryComponentFactory.newEntityAttributeCriteria();
    entityCriteria.setClassCode(SearchOperator.EQUALS, EntityClass.PSN);
    entityCriteria.setNameCriteria(nameCriteria);
    
    // Create an Entity Fetch with the EntityCriteria and request that Name and Id be retrieved.
    EntityFetch entityFetch = queryComponentFactory.newEntityFetch(entityCriteria);
    entityFetch.retrieveName(true);
    entityFetch.retrieveId(true);

    // Create an empty Role Fetch and attach it to the Entity Fetch with both a player and 
    // scoper link. As we are not associating any criteria with the Role Fetch it will 
    // return all roles that are played or scoped by the person Entity.
    RoleFetch roleFetch = queryComponentFactory.newRoleFetch();
    entityFetch.addPlayedRoleFetch(roleFetch);
    entityFetch.addScopedRoleFetch(roleFetch);


    // Create a query act with the top level fetch, attach it to a
    // Control Act and submit the ControlAct to the RimService.
    QueryAct queryAct = actFactory.newQueryAct(entityFetch);
    ControlAct queryControlAct = actFactory.newControlActEvent(null, null);
    queryControlAct.addOBActRelationship(ActRelationshipType.SUBJ, queryAct);
    ControlAct queryResult = rimService.submit(queryControlAct);

Skip navigation links


HDR Glossary   HDR Concept Lists   HDR Exceptions   HDR Programmer's Guide   HDR Implementation Guide   HDR Profile Options

Copyright © 2016, 2018, Oracle. All rights reserved