protected RequestType getRequestType(PRPAIN201305UV02 event, AssertionType assertion) {
    addDebugLog("Begin -- PatientDiscoveryPolicyTransformHelper.getRequestType()");
    RequestType request = new RequestType();

    setSubjectToRequestType(event, request, assertion);

    ResourceType resource = null;
    AttributeHelper attrHelper = new AttributeHelper();
    II ii = extractPatientIdentifier(event);
    if (ii != null) {
      resource = new ResourceType();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot()));
      String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(ii.getExtension());
      log.debug("transformSubjectAddedInToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));
      request.getResource().add(resource);
    }
    request.getResource().add(resource);
    addDebugLog("End -- PatientDiscoveryPolicyTransformHelper.getRequestType()");
    return request;
  }
  @Test
  public void ensureNoDuplicates() {
    II id1 = new II();
    id1.setRoot("1.1");
    id1.setExtension("patientId");
    id1.setAssigningAuthorityName("AA");

    II id2 = new II();
    id2.setRoot("1.1");
    id2.setExtension("patientId");
    id2.setAssigningAuthorityName("AA");

    II[] idArray = new II[2];
    idArray[0] = id1;
    idArray[1] = id2;

    AggregationService service = new AggregationService();
    Set<II> idSet = service.removeDuplicates(java.util.Arrays.asList(idArray));

    assertEquals(1, idSet.size());

    II[] noDupesArray = (II[]) idSet.toArray(new II[0]);
    assertEquals(id1.getAssigningAuthorityName(), noDupesArray[0].getAssigningAuthorityName());
    assertEquals(id1.getExtension(), noDupesArray[0].getExtension());
    assertEquals(id1.getRoot(), noDupesArray[0].getRoot());
    assertEquals(id1.isDisplayable(), noDupesArray[0].isDisplayable());
  }
  /**
   * Transform method to create a CheckPolicyRequest object from a 201306 message
   *
   * @param request
   * @return CheckPolicyRequestType
   */
  public CheckPolicyRequestType transformPatientDiscoveryNhincToCheckPolicy(
      PatDiscReqEventType event) {
    addDebugLog(
        "Begin -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryNhincToCheckPolicy()");
    CheckPolicyRequestType checkPolicyRequest = null;

    if (event == null) {
      addErrorLog("Request is null.");
      return checkPolicyRequest;
    } else {
      checkPolicyRequest = new CheckPolicyRequestType();
    }

    PRPAIN201306UV02 patDiscReq = event.getPRPAIN201306UV02();
    RequestType request = new RequestType();

    SubjectHelper subjHelp = new SubjectHelper();
    SubjectType subject =
        subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getAssertion());
    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding subject");
    request.getSubject().add(subject);

    II qualifiedPatientIdentifier = extractPatientIdentifier(patDiscReq);
    if (qualifiedPatientIdentifier != null) {
      ResourceType resource = new ResourceType();
      AttributeHelper attrHelper = new AttributeHelper();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId,
                  Constants.DataTypeString,
                  qualifiedPatientIdentifier.getRoot()));
      String sStrippedPatientId =
          PatientIdFormatUtil.parsePatientId(qualifiedPatientIdentifier.getExtension());
      log.debug(
          "transformPatientDiscoveryNhincToCheckPolicy: sStrippedPatientId = "
              + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));

      request.getResource().add(resource);
    }

    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding assertion data");
    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getAssertion());

    request.setAction(ActionHelper.actionFactory(ActionInValue));

    checkPolicyRequest.setRequest(request);
    checkPolicyRequest.setAssertion(event.getAssertion());
    addDebugLog(
        "End -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryNhincToCheckPolicy()");
    return checkPolicyRequest;
  }
  public static Identifiers ExtractPersonIdentifiers(PRPAMT201306UV02ParameterList params) {
    log.debug("Entering HL7Parser201305.ExtractPersonIdentifiers method...");

    Identifiers ids = new Identifiers();
    Identifier id = new Identifier();

    if (params.getLivingSubjectId() != null
        && params.getLivingSubjectId().size() > 0
        && params.getLivingSubjectId().get(0) != null) {
      PRPAMT201306UV02LivingSubjectId livingSubjectId = params.getLivingSubjectId().get(0);

      if (livingSubjectId.getValue() != null
          && livingSubjectId.getValue().size() > 0
          && livingSubjectId.getValue().get(0) != null) {
        II subjectId = livingSubjectId.getValue().get(0);

        if (subjectId.getExtension() != null
            && subjectId.getExtension().length() > 0
            && subjectId.getRoot() != null
            && subjectId.getRoot().length() > 0) {
          id.setId(subjectId.getExtension());
          id.setOrganizationId(subjectId.getRoot());
          log.info(
              "Created id from patient identifier [organization="
                  + id.getOrganizationId()
                  + "][id="
                  + id.getId()
                  + "]");
          ids.add(id);
        } else {
          log.info("message does not contain an id");
        }
      } else {
        log.info("message does not contain an id");
      }
    } else {
      log.info("message does not contain an id");
    }

    log.debug("Exiting HL7Parser201305.ExtractPersonIdentifiers method...");
    return ids;
  }
