openapi: 3.0.0
info:
  title: ""
  description: Used to interact with the Medical Information Cloud Inquiry Management module.
  version: v1.0.0
servers:
- url: "https://{instanceUrl}/services/apexrest/mvn/mic/{version}"
  description: Main (production) server.
  variables:
    instanceUrl:
      default: login
      enum:
      - login
      - test
    version:
      default: v1
      enum:
      - v1
tags:
- name: accounts
  description: Handling of `Account` records.
paths:
  /accounts/search:
    post:
      tags:
      - accounts
      summary: Search for accounts.
      description: "With the Account Search API, you can search for and retrieve a list of accounts that meet filter criteria."
      operationId: searchAccounts
      requestBody:
        description: Language and list of labels to translate.
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccountSearchRequest"
            examples:
              AccountSearchRequest:
                $ref: "#/components/examples/AccountSearchRequest"
        required: true
      responses:
        "201":
          description: Ok
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountSearchResponse"
              examples:
                AccountSearchResponse:
                  $ref: "#/components/examples/AccountSearchResponse"
        "400":
          description: Bad Request
components:
  schemas:
    Filter:
      title: Generic - Filter
      type: object
      properties:
        fieldName:
          type: string
          description: Field that the filter criteria is based on.
        operator:
          type: string
          description: Specifies how `fieldName` relates to `value`.
          enum:
          - Equals
          - Includes
        value:
          description: Value of the `fieldName` that the filter criteria is based on.
          oneOf:
          - type: boolean
          - type: integer
          - type: number
          - type: string
          - type: array
            items:
              oneOf:
              - type: boolean
              - type: integer
              - type: number
              - type: string
    SObject:
      title: Generic - SObject
      type: object
      properties:
        attributes:
          type: object
          properties:
            type:
              type: string
              description: Represents the type of SObject.
            url:
              type: string
              description: Represents the URL to the SObject.
          description: Represents the SObject attributes.
        Id:
          type: string
          description: Represents the Salesforce record Id.
      description: Represents a Salesforce Object.
    AccountSearchRequest:
      title: Account - Search Request
      type: object
      properties:
        isPersonAccount:
          type: boolean
          description: "Set to `true` to search Person Accounts, `false` for Accounts."
          default: false
        country:
          type: string
          description: Represents the country to search in.
        accountFilters:
          type: array
          description: Represents the Account filters.
          items:
            $ref: "#/components/schemas/Filter"
        contactInformationFilters:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: "#/components/schemas/Filter"
          description: Represents the Contact Information filters.
      description: The request for Account Search.
    AccountSearchResponse:
      title: Account - Search Response
      type: object
      properties:
        totalSize:
          type: integer
          description: Represents the length of the records list.
        records:
          type: array
          description: Represents the list of search results.
          items:
            type: object
            properties:
              account:
                $ref: "#/components/schemas/SObject"
              contactInformation:
                type: object
                additionalProperties:
                  type: array
                  description: Represents a grouping of Contact Information by Record Type.
                  items:
                    $ref: "#/components/schemas/SObject"
                description: Represents a map of Contact Information records.
            description: Represents a single search result.
      description: The response for Account Search.
  examples:
    AccountSearchRequest:
      value:
        isPersonAccount: true
        country: CA
        accountFilters:
        - fieldName: FirstName
          operator: Equals
          value: Céline
        - fieldName: LastName
          operator: Equals
          value: Dion
        contactInformationFilters:
          MED_Address:
          - fieldName: MED_State__c
            operator: Equals
            value:
            - CA
            - NY
          MED_Phone:
          - fieldName: MED_Phone__c
            operator: Equals
            value: +1-514-555-1234
    AccountSearchResponse:
      value:
        totalSize: 2
        records:
        - accounts:
            Id: 0032R00002CVSabQAH
            FirstName: Céline
            LastName: Dion
            RecordTypeId: 00f2R00002CVSabQAH
          contactInformation:
          - MED_Address:
            - Id: 0032R00002CVSabQAH
              MED_Country__c: CA
              RecordTypeId: 0032R00002CVSabQAH
          - MED_Phone:
            - Id: 0032R00002CVSabQAH
              MED_Phone__c: +1-450-555-1234
              RecordTypeId: 0032R00002CVSabQAx
        - accounts:
            Id: 0032R00002CVSabQAH
            FirstName: René
            LastName: Lévesque
            RecordTypeId: 00f2R00002CVSabQAH
          contactInformation: []
