FHIR Chat · Valueset POST fails · hapi

Stream: hapi

Topic: Valueset POST fails


view this post on Zulip Nath (Jun 10 2020 at 04:54):

Hello Implementers,
I have been desperately create a valueset in JPA hapi server. I tried this and its erroring out with the following error mgs
I tried this sample valueset from here http://hl7.org/fhir/R4/valueset-relatedperson-relationshiptype.json. I tried to post to my hapi jpa server.
curl --location --request POST 'http://localhost:8080/fhir/ValueSet' \
--header 'Content-Type: application/fhir+json' \
--header 'Cookie: JSESSIONID=45A8B8827CD707FD9A0CF7D25B5D0B41' \
--data-raw '{
"resourceType" : "ValueSet",
"id" : "relatedperson-relationshiptype",
"meta" : {
"lastUpdated" : "2019-11-01T09:29:23.356+11:00",
"profile" : ["http://hl7.org/fhir/StructureDefinition/shareablevalueset"]
},
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h2>Patient relationship type</h2><div><p>A set of codes that can be used to indicate the relationship between a Patient and a Related Person.</p>\n</div><p>This value set includes codes from the following code systems:</p><ul><li>Include all codes defined in <a href=\"v2/0131/index.html\"><code>http://terminology.hl7.org/CodeSystem/v2-0131</code></a></li><li>Include codes from <a href=\"v3/RoleCode/cs.html\"><code>http://terminology.hl7.org/CodeSystem/v3-RoleCode</code></a> where concept is-a <a href=\"v3/RoleCode/cs.html#v3-RoleCode-_PersonalRelationshipRoleType\">_PersonalRelationshipRoleType</a></li></ul></div>"
},
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg",
"valueCode" : "pa"
}],
"url" : "http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype",
"identifier" : [{
"system" : "urn:ietf:rfc:3986",
"value" : "urn:oid:2.16.840.1.113883.4.642.3.449"
}],
"version" : "4.0.1",
"name" : "PatientRelationshipType",
"title" : "Patient relationship type",
"status" : "draft",
"experimental" : false,
"date" : "2019-11-01T09:29:23+11:00",
"publisher" : "FHIR Project team",
"contact" : [{
"telecom" : [{
"system" : "url",
"value" : "http://hl7.org/fhir"
}]
}],
"description" : "A set of codes that can be used to indicate the relationship between a Patient and a Related Person.",
"compose" : {
"include" : [{
"system" : "http://terminology.hl7.org/CodeSystem/v2-0131"
},
{
"system" : "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
"filter" : [{
"property" : "concept",
"op" : "is-a",
"value" : "_PersonalRelationshipRoleType"
}]
}]
}
}'

but I got back this error
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "Failed to call access method: org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call"
}
]
}

Can you please kindly help me ?. thanks for your help.
FYI, I also removed id (as suggested in Implementers forum) and tried still the same error. Can you please help?.

thanks

view this post on Zulip Nath (Jun 10 2020 at 19:06):

Hello Implementers, is there a workaround or a different way to load the valueset ?. This is most common usecase, I am sure many people might be using it. May be I don't know how to load this. Could you please kindly give some pointers on how others are loading in Hapi?. thanks for your help.

view this post on Zulip Frederik Leonhardt (Jun 11 2020 at 05:51):

Is this with the Spring Boot HAPI server? If so I think that's a known bug (https://github.com/jamesagnew/hapi-fhir/issues/1594), I've had success POSTing the resource(s) within a transaction bundle instead.

view this post on Zulip Nath (Jun 11 2020 at 15:10):

thanks @Frederik Leonhardt . yea, the same error as in this issue just that it says for PUT but I was trying POST. So, its basically an issue for both Post and Put. I will try to wrap in a txn bundle and try it. thanks for your help. appreciate it.

view this post on Zulip Nath (Jun 12 2020 at 02:50):

