Exemplo n.º 1
0
        public AddPatientResponse AddPatient(AddPatientRequest request)
        {
            var profile = new PatientProfile();

            // check if we should auto-generate the MRN
            var workflowConfig = new WorkflowConfigurationReader();

            if (workflowConfig.AutoGenerateMrn)
            {
                var authorities = PersistenceContext.GetBroker <IEnumBroker>().Load <InformationAuthorityEnum>(false);

                // just use the first Information Authority (there is typically only one in this case)
                profile.Mrn.AssigningAuthority = CollectionUtils.FirstElement(authorities);
                profile.Mrn.Id = PersistenceContext.GetBroker <IMrnBroker>().GetNext();
            }


            var patient = new Patient();

            patient.AddProfile(profile);

            UpdateHelper(profile, request.PatientDetail, true, true, !workflowConfig.AutoGenerateMrn);

            PersistenceContext.Lock(patient, DirtyState.New);

            LogicalHL7Event.PatientCreated.EnqueueEvents(profile);

            PersistenceContext.SynchState();

            var assembler = new PatientProfileAssembler();

            return(new AddPatientResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext)));
        }
		private ListPatientProfilesResponse ListPatientProfiles(ListPatientProfilesRequest request)
		{
			var patient = this.PersistenceContext.Load<Patient>(request.PatientRef);

			var patientProfileAssembler = new PatientProfileAssembler();
			return new ListPatientProfilesResponse(
				CollectionUtils.Map<PatientProfile, PatientProfileSummary>(
					patient.Profiles,
					profile => patientProfileAssembler.CreatePatientProfileSummary(profile, this.PersistenceContext)));
		}
Exemplo n.º 3
0
        private ListPatientProfilesResponse ListPatientProfiles(ListPatientProfilesRequest request)
        {
            var patient = this.PersistenceContext.Load <Patient>(request.PatientRef);

            var patientProfileAssembler = new PatientProfileAssembler();

            return(new ListPatientProfilesResponse(
                       CollectionUtils.Map <PatientProfile, PatientProfileSummary>(
                           patient.Profiles,
                           profile => patientProfileAssembler.CreatePatientProfileSummary(profile, this.PersistenceContext))));
        }
Exemplo n.º 4
0
        public ListProfilesForPatientsResponse ListProfilesForPatients(ListProfilesForPatientsRequest request)
        {
            var assembler = new PatientProfileAssembler();
            var summaries = new List <PatientProfileSummary>();

            foreach (var patientRef in request.PatientRefs)
            {
                var patient = this.PersistenceContext.Load <Patient>(patientRef);
                foreach (var profile in patient.Profiles)
                {
                    summaries.Add(assembler.CreatePatientProfileSummary(profile, this.PersistenceContext));
                }
            }

            return(new ListProfilesForPatientsResponse(summaries));
        }
Exemplo n.º 5
0
        public UpdatePatientProfileResponse UpdatePatientProfile(UpdatePatientProfileRequest request)
        {
            var profile = PersistenceContext.Load <PatientProfile>(request.PatientProfileRef, EntityLoadFlags.CheckVersion);

            var updatePatient = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.Patient.Update);
            var updateProfile = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.PatientProfile.Update);

            UpdateHelper(profile, request.PatientDetail, updatePatient, updateProfile, false);

            LogicalHL7Event.PatientProfileModified.EnqueueEvents(profile);

            this.PersistenceContext.SynchState();

            var assembler = new PatientProfileAssembler();

            return(new UpdatePatientProfileResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext)));
        }
