CDCgov / dibbs-query-connector

A FHIR client allowing public health agencies to query health care organizations directly or via a TEFCA QHIN
Creative Commons Zero v1.0 Universal
4 stars 0 forks source link

insert valueset function #49

Closed fzhao99 closed 3 weeks ago

fzhao99 commented 1 month ago

PULL REQUEST

Summary

Adds a insertValueSet function that takes our internal ValueSet struct and attempts to insert the ValueSet, associated concepts, and associated concept <> valueset joins into the db.

I pushed a branch https://github.com/CDCgov/dibbs-query-connector/tree/bob/38-insert-valueset-test that 1) deletes migrations 2-6 so that on spinup, the db gets created without any data that also 2) has a button on the homepage that will insert the single example valueset that we added in a previous PR into the database. You can test that the code is working locally by running that branch, connecting to your db using your favorite Postgres viewer, and then hitting the below button. Hopefully, the example data should insert the valueset / concept / joins accordingly, and after, subsequent attempts at joining won't do anything .

Screenshot 2024-10-24 at 3 36 43 PM

Related Issue

Fixes #57

Acceptance Criteria

_Given the a valueset’s name, codes, system, externalid, author, relevant reportable conditions, and the clinical concept type the codes represent add the value set to the QC DB - Valuesets are uniquely identified by OID and version number - The behavior of this function should be idempotent

Idempotency considerations:

Additional consideration

Did a little more thinking around the conversation around concept-level fault tolerance at our previous meeting and made a ticket to expand this work rather than address it here. I think the core scope of the ticket is available as is, and I think that line of work can be parallelized with the next default query building step to flesh out the rest of the db creation refactoring.

robertandremitchell commented 4 weeks ago

@fzhao99 , is it okay if I push some changes to this branch: https://github.com/CDCgov/dibbs-query-connector/tree/bob/38-insert-valueset-test ? I had to touch up some things to get linting to pass

fzhao99 commented 3 weeks ago

I wonder if we want

tefca-viewer-1  | ValueSet <> concept join insert failed
tefca-viewer-1  | error: duplicate key value violates unique constraint "valueset_to_concept_pkey"

...I guess it will depend on how often we expect STLTs to update a valueset versus it maybe being a one-time thing they do per condition/topic area. I guess if we eventually add a remove option it's not the biggest deal, and it's probably better to have the remove/re-insert as two steps to ensure things aren't happening automatically/accidentally without people being aware of what's happening.

Thanks for raising! I think the handling of the valueset update flow deserves some larger consideration since I'm not sure when valuesets will be fully deleted versus just being updated with a new version. Depending on where we land on version addition vs update-in-place, think this join interaction would need different considerations.