1. SHAMEEM KAKKAD
  2. PowerBuilder
  3. Sunday, 20 February 2022 05:57 AM UTC

Hai All,

I have a Lab application which I created in powerbuilder - 2021. I want to send the Lab results with various method.

1. For outside clinic, they need the patient result with Lab Id number from my Database. Database working Lan network.

2. For Patient, they need result in whataspp.

How can manage this cases ?.

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Wednesday, 23 February 2022 06:41 AM UTC
  2. PowerBuilder
  3. # Permalink

Here is the code snippet [ for PHP, Slim Framework on server side ]

In routes.php

To fetch data

    $app->get('/tablename/connection', function (Request $request, Response $response)
    {
        $db = $this->get(PDO::class);
        $sql = "SELECT sendstatus FROM tablename";
        $exec_sql = $db->prepare($sql);
        $exec_sql->execute();

        $data = $exec_sql->fetchAll(PDO::FETCH_ASSOC);
        $data_encode = json_encode($data);
        $response->getBody()->write($data_encode);
        return $response->withHeader('Content-Type', 'application/json');
    }); 

To post data

    $app->post('/tablename/insertVehicleEnquiry', function (request $request, response $response)
    {
        $db = $this->get(PDO::class);
        $data = json_decode($data, true);
        $fieldpk = isset( data[0] ["fieldpk"] ) ? $data[0]["fieldpk"] : null ;
        $field1  = isset( $data[0]["field1"]  ) ? $data[0]["field1"]  : null ; 
        $query = "INSERT INTO tablename_header ( " ;
        $query = $query . "fieldpk)" ;
        $query = $query . "VALUES (" ;
        $query = $query . "'".$vehicleenquiryheaderpk_header."') ";

        $exec_sql = $db->prepare($query); 
         
        try
        {
           $exec_sql->execute();
           $recordcount_header_check = $recordcount_header_check + 1 ;
        }
        catch(PDOException $return_errorMessage)
        {
            $db->rollBack();
            $return_arr[] = array('return_status' => 400,
                                  'success_message' => '',
                                  'error_message' => $return_errorMessage->getMessage()
                                 ); 
           
            $data_encode = json_encode($return_arr);
            $data_encode = encrypt_decrypt('encrypt', $data_encode);
            $response->getBody()->write($data_encode);
            return $response->withHeader('Content-Type', 'application/json');
        }
        $db->commit();
        $return_arr[] = array('return_status' => 200,
                              'success_message' => 'Successful',
                              'error_message' => ''
                              ); 
        $data_encode = json_encode($return_arr);
        $data_encode = encrypt_decrypt('encrypt', $data_encode);
        $response->getBody()->write($data_encode);
        return $response->withHeader('Content-Type', 'application/json');
    ); 

I've simplified the server side code to a maximum extend.  For this, you need to go through Slim framework, IMO. 

HTH

 

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Sunday, 20 February 2022 15:33 PM UTC
  2. PowerBuilder
  3. # 1

Yes.

1.  Install webserver in one of your machines.  For local network, database server can be set as webserver.

2.  Write web application to return result in json format ( API).  Not only c#.net, one can use other server side languages also for this purpose, like PHP..  Personally I haven't used C# yet, so don't have any sample code with me.   Spending a day with PHP and some framework like Slim is enough to come out with workable codes.

3.  If you want php sample code, let me know.  I'll send once I reach office tomorrow.

Happiness Always

BKR Sivaprakash

 

Comment
  1. SHAMEEM KAKKAD
  2. Monday, 21 February 2022 11:26 AM UTC
Thank you for your reply....

If you don't mine, if you can provide it is too better....

  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Sunday, 20 February 2022 08:55 AM UTC
  2. PowerBuilder
  3. # 2

Hello,

1.  Create a API to fetch required data, given LabID, and send it in zipped, password protected JSON format.  Outside lab should have required software to read/parse those JSON and print it in required format.
2.  Subscribe with a service provider (like Twillo) to send the result to Patient's whatsapp number.  

HTH

Happiness Always
BKR Sivaprakash

 

Comment
  1. SHAMEEM KAKKAD
  2. Sunday, 20 February 2022 11:34 AM UTC
Thank you,

Have any example for how can create an API ?

I got a documentation which can create using Snap Develop... But I don't have any basic knowledge in Sanp...
  1. Helpful
  1. Sivaprakash BKR
  2. Monday, 21 February 2022 06:59 AM UTC
Btw, if it's local net (LAN), why one need to go with API? Doesn't a regular PB application do that work?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.