---
# System prepended metadata

title: GraphQL to Rest

---

# GraphQL to Rest
### **BenefitTypes** 
#### Method: **GET**
#### Response: 
```json=
{"name":"string","value":"string"}[]
```
#### Graphql: 
```typescript=
const GET_BENEFIT_TYPE= gql`
  query {
    insured_benefit_types {
      value
      comment
    }
  }`
```
---
### **ClaimStatusTypes** 
#### Method: **GET**
#### Response: {name:string,value:string}[]

```typescript=
const GET_STATUS_TYPE = gql`
  query {
    claim_statuses {
      comment
      value
    }
  }
`
```
---
### **CompanyTypes** 
#### Method: **GET**
#### Response: 
```json=
{"name":"string","value":"string"}[]
```
#### GraphQl
```typescript=
const COMPANY_TYPES = gql`
  query {
    company_role_types {
      value
    }
  }
`
```
---
### **CompanyCardList**
#### Method: **GET**
#### Response: 
```json=
{
    "id":"string", 
    "name":"string", 
    "content":"string", 
    "company":{
        "id":"string", 
        "code":"string", 
        "name":"string"
        }
        }[]     
```
#### GraphQl
```typescript=
const CARD_LIST_DATA = gql`
  query {
    cards {
      card_id
      company {
        company_id
        companyCode
        name
      }
      content
      name
    }
  }
`
```
---
### **UpdateCardDetail**
#### Method: **PUT**
#### Request: 
```json=
    {
	"id":"string", 
	"data": {
		"content": "string",
		"name": "string",
		"schema_data": "string",
		"insurer_id": "string"
	}
    }
```

#### Response: 
```json=
{
	"content": "string",
	"name": "string",
	"schema_data": "string",
	"insurer_id": "string"
}
```

#### Graphql: 
```javascript=
const UPDATE_CARD = gql`
  mutation UpdateCardById($card_id: uuid!, $data: cards_set_input!) {
    update_cards_by_pk(pk_columns: {card_id: $card_id}, _set: $data) {
      content
      name
      schema_data
      insurer_id
    }
  }
`
```

---
### **GetCardDetail**
#### Method: **GET**
#### Request: 
```json=
{"id":"string"}
```
#### Response: 
```json=
{
	"content":"string",
	"insurerId":"String",
	"name":"string"
}
```
#### Graphql
```typescript=
const GET_CARD_DETAIL = gql`
  query cardById($id: uuid!) {
    cards_by_pk(card_id: $id) {
      content
      insurer_id
      name
    }
  }
`
```

---
### **GetCardByInsurerId**
#### Method: **GET**
#### Request: 
```json=
{"id":"string"}
```
#### Response: 
```json=
{
	"cardId":"string", 
	"name":"string"
}
```
#### Graphql
```typescript=
const GET_CARD_BY_INSURER_ID = gql`
  query cardByInsurerId($id: uuid!) {
    companies_by_pk(company_id: $id) {
      cards {
        card_id
        name
      }
    }
  }
`
```
---
### **InsertCard**
#### Method: **POST**
#### Request: 
```json=
{
	"insurerId":"string",
	"content":"string",
	"name":"string",
	"schemaData":"string"
}
```
#### Response: 
```json=
{
	"cardId":"string", 
}
```
#### Graphql
```typescript=
const INSERT_CARD = gql`
  mutation ($content: String!, $insurer_id: uuid!, $name: String!, $schema_data: jsonb!) {
    insert_cards(objects: {content: $content, insurer_id: $insurer_id, name: $name, schema_data: $schema_data}) {
      returning {
        card_id
      }
    }
  }
`
```

---
### **GetCertificate**
#### Method: **GET**
#### Request: 
```json=
{
	"search":"string",
	"insurerId":"string",
	"policyNumber":"string",
	"insuredPersonName":"string",
	"insuredPersonPaperId":"string",
	"insuredCertificateCode":"string",
	"insuredPersonPhone":"string",
}
```

