Survey Description

For the purposes of this database, a "survey" is a predefined packet of information that represents the opinions of a single human at a single moment in time. All surveys must be submitted on behalf of a specific client, using a dedicated clientId. You may only upload data that conforms to a predefined survey listed under 'Surveys' on the right side of this screen.


Connecting to the API

URL Endpoint: https://naatpdata.com/v2/api/surveys.php

  • This endpoint accepts an ARRAY of completed surveys.
  • A maximum of 100 surveys may be submitted per request. Please batch your posts and spread them out by a few seconds or more to prevent overwhelming the server.
  • V2 A FoRSE Demographic Information Form MUST be submitted and properly saved before submitting any other survey.
    • You may include this survey and other surveys in the same push as Demographic Forms are always processed first, regardless of order of submission.
  • V2 Every survey submission must include answers to all questions.
  • V2 If you do not have the answer to a question, and the question allows unanswered questions, then you must supply "Not Answered" as the answer. Empty strings and NULLs are no longer permitted.

Required Variables

Include a surveys variable, wherein each survey object must contain all of the following. Please note that these variables must NOT contain patient names, dates, Social Security Numbers, Insurance Ids, any other PHI, or any other ID which has any external relevance or can be used to re-identify a patient.

    • sessionId up to 128 characters: identifies this set of answers to this survey completed by this human on this day at this facilityId. Must be UNIQUE among all completed surveys in your entire facility.
      • Before committing your data to our database, we will look at the survey's sessionId and see if it is already in our database:
        • If the sessionId is found in our database, and your provided instrumentId and clientId DOES match our database, then all data found in the new survey data will overwrite the data in our database.
        • If the sessionId is found in our database, but your provided instrumentId and clientId DOES NOT match our database, then the new survey data will be completely rejected. No data will be updated in our database.
        • If a sessionId was not found, then the new survey will be added to our database.
    • clientId Up To 64 CASE SENSITIVE characters.
    • assignedToType Any of ( C | Client | R | Relative | P | Professional ). This tells us what type of individual took the survey. eg: It may have been a Relative on behalf of (or in reference to) the client.
    • instrumentId predefined id of the survey that was completed. (see 'Surveys' at right)
    • yearOfAdmit YYYY : the year the Client was admitted.
    • yearCompleted YYYY : the year this survey was completed.
    • V2 daysFromAdmit Number of whole days between the date of client admission and completion of this survey.
      • Allowed values are -99, and -14 to 3650.
      • 0 means this survey was completed on the same day as admit.
      • Use negative integers if completed up to 2 weeks before admit.
      • If completedWhile = postDischarge, this value MUST be -99.
    • V2 daysFromDischarge Number of whole days between the date of client discharge and completion of this survey.
      • Allowed values are -99, and -14 to 3650.
      • 0 means this survey was completed on the same day as Discharge.
      • Use negative integers if completed up to 2 weeks before Discharge.
      • If completedWhile = inTreatment, this value MUST be -99.
    • V2 completedWhile Any of ( inTreatment | postDischarge ). Was the survey completed while the client was still in treatment, or on-or-after discharge?
    • answerStyle byText or byValue: When sending us answers for multiple choice questions, are you sending us the pre-defined VALUE of the answer, or are you sending the exact TEXT?
      • byText: The answer you provide must match the text of one of our pre-defined answers. The answer must not contain any html or special characters. Note: answers are compared by converting the string to lower case and stripping all but alphanumeric characters.
      • byValue: the answer you provide must be the numeric VALUE of one of our pre-defined answers.
      • NOTE: Text-based answers will always be silently truncated down to 1024 characters.
      • NOTE: Multiple-choice answers may be delimited with the 'pipe' character. eg: "2|3|4" or "Red|Blue|Green"
      • V2 NOTE: Empty strings '' are always considered to be UNANSWERED. The entire survey will be rejected.
      • V2 NOTE: If a Q# is not supplied, it will be considered UNANSWERED. The entire survey will be rejected.
    • V2 Q1 Numeric Value or exact Text Answer(s) to Question 1 ( or "Not Answered" if allow_NotAnswered = 'y' ).
    • V2 Q2 Numeric Value or exact Text Answer(s) to Question 2 ( or "Not Answered" if allow_NotAnswered = 'y' ).
    • V2 Q...

javascript Postman pre-request script


const FACILITY_ID = 'ABCDEFG';
const SECRET_KEY = 'a1b.....x9z';

const apiDate = parseInt(new Date().getTime() / 1000).toString();
const apiSignature = CryptoJS.HmacSHA256(apiDate + FACILITY_ID, SECRET_KEY).toString();

pm.environment.set("facilityId", FACILITY_ID);
pm.environment.set("apiDate", apiDate);
pm.environment.set("apiSignature", apiSignature);

Sample Postman POST :: Body = raw :: JSON


{
  "facilityId": "{{facilityId}}",
  "apiDate": {{apiDate}},
  "apiSignature": "{{apiSignature}}",
  "surveys": [
    {
      "sessionId": "sesh1",
      "instrumentId": "H85M",
      "clientId": "a100",
      "assignedToType": "Client",
      "yearOfAdmit": "2019",
      "yearCompleted": "2019",
      "daysFromAdmit": 30,
      V2 "daysFromDischarge": -99,
      V2 "completedWhile": "inTreatment",
      "answerStyle": "byValue",
      "Q1": 0,
      "Q2": 1,
      "Q3": 2,
      "Q4": 3,
      "Q5": 1,
      "Q6": 3,
      "Q7": 0,
      "Q8": 1
    },
    {
      "sessionId": "sesh2",
      "instrumentId": "H85M",
      "clientId": "a101",
      "assignedToType": "Client",
      "yearOfAdmit": "2019",
      "yearCompleted": 2021,
      V2 "daysFromAdmit": -99,
      "daysFromDischarge": 180,
      V2 "completedWhile": "postDischarge",
      "answerStyle": "byText",
      "Q1": "Several days",
      "Q2": "More than half the days",
      "Q3": "Nearly every day",
      "Q4": "Not at all",
      "Q5": "Nearly every day",
      "Q6": "Nearly every day",
      "Q7": "Several days",
      "Q8": "Extremely difficult"
    }
  ]
}

Sample Reply from API

Responses will be a JSON array and always include status and status_msg:


[
    status: 'string', // success|fail
    status_msg: 'string',
    surveys: //Array of statuses for each survey uploaded.
        {
            "sessionId": "sesh1",
            "errors": [],
            "action": "INSERTED"
        },
        {
            "sessionId": "sesh2",
            "errors": [],
            "action": "INSERTED"
        }
]