user_validate ()

user_validate ()

Function prototype

user_validate ( session, user, mode, team)

API VersionAll

Validate data of a user before create or update

If mode = new and there is already existent user in database function will return it's id.

Input

parameters:

  • session: is the token obtained in the session_init call
  • user: is a user XML object obtained from user_get_contact() call for example
  • mode: when user_validate was called: on creating new user (new) or on editing already existent (edit)
  • team: if is set will take setting for this team (FORMAT.USER or FORMAT.USER.NEW)

Output

parameters:

  • result: Structured information about the result of the validation.
  • ErrorMsg: if there is some problem with passed identifiers or channels (they are repeated in various patients or introduced identifier is different) will be returned error message.
  • ErrorCode: If any error occurs, then this value contains any of the standard ERROR CODES

Request

sample:

user_validate ( “LCAAAAAAAAA”,

<user>
   <ref />
   <name>
      <given_name />
      <middle_name />
      <family_name />
      <family_name2 />
   </name>
   <identifiers>
      <identifier>
         <label>NICKNAME</label>
         <value>pat001</value>
      </identifier>
      <identifier>
         <label>NAT_ES</label>
         <value />
      </identifier>
      <identifier>
         <label>PASS</label>
         <value />
      </identifier>
   </identifiers>
   <data>
      <age />
      <gender />
      <nationality_ref></nationality_ref>
      <status />
      <preferences>
         <password_expire />
      </preferences>
   </data>
   <channels>
      <emails>
         <email>
            <ref />
            <type>work</type>
            <value />
            <comment />
            <preferred>true</preferred>
         </email>
      </emails>
      <aims />
      <devices />
      <phones>
         <phone>
            <ref />
            <type>home</type>
            <value />
            <comment />
            <preferred>true</preferred>
         </phone>
         <phone>
            <ref />
            <type>work</type>
            <value />
            <comment />
            <preferred />
         </phone>
      </phones>
   </channels>
</user>

“, 'new', 1);

Response

sample:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<result>
  <user_validate>
    <validation>
      <errors>
        <field>
          <id>STUDY_REF</id>
          <name>Birthdate</name>
          <error>CONTACT_FIELD.CANT_BE_NULL</error>
          <description>can't be null</description>
        </field>
      </errors>
      <conflicts>
        <conflict>
          <name>Mary Doe</name>
          <gender>Female</gender>
          <birthdate>1968-03-12</birthdate>
          <age>52</age>
          <fields>
            <field>
              <id>CHANNEL.EMAIL</id>
              <name>e-mail</name>
              <value>marydoe@linkcare.es</value>
            </field>
          </fields>
        </conflict>
      </conflicts>
     </validation>
  </user_validate>
</result>
<ErrorMsg></ErrorMsg>

 Return Error codes

ERROR CODE

INVALID_TOKEN

The session token provided is not valid

INSUFFICIENT_PRIVILEGES

The session user does not have the necessary privileges to execute this action

USER.NOT_FOUND

The USER reference provided in XML data does not correspond to an existing USER

TEAM.NOT_FOUND

The TEAM reference provided does not correspond to a valid TEAM

PROGRAM.NOT_FOUNDThe PROGRAM reference provided does not correspond to a valid PROGRAM
CONTACT_DATA.VALIDATIONThe information provided to validate the CASE is not valid