/// <summary> /// 控制器初始化 /// </summary> public override void Init() { iAdmissionRegistration = (IAdmissionRegistration)DefaultView; ipatientInfo = iBaseView["FrmPatientInfo"] as IPatientInfo; ipayADeposit = iBaseView["FrmPayADeposit"] as IPayADeposit; iqueryMenber = iBaseView["FrmQueryMenber"] as IQueryMenber; }
private static void UpdateAge(IPatientInfo patientInfo, IAge age) { var previousAge = patientInfo.Age as Age; if (previousAge == null) { return; } previousAge.Year = age.Year; previousAge.Month = age.Month; previousAge.Week = age.Week; previousAge.Day = age.Day; previousAge.Unit = age.Unit; }
public static DicomDataSet GeneratePresentationStateForAnnotations ( string userName, string seriesInstanceUID, string annotationData, string description, string userData, DataSet seriesDs ) { AnnCodecs codec = new AnnCodecs(); using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(annotationData))) { ms.Position = 0; AnnCodecsInfo codecInfo = codec.GetInfo(ms); ms.Position = 0; JavaScriptSerializer jsSerialzer = new JavaScriptSerializer(); DicomAnnotationsUtilities dicomAnnotationsUtilities = new DicomAnnotationsUtilities(); if (null == seriesDs || seriesDs.Tables[DataTableHelper.PatientTableName].Rows.Count == 0 || seriesDs.Tables[DataTableHelper.StudyTableName].Rows.Count == 0) { throw new Exception("Series not found"); } DicomDataSet ds = new DicomDataSet(); { DataRow patient = seriesDs.Tables[DataTableHelper.PatientTableName].Rows[0]; DataRow study = seriesDs.Tables[DataTableHelper.StudyTableName].Rows[0]; IPatientInfo patientInfo = RegisteredDataRows.PatientInfo; PersonNameComponent pn = patientInfo.Name(patient); string sFamilyName = pn.FamilyName; string sGivenName = pn.GivenName; string sMiddleName = pn.MiddleName; string sNamePrefix = pn.NamePrefix; string sNameSuffix = pn.NameSuffix; string sPatientId = patientInfo.GetElementValue(patient, DicomTag.PatientID); //Patient Module C.7.1.1 ds.InsertElementAndSetValue(DicomTag.PatientName, string.Format("{0}^{1}^{2}^{3}^{4}", string.IsNullOrEmpty(sFamilyName) ? "" : sFamilyName, string.IsNullOrEmpty(sGivenName) ? "" : sGivenName, string.IsNullOrEmpty(sMiddleName) ? "" : sMiddleName, string.IsNullOrEmpty(sNamePrefix) ? "" : sNamePrefix, string.IsNullOrEmpty(sNameSuffix) ? "" : sNameSuffix)); ds.InsertElementAndSetValue(DicomTag.PatientID, sPatientId); ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, ""); ds.InsertElementAndSetValue(DicomTag.PatientSex, ""); IStudyInfo studyInfo = RegisteredDataRows.StudyInfo; string sStudyInstanceUid = studyInfo.GetElementValue(study, DicomTag.StudyInstanceUID); string sAccessionNumber = studyInfo.GetElementValue(study, DicomTag.AccessionNumber); string sStudyId = studyInfo.GetElementValue(study, DicomTag.StudyID); //Study Module C.7.2.1 ds.InsertElementAndSetValue(DicomTag.StudyInstanceUID, sStudyInstanceUid); ds.InsertElementAndSetValue(DicomTag.StudyDate, ""); ds.InsertElementAndSetValue(DicomTag.StudyTime, ""); ds.InsertElementAndSetValue(DicomTag.ReferringPhysicianName, ""); ds.InsertElementAndSetValue(DicomTag.StudyID, string.IsNullOrEmpty(sStudyId) ? "" : sStudyId); ds.InsertElementAndSetValue(DicomTag.AccessionNumber, string.IsNullOrEmpty(sAccessionNumber) ? "" : sAccessionNumber); //Series Module C.7.3.1 ds.InsertElementAndSetValue(DicomTag.SeriesInstanceUID, SeriesGenerator.GenerateDicomUniqueIdentifier()); ds.InsertElementAndSetValue(DicomTag.Modality, "PR"); ds.InsertElementAndSetValue(DicomTag.SeriesNumber, 1); ds.InsertElementAndSetValue(DicomTag.SeriesDate, DicomDateValue.Now); ds.InsertElementAndSetValue(DicomTag.SeriesTime, DicomTimeValue.Now); ds.InsertElementAndSetValue(DicomTag.SeriesDescription, "Annotations presentation state"); //General Equipment Module C.7.5.1 ds.InsertElementAndSetValue(DicomTag.Manufacturer, "LEADTOOLS IMAGING"); ds.InsertElementAndSetValue(DicomTag.InstitutionName, "LEADTOOLS, INC."); ds.InsertElementAndSetValue(DicomTag.StationName, "HTML5 Viewer"); //Presentation State Identification Module C.11.10 ds.InsertElementAndSetValue(DicomTag.PresentationCreationDate, DicomDateValue.Now); ds.InsertElementAndSetValue(DicomTag.PresentationCreationTime, DicomTimeValue.Now); //Content Identification Macro Table 10-12 ds.InsertElementAndSetValue(DicomTag.InstanceNumber, 1); ds.InsertElementAndSetValue(DicomTag.ContentLabel, "ANNOTATIONS"); ds.InsertElementAndSetValue(DicomTag.ContentDescription, description); ds.InsertElementAndSetValue(DicomTag.ContentCreatorName, userName); //Presentation State RelationShip Module C11.11 PresentationStateRelationShip referncedSeriesSeq = new PresentationStateRelationShip(); referncedSeriesSeq.ReferencedSeriesSequence = new List <ReferencedSeries>(); ReferencedSeries referencedSeries = new ReferencedSeries(); referencedSeries.SeriesInstanceUID = seriesInstanceUID; referencedSeries.ReferencedImageSequence = new List <SopInstanceReference>(); referncedSeriesSeq.ReferencedSeriesSequence.Add(referencedSeries); Dictionary <LeadSize, List <ImageSopInstanceReference> > displayedAreaInstance = new Dictionary <LeadSize, List <ImageSopInstanceReference> >(); for (int index = 0; index < codecInfo.Pages.Length; index++) { AnnContainer container = codec.Load(ms, codecInfo.Pages[index]); ms.Position = 0; if (null == container.UserData) { continue; } AnnUserData refInstance = (AnnUserData)jsSerialzer.Deserialize <AnnUserData>(container.UserData.ToString()); if (null != refInstance && null != refInstance.ReferencedImageSequence) { referncedSeriesSeq.ReferencedSeriesSequence[0].ReferencedImageSequence.Add(refInstance.ReferencedImageSequence); // The Medical Viewer defaults dpi to 150 // In this case, there is enough information to compute the dpi, which should be 150 //double dpiX = 0; //double dpiY = 0; //container.CalculateDpi(out dpiX, out dpiY); //if (dpiX == 0 || dpiY == 0) //{ // dpiX = 150.0; // dpiY = 150.0; //} double xDpi = 150; double yDpi = 150; dicomAnnotationsUtilities.ImageDpiX = xDpi; dicomAnnotationsUtilities.ImageDpiY = yDpi; DicomElement graphicSequenceItem = dicomAnnotationsUtilities.FromAnnContainerToDataSet(ds, container); DicomElement layerElement = ds.FindFirstElement(graphicSequenceItem, DicomTag.GraphicLayer, false); if (null == layerElement) { ds.InsertElementAndSetValue(graphicSequenceItem, true, DicomTag.GraphicLayer, "LAYER1"); } else { ds.SetStringValue(layerElement, "LAYER1", DicomCharacterSetType.Default); } GraphicAnnotationsModule annModule = new GraphicAnnotationsModule(); annModule.ReferencedImageSequence = new List <ImageSopInstanceReference>(); annModule.ReferencedImageSequence.Add(refInstance.ReferencedImageSequence); ds.Set(graphicSequenceItem, annModule); } if (!refInstance.ImageSize.IsEmpty) { if (!displayedAreaInstance.ContainsKey(refInstance.ImageSize)) { displayedAreaInstance[refInstance.ImageSize] = new List <ImageSopInstanceReference>(); } displayedAreaInstance[refInstance.ImageSize].Add(refInstance.ReferencedImageSequence); } } ds.Set(referncedSeriesSeq); //Displayed Area Module // // DisplayedAreaModule displayedAreaModule = new DisplayedAreaModule(); displayedAreaModule.DisplayedAreaSelection = new List <DisplayedAreaSelection>(); foreach (KeyValuePair <LeadSize, List <ImageSopInstanceReference> > areaInstance in displayedAreaInstance) { DisplayedAreaSelection displayedArea = new DisplayedAreaSelection(); displayedAreaModule.DisplayedAreaSelection.Add(displayedArea); displayedArea.DisplayedAreaTopLeftHandCorner = new List <long>(); displayedArea.DisplayedAreaBottomRightHandCorner = new List <long>(); displayedArea.DisplayedAreaTopLeftHandCorner.Add(1); displayedArea.DisplayedAreaTopLeftHandCorner.Add(1); displayedArea.DisplayedAreaBottomRightHandCorner.Add(areaInstance.Key.Width); displayedArea.DisplayedAreaBottomRightHandCorner.Add(areaInstance.Key.Height); displayedArea.PresentationSizeMode = PresentationSizeMode.ScaleToFit; displayedArea.PresentationPixelAspectRatio = new List <int>(); displayedArea.PresentationPixelAspectRatio.Add(1); displayedArea.PresentationPixelAspectRatio.Add(1); if (displayedAreaInstance.Count > 1) { displayedArea.ReferencedImageSequence = areaInstance.Value; } } ds.Set(displayedAreaModule); //Graphic Layer Module GraphicLayerModule graphicLayerModule = new GraphicLayerModule(); graphicLayerModule.GraphicLayerSequence = new List <GraphicLayer>(); GraphicLayer layer = new GraphicLayer(); layer.GraphicLayerName = "LAYER1"; layer.GraphicLayerOrder = 1; graphicLayerModule.GraphicLayerSequence.Add(layer); ds.Set(graphicLayerModule); //Softcopy Presentation LUT Module SoftCopyPresentationLutModule presentationLut = new SoftCopyPresentationLutModule(); presentationLut.PresentationLutShape = PresentationLutShape.Identity; ds.Set(presentationLut); //SOP Common Module ds.InsertElementAndSetValue(DicomTag.SOPClassUID, DicomUidType.GrayscaleSoftcopyPresentationStateStorage); ds.InsertElementAndSetValue(DicomTag.SOPInstanceUID, SeriesGenerator.GenerateDicomUniqueIdentifier()); ds.InsertElementAndSetValue(DicomTag.InstanceCreationDate, DicomDateValue.Now); ds.InsertElementAndSetValue(DicomTag.InstanceCreationTime, DicomDateValue.Now); ds.InsertElementAndSetValue(DicomTag.InstanceNumber, 1); } return(ds); } }
private IExamInfo CreateExamInfo(DataRow examInfoRow, IPatientInfo patientInfo) { var examTime = (DateTime)examInfoRow["ExamDate"]; ExamInfo examInfo = new ExamInfo((PatientInfo)patientInfo, examInfoRow["ExamId"].ToString(), examTime) { Comment = examInfoRow["Comment"].ToString(), ExtraInfo = examInfoRow["ExtraInfo"].ToString(), AccessionNumber = examInfoRow["AccessionNumber"].ToString(), Operator = examInfoRow["Operator"].ToString(), PerformingPhysician = examInfoRow["ExamPhysician"].ToString(), ReferringPhysician = examInfoRow["PerfPhysician"].ToString(), }; var eddValue = examInfoRow["OBInfo_EDDByLMP"]; var gaValue = examInfoRow["OBInfo_GAByLMP"]; if (eddValue != DBNull.Value && gaValue != DBNull.Value) { var edd = (DateTime)eddValue; var ga = (int)gaValue; var total = (edd.ToLocalTime().Date - examTime.ToLocalTime().Date).Days + ga; var flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; var gaConstraint = examInfo.OBInfo.GetType().GetField("_gaConstraint", flags); if (gaConstraint != null) { var constraintObj = gaConstraint.GetValue(examInfo.OBInfo); var eddFactor = constraintObj.GetType().GetField("_eddFactor", flags); if (eddFactor != null) { eddFactor.SetValue(constraintObj, total); } } } if (examInfoRow["GeneralInfo_Height"] != DBNull.Value) { examInfo.GeneralInfo.Height = (double)examInfoRow["GeneralInfo_Height"]; } if (examInfoRow["GeneralInfo_Weight"] != DBNull.Value) { examInfo.GeneralInfo.Weight = (double)examInfoRow["GeneralInfo_Weight"]; } if (examInfoRow["GeneralInfo_BSA"] != DBNull.Value) { examInfo.GeneralInfo.BSA = (double)examInfoRow["GeneralInfo_BSA"]; } examInfo.GYNInfo.Ectopic = examInfoRow["GYNInfo_Ectopic"].ToString(); if (examInfoRow["GYNInfo_AB"] != DBNull.Value) { examInfo.GYNInfo.AB = (int)examInfoRow["GYNInfo_AB"]; } if (examInfoRow["GYNInfo_Gravida"] != DBNull.Value) { examInfo.GYNInfo.Gravida = (int)examInfoRow["GYNInfo_Gravida"]; } if (examInfoRow["GYNInfo_LMP"] != DBNull.Value) { examInfo.GYNInfo.LMP = (DateTime)examInfoRow["GYNInfo_LMP"]; } if (examInfoRow["GYNInfo_Para"] != DBNull.Value) { examInfo.GYNInfo.Para = (int)examInfoRow["GYNInfo_Para"]; } if (examInfoRow["URInfo_PPSACoefficient"] != DBNull.Value) { examInfo.URInfo.PPSACoefficient = (double)examInfoRow["URInfo_PPSACoefficient"]; } if (examInfoRow["URInfo_PSA"] != DBNull.Value) { examInfo.URInfo.PSA = (double)examInfoRow["URInfo_PSA"]; } var obInfo = examInfo.OBInfo as PatientOBInfo; if (obInfo != null) { obInfo.GAOrigin = GAOrigins.Convert((int)examInfoRow["OBInfo_GestationalAgeOrigin"]); obInfo.Ectopic = examInfoRow["OBInfo_Ectopic"].ToString(); if (examInfoRow["OBInfo_FetusNumber"] != DBNull.Value) { obInfo.FetusNumber = (int)examInfoRow["OBInfo_FetusNumber"]; } if (examInfoRow["OBInfo_AB"] != DBNull.Value) { obInfo.AB = (int)examInfoRow["OBInfo_AB"]; } if (examInfoRow["OBInfo_Gravida"] != DBNull.Value) { obInfo.Gravida = (int)examInfoRow["OBInfo_Gravida"]; } if (examInfoRow["OBInfo_Para"] != DBNull.Value) { obInfo.Para = (int)examInfoRow["OBInfo_Para"]; } if (gaValue != DBNull.Value) { obInfo.GestationalDays = (int)gaValue; if (obInfo.GAOrigin == GAOrigins.GA) { //这里转换examInfoRow["OBInfo_GaSourceDate"]到datetime。再做计算 obInfo.PrevExamGA = obInfo.GestationalDays - (examInfo.ExamDate.ToLocalTime().Date - ((DateTime)examInfoRow["OBInfo_GaSourceDate"]).ToLocalTime().Date).Days; } } if (examInfoRow["WorkSheetsXml"] != DBNull.Value) { var workSheetXml = (byte[])examInfoRow["WorkSheetsXml"]; SetValueForExamWorkSheet(workSheetXml, examInfo); SaveWorksheet(examInfo); } } return(examInfo); }
public PatientCore(IPatientInfo patientInfo) { _patientInfo = patientInfo; }
string GetPatientIdFromStorage() { try { if (null == DataAccessAgent) { return(""); } MatchingParameterCollection matchingParamCollection; MatchingParameterList matchingParamList; matchingParamCollection = new MatchingParameterCollection(); matchingParamList = new MatchingParameterList(); matchingParamCollection.Add(matchingParamList); { ReverseDicomDatasetAdapter dataSetReader = new ReverseDicomDatasetAdapter() { query = DataSet }; string PatientID = dataSetReader.PatientID; string StudyInstanceUID = dataSetReader.StudyInstanceUID; string SeriesInstanceUID = dataSetReader.SeriesInstanceUID; string SOPInstanceUID = dataSetReader.SOPInstanceUID; if (!string.IsNullOrEmpty(SOPInstanceUID)) { Instance imageInstance = new Instance(SOPInstanceUID); matchingParamList.Add(imageInstance); } if (!string.IsNullOrEmpty(SeriesInstanceUID)) { Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Series seriesEntity = new Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Series(SeriesInstanceUID); matchingParamList.Add(seriesEntity); } if (!string.IsNullOrEmpty(StudyInstanceUID)) { Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Study studyEntity = new Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Study(StudyInstanceUID); matchingParamList.Add(studyEntity); } if (!string.IsNullOrEmpty(PatientID)) { Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Patient patientEntity = new Leadtools.Medical.Storage.DataAccessLayer.MatchingParameters.Patient(PatientID); matchingParamList.Add(patientEntity); } } DataSet result = DataAccessAgent.QueryPatients(matchingParamCollection); if (null != result) { if (result.Tables[DataTableHelper.PatientTableName].Rows.Count > 0) { // return result.Patient[0].PatientID; IPatientInfo patientInfo = RegisteredDataRows.PatientInfo; DataRow patientRow = result.Tables[DataTableHelper.PatientTableName].Rows[0]; string sPatientId = patientInfo.GetElementValue(patientRow, DicomTag.PatientID); return((string)result.Tables[DataTableHelper.PatientTableName].Rows[0]["PatientId"]); } } return(""); } catch (System.Exception) { System.Diagnostics.Debug.Assert(false); return(""); } }