public IActionResult GetAppointmentReport(AppointmentDTO dto) { String patientId = User.Identity.Name; List <Prescription> prescriptions = _prescriptionSearchService.GetPrescriptionsBy(dto.DoctorId, patientId, dto.StartTime); List <AppointmentPrescriptionDTO> prescriptionDTOs = PrescriptionMapper.ListPrescriptionToAppointmentPrescriptionDTO(prescriptions); return(Ok(prescriptionDTOs)); }
public IActionResult GetSearchedPrescription(PrescriptionSearchDTO dto) { try { PrescriptionSearchValidator.Validate(dto); } catch (Exception e) { return(BadRequest(e.Message)); } List <Prescription> prescriptions = _prescriptionSearchService.GetSearchedPrescription(dto.Medicine, dto.HourlyIntake, dto.StartDate, dto.EndDate); List <PrescriptionDTO> prescriptionDTOs = PrescriptionMapper.ListPrescriptionToPrescriptionDTO(prescriptions); return(Ok(prescriptionDTOs)); }
public void Export(ApplicationDataModel dataModel, string exportPath, Properties properties = null) { ParseExportProperties(properties); if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } // Path of exportfolder: "PluginFolder - [Name of Catalog]" var newPath = Path.Combine(exportPath, InfoFileConstants.PluginFolderPrefix + "-" + ZipUtils.GetSafeName(dataModel.Catalog.Description)); // ToDo: add more meta data of this export _JsonExporter.WriteInfoFile(newPath, Name, Version, dataModel.Catalog.Description, CustomProperties); switch (CustomProperties.ApplyingAnonymiseValuesPer) { case ApplyingAnonymiseValuesEnum.PerField: foreach (var fieldId in dataModel.Catalog.Fields.Select(f => f.Id.ReferenceId)) { List <int> workRecordIds = dataModel.Documents.WorkRecords .Where(wr => wr.FieldIds.Contains(fieldId)) .Select(wr => wr.Id.ReferenceId) .ToList(); if (CustomProperties.Anonymise) { // Randomize the Anonymization values AnonymizeUtils.GenerateRandomAffineTransformation(CustomProperties); } ; // OperationDataMapper // ToDo: replace with OperationDataMapper //var workRecordDtos = workRecordsMapper.MapAll(workRecordIds); //_JsonExporter.WriteWorkRecordDtos(newPath, workRecordDtos); // FieldBoundaryMapper // ToDo: FieldBoundaryMapper.MapAsSingleFeature([fieldId]) // GuidanceGroupMapper // ToDo: GuidanceGroupMapper.MapAs...([all GuidanceGroups for fieldId]) // WorkItemOperationMapper // ToDo: WorkItemOperationMapper.MapAs...([all WorkItemOperations for fieldId]) } break; case ApplyingAnonymiseValuesEnum.PerWorkRecord: foreach (var workRecord in dataModel.Documents.WorkRecords) { if (CustomProperties.Anonymise) { // Randomize the Anonymization values AnonymizeUtils.GenerateRandomAffineTransformation(CustomProperties); } ; // OperationDataMapper // ToDo: replace with OperationDataMapper //WorkRecordDto workRecordDto_mapped = workRecordsMapper.MapSingle(workRecord); //_JsonExporter.WriteWorkRecordDto(newPath, workRecordDto_mapped); // FieldBoundaryMapper // ToDo: FieldBoundaryMapper.MapAsMultipleFeatures([all FieldBoundaries for workRecord.Id]) // GuidanceGroupMapper // ToDo: GuidanceGroupMapper.MapAs...([all GuidanceGroups for workRecord.Id]) // WorkItemOperationMapper // ToDo: GuidanceGroupMapper.MapAs...([all WorkItemOperations for workRecord.Id]) } break; default: if (CustomProperties.Anonymise) { // Randomize the Anonymization values AnonymizeUtils.GenerateRandomAffineTransformation(CustomProperties); } ; foreach (var workRecord in dataModel.Documents.WorkRecords) { // OperationDataMapper // ToDo: OperationDataMapper.MapAsFeatureCollection([workRecord]) } FieldBoundaryMapper fieldBoundaryMapper = new FieldBoundaryMapper(CustomProperties, dataModel); foreach (var fieldBoundary in dataModel.Catalog.FieldBoundaries) { // FieldBoundaryMapper Feature fieldBoundaryFeature = fieldBoundaryMapper.MapAsSingleFeature(fieldBoundary); string fileNamePrescriptions = FieldBoundaryMapper.GetFieldBoundaryPrefix(); if (fieldBoundaryFeature.Properties.ContainsKey("FieldId")) { fileNamePrescriptions = fileNamePrescriptions + "_for_field_" + fieldBoundaryFeature.Properties["FieldId"]; } else if (fieldBoundaryFeature.Properties.ContainsKey("Guid")) { fileNamePrescriptions = fileNamePrescriptions + "_" + fieldBoundaryFeature.Properties["Guid"]; } else { fileNamePrescriptions = fileNamePrescriptions + "_" + Guid.NewGuid(); } _JsonExporter.WriteAsGeoJson(newPath, new List <Feature>() { fieldBoundaryFeature }, fileNamePrescriptions); // DrivenHeadlandMapper foreach (Headland headland in fieldBoundary.Headlands) { if (headland is DrivenHeadland) { DrivenHeadlandMapper drivenHeadlandMapper = new DrivenHeadlandMapper(CustomProperties, dataModel); Feature drivenHeadlandFeature = drivenHeadlandMapper.MapAsSingleFeature(headland as DrivenHeadland, fieldBoundaryFeature); if (drivenHeadlandFeature == null) { drivenHeadlandMapper = null; } else { string drivenHeadlandFileName = DrivenHeadlandMapper.GetPrefix(); if (drivenHeadlandFeature.Properties.ContainsKey("FieldId")) { drivenHeadlandFileName += "_for_field_" + drivenHeadlandFeature.Properties["FieldId"]; } _JsonExporter.WriteAsGeoJson(newPath, new List <Feature>() { drivenHeadlandFeature }, drivenHeadlandFileName); } } } } GuidanceGroupMapper guidanceGroupMapper = new GuidanceGroupMapper(CustomProperties, dataModel); foreach (var guidanceGroup in dataModel.Catalog.GuidanceGroups) { // GuidanceGroupMapper List <Feature> guidanceGroupFeatures = guidanceGroupMapper.MapAsMultipleFeatures(guidanceGroup); string fileNameGuidanceGroup = GuidanceGroupMapper.GetPrefix(); if (guidanceGroupFeatures[0] != null) { if (guidanceGroupFeatures[0].Properties.ContainsKey("GuidancePatternType")) { fileNameGuidanceGroup = fileNameGuidanceGroup + "_type_" + guidanceGroupFeatures[0].Properties["GuidancePatternType"]; } if (guidanceGroupFeatures[0].Properties.ContainsKey("FieldId")) { fileNameGuidanceGroup = fileNameGuidanceGroup + "_for_field_" + guidanceGroupFeatures[0].Properties["FieldId"]; } else if (guidanceGroupFeatures[0].Properties.ContainsKey("Guid")) { fileNameGuidanceGroup = fileNameGuidanceGroup + "_" + guidanceGroupFeatures[0].Properties["Guid"]; } else { fileNameGuidanceGroup = fileNameGuidanceGroup + "_" + Guid.NewGuid(); } } _JsonExporter.WriteAsGeoJson(newPath, guidanceGroupFeatures, fileNameGuidanceGroup); } //Prescriptions (without gridType) List <Feature> prescriptionFeatures = new List <Feature>(); List <Feature> prescriptionFeaturesSingle = new List <Feature>(); PrescriptionMapper prescriptionMapper = new PrescriptionMapper(CustomProperties, dataModel); foreach (var workItemOperation in dataModel.Documents.WorkItemOperations) { Console.WriteLine("WorkItemOperation: " + workItemOperation.Description + " OperationType " + workItemOperation.OperationType); Prescription adaptPrescription = dataModel.Catalog.Prescriptions.Where(f => f.Id.ReferenceId == workItemOperation.PrescriptionId).FirstOrDefault(); if (adaptPrescription != null) { // single var prescriptionFeature = prescriptionMapper.MapAsSingleFeature(adaptPrescription); if (prescriptionFeature != null) { prescriptionFeature.Properties.Add("OperationType", Enum.GetName(typeof(OperationTypeEnum), workItemOperation.OperationType)); // Enum: //workItemOperationFeature.Properties.Add("Description", workItemOperation.Description); //workItemOperationFeature.Properties.Add("ID", workItemOperation.Id); prescriptionFeaturesSingle.Add(prescriptionFeature); } else { Console.WriteLine("prescriptionFeature single null for: " + workItemOperation.PrescriptionId); } // multiple var features = prescriptionMapper.MapAsMultipleFeatures(adaptPrescription); if (features != null && features.Count > 0) { prescriptionFeatures.AddRange(features); } else { Console.WriteLine("prescriptionFeatures null or empty for: " + workItemOperation.PrescriptionId); } } else { Console.WriteLine("adaptPrescription not found : " + workItemOperation.PrescriptionId); } } // Todo: [Check] if all dataModel.Catalog.Prescriptions has been mapped if (dataModel.Catalog.Prescriptions.Count() != dataModel.Documents.WorkItemOperations.Count()) { Console.WriteLine("Count prescriptions and WorkItemOperations differ: " + dataModel.Catalog.Prescriptions.Count() + " " + dataModel.Documents.WorkItemOperations.Count()); } //else // Console.WriteLine("Count prescriptions and WorkItemOperations same: " + dataModel.Catalog.Prescriptions.Count() + " " + dataModel.Documents.WorkItemOperations.Count()); string fileNamePs; // @ToDo only when count > 0? fileNamePs = PrescriptionMapper.GetWorkItemOperationPrefix(); fileNamePs = fileNamePs + "_single_" + Guid.NewGuid(); _JsonExporter.WriteAsGeoJson(newPath, prescriptionFeaturesSingle, fileNamePs); string fileNamePm; fileNamePm = PrescriptionMapper.GetWorkItemOperationPrefix(); fileNamePm = fileNamePm + "_" + Guid.NewGuid(); _JsonExporter.WriteAsGeoJson(newPath, prescriptionFeatures, fileNamePm); // LoggedData OperationTimelogMapper operationTimelogMapper = new OperationTimelogMapper(CustomProperties, dataModel); // starting from workRecords --> Not doing this as some loggedData may have not been referenced in a workrecord; we want to catch all logged data in the adm // starting from LoggedData foreach (var loggedData in dataModel.Documents.LoggedData) { foreach (OperationData operation in loggedData.OperationData) { Console.WriteLine("OperationTimelog - operationData: " + operation.Id.ReferenceId + " " + operation.OperationType + " maxDepth " + operation.MaxDepth); IEnumerable <SpatialRecord> spatialRecords = operation.GetSpatialRecords != null?operation.GetSpatialRecords() : null; if (spatialRecords != null && spatialRecords.Any()) //No need to export a timelog if no data { var operationTimelogFeatures = operationTimelogMapper.MapMultiple(operation, spatialRecords); string fileNameL = OperationTimelogMapper.GetPrefix() + "_" + operation.OperationType + "_" + Guid.NewGuid(); _JsonExporter.WriteAsGeoJson(newPath, operationTimelogFeatures, fileNameL); } } } break; // Default ApplyingAnonymiseValuesPer switch } }
[HttpPost("advancedSearchPrescriptionsForPatient")] // POST /api/prescription/advancedSearchPrescriptionsForPatient public IActionResult FindPrescriptionsForPatient(PrescriptionDto dto) { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.FindPrescriptionsUsingAdvancedSearch(dto.PatientId, dto.SearchParams, dto.LogicOperators).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
[HttpGet("simpleSearchPrescriptionForPatient")] // GET /api/prescription/simpleSearchPrescriptionForPatient public IActionResult FindPrescriptionsForPatientUsingSimpleSearch([FromQuery(Name = "patientId")] int patientId, [FromQuery(Name = "doctor")] string doctor, [FromQuery(Name = "date")] string date, [FromQuery(Name = "comment")] string comment, [FromQuery(Name = "medicaments")] string medicaments) { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.FindPrescriptionsUsingSimpleSearch(patientId, doctor, date, comment, medicaments).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
[HttpGet("findPrescriptionsByMedicaments")] // GET /api/prescription/findPrescriptionsByMedicaments public IActionResult FindPrescriptionsByMedicaments([FromQuery(Name = "patientId")] int patientId, [FromQuery(Name = "medicaments")] string medicaments) { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.FindPrescriptionsForMedicamentsParameter(patientId, medicaments).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
[HttpGet("findPrescriptionsByDoctor")] // GET /api/prescription/findPrescriptionsByDoctor public IActionResult FindPrescriptionsByDoctor([FromQuery(Name = "patientId")] int patientId, [FromQuery(Name = "doctor")] string doctor) { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.FindPrescriptionsForDoctorParameter(patientId, doctor).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
[HttpGet("getForPatient/{patientID}")] // GET /api/prescription/getForPatient/{id} public IActionResult GetPrescriptionsForPatient(int patientID) { List <PrescriptionDto> prescriptionsForPatient = new List <PrescriptionDto>(); App.Instance().PrescriptionService.GetPrescriptionsForPatient(patientID).ToList().ForEach(prescription => prescriptionsForPatient.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(prescriptionsForPatient)); }
[HttpGet] // GET /api/prescription public IActionResult GetAllPrescriptions() { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.GetAllEntities().ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
[HttpGet("findPrescriptionsByComment")] // GET /api/prescription/findPrescriptionsByComment public IActionResult FindPrescriptionsByComment([FromQuery(Name = "patientId")] int patientId, [FromQuery(Name = "comment")] string comment) { List <PrescriptionDto> result = new List <PrescriptionDto>(); this.prescriptionService.FindPrescriptionsForCommentParameter(patientId, comment).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }