View Javadoc
1   package ca.uhn.fhir.jpa.dao.dstu3;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.hl7.fhir.dstu3.model.QuestionnaireResponse;
24  
25  public class FhirResourceDaoQuestionnaireResponseDstu3 extends FhirResourceDaoDstu3<QuestionnaireResponse> {
26  
27  	
28  //	@Override
29  //	protected void validateResourceForStorage(QuestionnaireResponse theResource, ResourceTable theEntityToSave, RequestDetails theRequestDetails) {
30  //		super.validateResourceForStorage(theResource, theEntityToSave, theRequestDetails);
31  //		if (!myValidateResponses) {
32  //			return;
33  //		}
34  //		
35  //		if (theResource == null || theResource.getQuestionnaire() == null || theResource.getQuestionnaire().getReference() == null || theResource.getQuestionnaire().getReference().isEmpty()) {
36  //			return;
37  //		}
38  //
39  //		FhirValidator val = getContext().newValidator();
40  //		val.setValidateAgainstStandardSchema(false);
41  //		val.setValidateAgainstStandardSchematron(false);
42  //
43  //		val.registerValidatorModule(myQuestionnaireResponseValidatorDstu3);
44  //
45  //		ValidationResult result = val.validateWithResult(getContext().newJsonParser().parseResource(getContext().newJsonParser().encodeResourceToString(theResource)));
46  //		if (!result.isSuccessful()) {
47  //			IBaseOperationOutcome oo = getContext().newJsonParser().parseResource(OperationOutcome.class, getContext().newJsonParser().encodeResourceToString(result.toOperationOutcome()));
48  //			throw new UnprocessableEntityException(getContext(), oo);
49  //		}
50  //	}
51  //
52  //	public class JpaResourceLoader implements IResourceLoader {
53  //
54  //		private RequestDetails myRequestDetails;
55  //
56  //		public JpaResourceLoader(RequestDetails theRequestDetails) {
57  //			super();
58  //			myRequestDetails = theRequestDetails;
59  //		}
60  //
61  //		@Override
62  //		public <T extends IBaseResource> T load(Class<T> theType, IIdType theId) throws ResourceNotFoundException {
63  //
64  //			/*
65  //			 * The QuestionnaireResponse validator uses RI structures, so for now we need to convert between that and HAPI
66  //			 * structures. This is a bit hackish, but hopefully it will go away at some point.
67  //			 */
68  //			if ("ValueSet".equals(theType.getSimpleName())) {
69  //				IFhirResourceDao<ValueSet> dao = getDao(ValueSet.class);
70  //				ValueSet in = dao.read(theId, myRequestDetails);
71  //				return (T) in;
72  //			} else if ("Questionnaire".equals(theType.getSimpleName())) {
73  //				IFhirResourceDao<Questionnaire> dao = getDao(Questionnaire.class);
74  //				Questionnaire vs = dao.read(theId, myRequestDetails);
75  //				return (T) vs;
76  //			} else {
77  //				// Should not happen, validator will only ask for these two
78  //				throw new IllegalStateException("Unexpected request to load resource of type " + theType);
79  //			}
80  //
81  //		}
82  //
83  //	}
84  
85  }