« 2009年5月 | トップページ | 2009年8月 »

2009年6月

2009年6月29日 (月)

新規カルテにテキストスタンプ挿入

新規カルテにテキストスタンプを自動的に挿入できるようにした。「テンプレート(初診)」「テンプレート(再診)」というテキストスタンプを作っておくと,新規カルテ作成時に自動的に挿入される。

 

client/StampTreeModules.java

/**
 * テキストスタンプから title のスタンプを取ってきて返す
 * @return ModuleModel
 */
public ModuleModel getTextStamp(String title) {

    ModuleModel mModel = new ModuleModel();
    ModuleInfoBean stamp = null;
    StampTree tree =  mediator.getStampTree("text");

    for (int i=0; i<tree.getRowCount(); i++) {
        StampTreeNode sn = (StampTreeNode) tree.getPathForRow(i).getLastPathComponent();
        if (sn.isLeaf()) {
            ModuleInfoBean bean = sn.getStampInfo();
            String name = bean.getStampName();
            if (name.equals(title)) {
                stamp = bean;
                break;
            }
        }
    }

    if (stamp != null) {
        StampDelegater sdl = new StampDelegater();
        // Stamp モデルをデータベースから取ってくる
        StampModel sModel = sdl.getStamp(stamp.getStampId());
        // Stamp モデルから info モデルを作る
        IInfoModel iModel = (IInfoModel) BeanUtils.xmlDecode(sModel.getStampBytes());
        // info モデル(実体)と stamp(情報) を module model にセット
        mModel.setModel(iModel);
        mModel.setModuleInfo(stamp);
        mModel.getModuleInfo().setStampRole(IInfoModel.ROLE_SOA);
    } else mModel = null;

    return mModel;
}

client/ChartImpl.java

/**
 * 新規カルテを作成する。
 */    
public void newKarte() {
 ・
 ・
  // Baseになるカルテがあるかどうかでモデルの生成が異なる
  if (params.getCreateMode() == Chart.NewKarteMode.EMPTY_NEW) {
    logger.debug("empty new is selected");
    editModel = getKarteModelToEdit(params);
  } else {
    logger.debug("copy new is selected");
    editModel = getKarteModelToEdit(base.getModel(), params);
  }

////↓   新規カルテにいろいろモジュールを入れる
  StampTreeModules stm = new StampTreeModules(this);
  // 初診・再診 stampTreeModule を自動入力する
  ModuleModel mm = stm.getBaseCharge();
  if (mm != null) editModel.addModule(mm);

  // 初期テキストスタンプ挿入
  if (stm.isShoshin()) {
      mm = stm.getTextStamp("テンプレート(初診)");
      if (mm != null) editModel.addModule(mm);
  } else {
      mm = stm.getTextStamp("テンプレート(再診)");
      if (mm != null) editModel.addModule(mm);
  }
}
////↑
 ・
 ・

client/KartePane.java

/**
 * このペインに Stamp を挿入する。
 */
