他社電子カルテのコンバートツールを開発した話 ~ オートマトン CSV との戦い ~ / Karte Convert Tool

他社電子カルテのコンバートツールを開発した話 ~ オートマトン CSV との戦い ~ / Karte Convert Tool

4cae187d836abc4428abdfb9cd448098?s=128

Taiju Aoki

July 31, 2020
Tweet

Transcript

  1. ଞࣾిࢠΧϧςͷίϯόʔτπʔϧΛ։ൃͨ͠࿩ ~ ΦʔτϚτϯ CSV ͱͷઓ͍ ~ @blue_1617

  2. ࢲ͸୭ʁ blue (@blue_1617) https://blue0513.github.io/show_room/ 2 Rails, JavaScript, Scala etc ΤϜεϦʔ:

    Ϋϥ΢υిࢠΧϧςνʔϜॴଐ ͨ·ʹ C# ͱ͔ DevOps ΋΍ΔΑ झຯͱ͔
  3. ͜Ε͸ͳΜͷ࿩ʁ 3 ଞࣾిࢠΧϧς Ϋϥ΢υిࢠΧϧςʢM3 DigiKarʣνʔϜ͕ ଞ͔ࣾΒͷ ίϯόʔτπʔϧ Λ࡞Δ࿩

  4. M3 DigiKar ͬͯͳʹʁ 4 https://digikar.co.jp/ Ϋϥ΢υͰಈ࡞͢Δ ిࢠΧϧς ٕज़ελοΫ͕͍ͬͺ͍

  5. Ϋϥ΢υͰಈ࡞͢Δ ిࢠΧϧς ٕज़ελοΫ͕͍ͬͺ͍ M3 DigiKar ͬͯͳʹʁ 5 https://digikar.co.jp/

  6. ଞ͔ࣾΒͷίϯόʔτͱ͸ 6 ଞࣾిࢠΧϧς M3 DigiKar: ༷ʑͳిࢠΧϧς͔Β৐Γ׵͑ͯ΄͍͠ ҩࢣ: ిࢠΧϧςΛ৐Γ׵͍͑ͨ

  7. ଞ͔ࣾΒͷίϯόʔτͱ͸ 7 ిࢠΧϧςA ʁ ిࢠΧϧςB طଘͷσʔλʢױऀ৘ใɺΧϧςʣ͸Ҡߦ͍ͨ͠ σʔλ

  8. ଞ͔ࣾΒͷίϯόʔτͱ͸ 8 ిࢠΧϧςA ʁ ిࢠΧϧςB طଘͷσʔλʢױऀ৘ใɺΧϧςʣ͸Ҡߦ͍ͨ͠ σʔλ ిࢠΧϧς͝ͱʹσʔλͷܗࣜɾ࣋ͪํ͕ҟͳΔͨΊ ༰қʹίϯόʔτ͸Ͱ͖ͳ͍

  9. ैདྷख๏ 9 ిࢠΧϧςA σʔλA σʔλ ిࢠΧϧςA༻ σʔλίϯόʔλ ֤ిࢠΧϧςʹରԠ͢ΔίϯόʔλπʔϧΛ։ൃ ిࢠΧϧςAͷσʔλΛɺDigiKarσʔλʹίϯόʔτ

  10. ैདྷख๏ͷ՝୊ 10 ిࢠΧϧςA ίϯόʔλA ిࢠΧϧς͝ͱͷίϯόʔλπʔϧΛ։ൃ͢Δඞཁ͕͋Δ ిࢠΧϧςB ిࢠΧϧςC ։ൃɺӡ༻·ͰؚΊΔͱίετ͕ඇৗʹେ͖͍ ίϯόʔλB ίϯόʔλC

  11. ఏҊख๏ 11 ిࢠΧϧςA ిࢠΧϧςB ిࢠΧϧςC ڞ௨σʔλϑΥʔϚοτΛग़ྗ͠ɺઐ༻ίϯόʔλΛ࡞Δ ڞ௨σʔλ ઐ༻ίϯόʔλ 1ͭͷίϯόʔλͰࡁΉͷͰɺίετ͕௿͍

  12. ڞ௨σʔλ: ϨηϓτిࢉϑΝΠϧ 12 ΫϦχοΫB ΫϦχοΫA ϨηϓτిࢉϑΝΠϧ ެతػؔ શͯͷҩྍػ͕ؔެతػؔʹૹ৴͢ΔϑΝΠϧ ͍ͭɺͲΜͳױऀʹɺͲͷΑ͏ͳ਍ྍΛ͔ͨ͠Λه͍ͯ͠Δ

  13. ڞ௨σʔλ: ϨηϓτిࢉϑΝΠϧ 13 ΫϦχοΫB ΫϦχοΫA ϨηϓτిࢉϑΝΠϧ ެతػؔ શͯͷҩྍػ͕ؔެతػؔʹૹ৴͢ΔϑΝΠϧ ͍ͭɺͲΜͳױऀʹɺͲͷΑ͏ͳ਍ྍΛ͔ͨ͠Λه͍ͯ͠Δ i.e.

    ҩྍػ͕ؔిࢠΧϧςʹଧͪࠐΉ΄΅શͯͷ৘ใ
  14. ϨηϓτిࢉϑΝΠϧ 14 جۚՖࢠ͞Μͱجۚଠ࿠͞Μͷฏ੒30೥6݄෼ͷ৘ใͰ͋Δ جۚՖࢠ͞Μ͸ࠃอͱެඅΛ͍࣋ͬͯΔ جۚՖࢠ͞Μ͸ইප: ̋̋ɺ˚˚ɺ˘˘Λױ͍ͬͯΔ ਍ྍʹ͸ಛఆػࡐ: ˑˑΛ༻͍ͯɺ̋೔ͱ̋೔ͱ̋೔ʹདྷӃ͍ͯ͠Δ etc etc

    etc ..... ҎԼͷ৘ใ͕ಡΈऔΕΔ
  15. ϨηϓτిࢉϑΝΠϧ is ͭΒ͍ 15 ױऀ ױऀ RE: ױऀ৘ใ HO: อݥ৘ใ

    KO: ެඅ৘ใ ..... etc 43006 = ฏ੒30೥6݄ 1ϑΝΠϧʹෳ਺ױऀͷσʔλʢRE~࣍ͷRE·Ͱʣ 1ϑΝΠϧ1ϲ݄෼ʢॱ൪ʹಡ·ͳ͍ͱཤྺΛ෮ݩͰ͖ͣʣ Ϩίʔυຖʹҙຯ΋਺΋ҟͳΔΧϥϜͰߏ੒ લͷϨίʔυʹΑͬͯޙΖͷϨίʔυͷҙຯ͕มΘΔ Shift_JIS ͨ·ʹϧʔϧແࢹ
  16. ϨηϓτిࢉϑΝΠϧ is ΦʔτϚτϯ 16 Ֆࢠ͞Μ͸ ෩अΛͻ͍ͯ ෩अༀΛॲํ͞Εͨ 1ߦൈਮ SY,....,෩अ,....,.....,݈߁਍அ RE,....,Ֆࢠ,....,.....,ϋφί

    IY,....,෩अༀ,......,...... SY,....,෩अ,....,.....,݈߁਍அ RE,....,Ֆࢠ,....,.....,ϋφί IY,....,෩अༀ,......,...... ෩अΛͻ͍ͨ ୭͕ɺ෩अΛͻ͍ͯɺԿΛॲํ͞Εͨͷ͔͸Θ͔Βͳ͘ͳΔ i.e. લޙͷϨίʔυͷঢ়ଶΛอ࣋͠ͳ͍ͱਖ਼֬ͳσʔλΛ෮ݩͰ͖ͳ͍
  17. ϨηϓτిࢉϑΝΠϧ is ΦʔτϚτϯ 17 1݄෼ 2݄෼ 3݄෼ ইප: ෩अ ইප:

    ෩अ ইප: ಄௧ 2݄தʹ෩अ͸׬࣏ͨ͠
  18. ϨηϓτిࢉϑΝΠϧ is ΦʔτϚτϯ 18 ͋Δ݄ͷσʔλ͚ͩͰ͸ɺͲͷΑ͏ʹ঱ঢ়͕ਪҠͨ͠ͷ͔ෆ໌ i.e. લ݄ͷঢ়ଶΛอ࣋͠ͳ͍ͱɺਖ਼֬ͳσʔλΛ෮ݩͰ͖ͳ͍ 1݄෼ 2݄෼ 3݄෼

    ইප: ෩अ ইප: ෩अ ইප: ಄௧
  19. ଞࣾిࢠΧϧςͷίϯόʔτπʔϧΛ։ൃͨ͠࿩ ~ ΦʔτϚτϯ CSV ͱͷઓ͍ ~

  20. ϨηϓτίϯόʔτͷྲྀΕ 20 ϨηϓτσʔλʢcsvʣͷऔΓࠐΈ DataTransferObject ʹม׵ ࣄલ ValidationʢPreCheckʣͷ࣮ࢪ DB ΁ͷ Import

    ॲཧ Error ग़ྗ DigiKar ͷ Model ΁ม׵
  21. CSV Λͦͷ··ѻ͏ͷ͸ਏ͍ͷͰɺ DataTransferObject Λט·ͤΑ͏

  22. Data Transfer ObjectʢDTOʣ 22 Recept Class TO Class ϨηϓτͷσʔλΛ Model

    Ϋϥεͱͯ͠ఆ͍ٛͯ͘͠ ReceFile Class KO Class …..
  23. Data Transfer ObjectʢDTOʣ 23 ϨηϓτͷσʔλΛ Model Ϋϥεͱͯ͠ఆ͍ٛͯ͘͠ Records ReceFile Recepts

    RE HO TO …. recept_code amount daily_counts
  24. Data Transfer ObjectʢDTOʣ 24 Records ReceFile Recepts RE HO TO

    …. recept_code amount daily_counts ϨηϓτͷσʔλΛ Model Ϋϥεͱͯ͠ఆ͍ٛͯ͘͠ ϓϩάϥϚ͕ཧղ͠΍͍͢ߏ଄ʹͳΔ
  25. Data Transfer ObjectʢDTOʣ 25 Ϩηϓτͷσʔλ DigiKar ͷϞσϧ RE Ϟσϧ RE,1,foobar,2,3,12

    Recept::Record::Re Patient
  26. औΓࠐΈॲཧதʹΤϥʔ͸ਏ͍ͷͰɺ ࣄલʹσʔλνΣοΫ͠Α͏

  27. PreCheck ͷඞཁੑ 27 https://www.ssk.or.jp/seikyushiharai/rezept/iryokikan/iryokikan_02.files/jiki_i01.pdf Ϩηϓτʹ͸ࡉ͔͍ϧʔϧ͕ଘࡏ͢Δ

  28. PreCheck ͷඞཁੑ 28 Digikar ʹ΋ࡉ͔͍ϧʔϧʢDB ੍໿౳ʣ͕ଘࡏ͢Δ Ұ෦ൈਮ

  29. PreCheck ͷඞཁੑ 29 ͨ·ʹϨηϓτͷن໿ʹԊΘͳ͍ϑΝΠϧ΋ଘࡏ͢Δ ‣ จࣈίʔυ͕͓͔͍͠ ‣ ඞਢͷ߲໨͕ۭ͢Δ etc …

    औΓࠐΈॲཧʢN͔͔࣌ؒΔʣޙʹΤϥʔ͢Δͱਏ͍ ‣ طଘίϯόʔλͰ͸͜ͷ໰୊΋͋ͬͨ औΓࠐΈલͷࣄલόϦσʔγϣϯʢPreCheckʣ is ઈରඞཁ
  30. PreCheck ͷཁ݅ 30 ‣ ࣄલʹશϑΝΠϧʢN೥෼ʣͷશϨίʔυΛνΣοΫ͢Δ ‣ ߴ଎ʢ15෼ఔ౓ʣͰνΣοΫ͢Δ ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘ ҎԼͷཁ݅Λຬͨ͢ඞཁ͕͋Δ

  31. PreCheck 31 ActiveModel::Validations Λ༻͍࣮ͯݱ ֤ Recept::Record Ϋϥεʹର࣮ͯ͠ߦ

  32. PreCheck 32 ҎԼͷཁ݅Λຬͨ͢ඞཁ͕͋ΔͷͰɺDB ૸ࠪ͸͠ͳ͍ ‣ ࣄલʹશϑΝΠϧʢN೥෼ʣͷશϨίʔυΛνΣοΫ͢Δ ‣ ߴ଎ʢ15෼ఔ౓ʣͰνΣοΫ͢Δ จࣈ਺ σʔλܕ

    CheckDigit ਺஋ͷൣғ ೥݄ͷଥ౰ੑ etc … ʢެతػ͕ؔνΣοΫ͍ͯ͠Δ͸ͣͳͷͰɺͦ͜·Ͱ invalid ͳ΋ͷ͸ͳ͍લఏʣ
  33. PreCheck 33 Error: ProviderNumber ͸ 8จࣈͰ ೖྗ͍ͯͩ͘͠͞ ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘ ActiveRecord::Validations

    ͷ݁ՌΛग़ྗ͢Δ͚ͩͰ͸ෆे෼ Q. ͲͷϨίʔυͷͲͷΧϥϜ͕Τϥʔͨ͠Ͱ͠ΐ͏ʁ
  34. PreCheck 34 locales/ja.yml Ͱ೔ຊޠԽ invalid ͳ஋Λදࣔ ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘

  35. PreCheck 35 Τϥʔʹױऀ൪߸ɺϑΝΠϧ໊ɺϨίʔυ໊ΛؚΊΔ ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘

  36. PreCheck 36 message: ProviderNumber อݥऀ൪߸ ͸ 8จࣈͰೖྗ͍ͯͩ͘͠͞ʢ9876543ʣ, filename: Test.UKE, recordType:

    HO, patientId: B123-456 ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘ ProviderNumber ͸ 8จࣈͰ ೖྗ͍ͯͩ͘͠͞
  37. PreCheck 37 message: ProviderNumber อݥऀ൪߸ ͸ 8จࣈͰೖྗ͍ͯͩ͘͠͞ʢ9876543ʣ, filename: Test.UKE, recordType:

    HO, patientId: B123-456 ‣ ϓϩάϥϚҎ֎Ͱ΋ཧղ͠΍͍͢ΤϥʔΛు͘ ProviderNumber ͸ 8จࣈͰ ೖྗ͍ͯͩ͘͠͞ Invalid Value!
  38. ΦʔτϚτϯ CSV ͸ਏ͍͚ͲɺؤுΖ͏

  39. CSV ಺ͷΦʔτϚτϯੑ 39 1ߦൈਮ SY,....,෩अ,....,.....,݈߁਍அ RE,....,Ֆࢠ,....,.....,ϋφί IY,....,෩अༀ,......,...... SY,....,෩अ,....,.....,݈߁਍அ RE,....,Ֆࢠ,....,.....,ϋφί IY,....,෩अༀ,......,......

    Records RE HO SY …. ্͔ΒॱʹಡΉ͜ͱ͕ඞཁ ͲͷױऀͰ ͳΜͷอݥΛ͍࣋ͬͯͯ ͲΜͳইපΛ͍࣋ͬͯΔ …. ҰߦҰߦΛಡΉ͚ͩͰ͸ɺਖ਼͍͠৘ใΛ෮ݩͰ͖ͳ͍
  40. CSV ಺ͷΦʔτϚτϯੑ 40 Records RE HO KO …. γϯϓϧʹ্͔Βॱʹ৘ใΛ DB

    อଘͯ͠ɺ݁ՌΛ࣋ͪճ͢
  41. CSV ಺ͷΦʔτϚτϯੑ 41 Records RE HO KO …. γϯϓϧʹ্͔Βॱʹ৘ใΛ DB

    อଘͯ͠ɺ݁ՌΛ࣋ͪճ͢
  42. CSV ؒͷΦʔτϚτϯੑ 42 1݄෼ 2݄෼ 3݄෼ ইප: ෩अ ইප: ෩अ

    ইප: ಄௧ ͋Δ݄ͷ CSV ͚ͩͰ͸ɺ͍ͭපؾ͕࣏͔ͬͨΘ͔Βͳ͍
  43. CSV ؒͷΦʔτϚτϯੑ 43 N݄෼Ϩίʔυ N+2݄෼Ϩίʔυ N+1݄෼Ϩίʔυ ࠷৽ͷ CSV ʹͳ͍ইප͸ɺઌ݄ʹ׬࣏͍ͯ͠Δ͸ͣ N

    ݄຤ʹ͸׬࣏ N+1 ݄຤ʹ͸׬࣏ ׬࣏͍ͯ͠ͳ͍
  44. CSV ؒͷΦʔτϚτϯੑ 44 N݄෼Ϩίʔυ N ݄ʹൃ঱ N ݄ʹൃ঱

  45. CSV ؒͷΦʔτϚτϯੑ 45 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢDB Updateʣ N ݄຤ʹ׬࣏ʢDB Updateʣ
  46. CSV ؒͷΦʔτϚτϯੑ 46 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+1 ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢ֬ఆʣ N ݄ʹൃ঱ N ݄຤ʹ׬࣏ʢDB Updateʣ औΓফ͠
  47. CSV ؒͷΦʔτϚτϯੑ 47 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+1 ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢ֬ఆʣ N ݄ʹൃ঱
  48. CSV ؒͷΦʔτϚτϯੑ 48 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+1 ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢ֬ఆʣ N ݄ʹൃ঱ N+2݄෼Ϩίʔυ N+1 ݄຤ʹ׬࣏ʢUpdateʣ N+1 ݄຤ʹ׬࣏ʢUpdateʣ
  49. CSV ؒͷΦʔτϚτϯੑ 49 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+1 ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢ֬ఆʣ N ݄ʹൃ঱ N+2݄෼Ϩίʔυ N+1 ݄຤ʹ׬࣏ʢ֬ఆʣ N+1 ݄຤ʹ׬࣏ʢUpdateʣ
  50. CSV ؒͷΦʔτϚτϯੑ 50 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+1 ݄ʹൃ঱ N ݄ʹൃ঱ N

    ݄຤ʹ׬࣏ʢ֬ఆʣ N ݄ʹൃ঱ N+2݄෼Ϩίʔυ N+1 ݄຤ʹ׬࣏ʢ֬ఆʣ
  51. CSV ؒͷΦʔτϚτϯੑ 51 N݄෼Ϩίʔυ N+1݄෼Ϩίʔυ N+2݄෼Ϩίʔυ

  52. ࠷ॳ͔Β׬ᘳ͸ແཧͳͷͰɺ ঃʑʹྑ͍ͯ͘͜͠͏

  53. ։ൃϓϩηε 53 ‣ QA͕ऴྃͨ͠ branch ͔Βɺdevelop ʹ merge ͍ͯ͘͠ ‣

    ࡉ͔͘ merge ͯ͠ɺQAͷޮ཰Խɺconflict ͷ࠷খԽ ‣ ػೳ΁ͷಋઢ͚ͩ௵ͯ͠ɺϢʔβ͔Β͸ݟ͑ͳ͍Α͏ʹ ‣ νέοτɺMRΛࡉ͔͘෼ׂʢϨίʔυ୯Ґɺॲཧ୯Ґʣ ‣ νέοτຖͷIAΛΤϯδχΞ͕ॻ͖ɺϨϏϡʔʹճ͢ ‣ QAνʔϜʹ΋ڞ༗͠ɺQAΛࡉ͔࣮͘ࢪ ‣ ʮ͋ͱͰ࣮૷͢Δ͔Βࠓ͸ແࢹͰʯ ‣ ͋Δ branch Ͱ໰୊͕ൃੜͨ͠Βɺผͷ MR ͰରԠ ‣ MR ͷࠩ෼Λେ͖ͤͣ͘ɺࡉ͔͘લʹਐΉ ‣ QAͱϢχοτςετΛ͖ͪΜͱ࣮ࢪ ‣ Ϣχοτςετ͸ΨϯΨϯॻ͘ ‣ ΤϯδχΞ؍఺ͱQA؍఺ͷ྆໘Ͱ඼࣭Λ୲อ
  54. ։ൃϓϩηε 54 ‣ ຊ൪ಥ߹ࢼݧͷ࣮ࢪ ‣ QAνʔϜɺϏδωενʔϜͱ࠷ऴड͚ೖΕཁ݅ͷݕ౼ ‣ ʢϚεΫࡁΈͷʣ࣮σʔλͷ༻ҙ ‣ ࣮σʔλΛ༻͍ͯɺظ଴௨Γͷ݁Ռ͕ಘΒΕΔ͔

    ‣ υϝΠϯ஌ࣝͷ͋Δϝϯόʹࡉ͔͘૬ஊ ‣ ࢓༷Ͱ٧·ͬͨΒࡉ͔͘૬ஊ ‣ ฦ৴଴ͪͷ࣌ؒ͸ผͷՕॴͷ࣮૷ΛΨϯΨϯͱ ‣ ઐ೚Ͱػೳ։ൃʹઐ೦ ‣ ଞͷνέοτ͸औΒͣɺίϯόʔτػೳʹूத ‣ νʔϜͷօ͞Μɺຊ౰ʹ͋Γ͕ͱ͏͍͟͝·ͨ͠
  55. ·ͱΊ 55 ‣ ϨηϓτిࢉϑΝΠϧΛ࢖͏͜ͱͰɺଞࣾిࢠΧϧς͔Β ͷίϯόʔτΛՄೳʹͨ͠ ‣ ϨηϓτిࢉϑΝΠϧ͸શҩྍػؔͰར༻͍ͯ͠ΔͷͰɺཧ࿦త ʹ͸શҩྍػ͕ؔ DigiKar ʹ৐Γ׵͑Մೳʹͳͬͨ

    ‣ DTO Λར༻ͯ͠ɺޙଓॲཧΛ༰қʹͨ͠ ‣ ෳࡶոحͳ CSV Λ ActiveModel ʹͯ͠ɺϦʔμϒϧʹͨ͠ ‣ PreCheck Λ࣮૷ͯ͠ɺσʔλͷࣄલݕূ͕Մೳʹͳͬͨ ‣ ActiveRecord ͷԸܙͰΤϥʔϝοηʔδ΋ಡΈ΍͘͢ͳͬͨ ‣ ΦʔτϚτϯͳ CSV Λॲཧͯ͠ɺσʔλΛऔΓࠐΊͨ ‣ DigiKar ΁ͷऔΓࠐΈϩδοΫΛ޻෉ͯ͠༏উͨ͠ ‣ पғͱڠྗ͢Δ։ൃϓϩηεʹΑͬͯޮ཰తͳ։ൃΛ ‣ ຊ౰ʹ͋Γ͕ͱ͏͍͟͝·ͨ͠ʢNճ໨ʣ