Val Nav Integration Service Example

This document provides detail on the use of the new import API as well as using the existing APIs to run economic running a PowerShell script.

The high-level steps are:

  • Connecting to the integration service
  • Importing data
    • Wells and header data
    • Production forecast arrays
    • Capital costs
    • Operating costs (by proxy)
  • Retrieving the DB config for economics
  • Running economics
  • Retrieving database results (since there is no first-class API for this yet)

Setup

To set up the integration service

  1. Copy the Val Nav 2022 DB to a local location (e.g. D:\temp\). Click here to download.
  2. Install the Val Nav 2022 web service.
  3. Configure the service to point to the .vndb from step 1:
    1. Open C:\Program Files\Quorum Software\Value Navigator Integration Service 2022\Eni.ValueNavigator.IntegrationService.exe.config
    2. Change the value of the ProjectFilePath node to the full path to the vndb (e.g., <value>D:\temp\integration_service_2022.vndb</value>)
  4. Restart the service (via Task Manager > Services or services.msc).
  5. Test that the service is running and set up correctly by visiting the Swagger at http://localhost:8081/swagger/ui/index and checking the System call (/api/system)

Connecting to the Integration Service

In the script:

$sysResult = Invoke-restmethod -Uri "http://localhost:8081/api/system" -UseDefaultCredentials

This script issues a GET request to the /api/system endpoint in Setup step 5, and validates the result. If successfully connected, the script proceeds.

Note, this example is built using a .vndb which only has the default ‘admin’ user to avoid Active Directory auth and any NTML authentication. This will be required when using a .vndl.

Importing Data

The example database is empty of wells to begin with. It has a single custom field called ‘Area’ and a corresponding Area hierarchy defined:

The first step is to bring in wells and headers, including populating the Area hierarchy with two areas, Area A and Area B:

$csvBody = @"

UWI,Product List,Well Type,Area,Country,State/Province

Well A1,Oil,Oil,Area A,United States,Texas

Well A2,Oil,Oil,Area A,United States,Texas

Well B1,Oil,Oil,Area B,United States,Texas

Well B2,Oil,Oil,Area B,United States,Texas

Well B3,Oil,Oil,Area B,United States,Texas

"@

$importParams = @{

Import = $csvBody

DataArea = "Well Info and Custom Fields"

UpdateMode = "Merge"

Header = "1"

}

$importResult = Invoke-restmethod -Uri "http://localhost:8081/api/csvImport" -UseDefaultCredentials -Method "POST" -Body $importParams

After completing the first step, Val Nav successfully loaded the wells.

As large imports can take some time to process, the endpoint returns a job status ID, which you can poll until the import is complete.

The script continues with more imports, one data area at a time. Of note is the operating costs import, which does the import by proxy – it does not identify individual wells but just areas. In the CSV payload, see that the UWI is just ‘Area A’ and ‘Area B’, and the additional parameter (Proxy = “Proxy - Area”) in the request body.

$csvBody = @"

UWI,Plan,Reserves Category,Date,WI Fixed Op Cost,WI Variable Op Cost - Oil

Area A,Working,PUD,Jan 2023,3000,5

Area B,Working,PUD,Jan 2024,3500,4.5

"@

$importParams = @{

Import = $csvBody

DataArea = "Operating Costs"

UpdateMode = "ReplaceAll"

Header = "1"

Proxy = "Proxy - Area"

}

The same approach should be followed to import Production History or Production Forecast from 3rd Party tools.

At this point, the imports are complete. The next step is to automate an economic run for these wells.

Retrieving the DB Config for Economics

The next section of the script deals with obtaining the necessary information to run economics: hierarchy nodes, plans, reserves categories, and scenarios (or jurisdictions). Each of these has endpoints to retrieve the current database config. In this case we’re hard-coding Working - TP for the sole Reserves jurisdiction in the DB.

$jurisdiction = Invoke-restmethod -Uri "http://localhost:8081/api/jurisdiction" -UseDefaultCredentials

$plans = Invoke-restmethod -Uri "http://localhost:8081/api/plans" -UseDefaultCredentials

$working = $plans | Where-Object { $_.DisplayName -EQ 'Working' }

$rescats = Invoke-restmethod -Uri "http://localhost:8081/api/reserveCategory" -UseDefaultCredentials

$tp = $rescats | Where-Object { $_.Name -EQ 'TP' }

Running Economics

Val Nav will headlessly trigger an economics run for the Area A folder node.

We first compose the request payload, and then issue the calculate command to the /api/economic/calculate/hierarchy endpoint:

$areaAResult = Invoke-restmethod -Uri "http://localhost:8081/api/economic/calculate/hierarchy" -UseDefaultCredentials -Method "POST" -Body $econRunConfigString -ContentType 'application/json'

Like the imports, economics can be a long-running job, so we receive back a job ID which we can poll for completion status. When complete, the full economics run is finished, including well-level results, folder-level consolidations, and persistence of results into the database, ready for retrieval.

Retrieving Database Results

The integration service does not have an endpoint to serve back economics results. Instead, we’re going to reach into the database directly and retrieve some results.

First the script ensures it has access to SQLite (since our sample database is a .vndb file). If running on a system with Val Nav installed, the $runLocal flag tells it to use the installed SQLite DLL. If not, it can download the assembly direct from the SQLite webpage.

Once SQLite is ready, the script opens a connection to the DB. Then it loops through the well nodes provided by the hierarchy API endpoint and retrieves a before-tax cash flow for each (undiscounted and discounted) by querying BTAX_NET_REVENUE and BTAX_NPV3 from the RESULTS_SUMMARY table.

The output:

Well A1 BTCF: 154335.506377472

Well A1 NPV @ 10%: 137384.851758335

Well A2 BTCF: 171965.354389965

Well A2 NPV @ 10%: 153097.936602865

We can look in Val Nav at the results in a simple one-liner report. Because the results were already calculated, Val Nav won’t have any work to do beyond report rendering.