#### Response: 
```json=
{
"insuredCertificates": {
        "certificateCode":"string",
        "createdAt":"string",
        "deletedAt":"string",
        "duedAt":"string",
        "email":"string",
        "insuredCertificateId":"string",
        "insuredPersonId":"string",
        "isVoluntary":"string",
        "issuedAt":"string",
        "parentInsuredCertificateId":"string",
        "planId":"string",
        "policyId":"string",
        "updatedAt":"string",
        "policy": {
          "brokerId":"string",
          "corporateId":"string",
          "createdAt":"string",
          "deletedAt":"string",
          "duedAt":"string",
          "insuredPersonId":"string",
          "insurerId":"string",
          "issuedAt":"string",
          "policyId":"string",
          "policyNumber":"string",
          "remarkCopay":"string",
          "tpaId":"string",
          "types": "string",
          "updatedAt":"string"
        },
        "insured_person": {
          "createdAt":"string",
          "deletedAt":"string",
          "dob":"string",
          "email":"string",
          "gender":"string",
          "insuredNumber":"string",
          "insuredPersonId":"string",
          "name":"string",
          "notes":"string",
          "paperExpiredAt":"string",
          "paperId":"string",
          "paperIssuedAt":"string",
          "paperIssuedPlace":"string",
          "phone":"string",
          "updatedAt":"string",
          "userId":"string"
        }
}
```
#### Graphql
```typescript=
const GET_CERTIFICATES = gql`
  query (
    $searchBy: search_by_enum!
    $insurerId: String
    $policyNumber: String
    $insuredPersonName: String
    $insuredPersonPaperId: String
    $insuredCertificateCode: String
    $insuredPersonPhone: String
  ) {
    search_certificates(
      search_by: $searchBy
      insurer_id: $insurerId
      policy_number: $policyNumber
      insured_person_name: $insuredPersonName
      insured_person_paper_id: $insuredPersonPaperId
      insured_certificate_code: $insuredCertificateCode
      insured_person_phone: $insuredPersonPhone
    ) {
      success
      message
      insured_certificates {
        certificate_code
        created_at
        deleted_at
        dued_at
        email
        insured_certificate_id
        insured_person_id
        is_voluntary
        issued_at
        parent_insured_certificate_id
        plan_id
        policy_id
        updated_at
        policy {
          broker_id
          corporate_id
          created_at
          deleted_at
          dued_at
          insured_person_id
          insurer_id
          issued_at
          policy_id
          policy_number
          remark_copay
          tpa_id
          types
          updated_at
        }
        insured_person {
          created_at
          deleted_at
          dob
          email
          gender
          insured_number
          insured_person_id
          name
          notes
          paper_expired_at
          paper_id
          paper_issued_at
          paper_issued_place
          phone
          updated_at
          user_id
        }
      }
    }
  }
`
```


---
### **GetCertificateList**
#### Method: **GET**
#### Response: 
```json=
{
"insuredCertificates": {
        "insuredCertificateId":"string",
        "certificateCode":"string",
        "duedAt":"string",
        "issuedAt":"string",
        "policy": {
          "companyByCorporateId" :{
            "name":"string"
          },
          "insuredPerson": {
            "name":"string"
          },
          "policyId":"string"
        },
        "parentInsuredCertificate" :{
          "insuredPerson": {
            "name":"string",
            "insuredNumber":"string"
          }
        }
      }
}
```
#### Graphql
```typescript=
const GET_CERTIFICATE_LIST = gql`
  query certificateByInsuredPersonId($id: uuid!) {
    insured_persons_by_pk(insured_person_id: $id) {
      insured_certificates {
        insured_certificate_id
        certificate_code
        dued_at
        issued_at
        policy {
          companyByCorporateId {
            name
          }
          insured_person {
            name
          }
          policy_id
        }
        parent_insured_certificate {
          insured_person {
            name
            insured_number
          }
        }
      }
    }
  }
`
```