Exemplo n.º 6
0
		public OrderRequisition CreateOrderRequisition(Order order, IPersistenceContext context)
		{
			var patientProfileAssembler = new PatientProfileAssembler();
			var visitAssembler = new VisitAssembler();
			var pracAssembler = new ExternalPractitionerAssembler();
			var facilityAssembler = new FacilityAssembler();
			var dsAssembler = new DiagnosticServiceAssembler();
			var attachmentAssembler = new OrderAttachmentAssembler();
			var noteAssembler = new OrderNoteAssembler();
			var resultRecipientAssembler = new ResultRecipientAssembler();

			var requisition = new OrderRequisition
								{
									OrderRef = order.GetRef(),
									Patient =
										patientProfileAssembler.CreatePatientProfileSummary(
											CollectionUtils.FirstElement(order.Procedures).PatientProfile, context),
									Visit = visitAssembler.CreateVisitSummary(order.Visit, context),
									DiagnosticService = dsAssembler.CreateSummary(order.DiagnosticService),
									SchedulingRequestTime = order.SchedulingRequestTime,
									OrderingPractitioner =
										pracAssembler.CreateExternalPractitionerSummary(order.OrderingPractitioner, context),
									OrderingFacility = facilityAssembler.CreateFacilitySummary(order.OrderingFacility),
									ReasonForStudy = order.ReasonForStudy,
									Priority = EnumUtils.GetEnumValueInfo(order.Priority, context),
									ResultRecipients = CollectionUtils.Map<ResultRecipient, ResultRecipientDetail>(
										order.ResultRecipients,
										r => resultRecipientAssembler.CreateResultRecipientDetail(r, context)),
									Procedures = CollectionUtils.Map<Procedure, ProcedureRequisition>(
										order.Procedures,
										procedure => CreateProcedureRequisition(procedure, context)),
									Attachments = CollectionUtils.Map<OrderAttachment, AttachmentSummary>(
										order.Attachments,
										attachment => attachmentAssembler.CreateOrderAttachmentSummary(attachment, context)),
									Notes = CollectionUtils.Map<OrderNote, OrderNoteDetail>(
										OrderNote.GetNotesForOrder(order),
										note => noteAssembler.CreateOrderNoteDetail(note, context)),
									ExtendedProperties = ExtendedPropertyUtils.Copy(order.ExtendedProperties),
									CanModify = !order.IsTerminated
								};

			return requisition;
		}
Exemplo n.º 7
0
        public OrderRequisition CreateOrderRequisition(Order order, IPersistenceContext context)
        {
            var patientProfileAssembler  = new PatientProfileAssembler();
            var visitAssembler           = new VisitAssembler();
            var pracAssembler            = new ExternalPractitionerAssembler();
            var facilityAssembler        = new FacilityAssembler();
            var dsAssembler              = new DiagnosticServiceAssembler();
            var attachmentAssembler      = new OrderAttachmentAssembler();
            var noteAssembler            = new OrderNoteAssembler();
            var resultRecipientAssembler = new ResultRecipientAssembler();

            var requisition = new OrderRequisition
            {
                OrderRef = order.GetRef(),
                Patient  =
                    patientProfileAssembler.CreatePatientProfileSummary(
                        CollectionUtils.FirstElement(order.Procedures).PatientProfile, context),
                Visit                 = visitAssembler.CreateVisitSummary(order.Visit, context),
                DiagnosticService     = dsAssembler.CreateSummary(order.DiagnosticService),
                SchedulingRequestTime = order.SchedulingRequestTime,
                OrderingPractitioner  =
                    pracAssembler.CreateExternalPractitionerSummary(order.OrderingPractitioner, context),
                OrderingFacility = facilityAssembler.CreateFacilitySummary(order.OrderingFacility),
                ReasonForStudy   = order.ReasonForStudy,
                Priority         = EnumUtils.GetEnumValueInfo(order.Priority, context),
                ResultRecipients = CollectionUtils.Map <ResultRecipient, ResultRecipientDetail>(
                    order.ResultRecipients,
                    r => resultRecipientAssembler.CreateResultRecipientDetail(r, context)),
                Procedures = CollectionUtils.Map <Procedure, ProcedureRequisition>(
                    order.Procedures,
                    procedure => CreateProcedureRequisition(procedure, context)),
                Attachments = CollectionUtils.Map <OrderAttachment, AttachmentSummary>(
                    order.Attachments,
                    attachment => attachmentAssembler.CreateOrderAttachmentSummary(attachment, context)),
                Notes = CollectionUtils.Map <OrderNote, OrderNoteDetail>(
                    OrderNote.GetNotesForOrder(order),
                    note => noteAssembler.CreateOrderNoteDetail(note, context)),
                ExtendedProperties = ExtendedPropertyUtils.Copy(order.ExtendedProperties),
                CanModify          = !order.IsTerminated
            };

            return(requisition);
        }
