Class: ODDB::TestBsvXmlPlugin

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
test/test_plugin/bsv_xml.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



24
25
26
27
28
29
30
31
32
33
34
# File 'test/test_plugin/bsv_xml.rb', line 24

def setup
  @url = 'http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip'
  ODDB.config.url_bag_sl_zip = @url
  @archive = File.expand_path '../data', File.dirname(__FILE__)
  @zip = File.join @archive, 'xml', 'XMLPublications.zip'
  @app = flexmock 'app'
  @plugin = BsvXmlPlugin.new @app
  @src = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<Preparations ReleaseDate=\"01.11.2008\">\n<Preparation ProductCommercial=\"33\">\n<NameDe>Ponstan</NameDe>\n<NameFr>Ponstan</NameFr>\n<NameIt>Ponstan</NameIt>\n<DescriptionDe>Filmtabs 500 mg </DescriptionDe>\n<DescriptionFr>filmtabs 500 mg </DescriptionFr>\n<DescriptionIt>filmtabs 500 mg </DescriptionIt>\n<AtcCode>M01AG01</AtcCode>\n<SwissmedicNo5>39271</SwissmedicNo5>\n<FlagItLimitation>Y</FlagItLimitation>\n<OrgGenCode>O</OrgGenCode>\n<FlagSB20>N</FlagSB20>\n<CommentDe />\n<CommentFr />\n<CommentIt />\n<Packs>\n<Pack Pharmacode=\"703279\" PackId=\"8853\" ProductKey=\"33\">\n<DescriptionDe>12 Stk</DescriptionDe>\n<DescriptionFr>12 pce</DescriptionFr>\n<DescriptionIt>12 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>39271028</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal>N</FlagModal>\n<BagDossierNo>12495</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>2.9</Price>\n<ValidFromDate>01.08.2006</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>NORMAL</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Normale Preismutation</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Mutation de prix normale</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Mutation de prix normale</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>7.5</Price>\n<ValidFromDate>01.08.2006</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>NORMAL</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Normale Preismutation</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Mutation de prix normale</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Mutation de prix normale</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Pfizer AG</Description>\n<Street>Sch\303\244renmoosstrasse 99</Street>\n<ZipCode>8052</ZipCode>\n<Place>Z\303\274rich</Place>\n<Phone>043/495 71 11</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>15.03.1977</IntegrationDate>\n<ValidFromDate>15.03.1977</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n</Packs>\n<Substances>\n<Substance>\n<DescriptionLa>Acidum mefenamicum</DescriptionLa>\n<Quantity>500</Quantity>\n<QuantityUnit>mg</QuantityUnit>\n</Substance>\n</Substances>\n<Limitations />\n<ItCodes>\n<ItCode Code=\"07.\">\n<DescriptionDe>STOFFWECHSEL</DescriptionDe>\n<DescriptionFr>METABOLISME</DescriptionFr>\n<DescriptionIt>METABOLISME</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"07.10.\">\n<DescriptionDe>Arthritis und rheumatische Krankheiten</DescriptionDe>\n<DescriptionFr>Arthrites et affections rhumatismales</DescriptionFr>\n<DescriptionIt>Arthrites et affections rhumatismales</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"07.10.10.\">\n<DescriptionDe>Einfache entz\303\274ndungshemmende Mittel </DescriptionDe>\n<DescriptionFr>Anti-inflammatoires simples </DescriptionFr>\n<DescriptionIt>Anti-inflammatoires simples </DescriptionIt>\n<Limitations />\n</ItCode>\n</ItCodes>\n<Status>\n<IntegrationDate>15.03.1977</IntegrationDate>\n<ValidFromDate>15.03.1977</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Preparation>\n</Preparations>\n"
  @conflicted_src = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<Preparations ReleaseDate=\"01.11.2008\">\n<Preparation ProductCommercial=\"33\">\n<NameDe>Ponstan</NameDe>\n<NameFr>Ponstan</NameFr>\n<NameIt>Ponstan</NameIt>\n<DescriptionDe>Filmtabs 500 mg </DescriptionDe>\n<DescriptionFr>filmtabs 500 mg </DescriptionFr>\n<DescriptionIt>filmtabs 500 mg </DescriptionIt>\n<AtcCode>M01AG01</AtcCode>\n<SwissmedicNo5>12345</SwissmedicNo5>\n<FlagItLimitation>Y</FlagItLimitation>\n<OrgGenCode>O</OrgGenCode>\n<FlagSB20>N</FlagSB20>\n<CommentDe />\n<CommentFr />\n<CommentIt />\n<Packs>\n<Pack Pharmacode=\"703279\" PackId=\"8853\" ProductKey=\"33\">\n<DescriptionDe>12 Stk</DescriptionDe>\n<DescriptionFr>12 pce</DescriptionFr>\n<DescriptionIt>12 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>39271028</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal>N</FlagModal>\n<BagDossierNo>12495</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>2.9</Price>\n<ValidFromDate>01.08.2006</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>NORMAL</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Normale Preismutation</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Mutation de prix normale</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Mutation de prix normale</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>7.5</Price>\n<ValidFromDate>01.08.2006</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>NORMAL</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Normale Preismutation</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Mutation de prix normale</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Mutation de prix normale</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Pfizer AG</Description>\n<Street>Sch\303\244renmoosstrasse 99</Street>\n<ZipCode>8052</ZipCode>\n<Place>Z\303\274rich</Place>\n<Phone>043/495 71 11</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>15.03.1977</IntegrationDate>\n<ValidFromDate>15.03.1977</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n</Packs>\n<Substances>\n<Substance>\n<DescriptionLa>Acidum mefenamicum</DescriptionLa>\n<Quantity>500</Quantity>\n<QuantityUnit>mg</QuantityUnit>\n</Substance>\n</Substances>\n<Limitations />\n<ItCodes>\n<ItCode Code=\"07.\">\n<DescriptionDe>STOFFWECHSEL</DescriptionDe>\n<DescriptionFr>METABOLISME</DescriptionFr>\n<DescriptionIt>METABOLISME</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"07.10.\">\n<DescriptionDe>Arthritis und rheumatische Krankheiten</DescriptionDe>\n<DescriptionFr>Arthrites et affections rhumatismales</DescriptionFr>\n<DescriptionIt>Arthrites et affections rhumatismales</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"07.10.10.\">\n<DescriptionDe>Einfache entz\303\274ndungshemmende Mittel </DescriptionDe>\n<DescriptionFr>Anti-inflammatoires simples </DescriptionFr>\n<DescriptionIt>Anti-inflammatoires simples </DescriptionIt>\n<Limitations />\n</ItCode>\n</ItCodes>\n<Status>\n<IntegrationDate>15.03.1977</IntegrationDate>\n<ValidFromDate>15.03.1977</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Preparation>\n</Preparations>\n"
  @lim_txt_src = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<Preparations ReleaseDate=\"01.04.2010\">\n<Preparation ProductCommercial=\"1018817\">\n<NameDe>Reminyl Prolonged Release</NameDe>\n<NameFr>Reminyl Prolonged Release</NameFr>\n<NameIt>Reminyl Prolonged Release</NameIt>\n<DescriptionDe>Kaps 16 mg </DescriptionDe>\n<DescriptionFr>caps 16 mg </DescriptionFr>\n<DescriptionIt>caps 16 mg </DescriptionIt>\n<AtcCode>N06DA04</AtcCode>\n<SwissmedicNo5>56754</SwissmedicNo5>\n<FlagItLimitation>Y</FlagItLimitation>\n<OrgGenCode />\n<FlagSB20>N</FlagSB20>\n<CommentDe />\n<CommentFr />\n<CommentIt />\n<Packs>\n<Pack Pharmacode=\"2993471\" PackId=\"14722\" ProductKey=\"1018817\">\n<DescriptionDe>28 Stk</DescriptionDe>\n<DescriptionFr>28 pce</DescriptionFr>\n<DescriptionIt>28 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>56754007</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal />\n<BagDossierNo>18168</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>125.8359</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>160.7</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Janssen-Cilag AG</Description>\n<Street>Sihlbruggstrasse 111</Street>\n<ZipCode>6341</ZipCode>\n<Place>Baar</Place>\n<Phone>041/767 34 34</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>01.07.2005</IntegrationDate>\n<ValidFromDate>01.07.2005</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n<Pack Pharmacode=\"\" PackId=\"14723\" ProductKey=\"1018817\">\n<DescriptionDe>84 Stk</DescriptionDe>\n<DescriptionFr>84 pce</DescriptionFr>\n<DescriptionIt>84 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>56754015</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal>Y</FlagModal>\n<BagDossierNo>18168</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>377.5076</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>449.35</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Janssen-Cilag AG</Description>\n<Street>Sihlbruggstrasse 111</Street>\n<ZipCode>6341</ZipCode>\n<Place>Baar</Place>\n<Phone>041/767 34 34</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>01.01.2010</IntegrationDate>\n<ValidFromDate>01.01.2010</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n</Packs>\n<Substances>\n<Substance>\n<DescriptionLa>Galantamini hydrobromidum</DescriptionLa>\n<Quantity />\n<QuantityUnit />\n</Substance>\n</Substances>\n<Limitations>\n<Limitation>\n<LimitationCode>THERAPIEBEG</LimitationCode>\n<LimitationType>KOM</LimitationType>\n<LimitationNiveau>IP</LimitationNiveau>\n<LimitationValue />\n<DescriptionDe>Zu Therapiebeginn Durchf\303\274hrung z.B. eines Minimentaltests.&lt;br&gt;\nErste Zwischenevaluation nach 3 Monaten, dann alle 6 Monate.&lt;br&gt;\nFalls die MMSE1)-Werte unter 10 liegen, ist die Behandlung abzubrechen.&lt;br&gt;\nDie Therapie kann nur mit einem Pr\303\244parat durchgef\303\274hrt werden.&lt;br&gt;\n\n1) mini mental status examination</DescriptionDe>\n<DescriptionFr>En d\303\251but de th\303\251rapie, application par ex. d'un test minimental.&lt;br&gt;\nPremi\303\250re \303\251valuation interm\303\251diaire apr\303\250s trois mois et ensuite tous les six mois.&lt;br&gt;\nSi les valeurs MMSE1) sont inf\303\251rieures \303\240 10, il y a lieu d'interrompre la prise du m\303\251dicament.&lt;br&gt;\nLa th\303\251rapie ne peut \303\252tre appliqu\303\251e qu'avec une pr\303\251paration.&lt;br&gt;\n\n1) mini mental status examination</DescriptionFr>\n<DescriptionIt>All'inizio della terapia si esegue ad es. un test minimentale.&lt;br&gt;\nPrima valutazione intermedia dopo 3 mesi, poi ogni 6 mesi.&lt;br&gt;\nSe i valori MMSE1) sono inferiori a 10 bisogna cessare la terapia.&lt;br&gt;\nLa terapia pu\303\262 essere effettuata soltanto con un preparato.&lt;br&gt;\n\n1) mini mental status examination</DescriptionIt>\n<ValidFromDate>01.01.2007</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n</Limitation>\n</Limitations>\n<ItCodes>\n<ItCode Code=\"01.\">\n<DescriptionDe>NERVENSYSTEM</DescriptionDe>\n<DescriptionFr>SYSTEME NERVEUX</DescriptionFr>\n<DescriptionIt>SYSTEME NERVEUX</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"01.99.\">\n<DescriptionDe>Varia</DescriptionDe>\n<DescriptionFr>Varia</DescriptionFr>\n<DescriptionIt>Varia</DescriptionIt>\n<Limitations />\n</ItCode>\n</ItCodes>\n<Status>\n<IntegrationDate>01.07.2005</IntegrationDate>\n<ValidFromDate>01.07.2005</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Preparation>\n<Preparation ProductCommercial=\"1018818\">\n<NameDe>Reminyl Prolonged Release</NameDe>\n<NameFr>Reminyl Prolonged Release</NameFr>\n<NameIt>Reminyl Prolonged Release</NameIt>\n<DescriptionDe>Kaps 24 mg </DescriptionDe>\n<DescriptionFr>caps 24 mg </DescriptionFr>\n<DescriptionIt>caps 24 mg </DescriptionIt>\n<AtcCode>N06DA04</AtcCode>\n<SwissmedicNo5>56754</SwissmedicNo5>\n<FlagItLimitation>Y</FlagItLimitation>\n<OrgGenCode />\n<FlagSB20>N</FlagSB20>\n<CommentDe />\n<CommentFr />\n<CommentIt />\n<Packs>\n<Pack Pharmacode=\"2993488\" PackId=\"14724\" ProductKey=\"1018818\">\n<DescriptionDe>28 Stk</DescriptionDe>\n<DescriptionFr>28 pce</DescriptionFr>\n<DescriptionIt>28 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>56754019</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal />\n<BagDossierNo>18168</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>125.8359</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>160.7</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Janssen-Cilag AG</Description>\n<Street>Sihlbruggstrasse 111</Street>\n<ZipCode>6341</ZipCode>\n<Place>Baar</Place>\n<Phone>041/767 34 34</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>01.07.2005</IntegrationDate>\n<ValidFromDate>01.07.2005</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n<Pack Pharmacode=\"\" PackId=\"14725\" ProductKey=\"1018818\">\n<DescriptionDe>84 Stk</DescriptionDe>\n<DescriptionFr>84 pce</DescriptionFr>\n<DescriptionIt>84 pce</DescriptionIt>\n<SwissmedicCategory>B</SwissmedicCategory>\n<SwissmedicNo8>56754029</SwissmedicNo8>\n<FlagNarcosis>N</FlagNarcosis>\n<FlagModal>Y</FlagModal>\n<BagDossierNo>18168</BagDossierNo>\n<Limitations />\n<PointLimitations />\n<Prices>\n<ExFactoryPrice>\n<Price>377.5076</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PEXF</PriceTypeCode>\n<PriceTypeDescriptionDe>Ex-Factory Preis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix ex-factory</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix ex-factory</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</ExFactoryPrice>\n<PublicPrice>\n<Price>449.35</Price>\n<ValidFromDate>01.03.2010</ValidFromDate>\n<Division />\n<DivisionPriveIncVat />\n<DivisionDescription />\n<PriceTypeCode>PPUB</PriceTypeCode>\n<PriceTypeDescriptionDe>Publikumspreis</PriceTypeDescriptionDe>\n<PriceTypeDescriptionFr>Prix public</PriceTypeDescriptionFr>\n<PriceTypeDescriptionIt>Prix public</PriceTypeDescriptionIt>\n<PriceChangeTypeCode>AUSLANDPV</PriceChangeTypeCode>\n<PriceChangeTypeDescriptionDe>Auslandspreisvergleich</PriceChangeTypeDescriptionDe>\n<PriceChangeTypeDescriptionFr>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionFr>\n<PriceChangeTypeDescriptionIt>Comparaison des prix avec l'\303\251tranger</PriceChangeTypeDescriptionIt>\n</PublicPrice>\n</Prices>\n<Partners>\n<Partner>\n<PartnerType>V</PartnerType>\n<Description>Janssen-Cilag AG</Description>\n<Street>Sihlbruggstrasse 111</Street>\n<ZipCode>6341</ZipCode>\n<Place>Baar</Place>\n<Phone>041/767 34 34</Phone>\n</Partner>\n</Partners>\n<Status>\n<IntegrationDate>01.01.2010</IntegrationDate>\n<ValidFromDate>01.01.2010</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Pack>\n</Packs>\n<Substances>\n<Substance>\n<DescriptionLa>Galantamini hydrobromidum</DescriptionLa>\n<Quantity />\n<QuantityUnit />\n</Substance>\n</Substances>\n<Limitations>\n<Limitation>\n<LimitationCode>THERAPIEBEG</LimitationCode>\n<LimitationType>KOM</LimitationType>\n<LimitationNiveau>IP</LimitationNiveau>\n<LimitationValue />\n<DescriptionDe>Zu Therapiebeginn Durchf\303\274hrung z.B. eines Minimentaltests.&lt;br&gt;\nErste Zwischenevaluation nach 3 Monaten, dann alle 6 Monate.&lt;br&gt;\nFalls die MMSE1)-Werte unter 10 liegen, ist die Behandlung abzubrechen.&lt;br&gt;\nDie Therapie kann nur mit einem Pr\303\244parat durchgef\303\274hrt werden.&lt;br&gt;\n\n1) mini mental status examination</DescriptionDe>\n<DescriptionFr>En d\303\251but de th\303\251rapie, application par ex. d'un test minimental.&lt;br&gt;\nPremi\303\250re \303\251valuation interm\303\251diaire apr\303\250s trois mois et ensuite tous les six mois.&lt;br&gt;\nSi les valeurs MMSE1) sont inf\303\251rieures \303\240 10, il y a lieu d'interrompre la prise du m\303\251dicament.&lt;br&gt;\nLa th\303\251rapie ne peut \303\252tre appliqu\303\251e qu'avec une pr\303\251paration.&lt;br&gt;\n\n1) mini mental status examination</DescriptionFr>\n<DescriptionIt>All'inizio della terapia si esegue ad es. un test minimentale.&lt;br&gt;\nPrima valutazione intermedia dopo 3 mesi, poi ogni 6 mesi.&lt;br&gt;\nSe i valori MMSE1) sono inferiori a 10 bisogna cessare la terapia.&lt;br&gt;\nLa terapia pu\303\262 essere effettuata soltanto con un preparato.&lt;br&gt;\n\n1) mini mental status examination</DescriptionIt>\n<ValidFromDate>01.01.2007</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n</Limitation>\n</Limitations>\n<ItCodes>\n<ItCode Code=\"01.\">\n<DescriptionDe>NERVENSYSTEM</DescriptionDe>\n<DescriptionFr>SYSTEME NERVEUX</DescriptionFr>\n<DescriptionIt>SYSTEME NERVEUX</DescriptionIt>\n<Limitations />\n</ItCode>\n<ItCode Code=\"01.99.\">\n<DescriptionDe>Varia</DescriptionDe>\n<DescriptionFr>Varia</DescriptionFr>\n<DescriptionIt>Varia</DescriptionIt>\n<Limitations />\n</ItCode>\n</ItCodes>\n<Status>\n<IntegrationDate>01.07.2005</IntegrationDate>\n<ValidFromDate>01.07.2005</ValidFromDate>\n<ValidThruDate>31.12.9999</ValidThruDate>\n<StatusTypeCodeSl>0</StatusTypeCodeSl>\n<StatusTypeDescriptionSl>Initialzustand</StatusTypeDescriptionSl>\n<FlagApd>N</FlagApd>\n</Status>\n</Preparation>\n</Preparations>\n"
