FHIR contained practionner in generalPractitioner - hl7-fhir

In the (last) FHIR specification (v1.8.0), it's mentioned that a contained resource can be embedded in a Reference (documentation), when no reference exists.
But, by looking at the XSD, I can't figure out how to validate the XML against the patient.xsd with such a mechanism.
Here is my attempt
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<identifier>
<system value="urn:oid:1.2.250.1.311.1.1"/>
<value value="2000100439"/>
<assigner>
<display value="ap-hm"/>
</assigner>
</identifier>
<name>
<use value="official"/>
<family value="COPTER"/>
<given value="ELI"/>
</name>
<gender value="male"/>
<birthDate value="1954-08-14"/>
<deceasedBoolean value="false"/>
<address>
<use value="home"/>
<line value="45 boulevard des cigales"/>
<city value="MARSEILLE 10"/>
<postalCode value="13010"/>
</address>
<maritalStatus>
<coding>
<system value="http://hl7.org/fhir/v3/MaritalStatus"/>
<code value="U"/>
</coding>
</maritalStatus>
<generalPractitioner>
<contained>
<Practitioner>
<id value="p1"/>
<name>
<family value="PASTEUR"/>
<given value="LOUIS"/>
</name>
<address>
<city>MARSEILLE</city>
<postalCode>13005</postalCode>
</address>
<gender value="male"/>
</Practitioner>
</contained>
</generalPractitioner>
</Patient>
What is the correct way to have a contained reference ?

All contained resources are sent near the top using the "contained" element. They are then referenced as a local reference. So your example would look as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<contained>
<Practitioner>
<id value="p1"/>
<name>
<family value="PASTEUR"/>
<given value="LOUIS"/>
</name>
<address>
<city>MARSEILLE</city>
<postalCode>13005</postalCode>
</address>
<gender value="male"/>
</Practitioner>
</contained>
<identifier>
<system value="urn:oid:1.2.250.1.311.1.1"/>
<value value="2000100439"/>
<assigner>
<display value="ap-hm"/>
</assigner>
</identifier>
<name>
<use value="official"/>
<family value="COPTER"/>
<given value="ELI"/>
</name>
<gender value="male"/>
<birthDate value="1954-08-14"/>
<deceasedBoolean value="false"/>
<address>
<use value="home"/>
<line value="45 boulevard des cigales"/>
<city value="MARSEILLE 10"/>
<postalCode value="13010"/>
</address>
<maritalStatus>
<coding>
<system value="http://hl7.org/fhir/v3/MaritalStatus"/>
<code value="U"/>
</coding>
</maritalStatus>
<generalPractitioner>
<reference value="#p1"/>
</generalPractitioner>
</Patient>

Related

Unable to toggle editor style after manually editing xcdatamodel/content file

After manually editing the xcdatamodel/content due to a merge conflict I'm able to open and run the project just fine, but I'm unable to toggle the toggle the editor style to show the "object relations diagram"
I'm using Xcode 13.4.1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="21G115" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Foo" representedClassName=".foo" syncable="YES">
...
</entity>
<entity name="Bar" representedClassName=".bar" syncable="YES">
...
</entity>
<entity name="FooBar" representedClassName=".fooBar" syncable="YES">
...
<fetchIndex name="fooie">
<fetchIndexElement property="fooeee" type="Binary" order="ascending"/>
</fetchIndex>
</entity>
<entity name="BarFoo" representedClassName=".barFoo" syncable="YES">
<fetchIndex name="byPropertyIndex">
<fetchIndexElement property="bla bla bla" type="Binary" order="descending"/>
</fetchIndex>
</entity>
<elements>
<element name="Foo" positionX="0" positionY="0" width="0" height="0"/>
<element name="Bar" positionX="0" positionY="0" width="0" height="0"/>
<element name="FooBar" positionX="0" positionY="0" width="0" height="0"/>
<element name="BarFoo" positionX="0" positionY="0" width="0" height="0"/>
</elements>
</model>
Any Idea what is going on here? How can I get xcode to open the object Diagram for this model version?

FHIR - Consent Resource - Giving Hl7.Fhir.Serialization.ComplexTypeReader error