public void stamp(final ModuleModel stamp) {
   if (stamp != null) {
////↓       text stamp がここに入った時の対策(新規カルテにテキストスタンプ挿入するときここに来る)
   if (stamp.getModuleInfo().getEntity().equals(IInfoModel.ENTITY_TEXT)) {
       insertTextStamp(stamp.getModel().toString());
       return;
   }
////↑
   EventQueue.invokeLater(new Runnable() {
 ・
 ・

2009年6月13日 (土)

カルテ検索機能

「引っ越すことになったので,次回受診時までに紹介状を書いて欲しい」という患者さんがいらっしゃったのだが,不覚にも誰だったか忘れてしまった。少し焦ったが,確かカルテに「引っ越しするので〜」と記録していたはずなので,「引っ越し」でカルテ検索して見つけることができた。カルテ検索機能を作っておいて良かったと思った。
 カルテ検索機能は,記載の古い方から検索するように作っていたが,今回,新しいものから開始した方が効率がよいことが分かった。そこで,新しい記載から検索するように書き直した。

 

delegater/DocumentPeekerDelegater.java

public Collection getPatientOfKarte() {
    if (endModuleId < 0L) return null; // 数えきった場合だけ null が返る

    List pm = new ArrayList();
    Set karteId = new HashSet();
    // 新しい module から検索していく
    Long startModuleId = endModuleId - increaseStep;
    if (startModuleId < fromModuleId) startModuleId = fromModuleId;
    List mc = getService().getModuleModel(startModuleId, endModuleId);
    // soaSpec, pSpec は getFreeText 必要。それ以外は model内容が toString() で取れる。
    for (ModuleModel model : mc) {
        InfoModel im = (InfoModel) BeanUtils.xmlDecode(model.getBeanBytes());
        String role = model.getModuleInfo().getStampRole();
        String text = "";

        if (role.equals(IInfoModel.ROLE_SOA_SPEC) || role.equals(IInfoModel.ROLE_P_SPEC)) {
            String xml = ((ProgressCourse) im).getFreeText();
            text = extractText(xml);
        } else {
            text = im.toString();
        }
        int pos = text.indexOf(searchText);
        if (pos != -1) {
            karteId.add(model.getKarte().getId());
        }
    }
    pm = getService().getPatientOfKarte(karteId); // 空の pm が返ることはあるが,null は返らない
    endModuleId -= increaseStep; // 次の検索に備えて endModuleId を下げる
    return pm;
}

2009年6月11日 (木)

メモ欄の自動セーブ

本家の OpenDolphin は,バージョン 1.4 になって,メモ欄の update ボタンが無くなり,メモ欄は自動的にセーブされるようになった。確かに,その方が便利なので,そのように変更した。

 

client/MemoInspector.java

private void initComponents() {
//// update ボタンは使わないことにするので,すべてコメントアウト        
  //int[] memoSize = ClientContext.getIntArray("patientInspector.memoInspector.textArea.size"); // 5,10
////        ImageIcon updateIcon = ClientContext.getImageIcon("ref_16.gif");

  memoArea = new CompositeArea(5, 10);
  memoArea.setLineWrap(true);
  memoArea.setMargin(new java.awt.Insets(3, 3, 2, 2));
////        memoArea.addFocusListener(AutoKanjiListener.getInstance());

////        updateMemoBtn = new JButton(updateIcon);
////        updateMemoBtn.setMargin(new Insets(2, 2, 2, 2));
////        updateMemoBtn.setEnabled(false);
////        updateMemoBtn.addActionListener(ProxyActionListener.create(this, "updateMemo"));
////        JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
////        btnPanel.add(updateMemoBtn);

  memoPanel = new JPanel(new BorderLayout());
  memoPanel.add(memoArea, BorderLayout.CENTER);
////        memoPanel.add(btnPanel, BorderLayout.EAST);
}
////↓
/**
 * メモ内容が変化したかどうかチェック
 * @return
 */
public boolean isDirty() {
  String oldText = patientMemoModel==null? "" : patientMemoModel.getMemo();
  String newText = memoArea.getText().trim();
  return !oldText.equals(newText);
}
////↑

client/PatientInspector.java

public void dispose() {
  // List をクリアする
  docHistory.clear();
  allergyInspector.clear();
  physicalInspector.clear();

////↓   memo 欄の自動セーブ
  if (memoInspector.isDirty()) {
    memoInspector.updateMemo();
  }
////↑
}

2009年6月 4日 (木)

患者検索でのID入力

患者検索で ID を入力する場合,桁数が足りない場合は先頭に 0 を補うようにした。

 

dto/PatientSearchSpec.java

public void setDigit(String digit) {
////↓   ID が6桁未満の数字の時は,先頭にゼロを補って6桁にする
  StringBuffer buf = new StringBuffer();
  for (int i=0; i<6-digit.length(); i++) {
    buf.append('0');
  }
  buf.append(digit);
  this.digit = buf.toString();
////↑
  ////this.digit = digit;
}

« 2009年5月 | トップページ | 2009年8月 »