Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ESB-Artifacts/QuickStartGuide/artifacts/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ curl -v -X POST "http://localhost:8280/services/ReserveAppointmentProxy" --heade
"category": "surgery"
},
"Payment": {
"patient": "Nadeeshaan Gunasinghe",
"patient": "Mark Smith",
"actualFee": 7000,
"discount": 20,
"discounted": 5600,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@
<artifact name="faultSequence" groupId="com.example.WSO2QuickStartGuide.sequence" version="1.0.0" type="synapse/sequence" serverRole="EnterpriseServiceBus">
<file>src/main/synapse-config/sequences/faultSequence.xml</file>
</artifact>
<artifact name="HospitalServiceApi" groupId="com.example.WSO2QuickStartGuide.api" version="1.0.0" type="synapse/api" serverRole="EnterpriseServiceBus">
<file>src/main/synapse-config/api/HospitalServiceApi.xml</file>
</artifact>
<artifact name="APIInSequence" groupId="com.example.WSO2QuickStartGuide.sequence" version="1.0.0" type="synapse/sequence" serverRole="EnterpriseServiceBus">
<file>src/main/synapse-config/sequences/APIInSequence.xml</file>
</artifact>
</artifacts>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<name>WSO2QuickStartGuide</name>
<description>WSO2QuickStartGuide</description>
<properties>
<maven.test.skip>false</maven.test.skip>
<CApp.type>bpel/workflow=zip,lib/registry/filter=jar,webapp/jaxws=war,lib/library/bundle=jar,service/dataservice=dbs,synapse/local-entry=xml,synapse/proxy-service=xml,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,lib/carbon/ui=jar,service/axis2=aar,synapse/sequence=xml,synapse/configuration=xml,wso2/gadget=dar,lib/registry/handlers=jar,lib/synapse/mediator=jar,synapse/task=xml,synapse/api=xml,synapse/template=xml,synapse/message-store=xml,synapse/message-processors=xml,synapse/inbound-endpoint=xml</CApp.type>
<maven.test.skip>false</maven.test.skip>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -163,6 +163,26 @@
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-api-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>api</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<configuration />
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<api context="/hospitalservice" name="HospitalServiceApi" xmlns="http://ws.apache.org/ns/synapse">
<resource faultSequence="faultSequence" inSequence="APIInSequence" methods="POST" url-mapping="/reserve">
<outSequence/>
</resource>
</api>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="channellingFee" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="http://localhost:8080/hospital/categories/appointments/{uri.var.appointment_id}/fee"/>
<http method="get" uri-template="http://localhost:8080/{uri.var.hospital.name}/categories/appointments/{uri.var.appointment_id}/fee"/>
</endpoint>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="discountEligibility" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="http://localhost:8080/hospital/categories/patient/appointment/{uri.var.appointment_id}/discount"/>
<http method="get" uri-template="http://localhost:8080/{uri.var.hospital.name}/categories/patient/appointment/{uri.var.appointment_id}/discount"/>
</endpoint>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="getPaymentDetails" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="http://localhost:8081/healthcare/payments/payment/{uri.var.payment_id}"/>
<http method="get" uri-template="http://localhost:8080/healthcare/payments/payment/{uri.var.payment_id}"/>
</endpoint>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="reserveAppointmentEp" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="http://localhost:8080/hospital/categories/{uri.var.category}/reserve"/>
<http method="post" uri-template="http://localhost:8080/{uri.var.hospital.name}/categories/{uri.var.category}/reserve"/>
</endpoint>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="settlePayment" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="http://localhost:8081/healthcare/payments"/>
<http method="post" uri-template="http://localhost:8080/healthcare/payments"/>
</endpoint>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<proxy name="ReserveAppointmentProxy" startOnLoad="true" statistics="enable" trace="enable" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target faultSequence="faultSequence">
<inSequence>
<!-- it is possible to assign the result of an XPath or JSON Path expression as well -->
<!-- the property mediator sets a local property on the *current* message -->
<log level="full">
<property name="StartFlow" value="Starting the Flow"/>
</log>
<property expression="json-eval($.reserveRequest.category)" name="uri.var.category" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.patientDetails.dob)" name="dob" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.cardNo)" name="card_num" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.hospital)" name="hospital_name" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{
"patient":{
Expand All @@ -32,6 +35,29 @@
<arg evaluator="json" expression="$.reserveRequest.hospital"/>
</args>
</payloadFactory>
<switch source="$ctx:hospital_name">
<case regex="grand oak community hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="grandoaks"/>
</case>
<case regex="clemency medical center">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="clemency"/>
</case>
<case regex="pine valley community hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="pinevalley"/>
</case>
<case regex="willow gardens general hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="willowogardens"/>
</case>
<default>
<payloadFactory media-type="json">
<format>{
"Status":"Invalid Hospital Name"
}</format>
<args/>
</payloadFactory>
<respond/>
</default>
</switch>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property name="ContentType" scope="axis2" type="STRING" value="application/json"/>
<log level="full"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="APIInSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="StartFlow" value="Starting the Flow"/>
</log>
<property expression="json-eval($.reserveRequest.category)" name="uri.var.category" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.patientDetails.dob)" name="dob" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.cardNo)" name="card_num" scope="default" type="STRING"/>
<property expression="json-eval($.reserveRequest.hospital)" name="hospital_name" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{
"patient":{
"name": "$1",
"dob":"$2",
"ssn": "$3",
"address": "$4",
"phone":"$5",
"email": "$6"
},
"doctor": "$7",
"hospital": "$8"
}</format>
<args>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.name"/>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.dob"/>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.ssn"/>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.address"/>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.phone"/>
<arg evaluator="json" expression="$.reserveRequest.patientDetails.email"/>
<arg evaluator="json" expression="$.reserveRequest.doctor"/>
<arg evaluator="json" expression="$.reserveRequest.hospital"/>
</args>
</payloadFactory>
<switch source="$ctx:hospital_name">
<case regex="grand oak community hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="grandoaks"/>
</case>
<case regex="clemency medical center">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="clemency"/>
</case>
<case regex="pine valley community hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="pinevalley"/>
</case>
<case regex="willow gardens general hospital">
<property name="uri.var.hospital.name" scope="default" type="STRING" value="willowogardens"/>
</case>
<default>
<payloadFactory media-type="json">
<format>{
"Status":"Invalid Hospital Name"
}</format>
<args/>
</payloadFactory>
<respond/>
</default>
</switch>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property name="ContentType" scope="axis2" type="STRING" value="application/json"/>
<log level="full"/>
<!-- Send request to reserve an appointment-->
<call>
<endpoint key="reserveAppointmentEp"/>
</call>
<filter regex="^[A-Za-z].*" source="json-eval($.status)">
<then>
<respond/>
</then>
<else/>
</filter>
<log level="full"/>
<property expression="json-eval($.appointmentNumber)" name="uri.var.appointment_id" scope="default" type="STRING"/>
<property expression="json-eval($.doctor)" name="doctorObj" scope="default" type="STRING"/>
<property expression="json-eval($.patient)" name="patientObj" scope="default" type="STRING"/>
<call>
<endpoint key="channellingFee"/>
</call>
<log level="full"/>
<property expression="json-eval($.actualFee)" name="channellingFee" scope="default" type="STRING"/>
<call>
<endpoint key="discountEligibility"/>
</call>
<log level="full"/>
<property expression="json-eval($.status)" name="status" scope="default" type="STRING"/>
<script language="js"><![CDATA[var status = mc.getProperty("status");
var discount = 0;
var actualFee = mc.getProperty("channellingFee");
var patientDob = mc.getProperty("dob");
var dobComponents = patientDob.split("-");
var yob = dobComponents[0];
var cur_date = new Date();
var current_year = cur_date.getFullYear();
var age = current_year-yob
if(status=="true") {
if(age<12) {
discount=15;
} else if(age>55) {
discount=20;
}

}
var discountedFee = actualFee*((100-discount)/100);
mc.setProperty("discountedFee",discountedFee);]]></script>
<payloadFactory media-type="json">
<format>{
"appointmentNumber":$1,
"doctor":$2,
"patient":$3,
"fee":$4,
"confirmed":"false",
"card_number":"$5"
}</format>
<args>
<arg evaluator="xml" expression="$ctx:uri.var.appointment_id"/>
<arg evaluator="xml" expression="$ctx:doctorObj"/>
<arg evaluator="xml" expression="$ctx:patientObj"/>
<arg evaluator="xml" expression="$ctx:discountedFee"/>
<arg evaluator="xml" expression="$ctx:card_num"/>
</args>
</payloadFactory>
<log level="full"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<call>
<endpoint key="settlePayment"/>
</call>
<log level="full">
<property name="EndOfFlow" value="Final Response Received from Backend "/>
</log>
<payloadFactory media-type="json">
<format>{
"appointmentNumber":$1,
"Doctor":$2,
"Payment":$3
}</format>
<args>
<arg evaluator="xml" expression="$ctx:uri.var.appointment_id"/>
<arg evaluator="xml" expression="$ctx:doctorObj"/>
<arg evaluator="json" expression="$."/>
</args>
</payloadFactory>
<log level="full"/>
<respond/>
</sequence>