Esempio n. 1
0
        //PV1|1|O|Ward1^RoomE8^Bed10^ADHAHOSP&2.16.840.1.113883.19.5&ISO||||ABCB^AttendingOmar^Muhammad^^^Dr^^^SUPER-LIS~123456^AttendingOmar^Muhammad^^^Dr^^^ADHAHOSP~2304227F^AttendingOmar^Muhammad^^^Dr^^^AUSHICPR|HIJK^ReferringWilliams^Simon^^^Dr^^^SUPER-LIS~858595^ReferringWilliams^Simon^^^Dr^^^ADHAHOSP~2929016F^ReferringWilliams^Simon^^^Dr^^^AUSHICPR
        public static ISegment GetPV1(string patientClassCode, Spia.PathologyReportModel.Model.Provider referringProvider, string performingLabNataSiteNumber)
        {
            ISegment PV1 = Creator.Segment("PV1");

            PV1.Field(1).AsString = "1";
            PV1.Field(2).AsString = patientClassCode;

            //IField PatientLocation = Creator.Field();
            //PatientLocation.Component(1).AsString = "Ward1";
            //PatientLocation.Component(2).AsString = "RoomE8";
            //PatientLocation.Component(3).AsString = "Bed10";
            //PatientLocation.Component(4).SubComponent(1).AsString = "ADHAHOSP";
            //PatientLocation.Component(5).SubComponent(2).AsString = "2.16.840.1.113883.19.5";
            //PatientLocation.Component(5).SubComponent(3).AsString = "ISO";
            //PV1.Element(3).Add(PatientLocation);


            foreach (var Id in referringProvider.IdentifierList)
            {
                var    IdentiferTypeInfo = HL7v2IdentifierSupport.GetIdentiferCode(Id, $"NATA{performingLabNataSiteNumber}");
                IField Field             = Creator.Field();
                Field.Component(1).AsString  = IdentiferTypeInfo.Value;
                Field.Component(2).AsString  = referringProvider.Name.Family;
                Field.Component(3).AsString  = referringProvider.Name.Given ?? "";
                Field.Component(6).AsString  = referringProvider.Name.Title ?? "";
                Field.Component(9).AsString  = IdentiferTypeInfo.AssigingAuthority;
                Field.Component(10).AsString = "L";
                Field.Component(13).AsString = IdentiferTypeInfo.TypeCode ?? "";

                //PV1-8: Definition: This field contains the referring physician information. Multiple names and identifiers for the same
                //physician may be sent. The field sequences are not used to indicate multiple referring doctors. The legal name must be sent
                //in the first sequence. If the legal name is not sent, then a repeat delimiter must be sent in the first sequence. Depending on
                //local agreements, either the ID or the name may be absent from this field. Refer to User-defined Table 0010 - Physician ID for suggested values
                PV1.Element(8).Add(Field);

                //https://confluence.hl7australia.com/display/OOADRM20181/2+Patient+Administration+for+Pathology#id-2PatientAdministrationforPathology-PV1-92.2.2.9PV1-9Consultingdoctor(XCN)00139
                //PV1-9: In the Australian setting this field is used to identify the target provider for this message.
                //A location specific ID is used and the field should not repeat as each message is unique for the target provider.
                //Where available the Medicare provider number is used as this provides for a location specific identifier. Messages
                //should be routed based on this field and only the first repeat is used.
                if (Id.Type == PathologyReportModel.Model.IdentifierType.MedicareProviderNumber)
                {
                    PV1.Element(9).Add(Field.Clone());
                }
            }

            return(PV1);
        }