end

- (Object) setup_meddata_server(opts = {})



1123
# File 'test/test_plugin/bsv_xml.rb', line 1123

def setup_meddata_server opts={}

- (Object) setup_package(opts = {})



1096
# File 'test/test_plugin/bsv_xml.rb', line 1096

def setup_package opts={}

- (Object) setup_registration(opts = {})



1114
# File 'test/test_plugin/bsv_xml.rb', line 1114

def setup_registration opts={}

- (Object) test_download_file



680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
# File 'test/test_plugin/bsv_xml.rb', line 680

def test_download_file
  # Preparing variables
  target_url = @url
  save_dir = File.expand_path 'var', File.dirname(__FILE__)
  file_name = "XMLPublications.zip"

  online_file = @zip
  temp_file = File.join save_dir, 'temp.zip'
  save_file = File.join save_dir, 
           Date.today.strftime("XMLPublications-%Y.%m.%d.zip")
  latest_file = File.join save_dir, 'XMLPublications-latest.zip'
  
  # Preparing mock objects
  flexstub(Tempfile).should_receive(:new).and_return do
    flexmock do |tempfile|
      tempfile.should_receive(:close)
      tempfile.should_receive(:unlink)
      tempfile.should_receive(:path).and_return(temp_file)
    end
  end
 
  fileobj = flexmock do |obj|
    obj.should_receive(:save_as).with(temp_file).and_return do
      FileUtils.cp online_file, temp_file   # instead of downloading
    end
    obj.should_receive(:save_as).with(save_file).and_return do
      FileUtils.cp online_file, save_file   # instead of downloading
    end
  end
  flexstub(Mechanize) do |mechclass|
    mechclass.should_receive(:new).and_return do
      flexmock do |mechobj|
        mechobj.should_receive(:get).and_return(fileobj)
      end
    end
  end

  # Downloading tests
  result = nil
  assert_nothing_raised do
    result = @plugin.download_file(target_url, save_dir, file_name)
  end
  assert_equal save_file, result

  # Not-downloading tests
  assert_nothing_raised do
    result = @plugin.download_file(target_url, save_dir, file_name)
  end
  assert_equal nil, result

  # Check files
  assert File.exist?(save_file), "download to #{save_file} failed."
  assert File.exist?(latest_file), "download to #{latest_file} failed."
