Beispiel #1
0
        public bool GetRecordList(ViewModel.UserAccountView UserAccountView, ViewModel.Presenter Presenter)
        {
            FhirApi          FhirApi          = new FhirApi(FhirGatewayEndpoint);
            ApiRequestHeader ApiRequestHeader = new ApiRequestHeader(UserAccountView.AccessToken, this.ApplicationStore.App_id, this.ApplicationStore.App_Version);

            FhirApi.ApiRequestHeader = ApiRequestHeader;

            RecordListResponse RecordListResponse = FhirApi.GetRecordList();

            if (RecordListResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                if (RecordListResponse.Format == FhirApi.FhirFormat.Xml)
                {
                    Presenter.TextEditorViewModel.FormatType = Extensions.AvalonEditSyntaxTypes.Xml;
                }
                else if (RecordListResponse.Format == FhirApi.FhirFormat.Json)
                {
                    Presenter.TextEditorViewModel.FormatType = Extensions.AvalonEditSyntaxTypes.Json;
                }
                else
                {
                    Presenter.TextEditorViewModel.FormatType = Extensions.AvalonEditSyntaxTypes.None;
                }
                Presenter.TextEditorViewModel.Text = RecordListResponse.Body;
                Presenter.CurrentUserAccount.UserAccountRecordList = new System.Collections.ObjectModel.ObservableCollection <ViewModel.UserAccountRecord>();
                foreach (var Person in RecordListResponse.ApiRelatedPersonList)
                {
                    var RecordItem = new ViewModel.UserAccountRecord();
                    RecordItem.Family = Person.Family;
                    RecordItem.Given  = Person.Given;
                    RecordItem.Ihi    = Person.Ihi;
                    RecordItem.RelationshipTypeDescription = Person.RelationshipDescription;
                    Presenter.CurrentUserAccount.UserAccountRecordList.Add(RecordItem);
                }
                if (Presenter.CurrentUserAccount != null && Presenter.CurrentUserAccount.UserAccountRecordList != null && Presenter.CurrentUserAccount.UserAccountRecordList.Count > 0)
                {
                    Presenter.CurrentUserAccount.SelectedUserAccountRecord = Presenter.CurrentUserAccount.UserAccountRecordList[0];
                }
                return(true);
            }
            else
            {
                if (RecordListResponse.ErrorResponse != null)
                {
                    Presenter.TextEditorViewModel.FormatType = Extensions.AvalonEditSyntaxTypes.None;
                    Presenter.TextEditorViewModel.Text       = RecordListResponse.ErrorResponse.Description;
                    return(false);
                }
                else
                {
                    Presenter.TextEditorViewModel.FormatType = Extensions.AvalonEditSyntaxTypes.None;
                    Presenter.TextEditorViewModel.Text       = $"Unknown Error, Status code {RecordListResponse.StatusCode.ToString()}";
                    return(false);
                }
            }
        }
        public void Test_GetRecordList(string RefreshToken)
        {
            //Arrange
            Uri     FhirGatewayEndpoint = new Uri("https://apinams.ehealthvendortest.health.gov.au");
            FhirApi Api = new FhirApi(FhirGatewayEndpoint);

            Api.Format = FhirApi.FhirFormat.Xml;
            //Act
            RecordListResponse RecordListResponse = Api.GetRecordList();

            //Assert
            Assert.Equal(RecordListResponse.StatusCode, System.Net.HttpStatusCode.OK);
            Assert.Equal(RecordListResponse.Format, FhirApi.FhirFormat.Xml);
            Assert.NotNull(RecordListResponse.Body);
            Assert.Null(RecordListResponse.ErrorResponse);
        }