HL7PRPA201306Transforms { public PRPAIN201306UV02 createPRPA201306ForErrors(PRPAIN201305UV02 oRequest, String sErrorCode) { LOG.trace("*** Entering createPRPA201306ForErrors() method ***"); if (oRequest == null) { LOG.error("The incomming patient discovery request, PRPAIN201305UV02, message was null."); return null; } boolean bRequiredFieldsAreNull = areIncommingRequiredPRPAIN201305FieldsNull(oRequest); if (bRequiredFieldsAreNull) { LOG.error("One or more required fields from the patient discovery request are null."); return null; } if (NullChecker.isNullish(sErrorCode)) { LOG.error("The sErrorCode parameter was null."); return null; } PRPAIN201306UV02 result = new PRPAIN201306UV02(); LOG.trace("Create the 201306 message header fields"); result.setITSVersion(HL7Constants.ITS_VERSION); String senderOID = getReceiverOIDFromPRPAIN201305UV02Request(oRequest); try { LOG.info("Attempting to retrieve property: " + NhincConstants.HOME_COMMUNITY_ID_PROPERTY + " from property file: " + NhincConstants.GATEWAY_PROPERTY_FILE); String sHomeCommunityId = PropertyAccessor.getInstance().getProperty(NhincConstants.GATEWAY_PROPERTY_FILE, NhincConstants.HOME_COMMUNITY_ID_PROPERTY); if (sHomeCommunityId != null) { LOG.info("Retrieving local home community id"); if (!sHomeCommunityId.isEmpty()) { senderOID = sHomeCommunityId; } } } catch (PropertyAccessException ex) { LOG.error("Error: Failed to retrieve {} from property file {}: {}", NhincConstants.HOME_COMMUNITY_ID_PROPERTY, NhincConstants.GATEWAY_PROPERTY_FILE, ex.getLocalizedMessage(), ex); } result.setId(getHL7MessageId(getSenderOIDFromPRPAIN201305UV02Request(oRequest))); result.setCreationTime(getHL7CreationTime()); result.setInteractionId(getHL7InteractionId()); result.setProcessingCode(getHL7ProcessingCode()); result.setProcessingModeCode(getHL7ProcessingModeCode()); result.setAcceptAckCode(HL7DataTransformHelper.CSFactory("NE")); result.getAcknowledgement().add(createAck(oRequest)); LOG.trace("Create the Receiver"); result.getReceiver().add(HL7ReceiverTransforms .createMCCIMT000300UV01Receiver(getSenderOIDFromPRPAIN201305UV02Request(oRequest))); LOG.trace("Create the Sender"); result.setSender(HL7SenderTransforms.createMCCIMT000300UV01Sender(senderOID)); LOG.trace("Create the ControlActProcess"); PRPAIN201306UV02MFMIMT700711UV01ControlActProcess oControlActProcess = createQUQIMT021001UV01ControlActProcessWithNoRegistrationEvent( oRequest); oControlActProcess.getQueryAck().getQueryResponseCode().setCode(HL7Constants.QUERY_ACK_QE); oControlActProcess.getReasonOf().add(createErrorReason(sErrorCode)); result.setControlActProcess(oControlActProcess); LOG.trace("*** Exiting createPRPA201306ForErrors() method ***"); return result; }  static PRPAIN201306UV02 createPRPA201306(PRPAMT201301UV02Patient patient, String senderOID,
        String receiverAAID, String receiverOID, String localDeviceId, PRPAIN201305UV02 query); PRPAIN201306UV02 createPRPA201306ForPatientNotFound(PRPAIN201305UV02 oRequest); PRPAIN201306UV02 createPRPA201306ForErrors(PRPAIN201305UV02 oRequest, String sErrorCode); PRPAIN201306UV02 createPRPA201306ForErrors(PRPAIN201305UV02 oRequest, String sErrorCode, String sErrorText); static PRPAIN201306UV02MFMIMT700711UV01ControlActProcess createQUQIMT021001UV01ControlActProcess(
        PRPAMT201301UV02Patient patient, String localDeviceId, PRPAIN201305UV02 query, String aaId, String orgId); static PRPAIN201306UV02MFMIMT700711UV01ControlActProcess createQUQIMT021001UV01ControlActProcessWithNoRegistrationEvent(
        PRPAIN201305UV02 query); static MFMIMT700711UV01QueryAck createQueryAck(PRPAIN201305UV02 query); static PRPAIN201306UV02MFMIMT700711UV01Subject2 createSubject2(PRPAMT201301UV02Patient patient,
        PRPAIN201305UV02 query, String patId, String orgId);  }
@Test public void createPRPA201306ForErrorsRequestNull() { PRPAIN201305UV02 query = null; String sErrorCode = "Patient Not available"; HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); assertNull(transforms.createPRPA201306ForErrors(query, sErrorCode)); }
@Test public void createPRPA201306ForErrorsSenderNull() { String sErrorCode = "Patient Not available"; HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); assertNull(transforms.createPRPA201306ForErrors(createPRPAIN201305UV02WhenSenderNull(), sErrorCode)); }
@Test public void createPRPA201306ForErrorsReceiverNull() { String sErrorCode = "Patient Not available"; HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); assertNull(transforms.createPRPA201306ForErrors(createPRPAIN201305UV02WhenReceiverNull(), sErrorCode)); }
@Test public void createPRPA201306ForErrorsIntercationIdNull() { String sErrorCode = "Patient Not available"; HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); assertNull(transforms.createPRPA201306ForErrors(createPRPAIN201305UV02WhenIntercationIdNull(), sErrorCode)); }
@Test public void createPRPA201306ForErrorsStringErrorNull() { String sErrorCode = null; HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); assertNull(transforms.createPRPA201306ForErrors(createPRPAIN201305UV02(), sErrorCode)); }
@Test public void createPRPA201306ForErrorsWhenErrorTextPresent() { HL7PRPA201306Transforms transforms = new HL7PRPA201306Transforms(); PRPAIN201306UV02 result; String sErrorCode = "patient not avialable"; String sErrorText = "Internal error"; result = transforms.createPRPA201306ForErrors(createPRPAIN201305UV02(), sErrorCode, sErrorText); assertEquals(result.getControlActProcess().getReasonOf().get(0).getDetectedIssueEvent().getText().getContent() .get(0).toString(), "Internal error"); }