hapi-fhir-jpaserver-starter icon indicating copy to clipboard operation
hapi-fhir-jpaserver-starter copied to clipboard

IG not installed when using POST /ImplementationGuide/$install

Open rmrlangford opened this issue 1 year ago • 18 comments

Steps:

  1. In hapi.application.yaml, add the config provided at the bottom of the steps.
  2. After running docker compose up, execute GET /StructureDefinition to verify that the IG in step 1 is installed.
  3. Using the script provided: https://chat.fhir.org/#narrow/stream/179167-hapi/topic/Installing.20implementation.20guide/near/429068829, download a package into Base64 binary.
  4. Copy the contents in the file created by the aforementioned script to the body of the request for POST /ImplementationGuide/$install
  5. Execute the request POST /ImplementationGuide/$install

Actual Behaviour: When executing GET /StructureDefinition, I still see the previously installed IG from steps 1 - 2. Expected Behaviour: When executing GET /StructureDefinition, I should see the newly installed IG from step 5.

image

rmrlangford avatar Aug 25 '24 05:08 rmrlangford

I'm unable to reproduce.

I made a slight adjustment to the generation script. It is as follows:

#!/bin/bash

# URL of the file to download
file_url="https://build.fhir.org/ig/jembi/ethiopia-hiv/package.tgz"

# File name after downloading
file_name="downloaded_file"

# Download the file using curl
curl -o "$file_name" "$file_url"

# Base64 encode the file content saving it to a temp file
base64 --input="$file_name" > base64_content.txt

# Generate JSON data using jq with input from the file
json_data=$(jq -n --rawfile base64_content base64_content.txt \
            '{ "resourceType": "Parameters", "parameter": [ { "name": "npmContent", "valueBase64Binary": $base64_content }]}')


echo "$json_data" > parameters.json
  • now, I set up the server as follows: docker run -p 8080:8080 -e "hapi.fhir.ig_runtime_upload_enabled=true" hapiproject/hapi:v7.4.0

  • then I run the script above and afterwards execute curl -X POST -H "Content-Type: application/json" -d @"parameters.json" "http://localhost:8080/fhir/ImplementationGuide/\$install"

after that, then I can inspect the structuredefinitions without any problem on /fhir/StructureDefinition. @rmrlangford please try the steps above.

jkiddo avatar Aug 31 '24 22:08 jkiddo

Thanks @jkiddo , the script and process as laid out above works as expected (previous process did also when only using the $install operation).

If there is an IG already installed where after executing the curl request above, what is the expected behaviour on HAPI?

rmrlangford avatar Sep 01 '24 14:09 rmrlangford

That both IGs are installed

jkiddo avatar Sep 01 '24 14:09 jkiddo

All saved here for future runs: https://github.com/jkiddo/ig-install-parameters-generator

jkiddo avatar Sep 01 '24 17:09 jkiddo

That both IGs are installed

Thanks @jkiddo . The reason why I ask is that if I install more than 1 IG, it only shows one IG when querying StructureDefinition and zero IG's when querying ImplementationGuide.

I did two tests:

  1. Install two IG's using application.yaml (see below) then queried the two aforementioned Resources.
  2. Installed one IG (Ethiopia HIV) using a new application.yaml and used the new script to install a Botswana Lab IG. After that, queried the two aforementioned Resources.

Both tests give me the same findings.

And thanks for creating the repo for the new scripts!

image

rmrlangford avatar Sep 02 '24 07:09 rmrlangford

I can't reproduce. I tried issuing an $install twice with the two different IG's on the server. Both IG's are installed

jkiddo avatar Sep 02 '24 07:09 jkiddo

Thanks @jkiddo , will test in a few hours and get back to you.

rmrlangford avatar Sep 02 '24 18:09 rmrlangford

@rmrlangford did this work?

joofio avatar Sep 25 '24 12:09 joofio

Hi @joofio , apologies for the late follow-up, I admit that I totally forgot about this due to other distractions. I was in the process of testing this but getting some weird issues and not sure why. Please see below.

Note: this first one is encountered when using the $install operation or when using a the implementation guides config in hapi.fhir.implementationguides

image