---
### **GetCertificateDetail**
#### Method: **GET**
#### Request: 
```json=
{"id":"string"}
```
#### Response:
```json=
{
      "insuredCertificateId":"string",
      "certificateCode":"string",
      "email":"string",
      "plan": {
        "name":"string",
        },
      "duedAt":"string",
      "issuedAt":"string",
      "insuredPerson" :{
        "name":"string",
        "paperId":"string",
      },
      "policy": {
        "policyNumber":"string"
      },
      "childrenInsuredCertificates" :{
        "insuredCertificateId":"string",
        "certificateCode":"string",
        "email":"string",
        "issuedAt":"string",
        "duedAt":"string",
        "plan" :{
          "name":"string"
        },
        "insuredPerson": {
          "name":"string",
          "paperId":"string"
        },
        "policy" :{
          "policyNumber":"string"
        }
      },
      "parentInsuredCertificate": {
        "insuredCertificateId":"string",
        "certificateCode":"string",
        "email":"string",
        "issuedAt":"string",
        "duedAt":"string",
        "plan" :{
          "name":"string"
        },
        "insuredPerson": {
          "name":"string",
          "paperId":"string",
        },
        "policy" :{
          "policyNumber":"string"
        }
      }
    }

```
#### Graphql
```typescript=
const GET_CERTIFICATE_DETAIL = gql`
  query certificateById($id: uuid!) {
    insured_certificates_by_pk(insured_certificate_id: $id) {
      insured_certificate_id
      certificate_code
      email
      plan {
        name
      }
      dued_at
      issued_at
      insured_person {
        name
        paper_id
      }
      policy {
        policy_number
      }
      children_insured_certificates {
        insured_certificate_id
        certificate_code
        email
        issued_at
        dued_at
        plan {
          name
        }
        insured_person {
          name
          paper_id
        }
        policy {
          policy_number
        }
      }
      parent_insured_certificate {
        insured_certificate_id
        certificate_code
        email
        issued_at
        dued_at
        plan {
          name
        }
        insured_person {
          name
          paper_id
        }
        policy {
          policy_number
        }
      }
    }
  }
`
```
---
### **GetMedicalProviderList**
#### Method: **GET**
#### Response: 
```json=
{
	"medicalProviderId":"string",
	"name":"string",
	"address":"string",
	"phone":"string",
	"province":"string",
	"IsDirectBilling":"boolean",
	"email":"string",
	"description":"string",
	"type":"string",
}
```
#### Graphql
```typescript=
const MEDICAL_PROVIDER_LIST = gql`
  query {
    mp_medical_providers {
      medical_provider_id
      name
      address
      phone
      province
      is_direct_billing
      email
      description
      type
    }
  }
`
```

---
### **GetMedicalProviderType**
#### Method: **GET**
#### Response: 
```json=
{"name":"string","value":"string"}
```
#### Graphql
```typescript=
const GET_MEDICAL_PROVIDER_TYPE = gql`
  query {
    mp_medical_provider_types {
      comment
      value
    }
  }
`
```
---
### **InsertMedicalProvider**
#### Method: **POST**
#### Request:
```json=
{
	"name":"string",
	"address":"string",
	"phone":"string",
	"email":"string",
	"province":"string",
	"type":"string",
	"isDirectBilling":"boolean",
	"description":"string"
}
```

#### Response: 
```json=
{  "medicalProviderId":"string"}

```
#### Graphql
```typescript=
const INSERT_MEDICAL_PROVIDER = gql`
  mutation (
    $name: String!
    $address: String
    $phone: String
    $email: String
    $province: String
    $type: mp_medical_provider_types_enum
    $is_direct_billing: Boolean
    $description: String
  ) {
    insert_mp_medical_providers(
      objects: {
        name: $name
        address: $address
        phone: $phone
        email: $email
        province: $province
        description: $description
        type: $type
        is_direct_billing: $is_direct_billing
      }
      on_conflict: {
        constraint: medical_providers_name_province_type_key
        update_columns: [address, description, phone, email]
      }
    ) {
      returning {
        medical_provider_id
      }
    }
  }
