Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike dmd codelist builder #2071

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jongmassey
Copy link
Contributor

Fixes #176

In-person hack with @evansd and @inglesp to provide ingredient, VMP, and AMP name based building of dm+d codelists

Co-authored-by: Peter Inglesby <[email protected]>
Co-authored-by: Dave Evans <[email protected]>
@Jongmassey
Copy link
Contributor Author

Jongmassey commented Oct 21, 2024

Having done a bit more digging, the NHSBSA dm+d supplementary file (aka dmdbonus) has VTM to ingredient mapping. This presents us with an opportunity to present the search results by VTM hierarchy more clearly.

This would require the dmd supplementary data to be added to the dm+d coding system.

For example, the descendent relationships defined here, go from ing-to-vmp, ing-to-amp, vmp-to-amp. This could be simplified to (assuming vtm ingredient as VTI)

vtms = VTM.objects.using(self.database_alias).filter(
   Q(vti__ing_id__in=codes) | Q(id__in=codes)
)
vmps = VMP.objects.using(self.database_alias).filter(
   Q(vtm__in=[vtm.id from vtm in vtms_from_ings]) | Q(id__in=codes)
)
amps = AMP.objects.using(self.database_alias).filter(vmp_id__in=[vmp.id for vmp in vmps_from_ings])

rv = (
   {
      (vti.ing_id, vtm.id)
      for vtm in vtms 
      for vti in vtm.vti_set.all()
    }
    | {(vmp.vtm_id, vmp.id) for vmp in vmps}
    | {(amp.vmp_id, amp.id) for amp in amps}
  )
return rv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Medicines definition builder
1 participant