Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated documentation to reflect new "expand=order" option

This document includes the API calls that will be used to create an order based on Ideal Stock Amounts in OpenLMIS. This information will be used to generate the flows in Nifi for the demo.

...

  1. Get an access token for the divo1 user

    Credentials: divo1/password

    Code Block
    languagebash
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic dXNlci1jbGllbnQ6Y2hhbmdlbWU=' 'https://uat.openlmis.org/api/oauth/token?grant_type=password&username=divo1&password=password'


  2. Store the access_token that's returned and use it in other requests

    Code Block
    languagejava
    titleResponse
    {
      "access_token" : "1dfd46c9-c2d0-480d-9640-17ae1437833f",
      "token_type" : "bearer",
      "expires_in" : 1799,
      "scope" : "read write",
      "referenceDataUserId" : "560be32a-ea2e-4d12-ae00-1f69376ad535",
      "username" : "divo1"
    }


  3. Update the Order File with the appropriate information
    1. Sample File: test_order.json
    2. Fields:
      1. externalId - This should come from the OpenSRP event_ID
  4. Post the order to the /api/orders/ endpoint (Make sure to update the access_token)

    Code Block
    languagebash
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @test_order.json 'https://uat.openlmis.org/api/orders?access_token=1dfd46c9-c2d0-480d-9640-17ae1437833f'


  5. Sample Response: test_order_response.json
    Store the entire response. The returned "id" (i.e "id" = "1c4887a4-28d8-4984-ab5d-af008f9ca2b3") is used to query for the shipment. The response will be used later to map the shipped quantities against the order to peform business logic.
  6. Wait for the demonstrator to perform the following actions in OpenLMIS:
    1. View order
    2. Start Fulfillment
    3. Fulfill order and "Confirm Shipment"
    4. View Order again and show status = SHIPPED
  7. On a regular schedule every 30 seconds during the demo, Nifi will kick off a job to query for shipments
  8. Check if the access token has expired.

    Code Block
    languagebash
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic dXNlci1jbGllbnQ6Y2hhbmdlbWU=' 'https://demo-v3.openlmis.org/api/oauth/check_token?token=1dfd46c9-c2d0-480d-9640-17ae1437833f'


    1. If it has expired, (Response Code 400) get another access token using the steps in step 1 above

      Code Block
      languagebash
      title400 Response body
      {
        "error": "invalid_token",
        "error_description": "Token was not recognised"
      }


  9. Search for Shipments by orderId

    Code Block
    languagebash
    curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' 'https://uat.openlmis.org/api/shipments?orderId=83080768-7df2-4c54-a4fe-66961d9c327d&access_token=1dfd46c9-c2d0-480d-9640-17ae1437833f'


    1. If there aren't any results returned, stop the process.
  10. Parse the response and perform business logic on itExtract the "id"

    Code Block
    languagejava
    titleSample Response
    collapsetrue
    {
      "content" : [ {
        "id" : "132d10f7-1cba-486f-b637-3f0262439cce",
        "order" : {
          "id" : "83080768-7df2-4c54-a4fe-66961d9c327d",
          "href" : "https://uat.openlmis.org/api/orders/83080768-7df2-4c54-a4fe-66961d9c327d"
        },
        "shippedBy" : {
          "id" : "560be32a-ea2e-4d12-ae00-1f69376ad535",
          "href" : "https://uat.openlmis.org/api/users/560be32a-ea2e-4d12-ae00-1f69376ad535",
          "username" : null
        },
        "shippedDate" : "2018-02-23T23:47:47.311Z",
        "notes" : null,
        "lineItems" : [ {
          "id" : "8b651e95-04f2-4a7a-a95a-4d897bc8602b",
          "orderable" : {
            "id" : "9c3bea84-487b-4e22-8759-3fe93f8201d9",
            "href" : "https://uat.openlmis.org/api/orderables/9c3bea84-487b-4e22-8759-3fe93f8201d9"
          },
          "lot" : {
            "id" : "f08d3db1-9132-487c-ba58-15ea12302aee",
            "href" : "https://uat.openlmis.org/api/lots/f08d3db1-9132-487c-ba58-15ea12302aee"
          },
          "quantityShipped" : 2
        }, {
          "id" : "e4d4edc9-b566-4abb-bdd2-80e381891f36",
          "orderable" : {
            "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
            "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
          },
          "lot" : {
            "id" : "edd308be-dcdc-4841-be05-d577a668fd09",
            "href" : "https://uat.openlmis.org/api/lots/edd308be-dcdc-4841-be05-d577a668fd09"
          },
          "quantityShipped" : 10
        }, {
          "id" : "282ae0f7-96a8-4073-8929-211b52c2cc38",
          "orderable" : {
            "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
            "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
          },
          "lot" : {
            "id" : "f9f9bb7c-7636-40c1-a548-b45e918a512a",
            "href" : "https://uat.openlmis.org/api/lots/f9f9bb7c-7636-40c1-a548-b45e918a512a"
          },
          "quantityShipped" : 0
        }, {
          "id" : "ec353a1f-47be-44b5-af8b-2a5f96f0b374",
          "orderable" : {
            "id" : "9c3bea84-487b-4e22-8759-3fe93f8201d9",
            "href" : "https://uat.openlmis.org/api/orderables/9c3bea84-487b-4e22-8759-3fe93f8201d9"
          },
          "lot" : {
            "id" : "9d0cd7cb-5739-491b-8d6b-890fd17ec810",
            "href" : "https://uat.openlmis.org/api/lots/9d0cd7cb-5739-491b-8d6b-890fd17ec810"
          },
          "quantityShipped" : 1
        }, {
          "id" : "f8adabe6-67c1-4587-bae4-61ced1f00760",
          "orderable" : {
            "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
            "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
          },
          "lot" : {
            "id" : "06f86552-1aa9-47d6-8857-6b7ad824f805",
            "href" : "https://uat.openlmis.org/api/lots/06f86552-1aa9-47d6-8857-6b7ad824f805"
          },
          "quantityShipped" : 180
        }, {
          "id" : "b467f4d0-9d09-4ad4-839d-c0fad5251c13",
          "orderable" : {
            "id" : "7c58f053-0ca5-46ad-8209-98cff0c79b42",
            "href" : "https://uat.openlmis.org/api/orderables/7c58f053-0ca5-46ad-8209-98cff0c79b42"
          },
          "lot" : null,
          "quantityShipped" : 2
        }, {
          "id" : "2c612d5a-2ce8-439a-8ef3-5ee18a6ee42b",
          "orderable" : {
            "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
            "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
          },
          "lot" : null,
          "quantityShipped" : 0
        }, {
          "id" : "dedc1d81-e552-4dd7-bdd8-b3e752b71af3",
          "orderable" : {
            "id" : "a852f785-d82e-4afe-bc6a-04f3236caf90",
            "href" : "https://uat.openlmis.org/api/orderables/a852f785-d82e-4afe-bc6a-04f3236caf90"
          },
          "lot" : null,
          "quantityShipped" : 2
        }, {
          "id" : "fb89d4c1-984f-4d36-bc02-0aa6909d5044",
          "orderable" : {
            "id" : "b75a88c7-70fa-4bab-9785-3dd980a5ffc3",
            "href" : "https://uat.openlmis.org/api/orderables/b75a88c7-70fa-4bab-9785-3dd980a5ffc3"
          },
          "lot" : null,
          "quantityShipped" : 23
        } ],
        "extraData" : null
      } ],
      "last" : true,
      "totalElements" : 1,
      "totalPages" : 1,
      "sort" : null,
      "numberOfElements" : 1,
      "first" : true,
      "size" : 2000,
      "number" : 0
    }


  11. Query for the shipment with the "expand=order" request parameter to get the order and shipment details in a single response

    Code Block
    languagebash
    curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' 'https://uat.openlmis.org/api/shipments/{shipmentId}?access_token=1dfd46c9-c2d0-480d-9640-17ae1437833f&expand=order'


  12. Perform business logic on the response

    Code Block
    languagejs
    collapsetrue
    {
      "id" : "70c104f4-6531-49f8-b8c0-3a6fa1d3301c",
      "order" : {
        "externalId" : "131b00b9-2a7e-43c1-aead-bbd6b12b8540",
        "emergency" : false,
        "facility" : {
          "code" : "N007",
          "name" : "Lurio, Cuamba",
          "description" : null,
          "active" : true,
          "goLiveDate" : "2010-09-01",
          "goDownDate" : null,
          "comment" : null,
          "enabled" : true,
          "openLmisAccessible" : true,
          "supportedPrograms" : [ {
            "code" : "PRG004",
            "name" : "EPI",
            "description" : null,
            "active" : null,
            "periodsSkippable" : false,
            "showNonFullSupplyTab" : false,
            "supportLocallyFulfilled" : true,
            "id" : "418bdc1d-c303-4bd0-b2d3-d8901150a983"
          } ],
          "geographicZone" : {
            "code" : "cuamba",
            "name" : "Cuamba",
            "level" : {
              "code" : "District",
              "name" : null,
              "levelNumber" : 3,
              "id" : "93c05138-4550-4461-9e8a-79d5f050c223"
            },
            "parent" : {
              "code" : "niassa",
              "name" : "Niassa",
              "level" : {
                "code" : "Region",
                "name" : null,
                "levelNumber" : 2,
                "id" : "9b497d87-cdd9-400e-bb04-fae0bf6a9491"
              },
              "parent" : {
                "code" : "moz",
                "name" : "Mozambique",
                "level" : {
                  "code" : "Country",
                  "name" : null,
                  "levelNumber" : 1,
                  "id" : "6b78e6c6-292e-4733-bb9c-3d802ad61206"
                },
                "parent" : null,
                "id" : "d22d86fb-9123-437a-9eae-da2b31b77e34"
              },
              "id" : "0d4eb5ee-ae7f-42e7-89e1-d0f276090755"
            },
            "id" : "9b8cfb5a-217a-4261-a64f-16ca06ae79fa"
          },
          "operator" : {
            "code" : "moh",
            "name" : "Ministry of Health",
            "id" : "9456c3e9-c4a6-4a28-9e08-47ceb16a4121"
          },
          "type" : {
            "code" : "health_center",
            "name" : "Health Center",
            "description" : null,
            "displayOrder" : 2,
            "active" : true,
            "id" : "ac1d268b-ce10-455f-bf87-9c667da8f060"
          },
          "id" : "4774fc63-a0c8-4a29-a01d-5b6b48632175"
        },
        "processingPeriod" : {
          "processingSchedule" : {
            "code" : "SCH001",
            "description" : null,
            "modifiedDate" : null,
            "name" : "Monthly",
            "id" : "9c15bd6e-3f6b-4b91-b53a-36c199d35eac"
          },
          "name" : "Jan2017",
          "description" : null,
          "startDate" : "2017-01-01",
          "endDate" : "2017-01-31",
          "id" : "516ac930-0d28-49f5-a178-64764e22b236"
        },
        "createdDate" : "2018-03-12T15:39:36.577Z",
        "createdBy" : {
          "username" : "divo1",
          "firstName" : "Alan",
          "lastName" : "Ehrenfreund",
          "email" : "divo1@openlmis.org",
          "verified" : true,
          "active" : true,
          "loginRestricted" : false,
          "homeFacilityId" : "c62dea9b-6974-4101-ba39-b09914165967",
          "roleAssignments" : [ {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          }, {
            "role" : null,
            "user" : null,
            "id" : null
          } ],
          "id" : "560be32a-ea2e-4d12-ae00-1f69376ad535"
        },
        "program" : {
          "code" : "PRG004",
          "name" : "EPI",
          "description" : null,
          "active" : true,
          "periodsSkippable" : false,
          "showNonFullSupplyTab" : false,
          "supportLocallyFulfilled" : false,
          "id" : "418bdc1d-c303-4bd0-b2d3-d8901150a983"
        },
        "requestingFacility" : {
          "code" : "N007",
          "name" : "Lurio, Cuamba",
          "description" : null,
          "active" : true,
          "goLiveDate" : "2010-09-01",
          "goDownDate" : null,
          "comment" : null,
          "enabled" : true,
          "openLmisAccessible" : true,
          "supportedPrograms" : [ {
            "code" : "PRG004",
            "name" : "EPI",
            "description" : null,
            "active" : null,
            "periodsSkippable" : false,
            "showNonFullSupplyTab" : false,
            "supportLocallyFulfilled" : true,
            "id" : "418bdc1d-c303-4bd0-b2d3-d8901150a983"
          } ],
          "geographicZone" : {
            "code" : "cuamba",
            "name" : "Cuamba",
            "level" : {
              "code" : "District",
              "name" : null,
              "levelNumber" : 3,
              "id" : "93c05138-4550-4461-9e8a-79d5f050c223"
            },
            "parent" : {
              "code" : "niassa",
              "name" : "Niassa",
              "level" : {
                "code" : "Region",
                "name" : null,
                "levelNumber" : 2,
                "id" : "9b497d87-cdd9-400e-bb04-fae0bf6a9491"
              },
              "parent" : {
                "code" : "moz",
                "name" : "Mozambique",
                "level" : {
                  "code" : "Country",
                  "name" : null,
                  "levelNumber" : 1,
                  "id" : "6b78e6c6-292e-4733-bb9c-3d802ad61206"
                },
                "parent" : null,
                "id" : "d22d86fb-9123-437a-9eae-da2b31b77e34"
              },
              "id" : "0d4eb5ee-ae7f-42e7-89e1-d0f276090755"
            },
            "id" : "9b8cfb5a-217a-4261-a64f-16ca06ae79fa"
          },
          "operator" : {
            "code" : "moh",
            "name" : "Ministry of Health",
            "id" : "9456c3e9-c4a6-4a28-9e08-47ceb16a4121"
          },
          "type" : {
            "code" : "health_center",
            "name" : "Health Center",
            "description" : null,
            "displayOrder" : 2,
            "active" : true,
            "id" : "ac1d268b-ce10-455f-bf87-9c667da8f060"
          },
          "id" : "4774fc63-a0c8-4a29-a01d-5b6b48632175"
        },
        "receivingFacility" : {
          "code" : "N007",
          "name" : "Lurio, Cuamba",
          "description" : null,
          "active" : true,
          "goLiveDate" : "2010-09-01",
          "goDownDate" : null,
          "comment" : null,
          "enabled" : true,
          "openLmisAccessible" : true,
          "supportedPrograms" : [ {
            "code" : "PRG004",
            "name" : "EPI",
            "description" : null,
            "active" : null,
            "periodsSkippable" : false,
            "showNonFullSupplyTab" : false,
            "supportLocallyFulfilled" : true,
            "id" : "418bdc1d-c303-4bd0-b2d3-d8901150a983"
          } ],
          "geographicZone" : {
            "code" : "cuamba",
            "name" : "Cuamba",
            "level" : {
              "code" : "District",
              "name" : null,
              "levelNumber" : 3,
              "id" : "93c05138-4550-4461-9e8a-79d5f050c223"
            },
            "parent" : {
              "code" : "niassa",
              "name" : "Niassa",
              "level" : {
                "code" : "Region",
                "name" : null,
                "levelNumber" : 2,
                "id" : "9b497d87-cdd9-400e-bb04-fae0bf6a9491"
              },
              "parent" : {
                "code" : "moz",
                "name" : "Mozambique",
                "level" : {
                  "code" : "Country",
                  "name" : null,
                  "levelNumber" : 1,
                  "id" : "6b78e6c6-292e-4733-bb9c-3d802ad61206"
                },
                "parent" : null,
                "id" : "d22d86fb-9123-437a-9eae-da2b31b77e34"
              },
              "id" : "0d4eb5ee-ae7f-42e7-89e1-d0f276090755"
            },
            "id" : "9b8cfb5a-217a-4261-a64f-16ca06ae79fa"
          },
          "operator" : {
            "code" : "moh",
            "name" : "Ministry of Health",
            "id" : "9456c3e9-c4a6-4a28-9e08-47ceb16a4121"
          },
          "type" : {
            "code" : "health_center",
            "name" : "Health Center",
            "description" : null,
            "displayOrder" : 2,
            "active" : true,
            "id" : "ac1d268b-ce10-455f-bf87-9c667da8f060"
          },
          "id" : "4774fc63-a0c8-4a29-a01d-5b6b48632175"
        },
        "supplyingFacility" : {
          "code" : "D001",
          "name" : "Depósito Distrital Cuamba",
          "description" : null,
          "active" : true,
          "goLiveDate" : "2010-09-01",
          "goDownDate" : null,
          "comment" : null,
          "enabled" : true,
          "openLmisAccessible" : true,
          "supportedPrograms" : [ {
            "code" : "PRG004",
            "name" : "EPI",
            "description" : null,
            "active" : null,
            "periodsSkippable" : false,
            "showNonFullSupplyTab" : false,
            "supportLocallyFulfilled" : true,
            "id" : "418bdc1d-c303-4bd0-b2d3-d8901150a983"
          } ],
          "geographicZone" : {
            "code" : "cuamba",
            "name" : "Cuamba",
            "level" : {
              "code" : "District",
              "name" : null,
              "levelNumber" : 3,
              "id" : "93c05138-4550-4461-9e8a-79d5f050c223"
            },
            "parent" : {
              "code" : "niassa",
              "name" : "Niassa",
              "level" : {
                "code" : "Region",
                "name" : null,
                "levelNumber" : 2,
                "id" : "9b497d87-cdd9-400e-bb04-fae0bf6a9491"
              },
              "parent" : {
                "code" : "moz",
                "name" : "Mozambique",
                "level" : {
                  "code" : "Country",
                  "name" : null,
                  "levelNumber" : 1,
                  "id" : "6b78e6c6-292e-4733-bb9c-3d802ad61206"
                },
                "parent" : null,
                "id" : "d22d86fb-9123-437a-9eae-da2b31b77e34"
              },
              "id" : "0d4eb5ee-ae7f-42e7-89e1-d0f276090755"
            },
            "id" : "9b8cfb5a-217a-4261-a64f-16ca06ae79fa"
          },
          "operator" : {
            "code" : "moh",
            "name" : "Ministry of Health",
            "id" : "9456c3e9-c4a6-4a28-9e08-47ceb16a4121"
          },
          "type" : {
            "code" : "dist_store",
            "name" : "District Store",
            "description" : null,
            "displayOrder" : 4,
            "active" : true,
            "id" : "5fc213c6-1bd7-46f0-9883-57c05250ca90"
          },
          "id" : "c62dea9b-6974-4101-ba39-b09914165967"
        },
        "orderCode" : "ORDER-14PW5XVYR",
        "status" : "SHIPPED",
        "quotedCost" : 0.00,
        "orderLineItems" : [ {
          "id" : "d2802dbd-1404-4c95-b39c-034d2beb27c3",
          "orderable" : {
            "productCode" : "MRK-MEASLESDIL-10-1234",
            "fullProductName" : "MMR II Diluent (10 dose)",
            "netContent" : 10,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 20.00
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : null,
            "id" : "7c58f053-0ca5-46ad-8209-98cff0c79b42"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 100
        }, {
          "id" : "916000bd-43a6-400c-bf0b-aa832b3c3391",
          "orderable" : {
            "productCode" : "IVX-BCG-20-1234",
            "fullProductName" : "Intervax BCG (20 dose)",
            "netContent" : 20,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 12.00
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : {
              "useVVM" : "true"
            },
            "id" : "9c3bea84-487b-4e22-8759-3fe93f8201d9"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 200
        }, {
          "id" : "a6409bf8-1f4d-4aff-a84e-8a0c7cff0d80",
          "orderable" : {
            "productCode" : "MRK-ROTA-1-1234",
            "fullProductName" : "RotaTeq (1 dose)",
            "netContent" : 1,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 8.50
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : {
              "useVVM" : "true"
            },
            "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 10
        }, {
          "id" : "0adb0c19-c150-4250-906c-188936c3db9d",
          "orderable" : {
            "productCode" : "SII-PENTA-10-1234",
            "fullProductName" : "Pentavac PFS (10 dose)",
            "netContent" : 10,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 3.13
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : {
              "useVVM" : "true"
            },
            "id" : "a852f785-d82e-4afe-bc6a-04f3236caf90"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 100
        }, {
          "id" : "a5decde1-c5f4-4d2d-a72d-ed0e0148a80e",
          "orderable" : {
            "productCode" : "GSK-PCV10-2-1234",
            "fullProductName" : "Synflorix PCV10 (2 dose)",
            "netContent" : 2,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 4.60
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : {
              "useVVM" : "true"
            },
            "id" : "b75a88c7-70fa-4bab-9785-3dd980a5ffc3"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 20
        } ],
        "statusMessages" : [ ],
        "statusChanges" : [ ],
        "lastUpdater" : {
          "id" : "560be32a-ea2e-4d12-ae00-1f69376ad535",
          "href" : "https://uat.openlmis.org/api/users/560be32a-ea2e-4d12-ae00-1f69376ad535",
          "username" : null
        },
        "lastUpdatedDate" : "2018-03-12T15:41:49.493Z",
        "id" : "1305428f-5d49-43f8-b243-9fca765ee74c",
        "href" : "https://uat.openlmis.org/api/orders/1305428f-5d49-43f8-b243-9fca765ee74c"
      },
      "shippedBy" : {
        "id" : "560be32a-ea2e-4d12-ae00-1f69376ad535",
        "href" : "https://uat.openlmis.org/api/users/560be32a-ea2e-4d12-ae00-1f69376ad535",
        "username" : null
      },
      "shippedDate" : "2018-03-12T15:41:49.3Z",
      "notes" : null,
      "lineItems" : [ {
        "id" : "446c6a5f-6835-462c-9961-9d466e5dff8f",
        "orderable" : {
          "id" : "9c3bea84-487b-4e22-8759-3fe93f8201d9",
          "href" : "https://uat.openlmis.org/api/orderables/9c3bea84-487b-4e22-8759-3fe93f8201d9"
        },
        "lot" : {
          "id" : "f08d3db1-9132-487c-ba58-15ea12302aee",
          "href" : "https://uat.openlmis.org/api/lots/f08d3db1-9132-487c-ba58-15ea12302aee"
        },
        "quantityShipped" : 1
      }, {
        "id" : "63b46ed4-307d-47c6-ba9a-a39949efc4e1",
        "orderable" : {
          "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
          "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
        },
        "lot" : {
          "id" : "edd308be-dcdc-4841-be05-d577a668fd09",
          "href" : "https://uat.openlmis.org/api/lots/edd308be-dcdc-4841-be05-d577a668fd09"
        },
        "quantityShipped" : 1
      }, {
        "id" : "af8779c9-e31f-49d0-9e0a-e047552a3dba",
        "orderable" : {
          "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
          "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
        },
        "lot" : {
          "id" : "f9f9bb7c-7636-40c1-a548-b45e918a512a",
          "href" : "https://uat.openlmis.org/api/lots/f9f9bb7c-7636-40c1-a548-b45e918a512a"
        },
        "quantityShipped" : 0
      }, {
        "id" : "73dff27e-cdda-4caa-9972-7e82cb8705d9",
        "orderable" : {
          "id" : "9c3bea84-487b-4e22-8759-3fe93f8201d9",
          "href" : "https://uat.openlmis.org/api/orderables/9c3bea84-487b-4e22-8759-3fe93f8201d9"
        },
        "lot" : {
          "id" : "9d0cd7cb-5739-491b-8d6b-890fd17ec810",
          "href" : "https://uat.openlmis.org/api/lots/9d0cd7cb-5739-491b-8d6b-890fd17ec810"
        },
        "quantityShipped" : 0
      }, {
        "id" : "fe149f2e-e556-49bf-9a30-e5bc2e61a46b",
        "orderable" : {
          "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
          "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
        },
        "lot" : {
          "id" : "06f86552-1aa9-47d6-8857-6b7ad824f805",
          "href" : "https://uat.openlmis.org/api/lots/06f86552-1aa9-47d6-8857-6b7ad824f805"
        },
        "quantityShipped" : 0
      }, {
        "id" : "026a8493-8eb5-41cb-aa15-2ef5f4a59c2c",
        "orderable" : {
          "id" : "7c58f053-0ca5-46ad-8209-98cff0c79b42",
          "href" : "https://uat.openlmis.org/api/orderables/7c58f053-0ca5-46ad-8209-98cff0c79b42"
        },
        "lot" : null,
        "quantityShipped" : 1
      }, {
        "id" : "f3321b6a-f022-40ea-b69d-3b502f32ab74",
        "orderable" : {
          "id" : "047638fa-92ce-4adf-9bbd-3bcb3216897a",
          "href" : "https://uat.openlmis.org/api/orderables/047638fa-92ce-4adf-9bbd-3bcb3216897a"
        },
        "lot" : null,
        "quantityShipped" : 0
      }, {
        "id" : "9c8e4ea1-a9f7-4be6-9de9-d6a3e9677825",
        "orderable" : {
          "id" : "a852f785-d82e-4afe-bc6a-04f3236caf90",
          "href" : "https://uat.openlmis.org/api/orderables/a852f785-d82e-4afe-bc6a-04f3236caf90"
        },
        "lot" : null,
        "quantityShipped" : 1
      }, {
        "id" : "4329f0d5-8de8-4919-a63c-ab75e8fcfda8",
        "orderable" : {
          "id" : "b75a88c7-70fa-4bab-9785-3dd980a5ffc3",
          "href" : "https://uat.openlmis.org/api/orderables/b75a88c7-70fa-4bab-9785-3dd980a5ffc3"
        },
        "lot" : null,
        "quantityShipped" : 1
      } ],
      "extraData" : null
    }


    Business Logic:

    We need to perform business logic in Nifi to map the Shipment to list of orderables in OpenLMIS and then map the quantityShipped to the OpenSRP antigen Type. The flow should go:
    OpenLMIS Shipment Line Item → Order line item details → OpenSRP AntigenType
    1. For each line item in the shipment:
      1. Query the order by orderable "id"
      2. Extract the following information:
        1. productCode
        2. netContent
        3. orderedQuantity
      3. Append the shippedQuantity to this line item so we know how much was shipped
      4. Map the productCode against the OpenSRP AntigenType (mapping table below)

        Here's a mapping file by orderable name.

        Code Block
        languagetext
        titleOpenLMIS Orderable ProductCode | OpenSRP AntigenType Map
        "openlmisOrderableProductCode","opensrpAntigenType"
        "MRK-MEASLESDIL-10-1234","M/MR"
        "IVX-BCG-20-1234","BCG"
        "SII-PENTA-10-1234","Penta"
        "GSK-PCV10-2-1234","PCV"
        "MRK-ROTA-1-1234","Rota"

        This means that all orderables that are received in the shipment should be mapped to the associated opensrpAntigenType. We will use this information to post 
        Note: We do not currently have demo data for the "OPV" antigenType in OpenLMIS and have excluded it from the order.

    2. Calculate total orderedQuantity by opensrpAntigenType
      1. The OpenLMIS order has the ability to define lot numbers and to have multiple orderables of the same product code. In this instance, there are multiple BCG line items in the shipment, totaling 3 shipped line items of two different lot numbers. In order to do this, we need to map add the quantityShipped from the shipment by opensrpAntigen type.
      2. Calculations:
        1. For Each opensrpAntigenType
          1. shippedQuantity = shippedQuantity lineItem1 + shippedQuantity lineItem2...shippedQuantity lineItemn
    3. Generate the JSON to post to OpenSRP
      1. Here's the template to be posted to OpenSRP

        Code Block
        languagejava
        titleRaw OpenSRP template
        collapsetrue
        {
          "orderedDate": "",
          "orderCode": "",
          "shippedDate": ""
          "receivingFacility": {
            "code": "",
            "name": ""
          },
          "supplyingFacility": {
            "code": "",
            "name": ""
          },
          "processingPeriod": {
            "name": "",
            "startDate": "",
            "endDate": ""
          },
          "lineItems": [
            {
              "antigenType": "",
              "orderedQuantity": 0,
              "shippedQuantity": 0,
              "numDoses": 0
            }
          ]
        }


      2. Source information:
        1. orderedDate - This comes from the order's createdDate ("createdDate" : "2018-02-23T23:43:27.982Z")
        2. orderCode - This comes from the order's orderCode ("orderCode" : "ORDER-CVRNFHVWR",)
        3. shippedDate - This comes from the shipment's shippedDate ("shippedDate" : "2018-02-23T23:47:47.311Z")
        4. receivingFacility - This comes from the order's receivingFacility

          Code Block
          languagejava
          titleOrder ReceivingFacility
          "receivingFacility" : {
              "code" : "N007",
              "name" : "Lurio, Cuamba"


        5. supplyingFacility - This comes from the order's supplyingFacility

          Code Block
          languagejava
          titleOrder supplyingFacility
          "supplyingFacility" : {
              "code" : "D001",
              "name" : "Dep—sito Distrital Cuamba"


        6. processingPeriod - This comes from the order's processingPeriod

          Code Block
          languagejava
          titleorder processingPeriod
          "processingPeriod" : {
              "processingSchedule" : {
                "code" : "SCH001",
                "description" : null,
                "modifiedDate" : null,
                "name" : "Monthly",
                "id" : "9c15bd6e-3f6b-4b91-b53a-36c199d35eac"
              },
              "name" : "Jan2017",
              "description" : null,
              "startDate" : "2017-01-01",
              "endDate" : "2017-01-31"


        7. lineItems - Each of these line items are derrived from the order and shipment as previously mentioned.
    4. Link to completed sample: sample_opensrp_shipment.json
    5. Sample: Linking order information to shipment information
      The first block below is from the Order that was posted to OpenLMIS in the previous steps. The second block is from the Shipment. The shipment doesn't store information about the line items, so we need to extract specific information from the order to generate the information that needs to be posted to OpenSRP server. The link is the "id" field from the shipment (second code block below). That orderable id (line#4) "7c58f053-0ca5-46ad-8209-98cff0c79b42" directly relates to the order line item (first clode block line#24)

      Code Block
      languagejava
      titleorderLineItem
      linenumberstrue
      {
          "id" : "b103fc4c-c81f-4a92-abe7-724f85d5ed9e",
          "orderable" : {
            "productCode" : "MRK-MEASLESDIL-10-1234",
            "fullProductName" : "MMR II Diluent (10 dose)",
            "netContent" : 10,
            "packRoundingThreshold" : 1,
            "roundToZero" : true,
            "programs" : [ {
              "programId" : "418bdc1d-c303-4bd0-b2d3-d8901150a983",
              "orderableDisplayCategoryId" : "16173fd0-f439-4222-931e-91c413a495c3",
              "orderableCategoryDisplayName" : "Vaccines",
              "orderableCategoryDisplayOrder" : 5,
              "active" : true,
              "fullSupply" : true,
              "displayOrder" : 5,
              "dosesPerPatient" : 1,
              "pricePerPack" : 20.00
            } ],
            "dispensable" : {
              "dispensingUnit" : null
            },
            "extraData" : null,
            "id" : "7c58f053-0ca5-46ad-8209-98cff0c79b42"
          },
          "orderedQuantity" : 10,
          "totalDispensingUnits" : 100
        },


      Code Block
      languagejava
      titleShipment lineItem
      linenumberstrue
      {
          "id" : "bbe3c2f8-99ce-4e92-a35b-0be39b796f39",
          "orderable" : {
            "id" : "7c58f053-0ca5-46ad-8209-98cff0c79b42",
            "href" : "https://uat.openlmis.org/api/orderables/7c58f053-0ca5-46ad-8209-98cff0c79b42"
          },
          "lot" : null,
          "quantityShipped" : 1
          }


  13. Post this JSON to OpenSRP Server

    Code Block
    languagejava
    titleSample POST Shipment
    {
      "orderedDate": "2018-02-23T23:43:27.982Z",
      "orderCode": "ORDER-CVRNFHVWR",
      "shippedDate": "2018-02-23T23:47:47.311Z",
      "receivingFacility": {
        "code": "N007",
        "name": "Lurio, Cuamba"
      },
      "supplyingFacility": {
        "code": "D001",
        "name": "Dep—sito Distrital Cuamba"
      },
      "processingPeriod": {
        "name": "Jan2017",
        "startDate": "2017-01-01",
        "endDate": "2017-01-31"
      },
      "lineItems": [
        {
          "antigenType": "M/MR",
          "orderedQuantity": 10,
          "shippedQuantity": 2,
          "numDoses": 10
        },
    	{
          "antigenType": "BCG",
          "orderedQuantity": 10,
          "shippedQuantity": 3,
          "numDoses": 20
        },
    	{
          "antigenType": "Penta",
          "orderedQuantity": 10,
          "shippedQuantity": 2,
          "numDoses": 10
        },
    	{
          "antigenType": "PCV",
          "orderedQuantity": 10,
          "shippedQuantity": 23,
          "numDoses": 2
        },
    	{
          "antigenType": "Rota",
          "orderedQuantity": 10,
          "shippedQuantity": 190,
          "numDoses": 1
        }
      ]
    }


...

Target Program: EPI

Fulfilling Facility: Dep—sito Distrital Cuamba

Immunization products have been created in the EPI program with available stock on hand at the fulfilling facility

...