I am not a techie but have assumed some responsibilities in someone's absence.
Trying to push below Consent FHIR Resource:
<Consent xmlns="http://hl7.org/fhir">
<id value="123" />
<status value="inactive" />
<scope>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentscope" />
<code value="patient-privacy" />
</coding>
</scope>
<category>
<coding>
<system value="http://loinc.org" />
<code value="59284-0" />
</coding>
</category>
<patient>
<reference value="Patient/41" />
<display value="John Stifiles" />
</patient>
<policyRule>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentpolicycodes" />
<code value="cric" />
</coding>
</policyRule>
<provision>
<type value="deny" />
<period>
<start value="2021-09-27" />
<end value="2021-09-27" />
</period>
</provision>
</Consent>
This is passed with no errors from inferno.healthit.gov/validator/ but when I run through my integrator (it hits HL7 validator), I get a variety of errors - Encountered unknown member 'Scope' or Encountered unknown member 'Patient', etc.
This is a Consent resource that conforms to FHIR version R4. Inferno runs FHIR R4 as well, so that works.
However, if you try and validate this resource against FHIR STU3, you will get the errors you mentioned, since the Consent resource structure significantly changed from STU3 to R4. Please check your integrator and make sure it runs FHIR R4 as well.

Jasper Report how to get a sibling node with parameter of another sibling?

