Skip to content

Commit

Permalink
feat: add op type for gtw
Browse files Browse the repository at this point in the history
  • Loading branch information
gb-cic committed Nov 9, 2023
1 parent 319c5b1 commit 9c6f14d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.finanze.sanita.fse2.gtwfhirmappingenginems.enums;

public enum GtwOperationEnum {
CREATE,
REPLACE,
UPDATE,
DELETE
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -53,7 +56,7 @@ public String toMessage(String transaction) {
}

@Override
public String toDocument(String transaction) {
public String toDocument(String transaction, GtwOperationEnum op) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "}" ;
Expand Down

0 comments on commit 9c6f14d

Please sign in to comment.