1698: For Requisition Template endpoints, add RAML and validation

Test Case #:284


Test Case Name: For Requisition Template endpoints, add RAML and validation

System: openLMIS

Subsystem: blue

Test case designed by: Lucyna Laska

Design Date:01.02.2017

Short description

(1) Add RAML Schemas so that the API Documentation includes the response example JSON and the POST/PUT example JSON. Currently there is nothing showing (screenshot attached).
(2) Verify/add validations on the Program when saving a Requisition Template (the POST or PUT endpoints listed above). We want to make sure the UUID for Program passed in actually exists, otherwise respond with a translate-able error Message.

                                                                                                                                                   

Pre – conditions:

                                                                                                                                                                                                                                                       

 

 

Step

Action

Expected system response

Comment

1

          Check if the proper validation is added for program during attempting the creation of Requisition Template.          

  • URL: api/requisitionTemplates
  • Method: POST
  • Body (wrong ID of program is provided):
    {
      "createdDate": "2016-06-14T12:00",
      "modifiedDate": null,
      "programId": "ece17f2e-af3e-40ad-8e00-3496adef44c3",
      "numberOfPeriodsToAverage": 2,
      "columnsMap": {
        "numberOfNewPatientsAdded": {
          "name": "numberOfNewPatientsAdded",
          "label": "Number of new patients added",
          "indicator": "F",
          "displayOrder": 18,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "5708ebf9-9317-4420-85aa-71b2ae92643d",
            "name": "numberOfNewPatientsAdded",
            "sources": [
              "USER_INPUT"
            ],
            "options": [
              {
                "id": "34b8e763-71a0-41f1-86b4-1829963f0704",
                "optionName": "newPatientCount",
                "optionLabel": "New patient count"
              },
              {
                "id": "4957ebb4-297c-459e-a291-812e72286eff",
                "optionName": "dispensingUnitsForNewPatients",
                "optionLabel": "Dispensing units for new patients"
              }
            ],
            "label": "Number of new patients added",
            "indicator": "F",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "New patients data.",
            "columnType": "NUMERIC"
          },
          "option": {
            "id": "34b8e763-71a0-41f1-86b4-1829963f0704",
            "optionName": "newPatientCount",
            "optionLabel": "New patient count"
          },
          "definition": "New patients data."
        },
        "adjustedConsumption": {
          "name": "adjustedConsumption",
          "label": "Adjusted consumption",
          "indicator": "N",
          "displayOrder": 20,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "720dd95b-b765-4afb-b7f2-7b22261c32f3",
            "name": "adjustedConsumption",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Adjusted consumption",
            "indicator": "N",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total consumed quantity after adjusting for stockout days. Quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total consumed quantity after adjusting for stockout days. Quantified in dispensing units."
        },
        "beginningBalance": {
          "name": "beginningBalance",
          "label": "Beginning balance",
          "indicator": "A",
          "displayOrder": 4,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "33b2d2e9-3167-46b0-95d4-1295be9afc22",
            "name": "beginningBalance",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Beginning balance",
            "indicator": "A",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Based on the Stock On Hand from the previous period. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Based on the Stock On Hand from the previous period. This is quantified in dispensing units."
        },
        "dispensingUnit": {
          "name": "orderable.dispensable.dispensingUnit",
          "label": "Unit/unit of issue",
          "indicator": "U",
          "displayOrder": 15,
          "isDisplayed": true,
          "source": "REFERENCE_DATA",
          "columnDefinition": {
            "id": "61e6d059-10ef-40c4-a6e3-fa7b9ad741ec",
            "name": "dispensingUnit",
            "sources": [
              "REFERENCE_DATA"
            ],
            "options": [],
            "label": "Unit/unit of issue",
            "indicator": "U",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Dispensing unit for this product.",
            "columnType": "TEXT"
          },
          "option": null,
          "definition": "Dispensing unit for this product."
        },
        "totalLossesAndAdjustments": {
          "name": "totalLossesAndAdjustments",
          "label": "Total losses and adjustments",
          "indicator": "D",
          "displayOrder": 7,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "cd57f329-f549-4717-882e-ecbf98122c38",
            "name": "totalLossesAndAdjustments",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Total losses and adjustments",
            "indicator": "D",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "All kind of losses/adjustments made at the facility.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "All kind of losses/adjustments made at the facility."
        },
        "totalStockoutDays": {
          "name": "totalStockoutDays",
          "label": "Total stockout days",
          "indicator": "X",
          "displayOrder": 13,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "750b9359-c097-4612-8328-d21671f88920",
            "name": "totalStockoutDays",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Total stockout days",
            "indicator": "X",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total number of days facility was out of stock.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total number of days facility was out of stock."
        },
        "packsToShip": {
          "name": "packsToShip",
          "label": "Packs to ship",
          "indicator": "V",
          "displayOrder": 16,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "dc9dde56-593d-4929-81be-d1faec7025a8",
            "name": "packsToShip",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Packs to ship",
            "indicator": "V",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total packs to be shipped based on pack size and applying rounding rules.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total packs to be shipped based on pack size and applying rounding rules."
        },
        "productName": {
          "name": "orderable.name",
          "label": "Product",
          "indicator": "R",
          "displayOrder": 3,
          "isDisplayed": true,
          "source": "REFERENCE_DATA",
          "columnDefinition": {
            "id": "e53e80de-fc63-4ecb-b6b2-ef376b34c926",
            "name": "productName",
            "sources": [
              "REFERENCE_DATA"
            ],
            "options": [],
            "label": "Product",
            "indicator": "R",
            "mandatory": false,
            "isDisplayRequired": true,
            "canChangeOrder": false,
            "canBeChangedByUser": false,
            "definition": "Primary name of the product.",
            "columnType": "TEXT"
          },
          "option": null,
          "definition": "Primary name of the product."
        },
        "totalReceivedQuantity": {
          "name": "totalReceivedQuantity",
          "label": "Total received quantity",
          "indicator": "B",
          "displayOrder": 5,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "5ba8b72d-277a-4da8-b10a-23f0cda23cb4",
            "name": "totalReceivedQuantity",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Total received quantity",
            "indicator": "B",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total quantity received in the reporting period. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total quantity received in the reporting period. This is quantified in dispensing units."
        },
        "approvedQuantity": {
          "name": "approvedQuantity",
          "label": "Approved quantity",
          "indicator": "K",
          "displayOrder": 11,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "a62a5fed-c0b6-4d49-8a96-c631da0d0113",
            "name": "approvedQuantity",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Approved quantity",
            "indicator": "K",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Final approved quantity. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Final approved quantity. This is quantified in dispensing units."
        },
        "skipped": {
          "name": "skipped",
          "label": "Skip",
          "indicator": "S",
          "displayOrder": 1,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "c6dffdee-3813-40d9-8737-f531d5adf420",
            "name": "skipped",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "skipped",
            "indicator": "S",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": false,
            "canBeChangedByUser": false,
            "definition": null,
            "columnType": "BOOLEAN"
          },
          "option": null,
          "definition": null
        },
        "total": {
          "name": "total",
          "label": "Total",
          "indicator": "Y",
          "displayOrder": 14,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "ef524868-9d0a-11e6-80f5-76304dec7eb7",
            "name": "total",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Total",
            "indicator": "Y",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total of beginning balance and quantity received.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total of beginning balance and quantity received."
        },
        "productCode": {
          "name": "orderable.productCode",
          "label": "Product code",
          "indicator": "O",
          "displayOrder": 2,
          "isDisplayed": true,
          "source": "REFERENCE_DATA",
          "columnDefinition": {
            "id": "bde01507-3837-47b7-ae08-cec92c0c3cd2",
            "name": "productCode",
            "sources": [
              "REFERENCE_DATA"
            ],
            "options": [],
            "label": "Product code",
            "indicator": "O",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": false,
            "canBeChangedByUser": false,
            "definition": "Unique identifier for each commodity/product.",
            "columnType": "TEXT"
          },
          "option": null,
          "definition": "Unique identifier for each commodity/product."
        },
        "totalConsumedQuantity": {
          "name": "totalConsumedQuantity",
          "label": "Total consumed quantity",
          "indicator": "C",
          "displayOrder": 6,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "9e825396-269d-4873-baa4-89054e2722f4",
            "name": "totalConsumedQuantity",
            "sources": [
              "CALCULATED",
              "USER_INPUT"
            ],
            "options": [],
            "label": "Total consumed quantity",
            "indicator": "C",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Quantity dispensed/consumed in the reporting period. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Quantity dispensed/consumed in the reporting period. This is quantified in dispensing units."
        },
        "pricePerPack": {
          "name": "pricePerPack",
          "label": "Price per pack",
          "indicator": "T",
          "displayOrder": 17,
          "isDisplayed": true,
          "source": "REFERENCE_DATA",
          "columnDefinition": {
            "id": "df524868-9d0a-18e6-80f5-76304ded7ab9",
            "name": "pricePerPack",
            "sources": [
              "REFERENCE_DATA"
            ],
            "options": [],
            "label": "Price per pack",
            "indicator": "T",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Price per pack. Will be blank if price is not defined.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Price per pack. Will be blank if price is not defined."
        },
        "requestedQuantity": {
          "name": "requestedQuantity",
          "label": "Requested quantity",
          "indicator": "J",
          "displayOrder": 9,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "4a2e9fd3-1127-4b68-9912-84a5c00f6999",
            "name": "requestedQuantity",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Requested quantity",
            "indicator": "J",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Requested override of calculated quantity. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Requested override of calculated quantity. This is quantified in dispensing units."
        },
        "stockOnHand": {
          "name": "stockOnHand",
          "label": "Stock on hand",
          "indicator": "E",
          "displayOrder": 8,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "752cda76-0db5-4b6e-bb79-0f531ab78e2c",
            "name": "stockOnHand",
            "sources": [
              "CALCULATED",
              "USER_INPUT"
            ],
            "options": [],
            "label": "Stock on hand",
            "indicator": "E",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Current physical count of stock on hand. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Current physical count of stock on hand. This is quantified in dispensing units."
        },
        "requestedQuantityExplanation": {
          "name": "requestedQuantityExplanation",
          "label": "Requested quantity explanation",
          "indicator": "W",
          "displayOrder": 10,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "6b8d331b-a0dd-4a1f-aafb-40e6a72ab9f5",
            "name": "requestedQuantityExplanation",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Requested quantity explanation",
            "indicator": "W",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Explanation of request for a quantity other than calculated order quantity.",
            "columnType": "TEXT"
          },
          "option": null,
          "definition": "Explanation of request for a quantity other than calculated order quantity."
        },
        "averageConsumption": {
          "name": "averageConsumption",
          "label": "Average consumption",
          "indicator": "P",
          "displayOrder": 21,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "89113ec3-40e9-4d81-9516-b56adba7f8cd",
            "name": "averageConsumption",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Average consumption",
            "indicator": "P",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Average consumption over a specified number of periods/months. Quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Average consumption over a specified number of periods/months. Quantified in dispensing units."
        },
        "calculatedOrderQuantity": {
          "name": "calculatedOrderQuantity",
          "label": "Calculated order quantity",
          "indicator": "I",
          "displayOrder": 23,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "5528576b-b1e7-48d9-bf32-fd0eefefaa9a",
            "name": "calculatedOrderQuantity",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Calculated order quantity",
            "indicator": "I",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Actual quantity needed after deducting stock in hand. This is quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Actual quantity needed after deducting stock in hand. This is quantified in dispensing units."
        },
        "remarks": {
          "name": "remarks",
          "label": "Remarks",
          "indicator": "L",
          "displayOrder": 12,
          "isDisplayed": true,
          "source": "USER_INPUT",
          "columnDefinition": {
            "id": "2ed8c74a-f424-4742-bd14-cfbe67b6e7be",
            "name": "remarks",
            "sources": [
              "USER_INPUT"
            ],
            "options": [],
            "label": "Remarks",
            "indicator": "L",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Any additional remarks.",
            "columnType": "TEXT"
          },
          "option": null,
          "definition": "Any additional remarks."
        },
        "totalCost": {
          "name": "totalCost",
          "label": "Total cost",
          "indicator": "Q",
          "displayOrder": 19,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "e3a0c1fc-c2d5-11e6-af2d-3417eb83144e",
            "name": "pricePerPack",
            "sources": [
              "CALCULATED"
            ],
            "options": [],
            "label": "Total cost",
            "indicator": "Q",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Total cost of the product based on quantity requested. Will be blank if price is not defined.",
            "columnType": "NUMERIC"
          },
          "option": null,
          "definition": "Total cost of the product based on quantity requested. Will be blank if price is not defined."
        },
        "maximumStockQuantity": {
          "name": "maximumStockQuantity",
          "label": "Maximum stock quantity",
          "indicator": "H",
          "displayOrder": 22,
          "isDisplayed": true,
          "source": "CALCULATED",
          "columnDefinition": {
            "id": "913e1a4f-f3b0-40c6-a422-2f73608c6f3d",
            "name": "maximumStockQuantity",
            "sources": [
              "CALCULATED"
            ],
            "options": [
              {
                "id": "ff2b350c-37f2-4801-b21e-27ca12c12b3c",
                "optionName": "default",
                "optionLabel": "Default"
              }
            ],
            "label": "Maximum stock quantity",
            "indicator": "H",
            "mandatory": false,
            "isDisplayRequired": false,
            "canChangeOrder": true,
            "canBeChangedByUser": false,
            "definition": "Maximum stock calculated based on consumption and max stock amounts. Quantified in dispensing units.",
            "columnType": "NUMERIC"
          },
          "option": {
            "id": "ff2b350c-37f2-4801-b21e-27ca12c12b3c",
            "optionName": "default",
            "optionLabel": "Default"
          },
          "definition": "Maximum stock calculated based on consumption and max stock amounts. Quantified in dispensing units."
        }
      }
    }

                                                                                                                            

The requisition Template cannot be updated  because of the wrong programID which does not exist.

                                                 

2

 

Check if the proper validation is added for program when Requisition Template is updated.

  • URL: api/requisitionTemplates/id
    • Method: PUT
    • Body (wrong ID of program is provided).


Note: use the json from above and add the id (example id:  "id": "5a268780-fafd-4243-9551-5c7daa824913")

 

The requisition Template cannot be updated because of the wrong programID which does not exist.

 

3

  

 

4

  

 

5

   

6

  

 

7

  

 

8

                                                 

 

 

 

Post – conditions:

OpenLMIS: the global initiative for powerful LMIS software