Beispiel #5
0
 public static void PrintId(II id, String idname) {
   if (idname == null) {
     idname = "";
   }
   if (!(id == null)) {
     log.info(idname + ".id.root=" + id.getRoot() + ";");
     log.info(idname + ".id.extension=" + id.getExtension() + ";");
   } else {
     log.info("id for " + idname + " is null");
   }
 }
  private static II extractPatientIdentifier(PRPAIN201305UV02 message) {
    II ii = null;
    String assigningAuthority = null;

    if (message != null
        && message.getControlActProcess() != null
        && NullChecker.isNotNullish(message.getControlActProcess().getAuthorOrPerformer())
        && message.getControlActProcess().getAuthorOrPerformer().get(0) != null
        && message.getControlActProcess().getAuthorOrPerformer().get(0).getAssignedDevice() != null
        && message
                .getControlActProcess()
                .getAuthorOrPerformer()
                .get(0)
                .getAssignedDevice()
                .getValue()
            != null
        && NullChecker.isNotNullish(
            message
                .getControlActProcess()
                .getAuthorOrPerformer()
                .get(0)
                .getAssignedDevice()
                .getValue()
                .getId())
        && message
                .getControlActProcess()
                .getAuthorOrPerformer()
                .get(0)
                .getAssignedDevice()
                .getValue()
                .getId()
                .get(0)
            != null
        && NullChecker.isNotNullish(
            message
                .getControlActProcess()
                .getAuthorOrPerformer()
                .get(0)
                .getAssignedDevice()
                .getValue()
                .getId()
                .get(0)
                .getRoot())) {
      assigningAuthority =
          message
              .getControlActProcess()
              .getAuthorOrPerformer()
              .get(0)
              .getAssignedDevice()
              .getValue()
              .getId()
              .get(0)
              .getRoot();
    }

    if ((message != null)
        && (message.getControlActProcess() != null)
        && (message.getControlActProcess().getQueryByParameter() != null)) {
      JAXBElement<PRPAMT201306UV02QueryByParameter> queryParam =
          message.getControlActProcess().getQueryByParameter();
      PRPAMT201306UV02QueryByParameter queryParam201306 = queryParam.getValue();
      if (queryParam201306.getParameterList() != null
          && queryParam201306.getParameterList().getLivingSubjectId() != null) {
        List<PRPAMT201306UV02LivingSubjectId> livingSubjectIdList =
            queryParam201306.getParameterList().getLivingSubjectId();
        if (NullChecker.isNotNullish(livingSubjectIdList)) {
          for (PRPAMT201306UV02LivingSubjectId livingSubId : livingSubjectIdList) {
            for (II id : livingSubId.getValue()) {
              if (id != null
                  && NullChecker.isNotNullish(id.getExtension())
                  && NullChecker.isNotNullish(id.getRoot())
                  && id.getRoot().equalsIgnoreCase(assigningAuthority)) {
                ii = id;

                // Break out of the inner loop
                break;
              }
            }

            // If the id was found break out of the outer loop
            if (ii != null) {
              break;
            }
          }
        }
      }
    }
    return ii;
  }
  /**
   * Transform method to create a CheckPolicyRequest object from a 201305 request
   *
   * @param request
   * @return CheckPolicyRequestType
   */
  public CheckPolicyRequestType transformPatientDiscoveryEntityToCheckPolicy(
      RespondingGatewayPRPAIN201305UV02RequestType event) {
    addDebugLog(
        "Begin -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()");

    CheckPolicyRequestType checkPolicyRequest = null;

    if (event == null) {
      addErrorLog("Request is null.");
      return checkPolicyRequest;
    } else {
      checkPolicyRequest = new CheckPolicyRequestType();
    }

    PRPAIN201305UV02 patDiscReq = event.getPRPAIN201305UV02();
    // RequestType request = getRequestType(patDiscReq, event.getAssertion());
    RequestType request = new RequestType();

    SubjectHelper subjHelp = new SubjectHelper();
    // SubjectType subject = subjHelp.subjectFactory(event.getAssertion().getHomeCommunity(),
    // event.getAssertion());
    SubjectType subject = new SubjectType();
    subject.setSubjectCategory(SubjectHelper.SubjectCategory);
    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding subject");
    request.getSubject().add(subject);

    II qualifiedPatientIdentifier = extractPatientIdentifier(patDiscReq);
    if (qualifiedPatientIdentifier != null) {
      ResourceType resource = new ResourceType();
      AttributeHelper attrHelper = new AttributeHelper();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId,
                  Constants.DataTypeString,
                  qualifiedPatientIdentifier.getRoot()));
      String sStrippedPatientId =
          PatientIdFormatUtil.parsePatientId(qualifiedPatientIdentifier.getExtension());
      log.debug(
          "transformPatientDiscoveryNhincToCheckPolicy: sStrippedPatientId = "
              + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));

      HomeCommunityType homeCommunityId = null;

      if (event != null
          && event.getPRPAIN201305UV02() != null
          && NullChecker.isNotNullish(event.getPRPAIN201305UV02().getReceiver())
          && event.getPRPAIN201305UV02().getReceiver().get(0) != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice() != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent() != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent().getValue()
              != null
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
              != null
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
              != null
          && NullChecker.isNotNullish(
              event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId())
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId()
                  .get(0)
              != null
          && NullChecker.isNotNullish(
              event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId()
                  .get(0)
                  .getRoot())) {
        homeCommunityId = new HomeCommunityType();
        homeCommunityId.setHomeCommunityId(
            event
                .getPRPAIN201305UV02()
                .getReceiver()
                .get(0)
                .getDevice()
                .getAsAgent()
                .getValue()
                .getRepresentedOrganization()
                .getValue()
                .getId()
                .get(0)
                .getRoot());
      }
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  Constants.HomeCommunityAttributeId,
                  Constants.DataTypeString,
                  subjHelp.determineSendingHomeCommunityId(homeCommunityId, event.getAssertion())));

      request.getResource().add(resource);
    }

    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding assertion data");
    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getAssertion());

    request.setAction(ActionHelper.actionFactory(ActionOutValue));

    checkPolicyRequest.setRequest(request);
    checkPolicyRequest.setAssertion(event.getAssertion());

    addDebugLog(
        "End -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()");
    return checkPolicyRequest;
  }