ensure
  FileUtils.rm_r save_dir if File.exists? save_dir
end

- (Object) test_update_it_codes



736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'test/test_plugin/bsv_xml.rb', line 736

def test_update_it_codes
  updates = []
  @app.should_receive(:update).times(38).and_return do |ptr, data|
    updates.push data
  end
  zip = Zip::ZipFile.open(@zip)
  zip.find_entry('ItCodes.xml').get_input_stream do |io|
    @plugin.update_it_codes io
  end
  expected = {
    :de => "NERVENSYSTEM", 
    :fr => "SYSTEME NERVEUX",
    :it => "SYSTEME NERVEUX", 
  }
  ith = updates.at(0)
  assert_equal expected, ith
  de = Text::Chapter.new
  pr = de.next_section.next_paragraph
  pr << "Gesamthaft zugelassen "
  pr.augment_format(:bold)
  pr << '120'
  pr.reduce_format(:bold)
  pr << " Punkte. "
  pr.augment_format(:bold)
  pr << "Iniectabilia sine limitatione"
  fr = Text::Chapter.new
  pr = fr.next_section.next_paragraph
  pr << "Prescription limitée au maximum à "
  pr.augment_format(:bold)
  pr << "120"
  pr.reduce_format(:bold)
  pr << " points. "
  pr.augment_format(:bold)
  pr << "Iniectabilia sine limitatione"
  it = Text::Chapter.new
  pr = it.next_section.next_paragraph
  pr << "Ammessi in totale "
  pr.augment_format(:bold)
  pr << "120"
  pr.reduce_format(:bold)
  pr << " punti. "
  pr.augment_format(:bold)
  pr << "Iniectabilia sine limitatione"
  expected = {
    :code       => "120PISL",
    :de         => de,
    :fr         => fr,
    :it         => it,
    :niveau     => "IP",
    :type       => "PKT",
    :valid_from => Date.new(2000),
    :value      => "120",
  }
  ith = updates.at(19)
  assert_equal expected, ith