When using the $install operation, it doesnt seem to work and likely related to the above issue. I am starting to wonder if this is perhaps an issue local to my machine but I have deleted existing HAPI images, started the process from the beginning again yet when calling StructureDefinition to ensure that my IG is installed, I get nothing back.

image image

Commented out existing IGs to be sure that if the $install operation is used that the IG is installed when calling StructureDefinition. image

rmrlangford avatar Sep 26 '24 08:09 rmrlangford

@rmrlangford I looked at your sample IG. Your Extensions (StructureDefs) has the status https://github.com/jembi/Starter-FHIR-IG/blob/33fe1b767fd1d42301c1fe290e09bbdd543466d1/input/fsh/extension.fsh#L10 draft. Flip them to active and try again. RuleSet for what is being installed and deemed 'valid' can be found here: https://github.com/hapifhir/hapi-fhir/blob/3f6d1eb29beb44232e56d5974e78d29ec1c83506/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java#L581

jkiddo avatar Sep 26 '24 10:09 jkiddo

Thanks @jkiddo , that was helpful! So the new script for the $install operation works perfectly and have verified its installation by calling StructureDefinition.

Possibly something unrelated and dont want to postpone the closure of this ticket intentionally but when installing two IG's it seems to always only return the StructureDefinitions for the very last IG installed.

image

rmrlangford avatar Sep 26 '24 12:09 rmrlangford

Have you trawled through all pages in the response from the server?

jkiddo avatar Sep 26 '24 12:09 jkiddo

Ahh right, yes...I know what the issue is...will confirm in a second.

rmrlangford avatar Sep 26 '24 12:09 rmrlangford

So the issue with the IG was that it's artifacts also had a status of draft so changed to active. Still, after doing that, only one IG's StructureDefinition is shown and this time, for the first IG. I think it will be best for me to do a screen recoding and narrative and then share that? So not sure if you prefer to resolve this issue given that the $install operation is working and then based on the findings from my screen recoding, we can open a new issue (if applicable)?

No errors on server.

rmrlangford avatar Sep 26 '24 12:09 rmrlangford

@rmrlangford can I ask you to be more specific. I only identified that you were referring to you sample IG because it was stated in the logs. Which IG's are you exactly referring to?

jkiddo avatar Sep 27 '24 15:09 jkiddo

@jkiddo We are also facing a lot of problem related to ig installation. We are not sure if the package itself contains the wrong or improper resources or there is something wrong in the hapi-fhir server itself. The issue is mainly with the hl7.fhir.r4.core package.

hapi:
  fhir:
    implementationguides:
      fhir-core:
        name: hl7.fhir.r4.core
        version: 4.0.1
        reloadExisting: false
        installMode: STORE_AND_INSTALL

Caused by: ca.uhn.fhir.parser.DataFormatException: HAPI-1684: Unknown resource name "DomainResource" (this name is not known in FHIR version "R4")

If we try to install via ImplementationGuide/$install (by removing the domainresource from the tar package):

Postgres log

 2025-10-14 06:50:00.479 UTC [267] ERROR:  duplicate key value violates unique constraint "idx_codesystem_and_ver"

2025-10-14 06:50:00.479 UTC [267] DETAIL:  Key (codesystem_pid, cs_version_id)=(995, 2018-08-12) already exists.

2025-10-14 06:50:00.479 UTC [267] STATEMENT:  update trm_codesystem_ver set cs_display=$1,codesystem_pid=$2,cs_version_id=$3,partition_id=$4,res_id=$5 where pid=$6

2025-10-14 06:50:00.487 UTC [267] ERROR:  current transaction is aborted, commands ignored until end of transaction block

2025-10-14 06:50:00.487 UTC [267] STATEMENT:  update hfj_resource rt1_0 set sp_index_status=$1 where rt1_0.res_id=$2

2025-10-14 06:51:01.127 UTC [270] ERROR:  duplicate key value violates unique constraint "idx_codesystem_and_ver"

2025-10-14 06:51:01.127 UTC [270] DETAIL:  Key (codesystem_pid, cs_version_id)=(310, 4.0.1) already exists.

2025-10-14 06:51:01.127 UTC [270] STATEMENT:  update trm_codesystem_ver set cs_display=$1,codesystem_pid=$2,cs_version_id=$3,partition_id=$4,res_id=$5 where pid=$6

