바이탈 17종 + 주치의 1종 + _Refer 사유 정정 — 76종 → 95종
## 바이탈(측정치) 17종
E_EmdInf_VITAL ⨝ E_EmrInf(삭제 제외) 를 내원으로 거르고 해당 컬럼이 빈 값이 아닌
행을 측정일시 순으로 한 건 집는다 — 무인자는 첫 측정(ASC), _LAST 는 마지막(DESC).
키/몸무게/체온/맥박/호흡/SPO2 (±LAST) · 혈압/혈압_LAST(BPS||'/'||BPD) ·
혈압_BPS/_BPD(단독값이지만 널 필터는 둘 다 — 레거시 그대로) · VITAL접수일시_LAST(HH:MM).
태그별 (식·컬럼·필터·정렬)을 전부 본문에서 확인해 표로 박았다(:11508-13046).
조회는 태그가 물을 때 한 값씩, 태그별 1회 캐시.
## 머리둘레 2종은 레거시가 고장이다
SELECT 는 EmdHc AS HC 인데 Item("BP") 를 읽는다(:11744, 12581) —
행이 있으면 예외 → MessageBox → "". 레거시에서 한 번도 값이 나온 적 없는 태그다.
그대로 빈 값 + "레거시 결함(컬럼명 불일치)으로 항상 빈 값이던 태그" 사유로 둔다.
고쳐서 값을 내면 레거시와 달라진다 — 고칠지는 별도 결정.
## 실DB 확인
--db-patient ㉙ 신규: 내원 6004487 에서 첫/마지막 몸무게 2자.
표 부재 가능성도 수술과 같은 방식으로 가른다(ORA-00942 명시).
## 게이트
- dotnet test 338/338 · --edit-smoke 실패 0(이름 검사 95종)
- --db-patient ①~㉙ 전건 통과 · --db-render P062 md5 불변
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3e9d5b5cf3
commit
94bdcc763f
@@ -152,6 +152,15 @@ public static class PatientIdentity
|
||||
: new ReviewDiagnosisStore(connection).Diagnoses(context.ComNum, scope);
|
||||
}
|
||||
|
||||
/// <summary>바이탈 공급자 — 태그가 물을 때 한 값씩 읽는다(측정 태그 없는 서식이 다수다)</summary>
|
||||
public static Func<string, string, string[], string, string> VitalSourceFor(PatientContext context)
|
||||
{
|
||||
var connection = ConfigService.Current.ConnectionString;
|
||||
return (expr, pick, notNull, order) => connection.Length == 0
|
||||
? string.Empty
|
||||
: new VitalStore(connection).One(context.ComNum, expr, pick, notNull, order);
|
||||
}
|
||||
|
||||
/// <summary>수술 행 공급자 — 상병과 같은 정책(필요할 때 1회, 실패는 던져 사유로)</summary>
|
||||
public static Func<IReadOnlyList<Dictionary<string, string>>> SurgerySourceFor(PatientContext context)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,8 @@ public static class PatientSession
|
||||
PatientIdentity.HospitalRowOf(picked),
|
||||
PatientIdentity.DiagnosisSourceFor(picked),
|
||||
PatientIdentity.SurgerySourceFor(picked),
|
||||
PatientIdentity.ReviewDiagnosisSourceFor(picked))
|
||||
PatientIdentity.ReviewDiagnosisSourceFor(picked),
|
||||
PatientIdentity.VitalSourceFor(picked))
|
||||
: session;
|
||||
return (tags, new MDataTableRunner(document, Variables()));
|
||||
}
|
||||
|
||||
@@ -185,6 +185,11 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
/// <summary>심사 상병(B_OkdInf) 공급자 — 상병과 같은 정책</summary>
|
||||
private readonly Func<DiagnosisStore.Scope, IReadOnlyList<Dictionary<string, string>>>? reviewSource;
|
||||
|
||||
/// <summary>바이탈 공급자 — (식, 컬럼, 필터, 정렬) 로 한 값을 읽는다. 태그별 1회 캐시</summary>
|
||||
private readonly Func<string, string, string[], string, string>? vitalSource;
|
||||
|
||||
private readonly Dictionary<string, string> vitalCache = new(StringComparer.Ordinal);
|
||||
|
||||
private readonly Dictionary<DiagnosisStore.Scope, IReadOnlyList<Dictionary<string, string>>> reviewCache = new();
|
||||
|
||||
public PatientTagResolver(PatientContext context, ITagValueResolver next,
|
||||
@@ -195,7 +200,8 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
IReadOnlyDictionary<string, string>? hospital = null,
|
||||
Func<DiagnosisStore.Scope, IReadOnlyList<Dictionary<string, string>>>? diagnosisSource = null,
|
||||
Func<IReadOnlyList<Dictionary<string, string>>>? surgerySource = null,
|
||||
Func<DiagnosisStore.Scope, IReadOnlyList<Dictionary<string, string>>>? reviewSource = null)
|
||||
Func<DiagnosisStore.Scope, IReadOnlyList<Dictionary<string, string>>>? reviewSource = null,
|
||||
Func<string, string, string[], string, string>? vitalSource = null)
|
||||
{
|
||||
this.context = context;
|
||||
this.next = next;
|
||||
@@ -208,6 +214,7 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
this.diagnosisSource = diagnosisSource;
|
||||
this.surgerySource = surgerySource;
|
||||
this.reviewSource = reviewSource;
|
||||
this.vitalSource = vitalSource;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -243,6 +250,10 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
{
|
||||
return reviewValue;
|
||||
}
|
||||
if (FromVital(tag) is { } vitalValue)
|
||||
{
|
||||
return vitalValue;
|
||||
}
|
||||
if (Computed.TryGetValue(tag, out var compute))
|
||||
{
|
||||
var made = compute(context);
|
||||
@@ -703,6 +714,72 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
: new TagValue(false, "심사 상병 행은 있는데 그 값이 비어 있습니다");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 바이탈 17종 — 태그별 (SELECT 식, 집는 컬럼, 널 필터, 정렬).
|
||||
/// 전부 본문에서 확인(bzDataInterface.vb:11508-13046). 무인자 = 첫 측정(ASC), _LAST = 마지막(DESC).
|
||||
/// 혈압 계열은 BPS·BPD <b>둘 다</b> 비어 있지 않아야 한다(레거시 필터 그대로 — _BPS 단독도 둘 다 건다).
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, (string Expr, string Pick, string[] NotNull, string Order)> Vitals =
|
||||
new(StringComparer.Ordinal)
|
||||
{
|
||||
["OCM_키"] = ("EmdHeight", "EmdHeight", new[] { "EmdHeight" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_키_LAST"] = ("EmdHeight", "EmdHeight", new[] { "EmdHeight" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_몸무게"] = ("EmdWeight", "EmdWeight", new[] { "EmdWeight" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_몸무게_LAST"] = ("EmdWeight", "EmdWeight", new[] { "EmdWeight" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_체온"] = ("EmdTemp", "EmdTemp", new[] { "EmdTemp" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_체온_LAST"] = ("EmdTemp", "EmdTemp", new[] { "EmdTemp" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_맥박"] = ("EmdPuls", "EmdPuls", new[] { "EmdPuls" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_맥박_LAST"] = ("EmdPuls", "EmdPuls", new[] { "EmdPuls" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_호흡"] = ("EmdResp", "EmdResp", new[] { "EmdResp" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_호흡_LAST"] = ("EmdResp", "EmdResp", new[] { "EmdResp" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_SPO2"] = ("EmdSpo", "EmdSpo", new[] { "EmdSpo" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_SPO2_LAST"] = ("EmdSpo", "EmdSpo", new[] { "EmdSpo" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_혈압"] = ("EmdBps || '/' || EmdBpd AS BP", "BP",
|
||||
new[] { "EmdBps", "EmdBpd" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_혈압_LAST"] = ("EmdBps || '/' || EmdBpd AS BP", "BP",
|
||||
new[] { "EmdBps", "EmdBpd" }, "EmdDte DESC, EmdTime DESC"),
|
||||
["OCM_혈압_BPS"] = ("EmdBps AS BP", "BP", new[] { "EmdBps", "EmdBpd" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_혈압_BPD"] = ("EmdBpd AS BP", "BP", new[] { "EmdBps", "EmdBpd" }, "EmdDte ASC, EmdTime ASC"),
|
||||
["OCM_VITAL접수일시_LAST"] = (
|
||||
"SUBSTR(EmrAdpTim,1,2) || ':' || SUBSTR(EmrAdpTim,3,2) AS EmrAdpTim", "EmrAdpTim",
|
||||
new[] { "EmrAdpTim" }, "EmrAdpTim DESC"),
|
||||
};
|
||||
|
||||
private TagValue? FromVital(string tag)
|
||||
{
|
||||
// 머리둘레 두 종은 레거시 결함이다 — SELECT 는 EmdHc AS HC 인데 Item("BP") 를 읽어
|
||||
// 행이 있으면 예외 → MessageBox → "" 다(bzDataInterface.vb:11744, 12581).
|
||||
// 즉 레거시에서 <b>한 번도 값이 나온 적 없는</b> 태그다. 그대로 빈 값 + 사유로 둔다.
|
||||
if (tag is "OCM_머리둘레" or "OCM_머리둘레_LAST")
|
||||
{
|
||||
return new TagValue(false,
|
||||
"레거시 결함(컬럼명 불일치)으로 항상 빈 값이던 태그입니다");
|
||||
}
|
||||
if (!Vitals.TryGetValue(tag, out var spec))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (vitalSource is null)
|
||||
{
|
||||
return new TagValue(false, "바이탈 조회가 연결되지 않았습니다");
|
||||
}
|
||||
if (!vitalCache.TryGetValue(tag, out var value))
|
||||
{
|
||||
try
|
||||
{
|
||||
value = vitalSource(spec.Expr, spec.Pick, spec.NotNull, spec.Order);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new TagValue(false, $"바이탈 조회에 실패했습니다: {ex.GetType().Name}");
|
||||
}
|
||||
vitalCache[tag] = value;
|
||||
}
|
||||
return value.Length > 0
|
||||
? new TagValue(true, value)
|
||||
: new TagValue(false, "이 내원에 해당 측정 기록이 없습니다");
|
||||
}
|
||||
|
||||
/// <summary>주민번호에서 나온 값 — 비면 <b>왜</b> 비었는지 말한다</summary>
|
||||
private TagValue Wrap(string value) => value.Length > 0
|
||||
? new TagValue(true, value)
|
||||
@@ -732,6 +809,10 @@ public sealed class PatientTagResolver : ITagValueResolver
|
||||
"OCM_OPNAME", "OCM_OPRCODNAM", "OCM_DX", "OCM_수술상병", "OCM_수술부위",
|
||||
"OCM_수술_OprPatETC", "OCM_수술집도의", "OCM_수술마취의사",
|
||||
"OCM_심사_주상병명", "OCM_심사_주상병코드", "OCM_심사_부상병명", "OCM_심사_부상병코드",
|
||||
"OCM_키", "OCM_키_LAST", "OCM_몸무게", "OCM_몸무게_LAST", "OCM_체온", "OCM_체온_LAST",
|
||||
"OCM_맥박", "OCM_맥박_LAST", "OCM_호흡", "OCM_호흡_LAST", "OCM_SPO2", "OCM_SPO2_LAST",
|
||||
"OCM_혈압", "OCM_혈압_LAST", "OCM_혈압_BPS", "OCM_혈압_BPD", "OCM_VITAL접수일시_LAST",
|
||||
"OCM_머리둘레", "OCM_머리둘레_LAST",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user