`
```
---
### **GetMedicalProviderDetail**
#### Method: **GET**
#### Request: 
```json=
{"id":"string"}
```
#### Response:
```json=
{
	"name":"string",
	"address":"string",
	"phone":"string",
	"email":"string",
	"province":"string",
	"type":"string",
	"isDirectBilling":"boolean",
	"description":"string"
}

```
#### Graphql
```typescript=
const GET_MEDICAL_PROVIDER_DETAIL = gql`
  query medicalProviderById($id: uuid!) {
    mp_medical_providers_by_pk(medical_provider_id: $id) {
      name
      type
      description
      is_direct_billing
      email
      phone
      address
      province
    }
  }
`
```
---
### **UpdateMedicalProvider**
#### Method: **PUT**
#### Request: 
```json=
{
	"id":"string",
	"name":"string",
	"address":"string",
	"phone":"string",
	"email":"string",
	"province":"string",
	"type":"string",
	"isDirectBilling":"boolean",
	"description":"string"
}
```
#### Graphql

```typescript=
const UPDATE_MEDICAL_PROVIDER_BY_ID = gql`
  mutation Update($medical_provider_id: uuid!, $data: mp_medical_providers_set_input!) {
    update_mp_medical_providers_by_pk(pk_columns: {medical_provider_id: $medical_provider_id}, _set: $data) {
      name
      phone
      province
      type
      address
      email
      is_direct_billing
      description
    }
  }
`
```
---
### **GetPlanBalanceType**
#### Method: **GET**
#### Response:
```json=
{"name":"string","value":"string"}
```
#### Graphql
```typescript=
const GET_PLAN_BALANCE_TYPE = gql`
  query {
    plan_balance_types {
      value
      comment
    }
  }
`
```
---
**GetCopaymentTarget**
Method: **GET**
Response:{name:string,value:string}

```typescript=
const GET_CO_PAYMENT_TARGET = gql`
  query {
    plan_co_payment_targets {
      comment
      value
    }
  }
`
```

---
### **GetOriginalClaim**
#### Method: **GET**
#### Request: 
```json=
{"id":"string"}
```
#### Response:
```json=
{ 
    "claimCode":"string",
    "benefitType":"string",
    "diagnosis":"string",
    "eventDates":"string",
    "medicalProviderName":"string",
    "paymentAccountName":"string",
    "paymentAccountNumber":"string",
    "paymentBankBranch":"string",
    "paymentBankCity":"string",
    "paymentBankName":"string",
    "requestAmount":"string",
    "source":"string",
    "claimInformations" :{
        "name":"string",
        "value":"string",
    },
    "insuredCertificate": {
        "parentInsuredCertificate": {
          	"insuredPerson": {
            	"name":"string",
          	}
        },
        "insuredPerson": {
          	"name":"string"
        },
        "policy" :{
          	"insurer" :{
            	"name":"string"
          	},
          "issuedAt":"string",
          "duedAt":"string"
        }	
     }
}
```
#### Graphql
```typescript=
const GET_ORIGINAL_CLAIM_DATA = gql`
  query originalDataByClaimId($id: uuid!) {
    claim_requests_by_pk(claim_request_id: $id) {
      claim_code
      benefit_type
      diagnosis
      event_dates
      medical_provider_name
      payment_account_name
      payment_account_number
      payment_bank_branch
      payment_bank_city
      payment_bank_name
      request_amount
      source
      claim_informations {
        name
        value
      }
      insured_certificate {
        parent_insured_certificate {
          insured_person {
            name
          }
        }
        insured_person {
          name
        }
        policy {
          insurer {
            name
          }
          issued_at
          dued_at
        }
      }
    }
  }
`
```
---
### **GetClaimInfoMetadata**
#### Method: **GET**
#### Response:
```json=
{"title":"string","value":"string"}
```
#### Graphql
```typescript=
const GET_METADATA_CLAIM_INFO = gql`
  query {
    metadata(where: {type: {_eq: "claim_info"}}) {
      title
      value
    }
  }
`
```






