CREATE COMPUTE MODULE SET_ISO_ERROR_GENERAL
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF InputRoot.XMLNSC.data.body.messageType = '0200' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0210';
		ELSEIF InputRoot.XMLNSC.data.body.messageType = '0400' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0410';
		ELSEIF InputRoot.XMLNSC.data.body.messageType = '0401' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0411';
		END IF;

		SET OutputRoot.XMLNSC.data.body.responseCode = '99';

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_ISO_ERROR_REQ_ORIGINAL
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		SET OutputRoot.XMLNSC.data.body = InputRoot.XMLNSC.data.original;

		IF InputRoot.XMLNSC.data.original.messageType = '0200' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0210';
		ELSEIF InputRoot.XMLNSC.data.original.messageType = '0400' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0410';
		ELSEIF InputRoot.XMLNSC.data.original.messageType = '0401' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0411';
		END IF;

		SET OutputRoot.XMLNSC.data.body.responseCode = '99';

		DELETE FIELD OutputRoot.XMLNSC.data.original;

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE FILTER MODULE MAPPING_NOT_FOUND_FILTER
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		IF FIELDTYPE(Root.XMLNSC.data.error) IS NULL THEN
			RETURN FALSE;
		ELSE
			IF STARTSWITH(Root.XMLNSC.data.error, 'Mapping ') AND ENDSWITH(Root.XMLNSC.data.error, ' not found') THEN
				RETURN TRUE;
			ELSE
				RETURN FALSE;
			END IF;
		END IF;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_ISO_ERROR_MAPPING_NOT_FOUND
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF InputRoot.XMLNSC.data.body.messageType = '0200' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0210';
		ELSEIF InputRoot.XMLNSC.data.body.messageType = '0400' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0410';
		ELSEIF InputRoot.XMLNSC.data.body.messageType = '0401' THEN
			SET OutputRoot.XMLNSC.data.body.messageType = '0411';
		END IF;

		SET OutputRoot.XMLNSC.data.body.responseCode = '92';

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_RAW_TO_BODY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF FIELDTYPE(InputLocalEnvironment.reqori.RAW) IS NOT NULL THEN
			SET OutputRoot.XMLNSC.data.raw = InputLocalEnvironment.reqori.RAW;
			SET OutputRoot.XMLNSC.data.type= InputLocalEnvironment.reqori.TYPE;
			DELETE FIELD OutputRoot.XMLNSC.data.body;
			RETURN TRUE;
		ELSE
			PROPAGATE TO TERMINAL 'failure';
			RETURN FALSE;
		END IF;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_ORIGINAL_TO_BODY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF FIELDTYPE(InputRoot.XMLNSC.data.original) IS NOT NULL THEN
			SET OutputRoot.XMLNSC.data.body.original = InputRoot.XMLNSC.data.original;
			DELETE FIELD OutputRoot.XMLNSC.data.original;
		END IF;

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_INSIDE_ORIGINAL_TO_BODY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF FIELDTYPE(InputRoot.XMLNSC.data.original) IS NOT NULL THEN
			SET OutputRoot.XMLNSC.data.body = InputRoot.XMLNSC.data.original;
			DELETE FIELD OutputRoot.XMLNSC.data.original;
		END IF;

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE SET_BODY_ORIGINAL_TO_BODY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyEntireMessage();

		IF FIELDTYPE(InputRoot.XMLNSC.data.body.original) IS NOT NULL THEN
			DELETE FIELD OutputRoot.XMLNSC.data.body;
			SET OutputRoot.XMLNSC.data.body = InputRoot.XMLNSC.data.body.original;
		END IF;

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE FILTER MODULE MULTIPLE_REQUEST_FILTER
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		IF FIELDTYPE(Root.XMLNSC.data.request.data.body.isMultipleRequest) IS NULL THEN
			RETURN FALSE;
		ELSE
			IF Root.XMLNSC.data.request.data.body.isMultipleRequest = 'true' THEN
				RETURN TRUE;
			ELSE
				RETURN FALSE;
			END IF;
		END IF;
	END;
END MODULE;


CREATE FILTER MODULE IS_NO_NEED_REPLY_FILTER
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		IF FIELDTYPE(Root.XMLNSC.data.request.data.body.isNoNeedReply) IS NULL THEN
			RETURN FALSE;
		ELSE
			IF Root.XMLNSC.data.request.data.body.isNoNeedReply = 'true' THEN
				RETURN TRUE;
			ELSE
				RETURN FALSE;
			END IF;
		END IF;
	END;
END MODULE;