Skip to content

Commit

Permalink
Merge pull request #251 from ngiger/master
Browse files Browse the repository at this point in the history
BSV-Import: Fix updating iksnr smaller 6 digits
  • Loading branch information
zdavatz authored Feb 22, 2024
2 parents 2dd9dcb + a2c3e4f commit 54eb429
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 173 deletions.
16 changes: 0 additions & 16 deletions jobs/update_narcotics

This file was deleted.

25 changes: 12 additions & 13 deletions src/plugin/bsv_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ def tag_start name, attrs
@valid_from = nil
@ppub_change_code = nil
@price = nil
@price_type = :public
@price_public = Util::Money.new(0, :public, 'CH')
@price_public.origin = @origin
@price_public.authority = :sl
@price_type = :public
when 'Limitation'
@in_limitation = true
when 'ItCode'
Expand Down Expand Up @@ -353,25 +353,23 @@ def tag_end name
})
elsif @pack && !@duplicate_iksnr
## don't take the Swissmedic-Category unless it's missing in the DB
## IKS Cat kommt von der Swissmedic Packungen Datei
@data.delete :ikscat if @pack.ikscat
@data.delete :narcotic # Der Narcotics Flag kommt von der Swissmedic Packungen Datei, Spalte X.
if !@price_exfactory.to_s.eql?(@pack.price_exfactory.to_s) || !@pexf_change_code.eql?(@pack.price_exfactory.mutation_code)
LogFile.debug "#{@iksnr} #{@pack.seqnr} #{@ikscd}: #{@price_exfactory.valid_from.to_date} set price_exfactory #{@pack.price_exfactory} now #{@price_exfactory}. #{@pack.price_exfactory&.mutation_code} now #{@pexf_change_code}"
@pack.price_exfactory = @price_exfactory
@pack.price_exfactory.mutation_code = @pexf_change_code
@pack.price_exfactory.valid_from = @price_exfactory.valid_from
@data.store :price_exfactory, @price_exfactory
end if @price_exfactory
if !@price_public.to_s.eql?(@pack.price_public.to_s) || !@ppub_change_code.eql?(@pack.price_public.mutation_code)
LogFile.debug "#{@iksnr} #{@pack.seqnr} #{@ikscd}: #{@price_public.valid_from.to_date} set price_public #{@pack.price_public} now #{@price_public}. #{@pack.price_public&.mutation_code} now #{@ppub_change_code}"
@pack.price_public = @price_public
@pack.price_public.valid_from = @price_public.valid_from
@pack.price_public.mutation_code = @ppub_change_code
@data.store :price_public, @price_public
end if @price_public
@data.delete(:sl_generic_type) if @pack.generic_type.eql?(@data[:sl_generic_type])
@data.delete(:deductible) if @pack.deductible.eql?(@data[:deductible])
@data.delete(:ikscat) if @pack.registration.ikscat.eql?(@data[:ikscat])
@data.delete(:narcotic) if @pack.narcotic?.eql?(@data[:narcotic])
@pack.deductible.eql?(@data[:deductible]) ? @data.delete(:deductible) : @pack.deductible = @data[:deductible]
@pack.sl_generic_type.eql?(@data[:sl_generic_type]) ? @data.delete(:sl_generic_type) : @pack.sl_generic_type = @data[:sl_generic_type]
if @data.keys.size > 0
@app.update @pack.pointer, @data, :bag
end
Expand Down Expand Up @@ -528,7 +526,7 @@ def tag_end name
end
if @registration
@ikscd = '%03i' % @text[-3,3].to_i
@pack ||= @app.package_by_ikskey(@text)
@pack ||= @app.package_by_ikskey(sprintf('%08i', @text.to_i))
@out_of_trade = @pack.out_of_trade if @pack
if !@pack.nil? && @pack.pointer.nil?
@pack.fix_pointers
Expand Down Expand Up @@ -558,19 +556,17 @@ def tag_end name
@sl_data.store :bsv_dossier, @text if @sl_data
when 'LastPriceChange' # just ignore
when 'ExFactoryPrice'
@price_exfactory = Util::Money.new(@price_amount, @price_type, 'CH')
@price_exfactory = Util::Money.new(@price_amount, :exfactory, 'CH')
@price_exfactory.origin = @origin
@price_exfactory.authority = :sl
@price_exfactory.mutation_code = @pexf_change_code
@price_exfactory.valid_from = @valid_from
@data.store :"price_#{@price_type}", @price_exfactory
when 'PublicPrice'
@price_public = Util::Money.new(@price_amount, @price_type, 'CH')
@price_public = Util::Money.new(@price_amount, :public, 'CH')
@price_public.origin = @origin
@price_public.authority = :sl
@price_public.mutation_code = @ppub_change_code
@price_public.valid_from = @valid_from
@data.store :"price_#{@price_type}", @price_public
when 'Price'
@price_amount = @text
when 'ValidFromDate'
Expand Down Expand Up @@ -721,16 +717,19 @@ def fix_flags_with_rss_logic
first = Time.local(cutoff.year, cutoff.month, cutoff.day)
last = Time.local(today.year, today.month, today.day)
range = first..last
if (current = @price) && range.cover?(current.valid_from) && !@pack.nil?
if (current = @price_public) && range.cover?(current.valid_from) && !@pack.nil?
previous = @pack.price_public
if previous.nil?
if current.authority == :sl
LogFile.debug("fix_flags_with_rss_logic #{@iksnr} sl_entry")
flag_change @pack.pointer, :sl_entry
end
elsif [:sl, :lppv, :bag].include?(@pack.data_origin(:price_public))
if previous > current
LogFile.debug("fix_flags_with_rss_logic #{@iksnr} price_cut")
flag_change @pack.pointer, :price_cut
elsif current > previous
LogFile.debug("fix_flags_with_rss_logic #{@iksnr} price_rise")
flag_change @pack.pointer, :price_rise
end
end
Expand Down
65 changes: 0 additions & 65 deletions src/plugin/narcotic.rb

