Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

Version 1 Next »

Servidor FHIR

Para este tutorial se ha utilizado lo siguiente:

Servicio para Eventos del tipo Rest Hook

  • Requiere Python 3.*

  • Instalar dependencias

    pip3 install Flask
  • Crear un archivo main.py

    from flask import Flask, request
    
    
    app = Flask(__name__)
    
    
    @app.route('/subscriptions', methods=['POST', 'PUT'])
    def simple_subscription():
        print(request.method)
        print(request.headers)
        if request.is_json:
            print(request.json)
        return 'Done Simple Subscription'
    
    
    @app.route('/subscriptions/Patient/<string:id>', methods=['POST', 'PUT'])
    def patient(id):
        print("id: %s", id)
        print(request.method)
        print(request.headers)
        if request.is_json:
            print(request.json)
        return 'Done advanced subscription'
    
  • Ejecutar servicio

    export FLASK_ENV=development
    export FLASK_APP=main.py 
    flask run --host=0.0.0.0

Pasos para notificación sin contenido

  • Se creará una subscripción para cualquier creación o modificación de Pacientes varones.

  • Crear un recurso Subscription para notificación sin contenido

    {
      "resourceType": "Subscription",
      "status": "active",
      "criteria": "Patient?gender=male", 
      "channel": {
          "type": "rest-hook",
          "endpoint": "http://localhost:5000/subscriptions",
          "header": [
              "Authorization: Bearer secret-token-abc-123"
          ]
      }
    }  
  • Crear un paciente para generar una notificación

    {
      "resourceType": "Patient",
      "identifier": [
        {
          "use": "usual",
          "type": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                "code": "MR"
              }
            ]
          },
          "system": "urn:oid:1.2.36.146.595.217.0.1",
          "value": "12345",
          "period": {
            "start": "2001-05-16"
          },
          "assigner": {
            "display": "Acme Healthcare"
          }
        }
      ],
      "active": true,
      "name": [
        {
          "use": "official",
          "family": "Chalmers",
          "given": [
            "Peter",
            "James"
          ]
        }
      ],
      "telecom": [
        {
          "system": "phone",
          "value": "(03) 5555 6473",
          "use": "work",
          "rank": 1
        },
        {
          "system": "phone",
          "value": "(03) 3410 5613",
          "use": "mobile",
          "rank": 2
        }
      ],
      "gender": "male",
      "birthDate": "1974-12-28"
    }
  • Debería llegar al servicio lo siguiente

    POST
    Authorization: Bearer secret-token-abc-123
    User-Agent: HAPI-FHIR/5.3.0 (FHIR Client; FHIR 4.0.1/R4; apache)
    Accept-Charset: utf-8
    Accept-Encoding: gzip
    If-None-Exist: http://localhost:5000/subscriptions,http://localhost:5000/subscriptions?
    Accept: application/fhir+xml;q=1.0, application/fhir+json;q=1.0, application/xml+fhir;q=0.9, application/json+fhir;q=0.9
    Content-Length: 0
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    Host: localhost:5000
    Connection: Keep-Alive
    

Pasos para notificación con contenido

  • Se creará una subscripción para cualquier creación o modificación de Pacientes varones.

  • Crear un recurso Subscription para notificación con contenido(parámetro payload)

    {
      "resourceType": "Subscription",
      "status": "active",
      "criteria": "Patient?gender=male", 
      "channel": {
          "type": "rest-hook",
          "endpoint": "http://localhost:5000/subscriptions",
          "payload": "application/fhir+json",
          "header": [
              "Authorization: Bearer secret-token-abc-123"
          ]
      }
    }  
  • Crear un paciente para generar una notificación

    {
      "resourceType": "Patient",
      "identifier": [
        {
          "use": "usual",
          "type": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                "code": "MR"
              }
            ]
          },
          "system": "urn:oid:1.2.36.146.595.217.0.1",
          "value": "12345",
          "period": {
            "start": "2001-05-16"
          },
          "assigner": {
            "display": "Acme Healthcare"
          }
        }
      ],
      "active": true,
      "name": [
        {
          "use": "official",
          "family": "Chalmers",
          "given": [
            "Peter",
            "James"
          ]
        }
      ],
      "telecom": [
        {
          "system": "phone",
          "value": "(03) 5555 6473",
          "use": "work",
          "rank": 1
        },
        {
          "system": "phone",
          "value": "(03) 3410 5613",
          "use": "mobile",
          "rank": 2
        }
      ],
      "gender": "male",
      "birthDate": "1974-12-29"
    }
  • Debería llegar al servicio lo siguiente

id: 1553
PUT
If-Match: "10"
User-Agent: HAPI-FHIR/5.3.0 (FHIR Client; FHIR 4.0.1/R4; apache)
Accept-Charset: utf-8
Accept-Encoding: gzip
Accept: application/fhir+json;q=1.0, application/json+fhir;q=0.9
Content-Type: application/fhir+json; charset=UTF-8
Authorization: Bearer secret-token-abc-123
Content-Length: 960
Host: localhost:5000
Connection: Keep-Alive


{'resourceType': 'Patient', 'id': '1553', 'meta': {'versionId': '10', 'lastUpdated': '2021-03-25T01:22:59.446-03:00'}, 'text': {'status': 'generated', 'div': '<div xmlns="http://www.w3.org/1999/xhtml"><div class="hapiHeaderText">Peter James <b>CHALMERS </b></div><table class="hapiPropertyTable"><tbody><tr><td>Identifier</td><td>12345</td></tr><tr><td>Date of birth</td><td><span>29 December 1974</span></td></tr></tbody></table></div>'}, 'identifier': [{'use': 'usual', 'type': {'coding': [{'system': 'http://terminology.hl7.org/CodeSystem/v2-0203', 'code': 'MR'}]}, 'system': 'urn:oid:1.2.36.146.595.217.0.1', 'value': '12345', 'period': {'start': '2001-05-16'}, 'assigner': {'display': 'Acme Healthcare'}}], 'active': True, 'name': [{'use': 'official', 'family': 'Chalmers', 'given': ['Peter', 'James']}], 'telecom': [{'system': 'phone', 'value': '(03) 5555 6473', 'use': 'work', 'rank': 1}, {'system': 'phone', 'value': '(03) 3410 5613', 'use': 'mobile', 'rank': 2}], 'gender': 'male', 'birthDate': '1974-12-29'}

Servicio para Eventos del tipo WebSocket

TODO

  • No labels