{
  "info": {
    "_postman_id": "fb7de475-ab15-412d-900f-a2496b8d889e",
    "name": "ERX Collection Arzt",
    "description": "## ReadMe:\n\n### This Collection is additional to the Documentation under [https://developers.e-rezept.ch/](https://developers.e-rezept.ch/)\n\n## Authhandle Doctor:\n\n### Preparation:\n\nFirst set the variables authservice_host(authservice-int.hin.ch or authservice.hin.ch) and erx_host(Local adress of the erx proxy).  \nAlso set your client id and client secret under Authorization. change the Auth URL to [https://apps.hin.ch/REST/v1/OAuth/GetAuthCode/hin_authservice](https://apps.hin.ch/REST/v1/OAuth/GetAuthCode/hin_authservice) if you use the collection in prod.\n\nTo use the ERX Proxy as a Doctor you need an Authandle from the Authservice.\n\n### Getting a Authhandle\n\nThere are two oauth2 flows, both are nescessary.\n\nFirst use normal Oauth2 autorization in the collection to get a token. Most variables are predefined, but you need to set your client id and secret.\n\nAfter that you need to get an auth_handle via authservice, this would be step 1, 2, 3 in this collection.  \nBeware this is not a standard oauth2 flow, so you will need to follow the steps 1, 2, 3.  \nAfter step 1 you will need to open the link in the browser from response -> copy the authcode from the redirect url,  \nand use it in step 2.\n\nThen you can use this auth_handle as bearer token for all the ERX requests to use it as a Doctor.  \nSet it in the variables under authandle.\n\n### Accessing the ERX Proxy:\n\nThen you can use this auth_handle as bearer token for all the ERX requests to use it as a Doctor.  \nSet it in the variables under authandle. Also a token-type header with the value oauth is nescessary, this is predefined in the collection.\n\n```\ntoken-type:oauth\n\n ```\n\n## Pitfalls:\n\nThere are two oauth flows, while the first flow is a normal oauth2 flow, the authandle flow is not a standard oauth2 flow. So authorization for the second flow with the framework provided by postman or similar wont work.\n\nOnly sending a valid auth_handle as bearer token to the erx app will result in an 401, you need to also specify a token-type header with the value oauth\n\n```\ntoken-type:oauth\n\n ```",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "34116957"
  },
  "item": [
    {
      "name": "1 Start oauth authservice",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{authservice_host}}/v1/oauth?targetUrl=http%3A%2F%2Flocalhost%2Fsuccess&style=redirect",
          "host": [
            "{{authservice_host}}"
          ],
          "path": [
            "v1",
            "oauth"
          ],
          "query": [
            {
              "key": "targetUrl",
              "value": "http%3A%2F%2Flocalhost%2Fsuccess"
            },
            {
              "key": "style",
              "value": "redirect"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "2 exchange auth_code to auth_handle authservice",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\"authCode\":\"35anTBkdgCWjrmA\"}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{authservice_host}}/v1/oauth/auth_handle",
          "host": [
            "{{authservice_host}}"
          ],
          "path": [
            "v1",
            "oauth",
            "auth_handle"
          ]
        }
      },
      "response": []
    },
    {
      "name": "3 request data by handle authservice",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\"authHandle\": \"xQdCRqbt4blig9Y1hTBZ\"}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{authservice_host}}/v1/oauth/handle/",
          "host": [
            "{{authservice_host}}"
          ],
          "path": [
            "v1",
            "oauth",
            "handle",
            ""
          ]
        }
      },
      "response": []
    },
    {
      "name": "Arzt verify rezept Erx",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{auth_handle}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "token-type",
            "value": "oauth",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "https://eprescription-test.hin.ch/#CHMED16A1H4sIAAAAAAAAE72WWW/bOBCA/wrB15VUHrrsp43XSTdA3TWcNAG6yAMljy1BMmVQVNA06/++Qyl2ribpLoLCB6jRkJxvZjicWzpXtgRt6fiWnnxWG6BjOgFjFfXop/1zCabE58kU1SgfJZHPmc8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kcx2MpxjL9jfExYc63i03V93WO0JWbu74SL3VV10BcG1L1bQhoR6ocKVl3loCpagVmSGRsYyauP6S7fwH9oBgMmgoAAA==&i=pract.+med+Dominique+Jud+%28HIN%7Cdomjud1%29&t=1776933890&s=3065023100ab238dddb078746ef8296f73f65e8f54aa00d59590c828e9235e5ebaa4bfc4191cffad51014ec4d2726134ca6f7f7ac7023064d7aa61fa822dfebf3880c0b5ac3288ac8957bacc00af9cce580c12741d39f3dc228ea535fa17c141c3c2b1d32bd579",
          "options": {
            "raw": {
              "language": "text"
            }
          }
        },
        "url": {
          "raw": "{{erx_host}}/ePrescription/verify",
          "host": [
            "{{erx_host}}"
          ],
          "path": [
            "ePrescription",
            "verify"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Arzt create prescription Erx",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{auth_handle}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "token-type",
            "value": "oauth",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "CHMED16A1H4sICJalKmoAA3JlemVwdC5qc29uADWOOwvCQBCEa/MrwrZ6sHuJ90iniCioWNiJxZGcaGEQcykk5L97DwPbzDc7sztkeQ5n4562dVDlg5cebE/mZb2EnWk7WCR4mOCx75z9THi9CUEgLSUj8gMzb4zBhaNtnrVPta7zO9cYSCe8uW9CjpeSIwn810V++b7DoSKSMbtNXROPOsWJlwXT2t4Zaboz3ShiwiolZG10szSxFla9e4RtKZAQUUollU5W+p4jLxgKxtWFqEJVlXqOvEKEbPwBg3+X7SMBAAA=",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{erx_host}}ePrescription/create?output-format=data",
          "host": [
            "{{erx_host}}ePrescription"
          ],
          "path": [
            "create"
          ],
          "query": [
            {
              "key": "output-format",
              "value": "data"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Arzt dispense e-rezept Erx",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{auth_handle}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "token-type",
            "value": "oauth",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{erx_host}}/ePrescription/dispense/{{prescription_id}}",
          "host": [
            "{{erx_host}}"
          ],
          "path": [
            "ePrescription",
            "dispense",
            "{{prescription_id}}"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Arzt revoke e-rezept Erx",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{auth_handle}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "token-type",
            "value": "oauth",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{erx_host}}/ePrescription/revoke/{{prescription_id}}",
          "host": [
            "{{erx_host}}"
          ],
          "path": [
            "ePrescription",
            "revoke",
            "{{prescription_id}}"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Arzt cancel event e-rezept Erx",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{auth_handle}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "token-type",
            "value": "oauth",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{erx_host}}/ePrescription/cancel/{{prescription_id}}/event/{{event_id}}",
          "host": [
            "{{erx_host}}"
          ],
          "path": [
            "ePrescription",
            "cancel",
            "{{prescription_id}}",
            "event",
            "{{event_id}}"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Check Token",
      "request": {
        "method": "GET",
        "header": []
      },
      "response": []
    }
  ],
  "auth": {
    "type": "oauth2",
    "oauth2": [
      {
        "key": "authUrl",
        "value": "https://apps.hin.ch/REST/v1/OAuth/GetAuthCode/hin_authservice_int",
        "type": "string"
      },
      {
        "key": "state",
        "value": "12345",
        "type": "string"
      },
      {
        "key": "clientSecret",
        "value": "",
        "type": "string"
      },
      {
        "key": "clientId",
        "value": "",
        "type": "string"
      },
      {
        "key": "client_authentication",
        "value": "body",
        "type": "string"
      },
      {
        "key": "scope",
        "value": "",
        "type": "string"
      },
      {
        "key": "accessTokenUrl",
        "value": "https://oauth2.hin.ch/REST/v1/OAuth/GetAccessToken",
        "type": "string"
      },
      {
        "key": "redirect_uri",
        "value": "http://localhost/getAccessToken",
        "type": "string"
      },
      {
        "key": "useBrowser",
        "value": false,
        "type": "boolean"
      },
      {
        "key": "tokenName",
        "value": "apps.hin.ch",
        "type": "string"
      },
      {
        "key": "refreshRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "tokenRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "authRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "challengeAlgorithm",
        "value": "S256",
        "type": "string"
      },
      {
        "key": "grant_type",
        "value": "authorization_code",
        "type": "string"
      },
      {
        "key": "addTokenTo",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "erx_host",
      "value": ""
    },
    {
      "key": "auth_handle",
      "value": ""
    },
    {
      "key": "authservice_host",
      "value": ""
    }
  ]
}