Esempio n. 2
0
        private bool PopulateDoctor()
        {
            var      ProviderRole     = "PP";
            var      ProviderType     = "GMPRC";
            ISegment TargetRolSegment = null;

            foreach (var ROL in Msg.SegmentList("ROL"))
            {
                if (ROL.Field(3).Component(1).AsString.ToUpper() == ProviderRole &&
                    ROL.Field(9).Component(1).AsString.ToUpper() == ProviderType)
                {
                    TargetRolSegment = ROL;
                }
            }

            if (TargetRolSegment == null)
            {
                //It is not an error to have no doctor, at least this is true for RMH
                DomainModel.Doctor = null;
                return(true);
            }
            else
            {
                DomainModel.Doctor.Given  = TargetRolSegment.Field(4).Component(3).AsString;
                DomainModel.Doctor.Family = TargetRolSegment.Field(4).Component(2).AsString;

                //Doctor Address
                //(1: Business, 2: Mailing Address, 3:Temporary Address, 4:Residential/Home, 9: Not Specified)
                //At RMH we had issues in that we got many addresses and could not pick the one required for the current primary doctor surgery
                //This was resolved and the PMI is to now only send a single address that being the correct address.
                //For this reason I have changes the code below to just take the first address regardless of there being many, which there should not be.

                //If we did not get the target address then just take the first address.
                if (TargetRolSegment.Element(11).RepeatCount > 0)
                {
                    ResolveAddress(TargetRolSegment.Element(11), DomainModel.Doctor.Address);
                }

                //Doctor Contacts (We only take the first of each type.
                ResolveContact(TargetRolSegment.Element(12), DomainModel.Doctor.Contact, PhoneUseType.Work.GetLiteral());

                return(true);
            }
        }
