Bkd_상병쿼리(bzDataInterface.vb:14625-14811)의 이식. DiagnosisStore 와 구조가 같고 표만 B_OkdInf(심사분)다. SQL 52줄 원문 기계 추출(블록1 UNION 블록2, 주/부 필터는 각 블록의 RN 접기 앞). 병원 분기는 KIMEYE 하나 — 그 병원만 미이식 안내. 태그 4종(본문 확인): 심사_주상병명/코드는 첫 행, 심사_부상병명/코드는 줄바꿈 결합 (가로형이 없다). ## 게이트 - dotnet test 338/338 · --edit-smoke 실패 0(이름 검사 63종) - --db-patient 전건 통과 (B_OkdInf 도 이 시험 DB 에 없을 수 있어 수술과 같은 취급 — 런타임에서 해석기가 예외를 사유로 바꾼다) - --db-render P062 md5 불변 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
79 lines
3.6 KiB
C#
79 lines
3.6 KiB
C#
using SheetMe.Core.Catalog;
|
|
using SheetMe.Data.Stores;
|
|
|
|
namespace SheetMe.Designer.Services;
|
|
|
|
/// <summary>
|
|
/// 지금 고른 환자 — 앱 전체가 하나를 공유한다.
|
|
///
|
|
/// <b>왜 전역인가.</b> 환자는 미리보기 창에서 고르는데, 그 값이 필요한 곳은 거기만이 아니다 —
|
|
/// 쿼리 편집기의 '검증 실행'도 같은 환자로 돌려야 의미가 있다.
|
|
/// 창마다 따로 들고 있으면 <b>같은 서식을 두 화면에서 서로 다른 환자로</b> 보게 되고,
|
|
/// 그건 화면으로 구분할 수 없다.
|
|
///
|
|
/// <b>하나만 둔다.</b> 여러 개를 허용하면 어느 것이 지금 것인지 알 수 없고,
|
|
/// 환자 정보가 걸린 문제에서 그건 개인정보 사고가 된다.
|
|
///
|
|
/// 앱이 닫힐 때까지 메모리에 남는다. 디스크에 쓰지 않는다 —
|
|
/// 환자 문맥은 로그에도 안 남기기로 한 값이다(<see cref="PatientPreviewPolicy.AuditLine"/>).
|
|
/// </summary>
|
|
public static class PatientSession
|
|
{
|
|
#region Member Fields
|
|
/// <summary>환자가 바뀌었다 — 열려 있는 화면들이 다시 그려야 한다</summary>
|
|
public static event EventHandler? Changed;
|
|
#endregion
|
|
|
|
#region Properties
|
|
/// <summary>지금 고른 환자의 문맥 — 안 골랐으면 null</summary>
|
|
public static PatientContext? Current { get; private set; }
|
|
|
|
/// <summary>사람에게 보여 줄 한 줄 — 창 머리에 그대로 쓴다</summary>
|
|
public static string Label { get; private set; } = string.Empty;
|
|
|
|
/// <summary>고른 환자가 있는가</summary>
|
|
public static bool HasPatient => Current is not null;
|
|
#endregion
|
|
|
|
#region Methods
|
|
/// <summary>환자를 붙이거나(문맥 전달) 뗀다(null 전달)</summary>
|
|
public static void Set(PatientContext? context, string label)
|
|
{
|
|
Current = context;
|
|
Label = context is null ? string.Empty : label;
|
|
Changed?.Invoke(null, EventArgs.Empty);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 치환 변수원 — 환자가 없으면 null 이고, 호출부는 그때 자리표시로 구문만 검사해야 한다.
|
|
/// </summary>
|
|
public static IQueryVariableSource? Variables()
|
|
=> Current is { } context
|
|
? new PatientQueryVariableSource(context, UserSession.Current.UidCod)
|
|
: null;
|
|
|
|
/// <summary>
|
|
/// 이 문서용 태그·배선 해석기 한 벌 — 지금 세션 환자 기준.
|
|
///
|
|
/// 미리보기를 거치지 않는 인쇄(Ctrl+P)가 쓴다. 미리보기 창은 자기 해석기를 창 수명만큼
|
|
/// 들고 있지만, 여기는 <b>한 번 뽑는 종이</b>라 그때그때 만든다.
|
|
/// 주민번호·주소·담당의를 이 자리에서 한 번씩 읽는다 — 태그마다 읽으면 왕복이 늘어난다.
|
|
/// </summary>
|
|
public static (SheetMe.Core.Catalog.ITagValueResolver Tags, MDataTableRunner Fields)
|
|
ResolversFor(SheetMe.Core.Models.FormDocument document)
|
|
{
|
|
var session = new SessionTagResolver();
|
|
SheetMe.Core.Catalog.ITagValueResolver tags = Current is { } picked
|
|
? new PatientTagResolver(picked, session,
|
|
PatientIdentity.ResidentNumberOf(picked), PatientIdentity.AddressOf(picked),
|
|
PatientIdentity.DoctorOf(picked), PatientIdentity.DepartmentOf(picked),
|
|
PatientIdentity.HospitalNameOf(picked),
|
|
PatientIdentity.DiagnosisSourceFor(picked),
|
|
PatientIdentity.SurgerySourceFor(picked),
|
|
PatientIdentity.ReviewDiagnosisSourceFor(picked))
|
|
: session;
|
|
return (tags, new MDataTableRunner(document, Variables()));
|
|
}
|
|
#endregion
|
|
}
|