end

- (Object) test_update_preparation



1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
# File 'test/test_plugin/bsv_xml.rb', line 1042

def test_update_preparation
  reg = setup_registration :iksnr => '39271'
  reg.should_receive(:packages).and_return []
  package = setup_package :pharmacode => "703279", :registration => reg, 
                          :steps => %w{39271 02 028}, 
                          :price_public => Util::Money.new(17.65), 
                          :price_exfactory => Util::Money.new(11.22)
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return package
  flexmock(Persistence).should_receive(:find_by_pointer)
  setup_meddata_server
  @app.should_receive(:registration).and_return reg
  @app.should_receive(:each_package)
  @app.should_receive(:delete)
  expected_updates = {}
  ptr = Persistence::Pointer.new [:registration, '39271']
  expected_updates.store ptr, { :generic_type => :original,
                                :index_therapeuticus => '07.10.10.' }
  ptr += [:sequence, '02']
  expected_updates.store ptr, { :atc_class => 'M01AG01' }
  pac_pointer = ptr += [:package, '028']
  data = { 
    :price_exfactory => Util::Money.new(2.9),
    :sl_generic_type => :original,
    :deductible      => :deductible_g,
    :price_public    => Util::Money.new(7.5),
    :narcotic        => false,
    :pharmacode      => '703279',
  }
  expected_updates.store ptr, data
  ptr += :sl_entry
  data = { 
    :bsv_dossier       => "12495",
    :valid_until       => Date.new(9999,12,31),
    :status            => "0",
    :valid_from        => Date.new(1977,3,15),
    :introduction_date => Date.new(1977,3,15),
    :limitation_points => nil,
    :limitation        => nil,
  }
  expected_updates.store ptr.creator, data
  @app.should_receive(:update).and_return do |ptr, data|
    assert_equal expected_updates.delete(ptr), data
  end
  @plugin.update_preparations StringIO.new(@src)
  assert_equal({}, expected_updates)
  assert_equal({pac_pointer => [:price_cut]}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  assert_equal [], listener.unknown_packages
  expected = []
  assert_equal [], listener.unknown_registrations
end

- (Object) test_update_preparation__conflicted_package



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
# File 'test/test_plugin/bsv_xml.rb', line 999

def test_update_preparation__conflicted_package
  package = setup_package :pharmacode => "987654",
                          :steps => %w{39271 02 028}, 
                          :price_public => Util::Money.new(17.65), 
                          :price_exfactory => Util::Money.new(11.22)
  reg = setup_registration :iksnr => '39271', :package => package
  reg.should_receive(:packages).and_return []
  package.should_receive(:registration).and_return reg
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return nil
  setup_meddata_server :ean13 => '7680392710281'
  @app.should_receive(:registration).and_return reg
  @app.should_receive(:each_package)
  expected_updates = {}
  ptr = Persistence::Pointer.new [:registration, '39271']
  expected_updates.store ptr, { :generic_type => :original,
                                :index_therapeuticus => '07.10.10.' }
  ptr += [:sequence, '02']
  pac_pointer = ptr += [:package, '028']
  @app.should_receive(:update).and_return do |ptr, data|
    assert_equal expected_updates.delete(ptr), data
  end
  @plugin.update_preparations StringIO.new(@conflicted_src)
  assert_equal({}, expected_updates)
  assert_equal({}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  expected = [ {
    :name_base          => "Ponstan",
    :name_descr         => "Filmtabs 500 mg ",
    :swissmedic_no5_bag => "12345",
    :swissmedic_no8_bag => "39271028",
    :pharmacode_bag     => "703279",
    :pharmacode_oddb    => "987654",
    :generic_type       => :original,
    :deductible         => :deductible_g,
    :atc_class          => "M01AG01",
  } ]
  assert_equal expected, listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  assert_equal [], listener.unknown_packages
  expected = []
  assert_equal [], listener.unknown_registrations
end

- (Object) test_update_preparation__conflicted_registration



830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
# File 'test/test_plugin/bsv_xml.rb', line 830

def test_update_preparation__conflicted_registration
  reg = setup_registration :iksnr => '39271'
  package = setup_package :pharmacode => "703279", :registration => reg, 
                          :steps => %w{39271 02 028}, 
                          :price_public => Util::Money.new(17.65), 
                          :price_exfactory => Util::Money.new(11.22)
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return package
  flexmock(Persistence).should_receive(:find_by_pointer)
  reg.should_receive(:packages).and_return []
  setup_meddata_server
  @app.should_receive(:registration).and_return reg
  @app.should_receive(:each_package)
  @app.should_receive(:delete)
  expected_updates = {}
  ptr = Persistence::Pointer.new [:registration, '39271']
  expected_updates.store ptr, { :generic_type => :original,
                                :index_therapeuticus => '07.10.10.' }
  ptr += [:sequence, '02']
  expected_updates.store ptr, { :atc_class => 'M01AG01' }
  pac_pointer = ptr += [:package, '028']
  pef = Util::Money.new(2.9)
  pef.origin = "http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (10.05.2010)"
  ppb = Util::Money.new(7.5)
  ppb.origin = "http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (10.05.2010)"
  data = { 
    :price_exfactory => pef,
    :sl_generic_type => :original,
    :deductible      => :deductible_g,
    :price_public    => ppb,
    :narcotic        => false,
    :pharmacode      => '703279',
  }
  expected_updates.store ptr, data
  ptr += :sl_entry
  data = { 
    :bsv_dossier       => "12495",
    :valid_until       => Date.new(9999,12,31),
    :status            => "0",
    :valid_from        => Date.new(1977,3,15),
    :introduction_date => Date.new(1977,3,15),
    :limitation_points => nil,
    :limitation        => nil,
  }
  expected_updates.store ptr.creator, data
  @app.should_receive(:update).and_return do |ptr, data|
    assert_equal expected_updates.delete(ptr), data, ptr.to_s
  end
  @plugin.update_preparations StringIO.new(@conflicted_src)
  assert_equal({}, expected_updates)
  assert_equal({pac_pointer => [:price_cut]}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  expected = [ {
    :name_base          => "Ponstan",
    :name_descr         => "Filmtabs 500 mg ",
    :swissmedic_no5_oddb=> "39271",
    :swissmedic_no5_bag => "12345",
    :swissmedic_no8_bag => "39271028",
    :pharmacode_bag     => "703279",
    :pharmacode_oddb    => "703279",
    :generic_type       => :original,
    :deductible         => :deductible_g,
    :atc_class          => "M01AG01",
  } ]
  assert_equal expected, listener.conflicted_registrations
  assert_equal [], listener.unknown_packages
  expected = []
  assert_equal [], listener.unknown_registrations
end

- (Object) test_update_preparation__unknown_package



927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
# File 'test/test_plugin/bsv_xml.rb', line 927

def test_update_preparation__unknown_package
  reg = setup_registration :iksnr => '39271'
  reg.should_receive(:packages).and_return []
  reg.should_receive(:sequences).and_return({})
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return nil
  setup_meddata_server :ean13 => '7680392710281'
  @app.should_receive(:registration).and_return reg
  @app.should_receive(:each_package)
  expected_updates = {}
  ptr = Persistence::Pointer.new [:registration, '39271']
  expected_updates.store ptr, [{ :generic_type => :original,
                                :index_therapeuticus => '07.10.10.' }, reg]
  ptr += [:sequence, '01']
  expected_updates.store ptr, [{ :atc_class => 'M01AG01' }, reg]
  seq = flexmock 'sequence'
  seq.should_receive(:compositions).and_return []
  seq.should_receive(:pointer).and_return ptr
  seq.should_receive(:active_agents).and_return([flexmock('active-agent')])
  reg.should_receive(:sequence).and_return(seq)
  expected_updates.store ptr.creator, [{:name_base=>"Ponstan"}, seq]
  ptr += [:package, '028']
  pac = flexmock 'package'
  pac.should_receive(:sl_entry).and_return nil
  data = { 
    :ikscat          => 'B',
    :price_exfactory => Util::Money.new(2.9),
    :sl_generic_type => :original,
    :deductible      => :deductible_g,
    :price_public    => Util::Money.new(7.5),
    :narcotic        => false,
    :pharmacode      => '703279',
  }
  seq.should_receive(:package).and_return pac
  expected_updates.store ptr.creator, [data, pac]
  part = flexmock 'part'
  data = { :composition => nil, :size => '12 Stk' }
  expected_updates.store((ptr + :part).creator, [data, pac])
  sl_entry = flexmock 'sl_entry'
  data = {
    :introduction_date => Date.new(1977, 3, 15),
    :limitation_points => nil,
    :status            => "0",
    :limitation        => nil,
    :bsv_dossier       => "12495",
  }
  expected_updates.store((ptr + :sl_entry).creator, [data, pac])
  @app.should_receive(:update).times(6).and_return do |ptr, data|
    exp, res = expected_updates.delete(ptr)
    assert_equal exp, data
    res
  end
  @plugin.update_preparations StringIO.new(@src)
  assert_equal({}, expected_updates)
  assert_equal({}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  expected = [ {
    :name_base          => "Ponstan",
    :name_descr         => "Filmtabs 500 mg ",
    :swissmedic_no5_bag => "39271",
    :swissmedic_no8_bag => "39271028",
    :pharmacode_bag     => "703279",
    :generic_type       => :original,
    :deductible         => :deductible_g,
    :atc_class          => "M01AG01",
  } ]
  assert_equal expected, listener.unknown_packages
  expected = []
  assert_equal [], listener.unknown_registrations
end

- (Object) test_update_preparation__unknown_package__out_of_trade



900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# File 'test/test_plugin/bsv_xml.rb', line 900

def test_update_preparation__unknown_package__out_of_trade
  reg = setup_registration :iksnr => '39271'
  seq = flexmock 'sequence'
  reg.should_receive(:packages).and_return []
  reg.should_receive(:sequences).and_return({})
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return nil
  setup_meddata_server
  @app.should_receive(:registration).and_return reg
  @app.should_receive(:each_package)
  expected_updates = {}
  ptr = Persistence::Pointer.new [:registration, '39271']
  expected_updates.store ptr, { :generic_type => :original,
                                :index_therapeuticus => '07.10.10.' }
  @app.should_receive(:update).times(1).and_return do |ptr, data|
    assert_equal expected_updates.delete(ptr), data
  end
  @plugin.update_preparations StringIO.new(@conflicted_src)
  assert_equal({}, expected_updates)
  assert_equal({}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  assert_equal [], listener.unknown_packages
  expected = []
  assert_equal [], listener.unknown_registrations
end

- (Object) test_update_preparation__unknown_registration



808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'test/test_plugin/bsv_xml.rb', line 808

def test_update_preparation__unknown_registration
  updates = []
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return nil
  setup_meddata_server :ean13 => '7680392710281'
  @app.should_receive(:registration).and_return nil
  @app.should_receive(:each_package)
  @plugin.update_preparations StringIO.new(@src)
  assert_equal [], updates
  assert_equal({}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  expected = []
  assert_equal expected, listener.unknown_packages
  expected = [ {
    :name_base          => "Ponstan",
    :name_descr         => "Filmtabs 500 mg ",
    :swissmedic_no5_bag => "39271",
  } ]
  assert_equal expected, listener.unknown_registrations
end

- (Object) test_update_preparation__unknown_registration__out_of_trade



792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
# File 'test/test_plugin/bsv_xml.rb', line 792

def test_update_preparation__unknown_registration__out_of_trade
  updates = []
  flexmock(Package).should_receive(:find_by_pharmacode).
                    times(1).and_return nil
  setup_meddata_server
  @app.should_receive(:registration).and_return nil
  @app.should_receive(:each_package)
  @plugin.update_preparations StringIO.new(@src)
  assert_equal [], updates
  assert_equal({}, @plugin.change_flags)
  listener = @plugin.preparations_listener
  assert_equal [], listener.conflicted_packages
  assert_equal [], listener.conflicted_registrations
  assert_equal [], listener.unknown_packages
  assert_equal [], listener.unknown_registrations
end