case_insert ()
Function prototype | case_insert ( session, case , subscription = null, allow_incomplete = false] ) |
---|---|
API Version | All The format of the response changed in version 2.7.12. See Response format prior to version 2.7.12 for additional information |
SOAP |
Description
Inserts a new CASE
When a new CASE is created, the default language assigned to the patient is the same that the language of the active session.
If the information provided for the new CASE corresponds unambiguously to another CASE already in the system, then that CASE will be used instead of creating a new one. The rules for checking the existence of a CASE with the same information are:
Any of the unique IDENTIFIER OBJECT (e.g. NAT_ES) provided for the CASE is already assigned to a CONTACT in the DB
Any of the preferred communication channels (email / phone) provided for the CASE is already assigned to a CONTACT in the DB
The username provided for the CASE is already assigned to a CONTACT in the DB
If more than one of the previous conditions is met, all of them must correspond to a single CONTACT. Otherwise an error will be returned indicating that there is a conflict with other existing CONTACTS and the CASE will not be created.
If more than one of the previous conditions is met and the birthdate and/or gender is provided in the CASE information, the CASE already stored in the DB must have the same birthdate/gender (or not have the fields informed). Otherwise an error will be returned indicating that there is a conflict with other existing CONTACTS and the CASE will not be created.
Required permissions: The active user must be a PROFESSIONAL
Input parameters: |
|
Output parameters: |
|
Request example
case_insert( “LCAAAAAAAAA”,
"<case>
<identifiers>
<identifier>
<label>NAT_ES</label>
<value>46114346J</value>
</identifier>
</identifiers>
<data>
<bdate>1992-05-30</bdate>
<gender>M</gender>
</data>
<name>
<given_name>Maria rosa</given_name>
<family_name>a</family_name>
</name>
<addresses>
<address>
<kind>Main Address</kind>
<address>Sepúlveda 7 3º 1ª</street>
<city>Barcelona</city>
<postcode />
<state />
<country>ES</country>
<comment />
</address>
</addresses>
<channels>
<phones>
<phone>
<type>mobile</type>
<value>+34934546365</value>
<comment />
</phone>
<phone>
<type>work</type>
<value>+34935555555</value>
<comment />
</phone>
</phones>
<emails>
<email>
<type>home</type>
<value>john.doe@linkcareapp.com</value>
<comment />
</email>
</emails>
</channels>
</case>");
Response
The response format is XML when the function has been invoked via the SOAP API, and JSON when it has been invoked via the REST API
Return Error codes
ERROR CODE |
|
---|---|
INVALID_TOKEN | The session token provided is not valid |
XML_ERROR | The information provided for creating the CASE does not have a valid XML format |
INSUFFICIENT_PRIVILEGES | The session user does not have the necessary privileges to execute this action |
CONTACT_DATA.VALIDATION | The information provided to validate the CASE is not valid |
Response format in version prior to version 2.7.12
The XML response generated in previous versions was the following
result: reference to the new CASE created or empty if any error occurred
type: ("NEW" / "EXIST") If the operation was successful, indicates whether a new CASE was created or a existing one that matched the information was used
ErrorMsg: any fault in the call, either in the validation of input parameters, errors in the connection to the database or any other error, this parameter returns the error message produced
ErrorCode: If any error occurs, then this value contains any of the standard ERROR CODES
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<result>case_id</result>
<type>NEW</type>
<ErrorMsg></ErrorMsg>