dm+d storage using sqlite
dm+d storage using sqlite
(apids conn id)
Return AMP ids for the given product.
Return AMP ids for the given product.
(apids-for-vpids conn vpids)
Return APIDs for the given VPIDs.
Return APIDs for the given VPIDs.
(appids conn id)
Return AMPP ids for the given product.
Return AMPP ids for the given product.
(atc->ecl conn
atc
&
{:keys [include-tf? include-product-packs?]
:or {include-tf? false include-product-packs? false}})
Convert an ATC code regexp into a SNOMED CT expression that will identify all
dm+d products relating to that code. It is almost always better to build an
ECL expression using atc->products-for-ecl
rather than this function.
Not all VMPs have a VTM, but a given VTM will subsume all VTMs, VMPs and AMPs in the SNOMED drug model.
Unfortunately, while the UK SNOMED drug extension includes trade family entities, dm+d does not. This is unfortunate. In order to identify the TF concept for any given AMP, we can use an ECL expression of the form (>'amp-concept-id' AND <9191801000001103|Trade Family|) to identify parent concepts in the hierarchy up to and not including the TF concept itself. However, this can result in a very long expression indeed. If you need to build an ECL expression that includes TF, this is better done within the context of the SNOMED drug extension. You can use 'atc->products-for-ecl' to help build that ECL expression.
It would not be usual to want to include VMPP or AMPP, but you can include if required. All AMPPs are subsumed by VMPPs, so we simply add clauses to include VMPPs and descendants for each VMP using the 'Has VMP' relationship.
Convert an ATC code regexp into a SNOMED CT expression that will identify all dm+d products relating to that code. It is almost always better to build an ECL expression using `atc->products-for-ecl` rather than this function. Not all VMPs have a VTM, but a given VTM will subsume all VTMs, VMPs and AMPs in the SNOMED drug model. Unfortunately, while the UK SNOMED drug extension includes trade family entities, dm+d does not. This is unfortunate. In order to identify the TF concept for any given AMP, we can use an ECL expression of the form (>'amp-concept-id' AND <9191801000001103|Trade Family|) to identify parent concepts in the hierarchy up to and not including the TF concept itself. However, this can result in a very long expression indeed. If you need to build an ECL expression that includes TF, this is better done within the context of the SNOMED drug extension. You can use 'atc->products-for-ecl' to help build that ECL expression. It would not be usual to want to include VMPP or AMPP, but you can include if required. All AMPPs are subsumed by VMPPs, so we simply add clauses to include VMPPs and descendants for each VMP using the 'Has VMP' relationship.
(atc->products-for-ecl conn atc)
Returns a map containing product type as key and a sequence of product identifiers as each value, designed for building an ECL expression.
As the child relationships of a VTM include all VMPs and AMPs, we do not have to include VMPs or AMPs unless there is no VTM for a given VMP. As such, VMPs are only returned iff there is no associated VTM. However, all AMPs are returned as it is likely that those will be needed in order to derive a list of TF products. It is sadly the case that the stock dm+d does not include TF products, while the SNOMED drug extension does include those products.
Returns a map containing product type as key and a sequence of product identifiers as each value, designed for building an ECL expression. As the child relationships of a VTM include all VMPs and AMPs, we do not have to include VMPs or AMPs unless there is no VTM for a given VMP. As such, VMPs are only returned iff there is no associated VTM. However, all AMPs are returned as it is likely that those will be needed in order to derive a list of TF products. It is sadly the case that the stock dm+d does not include TF products, while the SNOMED drug extension does include those products.
(atc-code conn id)
Return the ATC code for the product specified.
Return the ATC code for the product specified.
(batch->sql batch)
For the given batch of dm+d entities, return a map of :stmts and :errors
{:stmts ({:stmt "insert into SUPPLIER(CD,DESC) VALUES (?, ?) ON CONFLICT(CD) DO UPDATE SET DESC=excluded.DESC",
:data ([2070501000001104 "DDC Ltd"]
[3146101000001108 "Dragon Pharm Ltd"] ...)})}
:errors nil
For the given batch of dm+d entities, return a map of :stmts and :errors ``` {:stmts ({:stmt "insert into SUPPLIER(CD,DESC) VALUES (?, ?) ON CONFLICT(CD) DO UPDATE SET DESC=excluded.DESC", :data ([2070501000001104 "DDC Ltd"] [3146101000001108 "Dragon Pharm Ltd"] ...)})} :errors nil
(create-store filename
dirs
&
{:keys [batch-size release-date] :or {batch-size 50000}})
(create-tables conn)
Creates all database tables for dm+d entities.
Creates all database tables for dm+d entities.
(fetch-product-by-exact-name conn s)
Return a single product with the given exact name
Return a single product with the given exact name
(product-ids-from-atc conn atc)
(product-ids-from-atc conn atc product-types)
Return a lazy sequence of product ids matching the ATC code
Return a lazy sequence of product ids matching the ATC code
(vmps-from-atc conn atc)
Return VMPs matching the given ATC code as a prefix
Return VMPs matching the given ATC code as a prefix
(vpids conn id)
Return VMP ids for the given product.
Return VMP ids for the given product.
(vpids-for-apids conn apids)
Return VPIDs for the given APIDs.
Return VPIDs for the given APIDs.
(vpids-for-vtmids conn vtmids)
Returns VPIDs for the given VTMIDs.
Returns VPIDs for the given VTMIDs.
(vpids-from-atc conn atc)
Return a vector of VPIDs matching the given ATC code/prefix.
Return a vector of VPIDs matching the given ATC code/prefix.
(vpids-from-atc-wo-vtms conn atc)
Returns a vector of VPIDs matching the given ATC code/prefix that do not have an associated VTM. This is only useful when constructing SNOMED ECL expressions that use a combination of VTMs, VMPs and TFs, and therefore do not need VMPs unless there is no associated VTM.
Returns a vector of VPIDs matching the given ATC code/prefix that do not have an associated VTM. This is only useful when constructing SNOMED ECL expressions that use a combination of VTMs, VMPs and TFs, and therefore do not need VMPs unless there is no associated VTM.
(vppids conn id)
Return VMPP ids for the given product.
Return VMPP ids for the given product.
(vtmids conn id)
Return VTM ids for the given product.
Return VTM ids for the given product.
(vtmids-for-vpids conn vpids)
Return VTMIDs for the given VPIDs.
Return VTMIDs for the given VPIDs.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close