public OperationOutcome ValidTypeParameter(string type)
        {
            if (!_validationHelper.ValidReferenceParameter(type, FhirConstants.SystemPointerType))
            {
                return(OperationOutcomeFactory.CreateInvalidParameter("Invalid parameter", $"The given terminology system is not of the expected value - {FhirConstants.SystemPointerType}"));
            }

            var typeCode = _validationHelper.GetTokenParameterId(type, FhirConstants.SystemPointerType);

            var concept = new CodeableConcept(FhirConstants.VsRecordType, typeCode);


            if (!_validationHelper.ValidCodableConcept(concept, 1, FhirConstants.SystemPointerType, true, false, true, false, FhirConstants.VsRecordType))
            {
                return(OperationOutcomeFactory.CreateInvalidParameter("Invalid parameter", $"The given code is not from the expected terminology system - {FhirConstants.SystemPointerType}"));
            }

            return(null);
        }
示例#2
0
        public OperationOutcome ValidPointer(DocumentReference pointer)
        {
            //master identifier
            if (pointer.MasterIdentifier != null)
            {
                var masterIdentifierCheck = _validationHelper.ValidIdentifier(pointer.MasterIdentifier, "masterIdentifier");

                if (!masterIdentifierCheck.valid)
                {
                    return(OperationOutcomeFactory.CreateInvalidResource(masterIdentifierCheck.issue, "If the masterIdentifier is supplied then the value and system properties are mandatory"));
                }
            }

            //status
            if (!GetValidStatus(pointer.Status).HasValue)
            {
                return(OperationOutcomeFactory.CreateInvalidResource("status", "The status of a new DocumentReference can only be \"current\""));
            }

            //type
            if (pointer.Type == null)
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }
            else if (!_validationHelper.ValidCodableConcept(pointer.Type, FhirConstants.SystemPointerType, true, true, true, true, FhirConstants.VsRecordType))
            {
                return(OperationOutcomeFactory.CreateInvalidResource("type"));
            }

            //subject
            if (pointer.Subject != null)
            {
                var validNhsNumber = ValidatePatientReference(pointer.Subject);

                if (validNhsNumber != null)
                {
                    return(validNhsNumber);
                }
            }
            else
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }

            //validate orgcode is real done outside of here
            //author
            if (pointer.Author != null && pointer.Author.Count == 1)
            {
                var validAuthor = ValidateOrganisationReference(pointer.Author.First(), "author");

                if (validAuthor != null)
                {
                    return(validAuthor);
                }
            }
            else
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }


            //validate orgcode for match against fromASID and is real done outside of here
            //custodian
            if (pointer.Custodian != null)
            {
                var validCustodian = ValidateOrganisationReference(pointer.Custodian, "custodian");

                if (validCustodian != null)
                {
                    return(validCustodian);
                }
            }
            else
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }

            //indexed
            DateTime validIndexed;

            if (pointer.Indexed == null)
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }
            else if (!pointer.Indexed.HasValue || !FhirDateTime.IsValidValue(pointer.Indexed.Value.ToString(DateTimeFormat)) || !DateTime.TryParse(pointer.Indexed.Value.ToString(DateTimeFormat), out validIndexed))
            {
                return(OperationOutcomeFactory.CreateInvalidResource("indexed"));
            }

            //relatesTo
            //Only require basic checks here
            //Additional checks are carried out in NrlsMaintain.ValidateConditionalUpdate
            var relatesTo = GetValidRelatesTo(pointer.RelatesTo);

            if (pointer.RelatesTo != null && pointer.RelatesTo.Count > 0 && relatesTo.element == null)
            {
                return(OperationOutcomeFactory.CreateInvalidResource(relatesTo.issue));
            }

            //attachment
            if (pointer.Content != null)
            {
                var validContent = ValidateContent(pointer.Content);

                if (validContent != null)
                {
                    return(validContent);
                }
            }
            else
            {
                return(OperationOutcomeFactory.CreateInvalidResource(null));
            }

            return(OperationOutcomeFactory.CreateOk());
        }