Exemplo n.º 8
0
        public ListPatientReconciliationMatchesResponse ListPatientReconciliationMatches(ListPatientReconciliationMatchesRequest request)
        {
            var targetProfile = this.PersistenceContext.GetBroker <IPatientProfileBroker>().Load(request.PatientProfileRef);

            var strategy = (IPatientReconciliationStrategy)(new PatientReconciliationStrategyExtensionPoint()).CreateExtension();
            var matches  = strategy.FindReconciliationMatches(targetProfile, this.PersistenceContext);

            var profileAssembler = new PatientProfileAssembler();
            var rcAssembler      = new ReconciliationCandidateAssembler();
            var response         = new ListPatientReconciliationMatchesResponse
            {
                ReconciledProfiles =
                    CollectionUtils.Map <PatientProfile, PatientProfileSummary, List <PatientProfileSummary> >(
                        targetProfile.Patient.Profiles,
                        profile => profileAssembler.CreatePatientProfileSummary(profile, this.PersistenceContext)),
                MatchCandidates =
                    CollectionUtils.Map <PatientProfileMatch, ReconciliationCandidate, List <ReconciliationCandidate> >(
                        matches,
                        match => rcAssembler.CreateReconciliationCandidate(match, this.PersistenceContext))
            };

            return(response);
        }
        public ReconciliationCandidate CreateReconciliationCandidate(PatientProfileMatch profileMatch, IPersistenceContext context)
        {
            var rc = new ReconciliationCandidate();

            var profileAssembler = new PatientProfileAssembler();

            rc.PatientProfile = profileAssembler.CreatePatientProfileSummary(profileMatch.PatientProfile, context);
            switch (profileMatch.Score)
            {
            case PatientProfileMatch.ScoreValue.High:
                rc.Score = ReconciliationCandidate.ProbabilityScore.High;
                break;

            case PatientProfileMatch.ScoreValue.Moderate:
                rc.Score = ReconciliationCandidate.ProbabilityScore.Moderate;
                break;

            case PatientProfileMatch.ScoreValue.Low:
                rc.Score = ReconciliationCandidate.ProbabilityScore.Low;
                break;
            }
            return(rc);
        }
Exemplo n.º 10
0
		public UpdatePatientProfileResponse UpdatePatientProfile(UpdatePatientProfileRequest request)
		{
			var profile = PersistenceContext.Load<PatientProfile>(request.PatientProfileRef, EntityLoadFlags.CheckVersion);

			var updatePatient = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.Patient.Update);
			var updateProfile = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.PatientProfile.Update);

			UpdateHelper(profile, request.PatientDetail, updatePatient, updateProfile, false);

			LogicalHL7Event.PatientProfileModified.EnqueueEvents(profile);

			this.PersistenceContext.SynchState();

			var assembler = new PatientProfileAssembler();
			return new UpdatePatientProfileResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext));
		}
Exemplo n.º 11
0
		public AddPatientResponse AddPatient(AddPatientRequest request)
		{
			var profile = new PatientProfile();

			// check if we should auto-generate the MRN
			var workflowConfig = new WorkflowConfigurationReader();
			if (workflowConfig.AutoGenerateMrn)
			{
				var authorities = PersistenceContext.GetBroker<IEnumBroker>().Load<InformationAuthorityEnum>(false);

				// just use the first Information Authority (there is typically only one in this case)
				profile.Mrn.AssigningAuthority = CollectionUtils.FirstElement(authorities);
				profile.Mrn.Id = PersistenceContext.GetBroker<IMrnBroker>().GetNext();
			}


			var patient = new Patient();
			patient.AddProfile(profile);

			UpdateHelper(profile, request.PatientDetail, true, true, !workflowConfig.AutoGenerateMrn);

			PersistenceContext.Lock(patient, DirtyState.New);

			LogicalHL7Event.PatientCreated.EnqueueEvents(profile);

			PersistenceContext.SynchState();

			var assembler = new PatientProfileAssembler();
			return new AddPatientResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext));
		}