public void ActorOrganisation_Returns_ValidViewModel() { var orgs = MongoActorOrganisations.ActorOrganisations; var orgViewModel = orgs.Select(ActorOrganisation.ToViewModel).First(); var expectedViewModel = new ActorOrganisationViewModel { Id = "5a82f9ffcb969daa58d33377", Type = ActorType.Consumer, Name = "Ambulance Service", ImageUrl = "....", Context = new List <ContentView>() { new ContentView { Title = "Title Text", Content = new List <string> { "Content Text" }, CssClass = "CssClass Text", Order = 1 } }, OrgCode = "AMSR01", Benefits = new List <string> { "benefitid" }, PersonnelLinkId = "testlink" }; Assert.Equal(expectedViewModel, orgViewModel, Comparers.ModelComparer <ActorOrganisationViewModel>()); }
public async void Find_Search_Valid_Summary() { var search = new NrlsSearch(_nrlsApiSettings, _fhirSearch, _cache, _fhirValidation); var actualBundle = await search.Find <DocumentReference>(FhirRequests.Valid_Search_Summary) as Bundle; Assert.Equal(_expectedBundle, actualBundle, Comparers.ModelComparer <Bundle>()); }
public async void Find_Search_Valid() { var search = new NrlsSearch(_nrlsApiSettings, _fhirSearch, _sdsService, _fhirValidation); var actualBundle = await search.Find(FhirRequests.Valid_Search) as Bundle; Assert.Equal(_expectedBundle, actualBundle, Comparers.ModelComparer <Bundle>()); }
public void CreateOrg_Returns_Valid_Search() { var request = NrlsPointerHelper.CreateOrgSearch(FhirRequests.Valid_Create, "TestOrg"); var expected = new List <Tuple <string, string> > { new Tuple <string, string>("identifier", $"{FhirConstants.SystemOrgCode}|TestOrg") }; Assert.Equal(expected, request.QueryParameters, Comparers.ModelComparer <IEnumerable <Tuple <string, string> > >()); }
public void ValidPointer_TooMany_Author() { var validationService = new FhirValidation(_iValidationHelper); var pointer = NrlsPointers.TooMany_Author; var validPoiner = validationService.ValidPointer(pointer); var notexpected = OperationOutcomes.Ok; Assert.NotEqual(notexpected, validPoiner, Comparers.ModelComparer <OperationOutcome>()); }
public void CommandResponse_Set_Matches() { var validCommandResponse = new CommandResponse { Message = "Success", Success = true }; var commandResponse = CommandResponse.Set(true, "Success"); Assert.Equal(validCommandResponse, commandResponse, Comparers.ModelComparer <CommandResponse>()); }
public void FhirResponse_ValidOrganizationResources() { var organizationModels = MongoOrganizations.Organizations.ToList(); var organizationBundle = FhirBundle.GetBundle <Organization>(organizationModels); var actual = new FhirResponse(); actual.Resource = organizationBundle; Assert.Equal(organizationModels, actual.GetResources <Organization>(), Comparers.ModelComparer <Organization>()); }
public void ValidPointer_Invalid_MasterId_System() { var validationService = new FhirValidation(_iValidationHelper); var pointer = NrlsPointers.Invalid_MasterId_System; var validPoiner = validationService.ValidPointer(pointer); var notexpected = OperationOutcomes.Ok; Assert.NotEqual(notexpected, validPoiner, Comparers.ModelComparer <OperationOutcome>()); }
public void ValidPointer_Invalid_RelatesTo_Value() { var validationService = new FhirValidation(_iValidationHelper); var pointer = NrlsPointers.Missing_RelatesTo_Value; var validPoiner = validationService.ValidPointer(pointer); var notexpected = OperationOutcomes.Ok; Assert.NotEqual(notexpected, validPoiner, Comparers.ModelComparer <OperationOutcome>()); }
public void FhirResponse_ValidPatientResources() { var patientModels = MongoPatients.Patients.ToList(); var patientBundle = FhirBundle.GetBundle <Patient>(patientModels); var actual = new FhirResponse(); actual.Resource = patientBundle; Assert.Equal(patientModels, actual.GetResources <Patient>(), Comparers.ModelComparer <Patient>()); }
public void CommandResult_Set_Matches() { var validCommandResponse = new CommandResult <string> { Message = "Success", Result = null, Success = true }; var commandResponse = CommandResult <string> .Set(true, "Success", null); Assert.Equal(validCommandResponse, commandResponse, Comparers.ModelComparer <CommandResult <string> >()); }
public void NrlsPointerRequest_Read_Valid() { var viewModel = NrlsPointerRequest.Read("id001", "0001", "org1"); var expectedViewModel = new NrlsPointerRequest { Asid = "0001", PointerId = "id001", JwtOrgCode = "org1" }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <NrlsPointerRequest>()); }
public async void PointerService_Returns_ValidPointerList() { var patientModels = MongoPatients.Patients.ToList(); var organizationModels = MongoOrganizations.Organizations.ToList(); var documentReferenceModels = MongoDocumentReferences.DocumentReferences_3656987882; var testNhsNumber = "3656987882"; var testAsid = "200000000116"; var testOrgCode = "AMS01"; var _docRefService = new Mock <IDocumentReferenceServices>(); _docRefService.Setup(m => m.GetPointersBundle(It.IsAny <NrlsPointerRequest>())).Returns(SystemTasks.Task.Run(() => FhirBundle.GetBundle <DocumentReference>(documentReferenceModels) as Resource)).Verifiable(); var _patientService = new Mock <IPatientServices>(); _patientService.Setup(m => m.GetPatients()).Returns(SystemTasks.Task.Run(() => patientModels)).Verifiable(); var _organisationServices = new Mock <IOrganisationServices>(); _organisationServices.Setup(m => m.GetOrganisations()).Returns(SystemTasks.Task.Run(() => organizationModels)).Verifiable(); var pointerService = new PointerService(_docRefService.Object, _patientService.Object, _organisationServices.Object); var request = RequestViewModel.Create(testNhsNumber); request.Asid = testAsid; request.OrgCode = testOrgCode; var actual = await pointerService.GetPointers(request); var pointers = MongoPointerViewModels.PointerViewModels_3656987882; var patient = MongoPatientViewModels.PatientViewModel_3656987882; var org = MongoOrganizationViewModels.OrganizationViewModel_00003X; var expected = new List <PointerViewModel>(); foreach (var exp in pointers) { exp.SubjectViewModel = patient; exp.AuthorViewModel = org; exp.CustodianViewModel = org; expected.Add(exp); } _docRefService.Verify(); _patientService.Verify(); _organisationServices.Verify(); Assert.Equal(expected, actual, Comparers.ModelComparer <PointerViewModel>()); }
public void Returns_CleanedModel() { var model = new CrisisPlanViewModel { ActionForDependants = "test <", Active = true, Asid = "test <", CrisisNumber = "test <", EmergencyLocation = "test <", EmergencyNumber = "test <", Id = "test <", InvolveFamilyOrCarer = true, OrgCode = "test <", PatientAcceptsPlan = true, PatientNhsNumber = "test <", PlanCreatedBy = "test <", PlanCreatedByJobTitle = "test <", PotentialTriggers = "test <", RecordType = RecordType.MentalHealthCrisisPlan, SignsFeelingUnwell = "test <", Version = 1, WhatHelpsInCrisis = "test <" }; var cleanedModel = model.Cleaned(); var expected = new CrisisPlanViewModel { ActionForDependants = "test ", Active = true, Asid = "test ", CrisisNumber = "test ", EmergencyLocation = "test ", EmergencyNumber = "test ", Id = "test ", InvolveFamilyOrCarer = true, OrgCode = "test ", PatientAcceptsPlan = true, PatientNhsNumber = "test ", PlanCreatedBy = "test ", PlanCreatedByJobTitle = "test ", PotentialTriggers = "test ", RecordType = RecordType.MentalHealthCrisisPlan, SignsFeelingUnwell = "test ", Version = 1, WhatHelpsInCrisis = "test " }; Assert.Equal(expected, cleanedModel, Comparers.ModelComparer <CrisisPlanViewModel>()); }
public void NrlsPointerRequest_Search_Valid() { var viewModel = NrlsPointerRequest.Search("Test", "0001", "0001", "0001", null); var expectedViewModel = new NrlsPointerRequest { Asid = "0001", TypeCode = "0001", JwtOrgCode = "Test", NhsNumber = "0001", CustodianOrgCode = null }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <NrlsPointerRequest>()); }
public void CreatePatient_Returns_Valid_Search() { var request = NrlsPointerHelper.CreatePatientSearch(FhirRequests.Valid_Create, "1445545101"); var expected = new List <Tuple <string, string> > { new Tuple <string, string>("identifier", $"{FhirConstants.SystemNhsNumber}|1445545101") }; Assert.Equal(expected, request.QueryParameters, Comparers.ModelComparer <IEnumerable <Tuple <string, string> > >()); Assert.Equal("Patient", request.StrResourceType); Assert.Equal("http://hl7.org/fhir/STU3/patient.html", request.ProfileUri); }
public void CreateMasterId_Returns_Valid_Search() { var masterIdentifier = new Identifier("validSystem", "validValue"); var request = NrlsPointerHelper.CreateMasterIdentifierSearch(FhirRequests.Valid_Create, masterIdentifier, "nhsNumber"); var expectedParams = new List <Tuple <string, string> > { new Tuple <string, string>("identifier", "validSystem|validValue"), new Tuple <string, string>("subject", $"{FhirConstants.SystemPDS}nhsNumber") }; Assert.Equal(expectedParams, request.QueryParameters, Comparers.ModelComparer <IEnumerable <Tuple <string, string> > >()); Assert.Contains("identifier", request.AllowedParameters); }
public void ToResource_Is_Valid() { var bsonDocItems = new BsonElement[] { new BsonElement("_id", "5ae838bf461bbbf5792a5460"), new BsonElement("resourceType", "Organization"), new BsonElement("name", "test") }; var bsonDoc = new BsonDocument(); bsonDoc.AddRange(bsonDocItems); var expected = new Organization { Id = "5ae838bf461bbbf5792a5460", Name = "test" }; var actual = BsonToResourceFactory.ToResource <Organization>(bsonDoc); Assert.Equal(expected, actual, Comparers.ModelComparer <Organization>()); }
public void NrlsPointerRequest_Create_Valid() { var viewModel = NrlsPointerRequest.Create("TestOrg", "TestCustodian", "0001", "https://test.com/test/pdf", "test/test", "0001", "test", "0001"); var expectedViewModel = new NrlsPointerRequest { Asid = "0001", NhsNumber = "0001", JwtOrgCode = "TestOrg", CustodianOrgCode = "TestCustodian", PointerId = null, RecordContentType = "test/test", RecordUrl = "https://test.com/test/pdf", TypeCode = "0001", TypeDisplay = "test" }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <NrlsPointerRequest>()); }
public void Benefit_Returns_ValidViewModel() { var models = MongoBenefit.EfficiencyBenefits; var viewModel = models.Select(Benefit.ToViewModel).First(); var expectedViewModel = new BenefitViewModel { Id = "5a8417f68317338c8e080a62", Text = "Benefit E1", Categories = new List <string> { "Efficiency" }, Order = 1, Type = "Test", Active = true }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <BenefitViewModel>()); }
public void GenericSystem_Returns_ValidViewModel() { var models = MongoGenericSystems.GenericSystems; var viewModel = models.Select(GenericSystem.ToViewModel).First(); var expectedViewModel = new GenericSystemViewModel { Id = "5a8417338317338c8e0809e5", Name = "Ambulance Service Call Handler", FModule = "Ambulance_Service_Call_Handler", Asid = "200000000115", Context = "Some context...", ActionTypes = new List <ActorType> { ActorType.Consumer } }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <GenericSystemViewModel>()); }
public void Personnel_Returns_ValidViewModel() { var models = MongoPersonnel.Personnel; var viewModel = models.Select(Personnel.ToViewModel).First(); var expectedViewModel = new PersonnelViewModel { Id = "5a8417f68317338c8e080a62", Name = "999 Call Handler", ImageUrl = "....", Context = new List <ContentView>() { new ContentView { Title = "Title Text", Content = new List <string> { "Content Text" }, CssClass = "CssClass Text", Order = 1 } }, UsesNrls = true, ActorOrganisationId = "5a82f9ffcb969daa58d33377", CModule = "CModule-Type", SystemIds = new List <string> { "5a8417338317338c8e0809e5" }, Benefits = new List <string> { "benefitid" } }; Assert.Equal(expectedViewModel, viewModel, Comparers.ModelComparer <PersonnelViewModel>()); }
public void NrlsConformance_Valid() { var expected = new CapabilityStatement { Url = "https://fhir.nhs.uk/STU3/CapabilityStatement/NRL-CapabilityStatement-1", Version = ModelInfo.Version, Name = "NRL-CapabilityStatement-1", Status = PublicationStatus.Draft, Date = "2017-10-11T10:20:38+00:00", Publisher = "NHS Digital", Contact = new List <ContactDetail> { new ContactDetail { Name = "Interoperability Team", Telecom = new List <ContactPoint> { new ContactPoint { System = ContactPoint.ContactPointSystem.Email, Use = ContactPoint.ContactPointUse.Work, Value = "*****@*****.**" } } } }, Description = new Markdown("This profile defines the expected capabilities of the NRL STU3 FHIR server when conforming to the NRL API IG. The Capability Statement resource includes a complete list of actual profiles, RESTful operations, and search parameters that are expected to be supported by NRL STU3 FHIR Server."), Copyright = new Markdown("Copyright © 2017 NHS Digital"), Kind = CapabilityStatement.CapabilityStatementKind.Requirements, FhirVersion = "3.0.1", AcceptUnknown = CapabilityStatement.UnknownContentCode.No, Format = new List <string> { "application/fhir+xml", "application/fhir+json" }, Rest = new List <CapabilityStatement.RestComponent> { new CapabilityStatement.RestComponent { Mode = CapabilityStatement.RestfulCapabilityMode.Server, Security = new CapabilityStatement.SecurityComponent { Cors = true }, Resource = new List <CapabilityStatement.ResourceComponent> { new CapabilityStatement.ResourceComponent { Extension = new List <Extension> { new Extension { Url = "http://hl7.org/fhir/StructureDefinition/conformance-search-parameter-combination", Extension = new List <Extension> { new Extension { Url = "required", Value = new FhirString("_id") } } }, new Extension { Url = "http://hl7.org/fhir/StructureDefinition/conformance-search-parameter-combination", Extension = new List <Extension> { new Extension { Url = "required", Value = new FhirString("subject") }, new Extension { Url = "optional", Value = new FhirString("custodian") }, new Extension { Url = "optional", Value = new FhirString("type") } } }, new Extension { Url = "http://hl7.org/fhir/StructureDefinition/conformance-search-parameter-combination", Extension = new List <Extension> { new Extension { Url = "required", Value = new FhirString("subject") }, new Extension { Url = "required", Value = new FhirString("_summary") } } }, new Extension { Url = "http://hl7.org/fhir/StructureDefinition/conformance-search-parameter-combination", Extension = new List <Extension> { new Extension { Url = "required", Value = new FhirString("subject") }, new Extension { Url = "required", Value = new FhirString("identifier") } }, FhirComments = new List <string> { "This combination can only be used for Supersede, Patch, and Delete interactions." } } }, Type = ResourceType.DocumentReference, Profile = new ResourceReference { Reference = "https://fhir.hl7.org.uk/StructureDefinition/NRL-DocumentReference-1" }, Interaction = new List <CapabilityStatement.ResourceInteractionComponent> { new CapabilityStatement.ResourceInteractionComponent { Code = CapabilityStatement.TypeRestfulInteraction.SearchType, Documentation = "Allows discovery of existing NRL document reference resources using different search criteria" }, new CapabilityStatement.ResourceInteractionComponent { Code = CapabilityStatement.TypeRestfulInteraction.Read, Documentation = "Allows retrieval of specific NRL document references by id" }, new CapabilityStatement.ResourceInteractionComponent { Code = CapabilityStatement.TypeRestfulInteraction.Patch, Documentation = "Allows update of specific NRL document references by id" }, new CapabilityStatement.ResourceInteractionComponent { Code = CapabilityStatement.TypeRestfulInteraction.Delete, Documentation = "Allows deletion of specific NRL document references by id" }, new CapabilityStatement.ResourceInteractionComponent { Code = CapabilityStatement.TypeRestfulInteraction.Create, Documentation = "Allows creation of NRL document references" } }, SearchParam = new List <CapabilityStatement.SearchParamComponent> { new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("SHOULD") } }, Name = "subject", Definition = "http://hl7.org/fhir/SearchParameter/DocumentReference.subject", Type = SearchParamType.Reference, Documentation = "The Patient the DocumentReference relates to. This is MUST when searching by patient." }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("MAY") } }, Name = "custodian", Definition = "http://hl7.org/fhir/SearchParameter/DocumentReference.custodian", Type = SearchParamType.Reference, Documentation = "The owner of the DocumentReference" }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("SHOULD") } }, Name = "_id", Definition = "http://hl7.org/fhir/search", Type = SearchParamType.String, Documentation = "Logical id of the DocumentReference. This is MUST when searching by _id" }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("MAY") } }, Name = "type", Definition = "http://hl7.org/fhir/search", Type = SearchParamType.Token, Documentation = "Clinical type the DocumentReference refers too" }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("MAY") } }, Name = "_summary", Definition = "http://hl7.org/fhir/search", Type = SearchParamType.String, Documentation = "Type of summary to return" }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("MAY") } }, Name = "identifier", Definition = "http://hl7.org/fhir/search", Type = SearchParamType.Token, Documentation = "The MasterIdentifer associated to the DocumentReference. Used in Supersede, Patch, and Delete interactions." }, new CapabilityStatement.SearchParamComponent { Extension = new List <Extension> { new Extension { Url = "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CapabilityStatementExpectation-1", Value = new FhirString("MAY") } }, Name = "_format", Definition = "http://hl7.org/fhir/search", Type = SearchParamType.String, Documentation = "Content Type of returned result" } } } } } } }; var actual = new NrlsConformance().GetConformance(); Assert.Equal(expected, actual, Comparers.ModelComparer <CapabilityStatement>()); }
public void FhirResponse_ValidDocumentReferenceResources() { var documentReferenceModels = MongoDocumentReferences.DocumentReferences.ToList(); var documentReferenceBundle = FhirBundle.GetBundle <DocumentReference>(documentReferenceModels); var actual = new FhirResponse(); actual.Resource = documentReferenceBundle; Assert.Equal(documentReferenceModels, actual.GetResources <DocumentReference>(), Comparers.ModelComparer <DocumentReference>()); }
public async void PointerService_Returns_ValidPointerList() { var patientModels = MongoPatients.Patients.ToList(); var organizationModels = MongoOrganizations.Organizations.ToList(); var documentReferenceModels = MongoDocumentReferences.DocumentReferences_3656987882; var testNhsNumber = "3656987882"; var testAsid = "200000000116"; var testOrgCode = "AMS01"; var _docRefService = new Mock <IDocumentReferenceServices>(); _docRefService.Setup(m => m.GetPointersBundle(It.IsAny <NrlsPointerRequest>())).Returns(SystemTasks.Task.Run(() => FhirBundle.GetBundle <DocumentReference>(documentReferenceModels) as Resource)).Verifiable(); var _patientService = new Mock <IPatientServices>(); _patientService.Setup(m => m.GetPatients()).Returns(SystemTasks.Task.Run(() => patientModels)).Verifiable(); var _organisationServices = new Mock <IOrganisationServices>(); _organisationServices.Setup(m => m.GetOrganisations()).Returns(SystemTasks.Task.Run(() => organizationModels)).Verifiable(); var pointerCache = new PatientPointers { Pointers = MongoPointerViewModels.PointerViewModels_3656987882 }; var cacheMock = MemoryCacheStub.MockMemoryCacheService.GetMemoryCache(pointerCache); var pdfBinaryId = "TestBinaryPdf1"; var _documentServices = new Mock <IDocumentsServices>(); _documentServices.Setup(m => m.GetPointerDocument(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(SystemTasks.Task.Run(() => MongoBinaries.Binaries.FirstOrDefault(x => x.Id == pdfBinaryId) as Resource)).Verifiable(); var opts = new ApiSetting { BaseUrl = "://localhost", DefaultPort = "55448", Secure = false, SecureOnly = false, SecurePort = "55443", SupportedContentTypes = new List <string> { "application/fhir+json" } }; var _apiSettings = new Mock <IOptions <ApiSetting> >(); _apiSettings.Setup(op => op.Value).Returns(opts); var pointerService = new PointerService(_apiSettings.Object, _docRefService.Object, _patientService.Object, _organisationServices.Object, cacheMock, _documentServices.Object); var request = RequestViewModel.Create(testNhsNumber); request.Asid = testAsid; request.OrgCode = testOrgCode; var actual = await pointerService.GetPointers(request); var pointers = MongoPointerViewModels.PointerViewModels_3656987882; var patient = MongoPatientViewModels.PatientViewModel_3656987882; var org = MongoOrganizationViewModels.OrganizationViewModel_00003X; var expected = new List <PointerViewModel>(); foreach (var exp in pointers) { exp.SubjectViewModel = patient; exp.AuthorViewModel = org; exp.CustodianViewModel = org; expected.Add(exp); } _docRefService.Verify(); _patientService.Verify(); _organisationServices.Verify(); Assert.Equal(expected, actual, Comparers.ModelComparer <PointerViewModel>()); }