Esempio n. 3
0
        public static ISegment GetOBR(Spia.PathologyReportModel.Model.Request request, Spia.PathologyReportModel.Model.Report report, Spia.PathologyReportModel.Model.Laboratory performingLab)
        {
            //OBR|1|112233^PathologyOrder^2.16.840.1.113883.19.4.1.5^ISO|15P000005-123456^SUPER-LIS^2.16.840.1.113883.19.1.2^ISO|26604007^Complete blood count^SCT^FBE^Full Blood Count^SUPER-LIS|||201504100930+1000||||||Patient has a history of severe gout caused by rhubarb.|201504101100+1000||DFTR^OrderingRankin^Jeff^^^Dr^^^SUPER-LIS~958678^OrderingRankin^Jeff^^^Dr^^^ADHAHOSP~4322581B^OrderingRankin^Jeff^^^Dr^^^AUSHICPR~8003614899999997^OrderingRankin^Jeff^^^Dr^^^AUSHIC^^^^^NPI|^WPN^PH^^^^0893412041|||CP=N,DR=4322581B||201504101115+1000||HM|F||^^^201504100800+1000^^RT|2304227F^CopyDoctorRyan^Paul^^^Dr^^^AUSHICPR~0813266H^CopyDoctorArnet^Claire^^^Dr^^^AUSHICPR~4628361B^CopyDoctorTeller^Sally^^^Dr^^^AUSHICPR||||DRPRIM&PathologistThompson&Harry&&&DR&&&SUPER-LIS
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (report is null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            ISegment OBR = Creator.Segment("OBR");

            OBR.Field(1).AsString = "1";

            IField PlacerOrderNumber = Creator.Field();

            PlacerOrderNumber.Component(1).AsString = request.OrderNumber ?? "";
            PlacerOrderNumber.Component(2).AsString = "PathologyOrder";
            PlacerOrderNumber.Component(3).AsString = performingLab.NataSiteNumber;
            PlacerOrderNumber.Component(4).AsString = "AUSNATA";
            OBR.Element(2).Add(PlacerOrderNumber);

            IField FillerOrderNumber = Creator.Field();

            FillerOrderNumber.Component(1).AsString = report.ReportId;
            FillerOrderNumber.Component(2).AsString = performingLab.FacilityCode;
            FillerOrderNumber.Component(3).AsString = performingLab.NataSiteNumber;
            FillerOrderNumber.Component(4).AsString = "AUSNATA";
            OBR.Element(3).Add(FillerOrderNumber);

            //26604007^Complete blood count^SCT^FBE^Full Blood Count^SUPER-LIS
            IField UniversalServiceIdentifier = Creator.Field();

            UniversalServiceIdentifier.Component(1).AsString = report.ReportType.Snomed?.Term ?? "";
            UniversalServiceIdentifier.Component(2).AsString = report.ReportType.Snomed?.Description ?? "";
            if (!UniversalServiceIdentifier.Component(1).IsEmpty)
            {
                UniversalServiceIdentifier.Component(3).AsString = "SCT";
            }
            UniversalServiceIdentifier.Component(4).AsString = report.ReportType.Local.Term;
            UniversalServiceIdentifier.Component(5).AsString = report.ReportType.Local.Description;
            UniversalServiceIdentifier.Component(6).AsString = $"NATA{performingLab.NataSiteNumber}";
            OBR.Element(4).Add(UniversalServiceIdentifier);

            //Observation Date/Time (Collection DateTime)
            OBR.Field(7).Convert.DateTime.SetDateTimeOffset(report.CollectionDateTime, true);

            //Clinical Note
            OBR.Field(13).AsString = request.ClinicalNotes ?? "";

            //Specimen received date/time
            //Definition: For observations requiring a specimen, the specimen received date/time is the actual login time at the diagnostic service.
            //This field must contain a value when the order is accompanied
            //by a specimen, or when the observation required a specimen and the message is a report.
            OBR.Field(14).Convert.DateTime.SetDateTimeOffset(report.SpecimenReceivedDateTime, true);

            //Ordering Doctor
            foreach (var Id in request.RequestingProvider.IdentifierList)
            {
                var    IdentiferTypeInfo = HL7v2IdentifierSupport.GetIdentiferCode(Id, $"NATA{performingLab.NataSiteNumber}");
                IField Field             = Creator.Field();
                Field.Component(1).AsString  = IdentiferTypeInfo.Value;
                Field.Component(2).AsString  = request.RequestingProvider.Name.Family;
                Field.Component(3).AsString  = request.RequestingProvider.Name.Given;
                Field.Component(6).AsString  = request.RequestingProvider.Name.Title;
                Field.Component(9).AsString  = IdentiferTypeInfo.AssigingAuthority;
                Field.Component(10).AsString = "L";
                Field.Component(13).AsString = IdentiferTypeInfo.TypeCode;
                OBR.Element(16).Add(Field);
            }

            if (request.CallBackPhoneNumber is object)
            {
                IField OrderCallBackNumber = Creator.Field();
                OrderCallBackNumber.Component(2).AsString = "WPN";
                OrderCallBackNumber.Component(3).AsString = "PH";
                OrderCallBackNumber.Component(7).AsString = request.CallBackPhoneNumber;
                OBR.Element(17).Add(OrderCallBackNumber);
            }

            var OrderingDrProviderNumber = request.RequestingProvider.IdentifierList.SingleOrDefault(x => x.Type == PathologyReportModel.Model.IdentifierType.MedicareProviderNumber);

            if (OrderingDrProviderNumber is object)
            {
                //Copy = No, directed at the DR=ProviderNumber
                OBR.Field(20).AsString = $"CP=N,DR={OrderingDrProviderNumber.Value}";
            }

            //Report Status Change DateTime
            OBR.Field(22).Convert.DateTime.SetDateTimeOffset(report.ReportReleaseDateTime, true);

            //Service Section Id
            DiagnosticServiceSectionIdSupport DiagnosticServiceSectionIdSupport = new DiagnosticServiceSectionIdSupport();

            if (DiagnosticServiceSectionIdSupport.TryLookupByEnum(report.Department, out string DiagnosticServiceSectionIdCode))
            {
                OBR.Field(24).AsString = DiagnosticServiceSectionIdCode;
            }
            else
            {
                throw new ApplicationException($"Unable to convert the {nameof(report.Department)} of {report.Department.ToString()} to a code for the HL7 OBR-24 field.");
            }

            //Report Status
            ResultStatusTypeSupport ResultStatusTypeSupport = new ResultStatusTypeSupport();

            if (ResultStatusTypeSupport.TryLookupByEnum(report.ReportStatus, out string ReportStatus))
            {
                OBR.Field(25).AsString = ReportStatus;
            }
            else
            {
                throw new ApplicationException($"Unable to convert the {nameof(report.ReportStatus)} of {report.ReportStatus.ToString()} to a code for the HL7 OBR-25 field.");
            }

            //Quantity/Timing (Collection Date Time)
            IField QuantityTiming = Creator.Field();

            QuantityTiming.Component(4).Convert.DateTime.SetDateTimeOffset(request.RequestedDate, true);
            QuantityTiming.Component(6).AsString = "RT";
            OBR.Element(27).Add(QuantityTiming);

            //Copy Doctors
            if (request.CopyToList is object)
            {
                foreach (var CopyDr in request.CopyToList)
                {
                    var IdenitferToUserForCopyToDoctor = CopyDr.IdentifierList.SingleOrDefault(x => x.Type == PathologyReportModel.Model.IdentifierType.MedicareProviderNumber);
                    if (IdenitferToUserForCopyToDoctor == null)
                    {
                        IdenitferToUserForCopyToDoctor = CopyDr.IdentifierList.SingleOrDefault(x => x.Type == PathologyReportModel.Model.IdentifierType.LocalToLab);
                    }
                    if (IdenitferToUserForCopyToDoctor == null)
                    {
                        throw new ApplicationException($"All CopyTo doctors must have a Medicare Provider Number (preferred) or a Local Lab ID. The CopyTo entry of {CopyDr.Name.Title ?? ""} {CopyDr.Name.Family} {CopyDr.Name.Given ?? ""} did not have a either.");
                    }

                    var    IdentiferTypeInfo = HL7v2IdentifierSupport.GetIdentiferCode(IdenitferToUserForCopyToDoctor, $"NATA{performingLab.NataSiteNumber}");
                    IField Field             = Creator.Field();
                    Field.Component(1).AsString  = IdentiferTypeInfo.Value;
                    Field.Component(2).AsString  = CopyDr.Name.Family;
                    Field.Component(3).AsString  = CopyDr.Name.Given ?? "";
                    Field.Component(6).AsString  = CopyDr.Name.Title ?? "";
                    Field.Component(9).AsString  = IdentiferTypeInfo.AssigingAuthority;
                    Field.Component(10).AsString = "L";
                    Field.Component(13).AsString = IdentiferTypeInfo.TypeCode;
                    OBR.Element(28).Add(Field);
                }
            }
            //Principle Result Interpretor
            //DRPRIM&PathologistThompson&Harry&&&DR&&&SUPER-LIS
            var PrincipleResultInterpretorLocalLabCode = report.ReportingPathologist.IdentifierList.SingleOrDefault(x => x.Type == PathologyReportModel.Model.IdentifierType.LocalToLab);

            if (PrincipleResultInterpretorLocalLabCode != null)
            {
                IField PrincipleResultInterpretor = Creator.Field();
                PrincipleResultInterpretor.Component(1).SubComponent(1).AsString = PrincipleResultInterpretorLocalLabCode.Value;
                PrincipleResultInterpretor.Component(1).SubComponent(2).AsString = report.ReportingPathologist.Name.Family;
                PrincipleResultInterpretor.Component(1).SubComponent(3).AsString = report.ReportingPathologist.Name.Given;
                PrincipleResultInterpretor.Component(1).SubComponent(6).AsString = report.ReportingPathologist.Name.Title ?? "";
                PrincipleResultInterpretor.Component(1).SubComponent(9).AsString = $"NATA{performingLab.NataSiteNumber}";
                OBR.Element(32).Add(PrincipleResultInterpretor);
            }
            else
            {
                throw new ApplicationException($"Unable to locate a {PathologyReportModel.Model.IdentifierType.LocalToLab.ToString()} identifier for the Reporting Pathologist");
            }

            return(OBR);
        }
Esempio n. 4
0
        public static ISegment GetPID(Patient Patient)
        {
            if (Patient is null)
            {
                throw new ArgumentNullException(nameof(Patient));
            }

            //PID|1||2142363^^^ADHAHOSP^MR~61405230941^^^AUSHIC^MC~WA123456B^^^AUSDVA^DVG~8003608833357361^^^AUSHIC^NI||Smith^John^Brian^^Mr^^L~Smith^Johno^Bry^^Mr^^M||194506241031|M|||Unit 1^111 ADHA Street^Brisbane^QLD^4000^AUS^H~Unit 2^222 ADHATwo Street^Brisbane^QLD^4000^AUS^B||^PRN^PH^^^^93235615|^WPN^CP^^^^0414778341
            ISegment PID = Creator.Segment("PID");

            PID.Field(1).AsString = "1";

            foreach (var Id in Patient.IdentifierList)
            {
                var    IdCode         = HL7v2IdentifierSupport.GetIdentiferCode(Id);
                IField PatientIdField = Creator.Field();
                PatientIdField.Component(1).AsString = IdCode.Value;
                PatientIdField.Component(4).AsString = IdCode.AssigingAuthority;
                PatientIdField.Component(5).AsString = IdCode.TypeCode;
                PID.Element(3).Add(PatientIdField);
            }


            IField Field = Creator.Field();

            Field.Component(1).AsString = Patient.Name.Family;
            Field.Component(2).AsString = Patient.Name.Given ?? "";
            Field.Component(3).AsString = Patient.Name.Middle ?? "";
            Field.Component(5).AsString = Patient.Name.Title ?? "";
            Field.Component(7).AsString = "L";
            PID.Element(5).Add(Field);


            //DOB
            PID.Field(7).Convert.DateTime.SetDateTimeOffset(new DateTimeOffset(Patient.DateOfBirth), false, PeterPiper.Hl7.V2.Support.Tools.DateTimeSupportTools.DateTimePrecision.Date);

            //Gender
            GenderTypeSupport GenderTypeSupport = new GenderTypeSupport();

            if (GenderTypeSupport.TryLookupByEnum(Patient.Gender, out string GenderCode))
            {
                PID.Field(8).AsString = GenderCode;
            }
            else
            {
                throw new ApplicationException($"Unable to convert the {nameof(Patient.Gender)} of {Patient.Gender.ToString()} to a code for the HL7 PID-8 field.");
            }
            StateTypeSupport StateTypeSupport = new StateTypeSupport();

            AddressTypeSupport AddressTypeSupport = new AddressTypeSupport();

            foreach (var Add in Patient.AddressList)
            {
                IField AddressField = Creator.Field();
                AddressField.Component(1).AsString = Add.LineOne ?? "";
                AddressField.Component(2).AsString = Add.LineTwo ?? "";
                AddressField.Component(3).AsString = Add.City ?? "";
                if (StateTypeSupport.TryLookupByEnum(Add.State, out string StateCode))
                {
                    AddressField.Component(4).AsString = StateCode;
                }
                else
                {
                    throw new ApplicationException($"Unable to lookup the {nameof(StateType)} of {Add.State.ToString()}");
                }
                AddressField.Component(5).AsString = Add.PostCode ?? "";
                AddressField.Component(6).AsString = Add.Country ?? "";
                if (AddressTypeSupport.TryLookupByEnum(Add.TypeCode, out string AddressTypeCode))
                {
                    AddressField.Component(7).AsString = AddressTypeCode;
                }
                else
                {
                    throw new ApplicationException($"Unable to locate the code required for the {nameof(AddressType)} enum of {Add.TypeCode.ToString()}");
                }

                PID.Element(11).Add(AddressField);
            }

            //^PRN^PH^^^^93235615
            if (!string.IsNullOrWhiteSpace(Patient.HomePhoneNumber))
            {
                IField HomePhone = Creator.Field();
                HomePhone.Component(2).AsString = "PRN";
                if (IsMobileNumber(Patient.HomePhoneNumber))
                {
                    HomePhone.Component(3).AsString = "CP";
                }
                else
                {
                    HomePhone.Component(3).AsString = "PH";
                }
                HomePhone.Component(7).AsString = Patient.HomePhoneNumber;
                PID.Element(13).Add(HomePhone);
            }

            //^WPN^CP^^^^0414778341
            //if (Patient.WorkPhone is object)
            //{
            //  IField WorkPhone = Creator.Field();
            //  WorkPhone.Component(2).AsString = "WPN";
            //  if (IsMobileNumber(patient.WorkPhone))
            //  {
            //    WorkPhone.Component(3).AsString = "CP";
            //  }
            //  else
            //  {
            //    WorkPhone.Component(3).AsString = "PH";
            //  }
            //  WorkPhone.Component(3).AsString = "CP";
            //  WorkPhone.Component(7).AsString = patient.WorkPhone;
            //  PID.Element(14).Add(WorkPhone);
            //}

            return(PID);
        }