Объект ресурса org.hl7.fhir.dstu3.model.Parameters не будет гидратироваться / заполняться при расширенной работе. - PullRequest
1 голос
/ 07 марта 2019

У меня есть собственный IResourceProvider, который обслуживает Measure (Measure.class).

В этом коде у меня есть следующая расширенная операция. (от http://hapifhir.io/doc_rest_operations.html#_toc_extended_operations)

@Operation(name = "$humptydumpty")
public org.hl7.fhir.dstu3.model.Bundle acceptHumptyDumpty(HttpServletRequest servletRequest,
                                                                  @IdParam(optional = true) IdType theId,
                                                                  @OperationParam(name = "request") org.hl7.fhir.dstu3.model.Measure item) {
    String fakeMessage;

    if (null == item) {
        fakeMessage = "org.hl7.fhir.dstu3.model.Measure item is null.  Sad face.  :( ";
    } else {
        fakeMessage = "org.hl7.fhir.dstu3.model.Measure item is not null.  Happy face.  :) ";
    }


    Bundle retVal = new Bundle();
    retVal.setId(fakeMessage);
    return retVal;
}

Если я передам пример JSON из

http://hl7.org/fhir/STU3/measure-exclusive-breastfeeding.json.html

POST

http://localhost:8080/fhir/Measure/MyMeasureName123/$humptydumpty

Все отлично работает. Я вернусь.

{
    "resourceType": "Bundle",
    "id": "org.hl7.fhir.dstu3.model.Measure item is not null.  Happy face.  :) "
}

Итак, я понимаю основы работы $ myExtendedMethod.

СЕЙЧАС, когда я попробую то же самое для .Параметров ....

Java-код (тот же MyResourceProvider, что и выше)

@Operation(name = "$robinhood")
public Bundle acceptRobinHood(HttpServletRequest servletRequest,
                                         @IdParam(optional = true) IdType theId,
                                         @OperationParam(name = "request") org.hl7.fhir.dstu3.model.Parameters item) {

    String fakeMessage;

    if (null == item) {
        fakeMessage = "org.hl7.fhir.dstu3.model.Parameters item is null.  Sad face.  :( ";
    } else {
        fakeMessage = "org.hl7.fhir.dstu3.model.Parameters item is not null.  Happy face.  :) ";
    }


    Bundle retVal = new Bundle();
    retVal.setId(fakeMessage);
    return retVal;
}

POST

http://localhost:8080/fhir/Measure/MyMeasureName123/$robinhood

Я отправил «пример» от http://hl7.org/fhir/STU3/parameters-example.json.

{
  "resourceType": "Parameters",
  "id": "example",
  "parameter": [
    {
      "name": "start",
      "valueDate": "2010-01-01"
    },
    {
      "name": "end",
      "resource": {
        "resourceType": "Binary",
        "contentType": "text/plain",
        "content": "VGhpcyBpcyBhIHRlc3QgZXhhbXBsZQ=="
      }
    }
  ]
}

А если я отправлю ... самый простой json.

{
  "resourceType": "Parameters",
  "id": "MyParameterId234"
}

У меня грустное лицо. (

Я все перепробовал.

«Товар» всегда равен нулю. Ака, я вернул это.

{
    "resourceType": "Bundle",
    "id": "org.hl7.fhir.dstu3.model.Parameters item is null.  Sad face.  :( "
}

Я перепробовал много вещей и, наконец, вернулся к «.Measure», чтобы доказать, что я не сумасшедший.

Но я не могу понять, почему один будет заполняться (.Measure ресурс), а другой (.Parameters) - нет. # Помощь

Моя версия хапи фхир:

<properties>
    <hapi.version>3.6.0</hapi.version>
</properties>

    <!-- FHIR dependencies -->
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-structures-dstu3</artifactId>
        <version>${hapi.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-server</artifactId>
        <version>${hapi.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-base</artifactId>
        <version>${hapi.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
        <version>${hapi.version}</version>
    </dependency>

APPEND:

Я сделал один для пациента

@Operation(name = "$teddybear")
public org.hl7.fhir.dstu3.model.Bundle acceptTeddyBear(HttpServletRequest servletRequest,
                                                          @IdParam(optional = true) IdType theId,
                                                          @OperationParam(name = "request") org.hl7.fhir.dstu3.model.Patient item) {
    String fakeMessage;

    if (null == item) {
        fakeMessage = "org.hl7.fhir.dstu3.model.Patient item is null.  Sad face.  :( ";
    } else {
        fakeMessage = "org.hl7.fhir.dstu3.model.Patient item is not null.  Happy face.  :) ";
    }


    Bundle retVal = new Bundle();
    retVal.setId(fakeMessage);
    return retVal;
}

POST

http://localhost:8080/fhir/Measure/MyMeasureName123/$teddybear

http://hl7.org/fhir/STU3/patient-example.json

и работает нормально.

{
    "resourceType": "Bundle",
    "id": "org.hl7.fhir.dstu3.model.Patient item is not null.  Happy face.  :) "
}

Это только ресурс .Parameters, который причиняет мне боль.

APPEND

В соответствии с ответом Джеймса А. и подсказкой, я вставил ниже.

Код Обхода: (иначе, «ОТВЕТ» в смысле ответа обхода)

@Operation(name = "$robinhood")
public Bundle acceptRobinHood(HttpServletRequest servletRequest,
                              @IdParam(optional = true) IdType theId,
        /*@OperationParam(name = "request") org.hl7.fhir.dstu3.model.Parameters item*/ @ResourceParam String theRawBody) {
    String fakeMessage;

    if (null == theRawBody || StringUtils.isBlank(theRawBody)) {
        fakeMessage = "theRawBody is null or isBlank.  Sad face.  :( ";
    } else {
        fakeMessage = "theRawBody is not null and is not isBlank.  Happy face.  :) ";
    }

    org.hl7.fhir.dstu3.model.Parameters paramsObject = null;
    FhirContext ctx = FhirContext.forDstu3();//  this.getContext();  /* prefer encapsulated over hard coding, but for SOF, put in the hard code */
    IParser parser = ctx.newJsonParser();
    IBaseResource res = parser.parseResource(theRawBody);
    paramsObject = (org.hl7.fhir.dstu3.model.Parameters) res;
    if (null != paramsObject) {
        fakeMessage += " org.hl7.fhir.dstu3.model.Parameters was serialized from theRawBody.  Super Happy face.  :) :)";
    }
    else
    {
        fakeMessage += " org.hl7.fhir.dstu3.model.Parameters was NOT serialized from theRawBody (is null).  Super Sad face.  :( :( ";
    }

    Bundle retVal = new Bundle();
    retVal.setId(fakeMessage);
    return retVal;
}

и ответ от исполнения кода:

{
    "resourceType": "Bundle",
    "id": "theRawBody is not null and is not isBlank.  Happy face.  :)  org.hl7.fhir.dstu3.model.Parameters was serialized from theRawBody.  Super Happy face.  :) :)"
}

1 Ответ

1 голос
/ 07 марта 2019

Если честно, это похоже на ошибку в HAPI FHIR. Если бы вы хотели сообщить об этом на трекере GitHub, это было бы здорово.

Возможно, вы могли бы обойти это, добавив параметр в соответствии с:

@ ResourceParam String theRawBody

И использование парсера HAPI FHIR для анализа ресурса Parameters. Это, конечно, раздражает, но я верю, что это сработает.

...