I am working on a new Jaspert Report. It should print all data of a xml text.
The xml text looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<invoice:invoiceMessage>
<invoice>
<invoiceIdentification></invoiceIdentification>
<seller>
<address>
<name></name>
<city></city>
<cityCode></cityCode>
</address>
</seller>
</invoice>
</invoice:invoiceMessage>
And the Jasper Report looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.1.0.final using JasperReports Library version 6.4.3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="main_report_xml1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="24a4119c-6e8f-4411-bbb5-c069ab379330">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="http://10.100.10.236/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="reko"/>
<property name="ireport.jasperserver.reportUnit" value="/Reko/main_report_xml1"/>
<subDataset name="pageHeader" uuid="cf87fcbb-cbcd-4c3b-bf87-3cf147854adb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<queryString language="xPath">
<![CDATA[//seller/address]]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="streetAdressOne" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="streetAdressOne"/>
<fieldDescription><![CDATA[streetAdressOne]]></fieldDescription>
</field>
<field name="cityCode" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="cityCode"/>
<fieldDescription><![CDATA[cityCode]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="city"/>
<fieldDescription><![CDATA[city]]></fieldDescription>
</field>
</subDataset>
<parameter name="xmlString" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[xmlText]]></defaultValueExpression>
</parameter>
<parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
<defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{xmlString}.getBytes("ISO-8859-1"))]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/invoiceMessage/invoice[invoiceIdentification/entityIdentification=9000009029]]]>
</queryString>
<field name="value" class="java.lang.String">
<fieldDescription><![CDATA[creationDateTime]]></fieldDescription>
</field>
<pageHeader>
<band height="38"/>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="488" splitType="Stretch">
<componentElement>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="21" width="552" height="30" isRemoveLineWhenBlank="true" uuid="fc7d22c7-8c60-4ecb-974f-c842becc4bf7"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="pageHeader" uuid="1e20fa2b-bb3a-475f-b721-5a13d3c374eb">
<datasetParameter name="XML_DATE_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_DATE_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_NUMBER_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_NUMBER_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_LOCALE">
<datasetParameterExpression><![CDATA[$P{XML_LOCALE}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_TIME_ZONE">
<datasetParameterExpression><![CDATA[$P{XML_TIME_ZONE}]]></datasetParameterExpression>
</datasetParameter>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//*[entityIdentification=9000009029]/parent::*/seller")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30">
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="552" height="15" uuid="eac696b9-e20f-48a3-b70d-b186f5e649d6"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
</jasperReport>
My question is:
What should my dataSourceExpression in the componentElement be, so I can get the data out of it?
I also have some data in the invoice node that I need to show and thats why i set it like this in the query string. And I need to filter by the parameter that is stored inside of invoiceIdentification node.

How to apply PlanDefinition inorder to generate a carePlan

I am newbie to FHIR. Trying to create careplan by applying PlanDefinition/$apply. Are there any examples available so that I can take them as reference and generate careplan out of planDefintion.
I am able to post an planDefinition but I don't have any clue on implementing $apply out of it.
There is an implementation of PlanDefinition/$apply here:
https://github.com/DBCG/cqf-ruler/blob/master/r4/src/main/java/org/opencds/cqf/r4/providers/PlanDefinitionApplyProvider.java#L84
Note that there is in-progress work on that provider to make it more modular, but the logic is essentially the same.
Have a look at this example from the FHIR Wiki
Request: Apply the low suicide risk order set to patient 124
GET [base]/PlanDefinition/example/$apply?subject=Patient/124
Response: Returned on successful application of the order set
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<CarePlan xmlns="http://hl7.org/fhir">
<!-- This example demonstrates the result of an $apply operation for the citalopramPrescription activity definition. -->
<id value="apply-operation-response"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
Generated...
</div>
</text>
<contained>
<ServiceRequest>
<id value="referralrequest"/>
<status value="draft"/>
<intent value="proposal"/>
<code>
<coding>
<system value="http://snomed.info/sct"/>
<code value="306206005"/>
</coding>
<text value="Referral to service (procedure)"/>
</code>
<subject>
<reference value="Patient/124"/>
</subject>
<occurrenceDateTime value="2017-02-26T11:47:00.000Z"/>
<requester>
<reference value="Practitioner/123"/>
</requester>
<performerType>
<coding>
<system value="http://nucc.org/provider-taxonomy"/>
<code value="261QM0850X"/>
<display value="Adult Mental Health"/>
</coding>
</performerType>
<reasonCode>
<coding>
<system value="http://example.org/CodeSystem/suicide-risk-assessment-score"/>
<code value="Low"/>
<display value="Low Suicide Risk"/>
</coding>
<text value="Low Suicide Risk"/>
</reasonCode>
<reasonReference>
<reference value="RiskAssessment/suicide-risk-assessment"/>
</reasonReference>
</ServiceRequest>
</contained>
<contained>
<Medication>
<id value="citalopramMedication"/>
<code>
<coding>
<system value="http://www.nlm.nih.gov/research/umls/rxnorm"/>
<code value="200371"/>
</coding>
<text value="citalopram"/>
</code>
<form>
<coding>
<system value="http://snomed.info/sct"/>
<code value="385055001"/>
<display value="Tablet dose form"/>
</coding>
<text value="Tablet dose form"/>
</form>
<ingredient>
<itemReference>
<reference value="#citalopramSubstance"/>
</itemReference>
<amount>
<numerator>
<value value="20"/>
<unit value="mg"/>
</numerator>
<denominator>
<value value="1"/>
<unit value="{tbl}"/>
</denominator>
</amount>
</ingredient>
</Medication>
</contained>
<contained>
<Substance>
<id value="citalopramSubstance"/>
<code>
<coding>
<system value="http://www.nlm.nih.gov/research/umls/rxnorm"/>
<code value="2556"/>
</coding>
<text value="citalopram"/>
</code>
</Substance>
</contained>
<contained>
<MedicationRequest>
<id value="citalopramPrescription"/>
<status value="draft"/>
<intent value="proposal"/>
<medicationReference>
<reference value="#citalopramMedication"/>
</medicationReference>
<subject>
<reference value="Patient/124"/>
</subject>
<requester>
<reference value="Practitioner/123"/>
</requester>
<reasonCode>
<coding>
<system value="http://example.org/CodeSystem/suicide-risk-assessment-score"/>
<code value="Low"/>
<display value="Low Suicide Risk"/>
</coding>
<text value="Low Suicide Risk"/>
</reasonCode>
<reasonReference>
<reference value="RiskAssessment/suicide-risk-assessment"/>
</reasonReference>
<!--definition>
<reference value="ActivityDefinition/citalopramPrescription"/>
</definition-->
<instantiates value="ActivityDefinition/citalopramPrescription"/>
<dosageInstruction>
<text value="1 tablet oral 1 time daily"/>
<timing>
<repeat>
<frequency value="1"/>
<period value="1"/>
<periodUnit value="d"/>
</repeat>
</timing>
<route>
<coding>
<code value="26643006"/>
<display value="Oral route (qualifier value)"/>
</coding>
<text value="Oral route (qualifier value)"/>
</route>
<doseAndRate>
<type><text value="ordered"/></type>
<doseQuantity>
<value value="1"/>
<unit value="{tbl}"/>
</doseQuantity>
</doseAndRate>
</dosageInstruction>
<dispenseRequest>
<numberOfRepeatsAllowed value="3"/>
<quantity>
<value value="30"/>
<unit value="{tbl}"/>
</quantity>
</dispenseRequest>
</MedicationRequest>
</contained>
<instantiatesCanonical value="PlanDefinition/example"/>
<status value="draft"/>
<intent value="proposal"/>
<subject>
<reference value="Patient/124"/>
</subject>
<activity>
<reference>
<reference value="#referralrequest"/>
</reference>
</activity>
<activity>
<reference>
<reference value="#citalopramPrescription"/>
</reference>
</activity>
</CarePlan>
I am actively looking for the Plandefinition$apply operation usage or implementation.
as #code tutorial meny

Combine two queries using WSO2 ESB

I've been trying to figure out how to get WSO2's ESB to make calls to two different APIs and combine their results into a single response, and running into nothing but trouble. At its most basic, I've got two backends I'm making requests to that respond something like this:
http://example.com/items:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query name="items" xmlns="http://example.com/query">
<row>
<id>1</id>
<name>Item 1</name>
</row>
<row>
<id>2</id>
<name>Item 2</name>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
http://example.com/parts:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query name="parts" xmlns="http://example.com/query">
<row>
<id>1</id>
<part>Part 1.1</part>
</row>
<row>
<id>1</id>
<part>Part 1.2</part>
</row>
<row>
<id>1</id>
<part>Part 1.3</part>
</row>
<row>
<id>2</id>
<part>Part 2.1</part>
</row>
<row>
<id>2</id>
<part>Part 2.2</part>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
I'd like to request both of those, then combine their results to look something like this:
<items>
<item>
<id>1</id>
<name>Item 1</name>
<parts>
<part>
<id>1</id>
<name>Part 1.1</name>
</part>
<part>
<id>1</id>
<name>Part 1.2</name>
</part>
<part>
<id>1</id>
<name>Part 1.3</name>
</part>
</parts>
</item>
<item>
<id>2</id>
<name>Item 2</name>
<parts>
<part>
<id>2</id>
<name>Part 2.1</name>
</part>
<part>
<id>2</id>
<name>Part 2.2</name>
</part>
</parts>
</item>
</items>
Basically, every response from both APIs has a list of rows, each of which contains an id element. The ids in the call to /items are unique within that response, and each row in the response from parts has an id that ties it to a row from /items.
I've got the following API definition in the ESB:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/item_list" name="ItemList" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/">
<inSequence>
<header name="Content-Type" scope="transport" value="text/xml; charset=utf-8"/>
<clone>
<target>
<sequence>
<send>
<endpoint>
<address format="soap11" uri="http://example.com/items"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint>
<address format="soap11" uri="http://example.com/parts"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<aggregate>
<correlateOn expression="//*[name()='response']/*[name()='query']/*[name()='row']/*[name()='id']" />
<completeCondition>
<messageCount max="2" min="2"/>
</completeCondition>
<onComplete expression="//*[name()='response']/*[name()='query']/*[name()='row']">
<send/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence/>
</resource>
</api>
The inSequence here is heavily simplified, but it does send two valid queries and gets back the expected responses. The outSequence as it's written here never sends a response to the client or logs an error on the server. If I remove the correlateOn element from aggregate, I get back a single row, seemingly at random, from one of the two API calls. I think correlateOn is something I want to be using here, but I can't find any useful documentation on it from either WSO2 or Apache, so I'm sure I'm using it incorrectly. My XPath background is pretty weak, so I'm sure that expression could also use some work.
Am I at least on the right track here with the clone/aggregate pattern? How would I go about combining the results from these two queries into something similar to my example? If I can get something even sort of close, I should be able to do the rest with XSLT.
take a look at this demo:
Backend 1 with the items response:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="items"
transports="https http"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query xmlns="http://example.com/query" name="items">
<row>
<id>1</id>
<name>Item 1</name>
</row>
<row>
<id>2</id>
<name>Item 2</name>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
Backend 2 with the parts response:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="parts"
transports="https http"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query xmlns="http://example.com/query" name="parts">
<row>
<id>1</id>
<part>Part 1.1</part>
</row>
<row>
<id>1</id>
<part>Part 1.2</part>
</row>
<row>
<id>1</id>
<part>Part 1.3</part>
</row>
<row>
<id>2</id>
<part>Part 2.1</part>
</row>
<row>
<id>2</id>
<part>Part 2.2</part>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
My API calling backend 1 and backend 2 and transforming with xslt:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="ItemList"
context="/item_list">
<resource methods="POST" uri-template="/">
<inSequence>
<header name="Action" scope="default" value="urn:mediate"/>
<call>
<endpoint>
<address uri="http://localhost:8283/services/items.itemsHttpSoap11Endpoint"
format="soap11"/>
</endpoint>
</call>
<enrich>
<source type="inline" clone="true">
<Payloads/>
</source>
<target type="property" property="Items"/>
</enrich>
<enrich>
<source clone="true" xpath="$body/*"/>
<target action="child" xpath="$ctx:Items"/>
</enrich>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body/>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<call>
<endpoint>
<address uri="http://localhost:8283/services/parts.partsHttpSoap11Endpoint"
format="soap11"/>
</endpoint>
</call>
<enrich>
<source clone="true" xpath="$body/*[name()='response']/*[name()='query']"/>
<target type="property" property="Parts"/>
</enrich>
<enrich>
<source type="property" clone="true" property="Parts"/>
<target action="child" xpath="$ctx:Items"/>
</enrich>
<enrich>
<source type="property" property="Items"/>
<target type="body"/>
</enrich>
<xslt key="transformTwoSourcesToOneResult"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
And my xslt transformation:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="transformTwoSourcesToOneResult" xmlns="http://ws.apache.org/ns/synapse">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://example.com/query"
xmlns:ns1="http://example.com/response"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:exslt="http://exslt.org/common"
xmlns:saxon="http://saxon.sf.net/"
xmlns:syn="http://ws.apache.org/ns/synapse"
exclude-result-prefixes="ns0 ns1 xs">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_instance_Payloads" select="."/>
<items>
<xsl:for-each select="$var1_instance_Payloads/syn:Payloads">
<xsl:variable name="var2_Payloads" select="."/>
<xsl:for-each select="$var2_Payloads/ns1:response/ns0:query/ns0:row">
<xsl:variable name="var2_row" select="."/>
<item>
<id>
<xsl:value-of select="number(string($var2_row/ns0:id))"/>
</id>
<name>
<xsl:value-of select="string($var2_row/ns0:name)"/>
</name>
<parts>
<xsl:for-each select="$var2_Payloads/ns0:query/ns0:row">
<xsl:variable name="var4_row" select="."/>
<xsl:if test="string((number(string($var2_row/ns0:id)) = number(string($var4_row/ns0:id)))) != 'false'">
<part>
<id>
<xsl:value-of select="number(string($var4_row/ns0:id))"/>
</id>
<name>
<xsl:value-of select="string($var4_row/ns0:part)"/>
</name>
</part>
</xsl:if>
</xsl:for-each>
</parts>
</item>
</xsl:for-each>
</xsl:for-each>
</items>
</xsl:template>
</xsl:stylesheet>
</localEntry>
The API response:
<items xmlns="http://ws.apache.org/ns/synapse" xmlns:syn="http://ws.apache.org/ns/synapse" xmlns:saxon="http://saxon.sf.net/" xmlns:exslt="http://exslt.org/common">
<item>
<id>1</id>
<name>Item 1</name>
<parts>
<part>
<id>1</id>
<name>Part 1.1</name>
</part>
<part>
<id>1</id>
<name>Part 1.2</name>
</part>
<part>
<id>1</id>
<name>Part 1.3</name>
</part>
</parts>
</item>
<item>
<id>2</id>
<name>Item 2</name>
<parts>
<part>
<id>2</id>
<name>Part 2.1</name>
</part>
<part>
<id>2</id>
<name>Part 2.2</name>
</part>
</parts>
</item>
</items>

Resources