This file was deleted.

4 changes: 0 additions & 4 deletions src/util/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require 'plugin/epha_interactions'
require 'plugin/lppv'
require 'plugin/medical_products'
require 'plugin/narcotic'
require 'plugin/ouwerkerk'
require 'plugin/rss'
require 'plugin/swissmedic'
Expand Down Expand Up @@ -367,9 +366,6 @@ def update_recall_feed(month = @@today)
def update_hpc_feed(month = @@today)
update_immediate_with_error_report(RssPlugin, 'hpc.rss', :update_hpc_feed)
end
def update_btm(path)
update_notify_simple(NarcoticPlugin, 'Narcotics (XLS)', :update_from_xls, [path])
end
def update_swissmedic(*args)
logs_pointer = Persistence::Pointer.new([:log_group, :swissmedic])
logs = @app.create(logs_pointer)
Expand Down
131 changes: 131 additions & 0 deletions test/data/xml/hepatec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Preparations ReleaseDate="01.02.2024">
<Preparation ProductCommercial="3439">
<NameDe>Hepatect CP</NameDe>
<NameFr>Hepatect CP</NameFr>
<NameIt>Hepatect CP</NameIt>
<DescriptionDe>Inj Lös 500 E/10ml </DescriptionDe>
<DescriptionFr>sol inj 500 U/10ml </DescriptionFr>
<DescriptionIt>Inj Lös 500 E/10ml </DescriptionIt>
<AtcCode>J06BB04</AtcCode>
<FlagItLimitation>Y</FlagItLimitation>
<OrgGenCode />
<FlagSB20>N</FlagSB20>
<FlagGGSL>N</FlagGGSL>
<CommentDe />
<CommentFr />
<CommentIt />
<VatInEXF>N</VatInEXF>
<GammeNumber>1165</GammeNumber>
<GammeName>Hepatect Parenteral</GammeName>
<Preismodell />
<Packs>
<Pack ProductKey="3439" PackId="5045">
<DescriptionDe>Amp 10 ml</DescriptionDe>
<DescriptionFr>amp 10 ml</DescriptionFr>
<DescriptionIt>Amp 10 ml</DescriptionIt>
<SwissmedicCategory>B</SwissmedicCategory>
<SwissmedicNo8>488001</SwissmedicNo8>
<SwissmedicNo8ParallelImp />
<FlagNarcosis>N</FlagNarcosis>
<FlagModal>Y</FlagModal>
<FlagGGSL>N</FlagGGSL>
<BagDossierNo>16710</BagDossierNo>
<GTIN>7680004880018</GTIN>
<SizePack />
<PrevGTINcode />
<Limitations />
<PointLimitations />
<Prices>
<PublicPrice>
<Price>415.25</Price>
<ValidFromDate>01.01.2024</ValidFromDate>
<DivisionDescription />
<PriceTypeCode>PPUB</PriceTypeCode>
<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>
<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>
<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>
<PriceChangeTypeCode>MWSTAENDERUNG</PriceChangeTypeCode>
<PriceChangeTypeDescriptionDe>MwSt-Änderung</PriceChangeTypeDescriptionDe>
<PriceChangeTypeDescriptionFr>MwSt-Änderung</PriceChangeTypeDescriptionFr>
<PriceChangeTypeDescriptionIt>MwSt-Änderung</PriceChangeTypeDescriptionIt>
</PublicPrice>
<ExFactoryPrice>
<Price>347.09</Price>
<ValidFromDate>01.12.2022</ValidFromDate>
<DivisionDescription />
<PriceTypeCode>PEXF</PriceTypeCode>
<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>
<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>
<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>
<PriceChangeTypeCode>3JUEBERPRUEF</PriceChangeTypeCode>
<PriceChangeTypeDescriptionDe>Preisänderung nach 3-jährlicher Überprüfung der Aufnahmebedingungen</PriceChangeTypeDescriptionDe>
<PriceChangeTypeDescriptionFr>Réduction de prix à cause du réexamen des conditions d’admission tous les trois ans</PriceChangeTypeDescriptionFr>
<PriceChangeTypeDescriptionIt>Preisänderung nach 3-jährlicher Überprüfung der Aufnahmebedingungen</PriceChangeTypeDescriptionIt>
<LastPriceChange>01.12.2022</LastPriceChange>
</ExFactoryPrice>
</Prices>
<Partners>
<Partner>
<PartnerType>V</PartnerType>
<Description>Biotest (Schweiz) AG</Description>
<Street>Schützenstrasse 17</Street>
<ZipCode>5102</ZipCode>
<Place>Rupperswil</Place>
<Phone>+41628890000</Phone>
</Partner>
</Partners>
<Status>
<IntegrationDate>15.03.1997</IntegrationDate>
<ValidFromDate>15.03.1997</ValidFromDate>
<ValidThruDate>31.12.9999</ValidThruDate>
<StatusTypeCodeSl>0</StatusTypeCodeSl>
<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>
<FlagApd>N</FlagApd>
</Status>
</Pack>
</Packs>
<Substances>
<Substance>
<DescriptionLa>Immunoglobulinum humanum hepatitidis B</DescriptionLa>
<Quantity>500</Quantity>
<QuantityUnit>UI</QuantityUnit>
</Substance>
</Substances>
<Limitations>
<Limitation>
<LimitationCode>EXPO TRANSPL</LimitationCode>
<LimitationType>DIA</LimitationType>
<LimitationNiveau>P</LimitationNiveau>
<IndicationsCodes />
<DescriptionDe>Bei Exposition und bei Transplantationen.</DescriptionDe>
<DescriptionFr>En cas d'exposition et de transplantations.</DescriptionFr>
<DescriptionIt>In caso di esposizione e di trapianti.</DescriptionIt>
<ValidFromDate>01.01.2007</ValidFromDate>
<ValidThruDate>31.12.9999</ValidThruDate>
</Limitation>
</Limitations>
<ItCodes>
<ItCode Code="08.">
<DescriptionDe>INFEKTIONSKRANKHEITEN</DescriptionDe>
<DescriptionFr>MALADIES INFECTIEUSES</DescriptionFr>
<DescriptionIt>MALATTIE INFETTIVE </DescriptionIt>
<Limitations />
</ItCode>
<ItCode Code="08.09.">
<DescriptionDe>Immuno-Globuline ex Plasma humano</DescriptionDe>
<DescriptionFr>Immuno-Globuline ex Plasma humano</DescriptionFr>
<DescriptionIt>Immunoglobuline umane </DescriptionIt>
<Limitations />
</ItCode>
</ItCodes>
<Status>
<IntegrationDate>15.03.1997</IntegrationDate>
<ValidFromDate>15.03.1997</ValidFromDate>
<ValidThruDate>31.12.9999</ValidThruDate>
<StatusTypeCodeSl>0</StatusTypeCodeSl>
<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>
<FlagApd>N</FlagApd>
</Status>
</Preparation>
</Preparations>
Loading

0 comments on commit 54eb429

Please sign in to comment.