diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/ITransformerCTL.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/ITransformerCTL.java index 6357fe6..dd0ab61 100644 --- a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/ITransformerCTL.java +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/ITransformerCTL.java @@ -27,6 +27,7 @@ import it.finanze.sanita.fse2.gtwfhirmappingenginems.dto.TransformResDTO; import it.finanze.sanita.fse2.gtwfhirmappingenginems.dto.error.base.ErrorResponseDTO; import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.BundleTypeEnum; +import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.GtwOperationEnum; import org.bson.Document; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -69,6 +70,8 @@ Document convertCDAToBundleStateless( String objectId, @RequestParam(value = API_QP_BUNDLE_TYPE, required = false) BundleTypeEnum type, + @RequestParam(value = API_QP_OP_TYPE) + GtwOperationEnum op, @RequestPart(API_FILE_VAR) MultipartFile file ) throws IOException; diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/impl/TransformerCTL.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/impl/TransformerCTL.java index 3ae2e9f..f2e6fe6 100644 --- a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/impl/TransformerCTL.java +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/controller/impl/TransformerCTL.java @@ -21,6 +21,7 @@ import it.finanze.sanita.fse2.gtwfhirmappingenginems.dto.FhirResourceDTO; import it.finanze.sanita.fse2.gtwfhirmappingenginems.dto.TransformResDTO; import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.BundleTypeEnum; +import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.GtwOperationEnum; import it.finanze.sanita.fse2.gtwfhirmappingenginems.exception.BusinessException; import it.finanze.sanita.fse2.gtwfhirmappingenginems.service.IConverterSRV; import it.finanze.sanita.fse2.gtwfhirmappingenginems.service.ITransformerSRV; @@ -79,11 +80,11 @@ public TransformResDTO convertCDAToBundle(FhirResourceDTO dto, HttpServletReques } @Override - public Document convertCDAToBundleStateless(String engineId, String objectId, BundleTypeEnum type, MultipartFile file) throws IOException { + public Document convertCDAToBundleStateless(String engineId, String objectId, BundleTypeEnum type, GtwOperationEnum op, MultipartFile file) throws IOException { log.debug("Invoked transform controller"); if(type == null) type = TRANSACTION; String transaction = service.transform(getCDA(file), engineId, objectId, null); - Document doc = converter.convert(type, transaction); + Document doc = converter.convert(type, op, transaction); log.debug("Conversion of CDA completed"); return doc; } diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/enums/GtwOperationEnum.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/enums/GtwOperationEnum.java new file mode 100644 index 0000000..7335bde --- /dev/null +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/enums/GtwOperationEnum.java @@ -0,0 +1,8 @@ +package it.finanze.sanita.fse2.gtwfhirmappingenginems.enums; + +public enum GtwOperationEnum { + CREATE, + REPLACE, + UPDATE, + DELETE +} diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/IConverterSRV.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/IConverterSRV.java index c912a74..edc8d4c 100644 --- a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/IConverterSRV.java +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/IConverterSRV.java @@ -1,10 +1,11 @@ package it.finanze.sanita.fse2.gtwfhirmappingenginems.service; import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.BundleTypeEnum; +import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.GtwOperationEnum; import org.bson.Document; public interface IConverterSRV { - Document convert(BundleTypeEnum type, String transaction); + Document convert(BundleTypeEnum type, GtwOperationEnum op, String transaction); String toMessage(String transaction); - String toDocument(String transaction); + String toDocument(String transaction, GtwOperationEnum op); } diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/impl/ConverterSRV.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/impl/ConverterSRV.java index 9540105..f743a3a 100644 --- a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/impl/ConverterSRV.java +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/service/impl/ConverterSRV.java @@ -1,6 +1,7 @@ package it.finanze.sanita.fse2.gtwfhirmappingenginems.service.impl; import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.BundleTypeEnum; +import it.finanze.sanita.fse2.gtwfhirmappingenginems.enums.GtwOperationEnum; import it.finanze.sanita.fse2.gtwfhirmappingenginems.service.IConverterSRV; import org.apache.commons.lang3.StringUtils; import org.bson.Document; @@ -15,10 +16,12 @@ public class ConverterSRV implements IConverterSRV { @Override - public Document convert(BundleTypeEnum type, String transaction) { + public Document convert(BundleTypeEnum type, GtwOperationEnum op, String transaction) { String bundle = transaction; switch (type) { case DOCUMENT: + bundle = toDocument(transaction, op); + break; case MESSAGE: bundle = toMessage(transaction); break; @@ -53,7 +56,7 @@ public String toMessage(String transaction) { } @Override - public String toDocument(String transaction) { + public String toDocument(String transaction, GtwOperationEnum op) { return null; } diff --git a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/utility/RouteUtility.java b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/utility/RouteUtility.java index 691b9c8..659ced8 100644 --- a/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/utility/RouteUtility.java +++ b/src/main/java/it/finanze/sanita/fse2/gtwfhirmappingenginems/utility/RouteUtility.java @@ -30,6 +30,7 @@ private RouteUtility() {} public static final String API_FILE_VAR = "file"; public static final String API_ENGINE_ID_VAR = "engineId"; public static final String API_QP_BUNDLE_TYPE = "type"; + public static final String API_QP_OP_TYPE = "op"; public static final String API_ENGINE_ID_PATH_VAR = "{" + API_ENGINE_ID_VAR + "}" ; public static final String API_OBJECT_ID_VAR = "objectId"; public static final String API_OBJECT_ID_PATH_VAR = "{" + API_OBJECT_ID_VAR + "}" ;