I tried with wrapping in a bundle but I get this error
curl --location --request POST 'http://localhost:8090/fhir' \
--header 'Content-Type: application/fhir+json' \
--header 'X-Platform-Key: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJpYXQiOjE1OTE4Mjc3MDAsImV4cCI6MTU5Mjc1NjUwMCwiaXNzIjoiaHR0cHM6Ly9wbGF0Zm9ybS5uYXZpZnkuY29tIiwic3ViIjoiZTVlMzg0ZmYtMTc0MC00ZWQ0LWFkYmItZTUxOGRiMjRjYmMwIiwidGVuYW50X2lkIjoiMGYwNWEyNDAtZjI5YS0xMWU4LWE4ZDEtYWZkZGM2OWM0ZGI5Iiwicm9sZXMiOlsicGxhdGZvcm1BZG1pbiJdLCJjbGFpbXMiOlsicmVhZEFwcHMiLCJyZWFkQXBwIiwidXBkYXRlQXBwcyIsImRlbGV0ZUFwcHMiLCJkZXBsb3lBcHBzIl19.wjqxx6-Ypn-zEeqQLFCxBdGxUKIsmOh1t8O9pAiJRCp3lVQYSmNBLxvX23NNtjZBj_OvxvTIg62WKiWhiA_Rym2yA24od99TnFb0PnNrQHZjZ-PnjymqQWsk8fDRbFY3bGgL1J-hZhchjO55AjYzIYd-c-s2EWGI9jR5XE98EIsSULZMlpXnp91Bvs7Xz__bKCWP63MmoNBmZNfe_R9r0bFLLBuR9oKicZcNB6eo8FkRn8qGIFKEkNwG8TnIpq9bWTgBkZoVRsIcm3G_S8EQZbne28tXlD3cMKJdXDYr_n5zIR0K8lOXKSlCGCX7jZ2swhTYVewqfqhBeiRpEPMhaQ' \
--header 'Cookie: JSESSIONID=BBAF1280718966F3969D5CDE6AF046FD' \
--data-raw '{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource" : "ValueSet",
"id" : "action-type",
"meta" : {
"lastUpdated" : "2019-11-01T09:29:23.356+11:00",
"profile" : ["http://hl7.org/fhir/StructureDefinition/shareablevalueset"]
},
"text" : {
"status" : "generated",
"div" : "<div>!-- Snipped for Brevity --></div>"
},
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg",
"valueCode" : "cds"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
"valueCode" : "trial-use"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm",
"valueInteger" : 2
}],
"url" : "http://hl7.org/fhir/ValueSet/action-type",
"identifier" : [{
"system" : "urn:ietf:rfc:3986",
"value" : "urn:oid:2.16.840.1.113883.4.642.3.809"
}],
"version" : "4.0.1",
"name" : "ActionType",
"title" : "ActionType",
"status" : "draft",
"experimental" : false,
"date" : "2019-11-01T09:29:23+11:00",
"publisher" : "HL7 (FHIR Project)",
"contact" : [{
"telecom" : [{
"system" : "url",
"value" : "http://hl7.org/fhir"
},
{
"system" : "email",
"value" : "fhir@lists.hl7.org"
}]
}],
"description" : "The type of action to be performed.",
"immutable" : true,
"compose" : {
"include" : [{
"system" : "http://terminology.hl7.org/CodeSystem/action-type"
}]
},
"request": {
"method": "POST",
"url": "/ValueSet"
}
}
]
}'

Error
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "theResource must not be null"
}
]
}

stacktrace
020-06-11 19:49:24.652 WARN 20217 --- [nio-8090-exec-2] ca.uhn.fhir.parser.LenientErrorHandler : Unknown attribute 'value' found while parsing
2020-06-11 19:49:24.660 ERROR 20217 --- [nio-8090-exec-2] c.u.f.r.s.i.ExceptionHandlingInterceptor : Failure during REST processing: java.lang.NullPointerException: theResource must not be null

java.lang.NullPointerException: theResource must not be null
at org.apache.commons.lang3.Validate.notNull(Validate.java:225) ~[commons-lang3-3.9.jar!/:3.9]
at ca.uhn.fhir.context.FhirContext.getResourceDefinition(FhirContext.java:428) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.ParserState$PreResourceState.stitchBundleCrossReferences(ParserState.java:1055) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.ParserState$PreResourceState.endingElement(ParserState.java:950) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.ParserState.endingElement(ParserState.java:106) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1112) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1015) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1098) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1079) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1015) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:196) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:178) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:710) ~[hapi-fhir-base-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.ResourceParameter.loadResourceFromRequest(ResourceParameter.java:184) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.ResourceParameter.parseResourceFromRequest(ResourceParameter.java:227) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.TransactionParameter.translateQueryParametersIntoServerArgument(TransactionParameter.java:85) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.BaseMethodBinding.createMethodParams(BaseMethodBinding.java:98) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:245) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:384) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:1002) ~[hapi-fhir-server-4.2.0.jar!/:na]
at ca.uhn.fhir.rest.server.RestfulServer.doPost(RestfulServer.java:346) ~[hapi-fhir-server-4.2.0.jar!/:na]


Last updated: Apr 12 2022 at 19:14 UTC