<commit_before><xsl:stylesheet version="1.0"
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:adeers="http://types.ws.adeers.ctep.nci.nih.gov"
                xmlns:ns1="http://localhost:8080/AdEERSWSMap/services/AEReportXMLService"
				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!-- Assuming that the following Parameters are derived runtime from header -->
    <xsl:param name="c2r_msg_id" /> <!-- a UUID -->
    <xsl:param name="c2r_today_204" />
    <xsl:param name="c2r_report_received_on_102" />
    <xsl:param name="c2r_msg_number" />
    <xsl:param name="c2r_msg_date" />
    <xsl:param name="c2r_msg_sender_id" />
    <xsl:param name="c2r_msg_receiver_id" />
    <xsl:param name="c2r_msg_safety_report_id" />

    <xsl:template match="//adeers:submitAEDataXMLAsAttachmentResponse">
		<xsl:variable name="report_id" select="$c2r_msg_safety_report_id"/>
        <ichicsrack lang="en">
            <ichicsrmessageheader>
                <messagetype>ichicsrack</messagetype>
                <!-- always ichicsrack for ach-->
                <messageformatversion>1.1</messageformatversion>
                <!-- ich-icsrack-v1.1.dtd is used for icsr 2.1-->
                <messageformatrelease>1.0</messageformatrelease>
                <!-- release of dtd is 1.0 -->
                <messagenumb><xsl:value-of select="$c2r_msg_id" /></messagenumb>
                <!-- caAERS's unique message number, for this ACK message -->
                <messagesenderidentifier><xsl:value-of select="$c2r_msg_receiver_id" /></messagesenderidentifier>
                <messagereceiveridentifier><xsl:value-of select="$c2r_msg_sender_id" /></messagereceiveridentifier>
                <messagedateformat>204</messagedateformat>
                <messagedate><xsl:value-of select="$c2r_today_204" /></messagedate>
                <!-- Date on which ack got created : in CCYYMMDDHHMMSS format-->
            </ichicsrmessageheader>
            <xsl:variable name="reportStatus" select="//adeers:reportStatus"/>
            <xsl:choose>
                <xsl:when test="$reportStatus='SUCCESS'">
					<xsl:variable name="status" select="'01'"/>
				</xsl:when>
				<xsl:when test="$reportStatus='SUCCESS' and fn:string-length($report_id) > 0">
					<xsl:variable name="status" select="'02'"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:variable name="status" select="'03'"/>
				</xsl:otherwise>
            </xsl:choose>
            <acknowledgment>
                <messageacknowledgment>
                    <icsrmessagenumb><xsl:value-of select="$c2r_msg_number" /></icsrmessagenumb>
                    <!-- obtained as part of the input safety report message -->
                    <localmessagenumb><xsl:value-of select="//ns1:AEReportJobInfo/adeers:jobID" /></localmessagenumb>
                    <!-- optional, might not be present if there was processing error. This number was assigned to the input safety Message by caAERS -->
                    <icsrmessagesenderidentifier><xsl:value-of select="$c2r_msg_sender_id" /></icsrmessagesenderidentifier>
                    <icsrmessagereceiveridentifier><xsl:value-of select="$c2r_msg_receiver_id" /></icsrmessagereceiveridentifier>
                    <icsrmessagedateformat>204</icsrmessagedateformat>
                    <icsrmessagedate><xsl:value-of select="$c2r_msg_date" /></icsrmessagedate>
                    <!-- Date in CCYYMMDDHHMMSS -->
                    <!--
                    01= All Reports loaded into database
                    02 = ICSR Error, not all reports loaded into the database, check section B
                    03= SGML parsing error, no data extracted
                    -->					
	                <transmissionacknowledgmentcode><xsl:value-of select="$status" /></transmissionacknowledgmentcode>	
	                  
                    <xsl:if test="$status='03'">
                        <parsingerrormessage><xsl:apply-templates select="//ns1:AEReportJobInfo/adeers:jobExceptions" mode="ERR"/> System error occurred in <xsl:value-of
                                   select="//SYSTEM_NAME" /></parsingerrormessage><commit_msg>CAAERS-7136, update ack generation to correctly repond with 02 and 03 messages in cases of error.<commit_after><xsl:stylesheet version="1.0"
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:adeers="http://types.ws.adeers.ctep.nci.nih.gov"
                xmlns:ns1="http://localhost:8080/AdEERSWSMap/services/AEReportXMLService"
				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!-- Assuming that the following Parameters are derived runtime from header -->
    <xsl:param name="c2r_msg_id" /> <!-- a UUID -->
    <xsl:param name="c2r_today_204" />
    <xsl:param name="c2r_report_received_on_102" />
    <xsl:param name="c2r_msg_number" />
    <xsl:param name="c2r_msg_date" />
    <xsl:param name="c2r_msg_sender_id" />
    <xsl:param name="c2r_msg_receiver_id" />
    <xsl:param name="c2r_msg_safety_report_id" />

    <xsl:template match="//adeers:submitAEDataXMLAsAttachmentResponse">
		<xsl:variable name="report_id" select="$c2r_msg_safety_report_id"/>
        <ichicsrack lang="en">
            <ichicsrmessageheader>
                <messagetype>ichicsrack</messagetype>
                <!-- always ichicsrack for ach-->
                <messageformatversion>1.1</messageformatversion>
                <!-- ich-icsrack-v1.1.dtd is used for icsr 2.1-->
                <messageformatrelease>1.0</messageformatrelease>
                <!-- release of dtd is 1.0 -->
                <messagenumb><xsl:value-of select="$c2r_msg_id" /></messagenumb>
                <!-- caAERS's unique message number, for this ACK message -->
                <messagesenderidentifier><xsl:value-of select="$c2r_msg_receiver_id" /></messagesenderidentifier>
                <messagereceiveridentifier><xsl:value-of select="$c2r_msg_sender_id" /></messagereceiveridentifier>
                <messagedateformat>204</messagedateformat>
                <messagedate><xsl:value-of select="$c2r_today_204" /></messagedate>
                <!-- Date on which ack got created : in CCYYMMDDHHMMSS format-->
            </ichicsrmessageheader>
            <xsl:variable name="reportStatus" select="//adeers:reportStatus"/>
            <xsl:choose>
                <xsl:when test="$reportStatus='SUCCESS'">
					<xsl:variable name="status" select="'01'"/>
				</xsl:when>
				<xsl:when test="$reportStatus='SUCCESS' and string-length($report_id) > 0">
					<xsl:variable name="status" select="'02'"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:variable name="status" select="'03'"/>
				</xsl:otherwise>
            </xsl:choose>
            <acknowledgment>
                <messageacknowledgment>
                    <icsrmessagenumb><xsl:value-of select="$c2r_msg_number" /></icsrmessagenumb>
                    <!-- obtained as part of the input safety report message -->
                    <localmessagenumb><xsl:value-of select="//ns1:AEReportJobInfo/adeers:jobID" /></localmessagenumb>
                    <!-- optional, might not be present if there was processing error. This number was assigned to the input safety Message by caAERS -->
                    <icsrmessagesenderidentifier><xsl:value-of select="$c2r_msg_sender_id" /></icsrmessagesenderidentifier>
                    <icsrmessagereceiveridentifier><xsl:value-of select="$c2r_msg_receiver_id" /></icsrmessagereceiveridentifier>
                    <icsrmessagedateformat>204</icsrmessagedateformat>
                    <icsrmessagedate><xsl:value-of select="$c2r_msg_date" /></icsrmessagedate>
                    <!-- Date in CCYYMMDDHHMMSS -->
                    <!--
                    01= All Reports loaded into database
                    02 = ICSR Error, not all reports loaded into the database, check section B
                    03= SGML parsing error, no data extracted
                    -->					
	                <transmissionacknowledgmentcode><xsl:value-of select="$status" /></transmissionacknowledgmentcode>	
	                  
                    <xsl:if test="$status='03'">
                        <parsingerrormessage><xsl:apply-templates select="//ns1:AEReportJobInfo/adeers:jobExceptions" mode="ERR"/> System error occurred in <xsl:value-of
                                   select="//SYSTEM_NAME" /></parsingerrormessage>
{'fraction_non_alphanumeric': 0.13136136019564457, 'fraction_numerical': 0.0186328170490276, 'mean_word_length': 2.367843137254902, 'pattern_counts': {'":': 0, '<': 171, '<?xml version=': 0, '>': 173, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4946235', 'n_tokens_mistral': 2853, 'n_tokens_neox': 2432, 'n_words': 432}