2025-10-14 06:51:01.169 UTC [270] ERROR:  current transaction is aborted, commands ignored until end of transaction block

2025-10-14 06:51:01.169 UTC [270] STATEMENT:  update hfj_resource rt1_0 set sp_index_status=$1 where rt1_0.res_id=$2

2025-10-14 06:51:27.690 UTC [55] LOG:  checkpoint complete: wrote 2395 buffers (14.6%); 0 WAL file(s) added, 0 removed, 2 recycled; write=238.839 s, sync=0.028 s, total=238.896 s; sync files=91, longest=0.005 s, average=0.001 s; distance=32558 kB, estimate=48449 kB

2025-10-14 06:52:28.736 UTC [55] LOG:  checkpoint starting: time

2025-10-14 06:55:55.428 UTC [55] LOG:  checkpoint complete: wrote 2074 buffers (12.7%); 0 WAL file(s) added, 0 removed, 1 recycled; write=206.663 s, sync=0.007 s, total=206.693 s; sync files=87, longest=0.006 s, average=0.001 s; distance=26848 kB, estimate=46289 kB

2025-10-14 06:57:28.502 UTC [55] LOG:  checkpoint starting: time

2025-10-14 07:00:08.734 UTC [55] LOG:  checkpoint complete: wrote 1599 buffers (9.8%); 0 WAL file(s) added, 0 removed, 1 recycled; write=160.187 s, sync=0.013 s, total=160.232 s; sync files=74, longest=0.005 s, average=0.001 s; distance=18731 kB, estimate=43533 kB

2025-10-14 07:01:01.509 UTC [363] ERROR:  duplicate key value violates unique constraint "idx_codesystem_and_ver"

2025-10-14 07:01:01.509 UTC [363] DETAIL:  Key (codesystem_pid, cs_version_id)=(310, 4.0.1) already exists.

2025-10-14 07:01:01.509 UTC [363] STATEMENT:  update trm_codesystem_ver set cs_display=$1,codesystem_pid=$2,cs_version_id=$3,partition_id=$4,res_id=$5 where pid=$6

2025-10-14 07:01:01.570 UTC [363] ERROR:  current transaction is aborted, commands ignored until end of transaction block


hapi-server logs:

2025-10-14T11:20:18.731+05:45 ERROR 2000069 --- [-notification-5] ca.uhn.fhir.log.batch_troubleshooting : Error during job[620b9a91-d266-4d61-a8b2-a1938251d] step[reindex-start]: Failed to reindex resource ConceptMap/cdshooks-indicator/history/1: ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException: HAPI-0840: Can not create multiple ConceptMap resources with ConceptMap.url "http://cds-hooks.hl7.org/ConceptMap/indicator-to-request-priority", already have one with resource ID: ConceptMap/cdshooks-indicator
2025-10-14T11:20:18.732+05:45 INFO 2000069 --- [-notification-5] ca.uhn.fhir.log.batch_troubleshooting : Temporary problem executing job REINDEX step reindex-start, marking chunk 9d99c0b-b3c94-4545-8e0a-71829f009548 as RETRIABLE ERRORED
2025-10-14T11:20:18.737+05:45 ERROR 2000069 --- [-notification-5] f.j.s.c.i.RetryingMessageHandlerWrapper : Failure 1 processing message in channel [batch2-work-notification]: ca.uhn.fhir.batch.api.JobStepFailedException: HAPI-2041: Transaction silently rolled back because it has been marked as rollback-only
2025-10-14T11:20:18.737+05:45 ERROR 2000069 --- [-notification-5] f.j.s.c.i.RetryingMessageHandlerWrapper : Failure

centaurusgod avatar Oct 14 '25 08:10 centaurusgod

@centaurusgod you should not install the standard publications. Thats not needed and they will be ignored: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/cf003331e4d30e23065022fa771fad828e5d958b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java#L248

jkiddo avatar Oct 14 '25 08:10 jkiddo

@jkiddo Thanks for replying.

But the ValueSets like practitioner-role, ucum-bodytemp etc. are present in the hl7.fhir.r4.core package. If this package is ignored, how are we supposed to perform ValueSet/$expand and CodeSystem/$lookup operations?

centaurusgod avatar Nov 10 '25 09:11 centaurusgod