Home Page › Forums › BizTalk 2004 – BizTalk 2010 › XSLT sum and for each problem
- This topic has 0 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
July 10, 2009 at 9:00 PM #22836
Hi All,
I am working on a scenario where I have a custom XSLT for the Map to loop through some field elements and sum them up.
What I am looking for is i need to check two or three conditions before i sum up the field element.
I need to sum up the <InvoicedDaysofCare> for every <Contact> depending on the <PatientFeeAmount>.
The XSLT works if I only have one <Contact> in the input schema but if their is multiple <Contact> (which is the normal case) it sums up the whole <InvoicedDaysofCare> for all of the <Contact> in the whole input message.
I haven’t done much with XSLT.
Here is my XSLT:
<xsl:template name=”PatientInvoicedDaysofCare”>
<xsl:param name =”Permission”/>
<xsl:for-each select=”/*[local-name()=’PatientInvoiceExport’]/*[local-name()=’Contacts’]/*[local-name()=’Contact’]/*[local-name()=’Admission’]/*[local-name()=’PatientFeePeriods’]/*[local-name()=’PatientFeePeriod’][not(PatientFeeAmount=preceding-sibling::PatientFeePeriod/PatientFeeAmount)]/PatientFeeAmount”>
<xsl:element name=”ns0:XslLoopDaysofCare”>
<xsl:element name=”ns0:Text”>
<xsl:value-of select=”(//PatientFeePeriod[PatientFeeAmount=current()]/PatientFeeName)” />
</xsl:element>
<xsl:element name=”ns0:DayPrice”>
<xsl:value-of select=”current()” />
</xsl:element>
<xsl:element name=”ns0:InvoicedDaysofCare”>
<xsl:value-of select=”sum(//PatientFeePeriod[not(Permission =’true’)][PatientFeeAmount=current()]/InvoicedDaysofCare)” />
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>Input schema looks something like this:
<Contacts>
<Contact>
<ContactID>172297246</ContactID>
<Admission>
<PatientFeePeriods>
<PatientFeePeriod>
<Permission>false</Permission>
<PatientFeeName>Patientclass – From 18 year</PatientFeeName>
<PatientFeeAmount>80.0</PatientFeeAmount>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</PatientFeePeriod>
<PatientFeePeriod>
<Permission>false</Permission>
<PatientFeeName>Patientclass – From 18 year</PatientFeeName>
<PatientFeeAmount>80.0</PatientFeeAmount>
<InvoicedDaysofCare>3</InvoicedDaysofCare>
</PatientFeePeriod>
</PatientFeePeriods>
</Admission>
</Contact>
<Contact>
<ContactID>172297287</ContactID>
<Admission>
<PatientFeePeriods>
<PatientFeePeriod>
<Permission>false</Permission>
<PatientFeeName>Patientclass – From 18 year</PatientFeeName>
<PatientFeeAmount>80.0</PatientFeeAmount>
<InvoicedDaysofCare>5</InvoicedDaysofCare>
</PatientFeePeriod>
<PatientFeePeriod>
<Permission>false</Permission>
<PatientFeeName>Patientclass – From 18 year</PatientFeeName>
<PatientFeeAmount>80.0</PatientFeeAmount>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</PatientFeePeriod>
<PatientFeePeriod>
<Permission>false</Permission>
<PatientFeeName>Patientclass – From 18 year</PatientFeeName>
<PatientFeeAmount>40.0</PatientFeeAmount>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</PatientFeePeriod>
</PatientFeePeriods>
</Admission>
</Contact>
</Contacts>The output schema should look like this:
<Contacts>
<Contact>
<ContactID>172297246</ContactID>
<Admission>
<PatientFeePeriods>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>7</InvoicedDaysofCare>
</XslLoopDaysofCare>
</PatientFeePeriods>
</Admission>
</Contact>
<Contact>
<ContactID>172297287</ContactID>
<Admission>
<PatientFeePeriods>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>9</InvoicedDaysofCare>
</XslLoopDaysofCare>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>40.0</DayPrice>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</XslLoopDaysofCare>
</PatientFeePeriods>
</Admission>
</Contact>
</Contacts>But it doesn’t, instead it looks like this:
<Contacts>
<Contact>
<ContactID>172297246</ContactID>
<Admission>
<PatientFeePeriods>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>16</InvoicedDaysofCare>
</XslLoopDaysofCare>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>40.0</DayPrice>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</XslLoopDaysofCare>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>16</InvoicedDaysofCare>
</XslLoopDaysofCare>
</PatientFeePeriods>
</Admission>
</Contact>
<Contact>
<ContactID>172297287</ContactID>
<Admission>
<PatientFeePeriods>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>16</InvoicedDaysofCare>
</XslLoopDaysofCare>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>40.0</DayPrice>
<InvoicedDaysofCare>4</InvoicedDaysofCare>
</XslLoopDaysofCare>
<XslLoopDaysofCare>
<Text>Patientclass – From 18 year</Text>
<DayPrice>80.0</DayPrice>
<InvoicedDaysofCare>16</InvoicedDaysofCare>
</XslLoopDaysofCare>
</PatientFeePeriods>
</Admission>
</Contact>
</Contacts>What am I doing wrong or have I missed something?
I have tried to used a condition for every uniq ContactID but I haven’t got that to work either.Best regards and thanks in advanced,
Jock
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.